TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
95
www.trinamic.com
9.11.2
Example Program 2
In the second example program, the encoder resolution is detected automatically. Here, the motor will run
increasing and decreasing the positioning counter while using position reached interrupts.
SAP 6, 0, 128 //set max. motor current
//Start encoder detection and wait until ready
SAP 132, 0, 1
Detect: GAP 132, 0
COMP 2
JC NE, Detect
//Switch on closed loop and wait until ready
SAP 129, 0, 1
Init: GAP 133, 0
JC ZE, Init
//Let motor run (using position reached interrupt)
VECT 3, PosReached1
EI 3
EI 255
MVP ABS, 0, 51200
Loop: WAIT TICKS, 0, 1000
JA Loop
PosReached1:
VECT 3, PosReached2
MVP ABS, 0, 0
RETI
PosReached2:
VECT 3, PosReached1
MVP ABS, 0, 51200
RETI