element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Pulse Train Hat for the Raspberry Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: pthat
  • Date Created: 14 Apr 2017 1:49 PM Date Created
  • Views 3460 views
  • Likes 1 like
  • Comments 14 comments
Related
Recommended
  • pthat
  • raspberry pi
  • pulse train hat
  • dds generators
  • pulse train
  • raspberry pi hat

Pulse Train Hat for the Raspberry Pi

pthat
pthat
14 Apr 2017

I am hoping that a new HAT we have designed and released will be of interest to anyone wanting to control motors within their own projects using the Raspberry Pi computer.

image

The Pulse Train Hat is an add-on board for the Rapsberry Pi computer and allows clean, fast and accurate pulses to be created using simple ASCII commands.

 

There are many hardware designs where a variable frequency pulse is needed, but one that is the most popular is for driving stepper/servo motors that use pulse and direction lines.

Motors like this are found in machines such as 3D Printers, CNC machines, Robot Arms and not to mention the other endless motion control and automation machines.

 

Below is a Test Rig we used while developing the code.

 

It allows us to test all 4 channels of the PTHAT by sending the pulses to stepper drivers, that were connected to small Nema 17 motors. It also has all the limit switch inputs brought out to switches, the ADC inputs connect to 10K pots and AUX outputs connected to LED’s.

 

We decided to use low cost stepper drivers that are usually found in 3D printers as they are not brilliant, but do the job. Our thinking is if the PTHAT can control these noisy little drivers, then handling the more expensive drivers would be easier!

 

image

 

Controlling motors may seem simple, but when you get down to detailed control, it can all become very confusing and a big learning curve.

 

With the new Pulse Train Hat (PTHAT) add-on for the Raspberry Pi and a new dedicated support site http://www.pthat.com , we plan to make that task very simple and allow everyone to easily create their automation product.

 

image

 

We have created an number of example applications using Visual Studio 2015 that can be used with Windows 10 IOT.

These examples have been written in C# as a Universal Windows Platform (UWP) and all the source code can be downloaded from the website.

 

image

image

 

image

image

image

 

We have also designed the PTHAT to have it's firmware upgraded easily using a JTAG programmer that we supply with each board.

Also full details on the ARM processor we use has been released covering all the GPIO information, Clock settings and peripherals for people wanting to write their own firmware.

 

image

 

Also there are a number of wiring diagrams released covering various stepper driver hook ups.

image

Of course you do not have to use the PTHAT to control motors and can be used as a pulse generator for other projects.

 

image

 

image

 

Please feel free to check out the dedicated support site for more information http://www.pthat.com

  • Sign in to reply

Top Comments

  • pthat
    pthat over 8 years ago +4
    Yep most of controllers out there accept raw Gcode commands and do all the calculations in firmware, including G01 Linear interpolation commands and G02 Circular interpolation commands. So software like…
  • pthat
    pthat over 8 years ago +3
    There are already a lot of dedicated controllers out there for CNC machines and 3D printers etc, that are used as either dedicated toolpath engines, accepting Gcode and they work well. The Pulse Train…
  • Robert Peter Oakes
    Robert Peter Oakes over 8 years ago in reply to pthat +3
    Thanks for the prompt response, checking the specifications of the CPU, looks like it would be more than able to take a port from any of the Arduino based GCode engines and provide a better performance…
  • pthat
    pthat over 8 years ago

    Yep most of controllers out there accept raw Gcode commands and do all the calculations in firmware, including G01 Linear interpolation commands and G02 Circular interpolation commands.

    So software like Gcode sender, simply send out these commands and have nice features like GUI windows plotting the course of each Axis for display purposes.

     

    We have no plans to add this ourselves at the moment as a huge bit of work, but with the undocumented RAW buffer commands, already in the firmware it is possible to send many small commands.

     

    Here is the screenshot of the Universal Application we have been testing with.

    This takes each line of Gcode and converts it to RAW buffered commands. It looks ahead and knows when a command will change direction and hence injects ramping into the start command and finish command of that segment automatically.

     

    Once the motors have started, all you are doing is sending commands with frequency and pulse count for each movement, that get buffered and executed one after the other.
    The processor does not have to do much really apart from monitor pulse counts and change the frequency on the fly for each DDS generator.

     

    We have a high speed baud setting as well of 806400 which helps a lot. But you can still run it at 115200 with a change of jumper on board.

     

    Excuse the rough layout, it is only test at the moment.

     

    image

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 8 years ago in reply to Robert Peter Oakes

    Hello Peter, it is correct, in fact I wrote this:

     

    At this point it is not needed to make a new firmware on the HAT to receive the G-Code commands and convert them in direct motion commands; this means to recreate the entire math and logic of the G-Code language. Fortunately the Universal G-Code sender manages the commands in GRBL, an open source standard for low-level motor control. The repository on GitHub can be found here: https://github.com/grbl/grbl/wiki

    So what we need is "just" to port the GRBL standard on the HAT. This is not so difficult as it seems because of the advantage of the ASCII commands available on the standard firmware of the HAT. I see two phases porting:

     

    1 - After forking the GRBL repository setup the low level calls using the way the HAT controls motors (ASCII commands)

    2 - Optimise the GRBL math algorithms accordingly with the advanced features of the motor controller

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Robert Peter Oakes
    Robert Peter Oakes over 8 years ago in reply to balearicdynamics

    The Universal GCode sender does not interpret the GCode into direction and steps, it simply manages a user interface and spools the cgode to the controller., there is a separate program for that

     

    you may be thinking of something like this

    https://github.com/grbl/grbl

     

    now all the C source is available to port to the ST micro if needed.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • pthat
    pthat over 8 years ago

    To keep the price down, most of the dedicated boards use the processors on board peripherals like timers or hardware PWM's.

     

    We went a different direction with the PTHAT and decided to use dedicated DDS pulse generators, to give us the resolution and the speed, but also to allow the PTHAT to be used as a square pulse generator for other applications.

     

    With the PTHAT bundle it has 4 DDS Pulse Generators and these are the AD9833

    http://uk.farnell.com/analog-devices/ad9833brmz/waveform-generator-9833-msop10/dp/1581966?st=ad9833&gs=true&ddkey=http%3Aen-GB%2FElement14_United_Kingdom%2Fw%2Fc%2Fsemiconductors-ics%2Fspecial-function

     

    And the processor STM32F411
    http://uk.farnell.com/stmicroelectronics/stm32f411ret6/mcu-32bit-cortex-m4-100mhz-lqfp/dp/2456967

     

    As you can see if you wanted to build it yourself, the price does add up.

     

    But we felt it was worth it when accurate interpolation was needed between motors and show an example on our website.

     

    Motor1 that needs 1000 pulses and motor2 that needs 2222 pulses to reach the target travel distance.

     

    You can see on the scope shot, by having the resolution of the DDS pulse generators, you can get a very accurate speed on both motors and both should stop and start at the same time, keeping interpolation.

     

    Run motor2 at 2666.66Hz (100RPM)

    Run motor1 at 1200.11Hz (45.45RPM)

     

    scope-interpolation3.jpg

    We would love to see someone develop firmware for the PTHAT so it can run as a dedicated Gcode engine and by us supplying a JTAG  programmer with each PTHAT, makes it possible for people to develop their own firmware and upload it.

     

    As I have said we are still working on the RAW buffer command set in the background, but it has to be done as time allows. We are only a small company and resource can be an issue when busy on other products we make.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 8 years ago in reply to pthat

    Sean,

    to be honest I was wondering how it was so difficult - until now - to find on the market a good hardware platform not strictly g-code oriented for the Pi. I should exclude Arduino from some of my motor controller projects for a lot of reasons and this sounds to be the better alternative.

     

    By the way in the case there users need to interface the device with the G-Code feed from somewhere (e.g. laser cutters of 3D printers) I am following this option by a while and actively interact with a couple of development communities that I think maybe useful for who is interested:

     

    The universal G-Code sender is a java tool adaptable on any platform as well as the PI (already tested) to solve the interfacing problems and can be found here: https://github.com/winder/Universal-G-Code-Sender

     

    At this point it is not needed to make a new firmware on the HAT to receive the G-Code commands and convert them in direct motion commands; this means to recreate the entire math and logic of the G-Code language. Fortunately the Universal G-Code sender manages the commands in GRBL, an open source standard for low-level motor control. The repository on GitHub can be found here: https://github.com/grbl/grbl/wiki

    So what we need is "just" to port the GRBL standard on the HAT. This is not so difficult as it seems because of the advantage of the ASCII commands available on the standard firmware of the HAT. I see two phases porting:

     

    1 - After forking the GRBL repository setup the low level calls using the way the HAT controls motors (ASCII commands)

    2 - Optimise the GRBL math algorithms accordingly with the advanced features of the motor controller

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube