TMCL: Usage of subroutines
TMCL is the simple way to implement your motion control application. With this series of simple coding examples we want to provide you an easy start.
This programs demonstrates the usage of subroutines and is turning motor 0 for 5 seconds left and then forn 5 seconds right, same as EX0001 except for the movement commands to be outsourced into subroutines.
Before use: Restore Factory Defaults
// *** Values that have to be adapted *** // amax = 1000 //max. acceleration (0 ... 2047) vmax = 2000 //max. speed (0 ... 2047) cmax = 100 //max. current (0 ... 255) // *** Initialization / Set up axis parameter *** // SAP 5, 0, amax //set max. acceleration SAP 6, 0, cmax //set max. current // *** Main Loop *** // loop: CSUB turnLeft //jump to subroutine turnLeft WAIT TICKS, 0, 500 //wait 5 seconds. 500 * 10ms CSUB turnRight //jump to subroutine turnRight WAIT TICKS, 0, 500 //wait 5 seconds. 500 * 10ms JA loop //jump to loop // *** Subroutine turnLeft *** // turnLeft: ROL 0, vmax //turn left at vmax RSUB //end of subroutine // *** Subroutine turnRight *** // turnRight: ROR 0, vmax //turn right at vmax RSUB //end of subroutine
For more details look at TMCL_reference.pdf at http://www.trinamic.com/software-tools/tmcl-ide
Basic Commands, this sample can be used with any TMCL module with one or multiple axes tested with TMCM-1140, TMCM-1161, TMCM-6110.
October 29, 2015 / Jonas P. Proeger / 0