TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
94
www.trinamic.com
9.11
Example Programs: Closed Loop Operation
Both example programs show that it is necessary to set the maximum current first. Then, check (example
2) or set (example 1) the motor steps and the encoder steps before switching to closed loop operation.
After setting axis parameter 126 to 1 for closed loop mode wait until the closed loop flag is set!
9.11.1
Example Program 1
To run example program 1, an encoder with 40000 increments per rotation has to be connected. For
positioning, the commands MVP ABS and WAIT POS are used.
//Initialize the parameters
SAP 6, 0, 128 //max. current
SAP 202, 0, 200 //motor full steps
SAP 210, 0, 40000 //encoder steps
SAP 4, 0, 398105 //positioning speed
SAP 5, 0, 3981070 //acceleration
SAP 126, 0, 1023950 //correction speed
SAP 129, 0, 1 //switch on closed loop
ClWait: GAP 133, 0 //wait until closed loop is ready
JC ZE, ClWait
//Let motor run
Loop: MVP ABS, 0, 512000
WAIT POS, 0, 0
WAIT TICKS, 0, 100
MVP ABS, 0, 0
WAIT POS, 0, 0
WAIT TICKS, 0, 100
JA Loop
STOP