Trinamic motor program

This is the program we use on the motor in the pellet feeder. It’s a very simple program that waits for an input on a DIO-pin and on input it turns the motor 18° (there are 20 positions in our feeder disc). During rotation the motor sets a DIO-pin high, this signal can be used to control if the motion was executed in time or if anything went wrong. Motor documentation, drivers and software can be obtained from Trinamic.

In order to upload this program to the motor the code needs to be saved as textfile with ending *.tmc.

 // Trinamic stepper motor PD1141/ 1140
 // Program for use with pellet-feeder (www.jonasrose.net)
 
 // basic parameters
 SAP 138, 0, 1  // ramp mode
 SAP 4, 0, 1000 // speed
 SAP 5, 0, 150  // acceleration max
 SAP 6, 0, 150  // current max
 SAP 7, 0, 50   // holding force max

Loop: WAIT LIMSW, 0, 0 // wait for DIO-trigger
 SIO 0, 2, 1           // set DIO 0 high (can be used as error signal) 
 MVP REL, 0, 2560      // move (51200 total steps /2560 = 20 pos)
 WAIT POS, 0, 0        // wait until at new position
 WAIT TICKS, 0, 25     // wait 25 more tics to be safe
 SIO 0, 2, 0           // set DIO 0 low ()
 JA Loop               // loop