element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Industrial Automation
  • Technologies
  • More
Industrial Automation
Blog Stepper Motor Control with Hercules High-End Timer - Part 8: HET Based Pulse Train Output
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Industrial Automation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 16 Jun 2017 11:52 AM Date Created
  • Views 2745 views
  • Likes 4 likes
  • Comments 6 comments
  • stepper_motor
  • boosterpack
  • drv8711
  • texas_instruments
  • msp430
  • hercules
  • launchpad
Related
Recommended

Stepper Motor Control with Hercules High-End Timer - Part 8: HET Based Pulse Train Output

Jan Cumps
Jan Cumps
16 Jun 2017

I'm trying to control an Adafruit stepper motor with the high-end timer (NHET) module of a Texas Instruments Hercules microcontroller

image

I got a freebie from TI almost a year ago. An Adafruit stepper motor, a driver board and a Hercules RM57 LaunchPad. The code to run the motor was expected to arrive too (it was an assignment for an internal) but that never materialised. In this blog series I'm trying to program the NHET module so that it sends the right signals to make the stepper step.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

In the 8th blog I finally try to create the dynamic pulses for the Stepper Motor with the Hercules HET module.

 

When you think something is complex, and it's already been done and published

 

N2HET Based Pulse Train Output

(first it was called HET, then NHET for New HET, now N2HET for New Advanced 2nd Ggeneration HET. Don't ask me. Call TI)

 

I have found an application note for the Hercules RM57: "TI Designs: High Availability Industrial High Speed Counter (HSC) / Pulse Train Output (PTO)".

An amazing document that shows how to control  production line belt using counters and pulses to check and drive it.

 

It's a great document if you're interested in autonomous timer co-processors. One of the best documents on that subject for the Hercules HET.

It covers a number of areas that are hard to understand and even harder to get examples for:

  • dynamic loading of timer code, based on the strategy selected (in this case: switch between different ways to drive a motor at run-time)
  • real world example with interaction between controller and timer co-processor
  • and info and insights into the HET module that you don't find anywhere else. Hardware, software, theory behind the decisions, practical considerations)

I don't like to be the fanboy. But I am. I can't hide it this time image

(and tru fakt: I only realised today that it's written by my favourite Hercules engineer)

image

 

I am interested in the part that explains how to program the HET module to drive a stepper motor.

The appnote supports three ways to drive the motor.

I'm using the document's count/dir functionality to generate period-shifted pulses, because the DRV8711 stepper motor controller expects pulses.

 

Ramp up and Ramp down Profiles

The HET design supports stable speed, ramp-up and ramp-down. All functions accept the number of pulses to generate.

In the stable speed function, the requested number of pulses are generated with the same time base.

In the two ramp-xx functions, the period of the pulses decreases (ramp-up) or increases (ramp-down) linear.

 

The HET is programmed as an autonomous state machine.

image

 

 

The only duty for the ARM core (called HOST DRIVER on the above state diagram) of the Hercules controller is to fill the command buffer with a profile:

 

    ptoInit(pto1, ptoModeCountDir);
    ptoCmdCreate(&cmdList[0], 1000000, 50, ptoDirRev, ptoAccLinAcc);
 ptoCmdCreate&cmdList[1  105132 10 ptoDirRev ptoAccZero 
 ptoCmdCreate&cmdList[2  105132 50 ptoDirRev ptoAccLinDec 
// ...
    ptoStart(pto1);
    for (i = 0; i < NUMCMD; i++) {
        ptoCmdSubmit(pto1, cmdList[i]);
    }

 

 

 

* ptoRetVal_t ptoCmdCreate(ptoCmd_t *cmd, uint32_t icnt, uint32_t nstp, ptoDir_t dir, ptoAcc_t acc);
* - icnt = initial pulse width (in counts of N2HET High Resolution Clocks
* - nstp = number of steps to execute in the command
* - dir = direction of steps (forward, reverse, or pure time delay)
* - acc = acceleration type (accelerate, decelerate, or zero acceleration/constant speed)
*/

 

HET will first pulse out a train of 50 pulses, with the pulse width 1 000 000 times the period of NHET clock as start period:

 

image

 

If I count correctly, 1 / 110 MHz * 1 000 000 = 9.090909.... ms. Let's check on a capture of the sequence above with the logic analyzer:

image

Spot on!.

 

Then 10 steps at the stable speed of 1 110 MHz  105132105132 956 s

image

Again correct.

It will the ramp-down in 50 pulses.

 

Here's a capture of the SPI initialisation (expanded in the inset below right) and the pulse train from start to stable.

 

image

 

If you have OpenLogic Sniffer software, you can review the measurements. I've attached the .olp project. It contains all sample info.

In the sample resolution that I used, my logic analyser (a Papilio Pro FPGA board!) doesn't have enough memory to catch the full pulse train and all HET information in one shot.

Here's a capture, at slower sampling speed, of the pulse train only (click for higher image resolution):

image

On an oscilloscope:

image

Next

I assumed that my motor would start spinning, now that I have replicated SPI sequence and pulse train - and drive the nSLEEP pin correctly.

But it doesn't. I'm going to rewire the original MSP430 setup and see if I miss something.

Hang on....

 

 

edit: the reason why it wasn't working was because of the SPI settings.

I had to change the clock phase. That changes at what time the data is written (and read) relative to the clock signal.

I've attached the code composer studio project, including the HET assembly code.

image

 

Related Blog
Part 1: Hardware Overview
Part 2: Stepper Controller and MSP430 Firmware
Part 3: SPI Commands and Pulse Control
Part 4: Analyse MSP430 PWM Step Signal
Part 5: Hercules RM57 Hardware Provisioning
Part 6: Hercules RM57 SPI
Part 7: HET Assembly Language Test
Part 8: HET Based Pulse Train Output
Attachments:
stepper.project.olp.zip
RM57_Stepper.zip
RM57_Stepper_20190720.zip
  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +2
    Nice update Jan. Great series. DAB
  • Jan Cumps
    Jan Cumps over 8 years ago +1
    I've added a video to the start of the blog. A review of the signals coming out of the Hercules HET module.
  • Jan Cumps
    Jan Cumps over 6 years ago in reply to Jan Cumps

    (I revisited this because I'm trying to replicate High Performance Pulse Train Output (PTO) With PRU-ICSS for Industrial Applications. Control stepper motors from the BeagleBone PRU while freeing the controller ....)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 6 years ago

    The settings for the RM57 controller have changed in Code Composer Studio v9.

    I've attached a new project file for that version:

    https://www.element14.com/community/servlet/JiveServlet/download/38-285412/RM57_Stepper_20190720.zip

    The sources haven't changed. Only the flash and memory configuration for linker and loader.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago

    ... and source code, HET assembler code + Code Composer Studio project attached to the blog post ...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago

    The motor is now stepping image.

    I had to correct the phase of the SPI signal to the stepper motor driver.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago

    I've added a video to the start of the blog. A review of the signals coming out of the Hercules HET module.

    • Cancel
    • Vote Up +1 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