-
TMCL: how to implement a for loop
This program demonstrates how to implement a for loop
For more details look at TMCL_reference.pdfSGP 0, 2, 0 //set user variable #0 //for Loop forLoop: // add your code here // GGP 0, 2 //get user variable #0 to accu CALC ADD, 1 //add 1 to accu AGP 0, 2 //accu to user variable #0 COMP 5 //amount of loops JC LE, forLoop //jump to label forLoop STOP
Before use: Restore Factory Defaults
Related
December 17, 2015 / Jonas P. Proeger / 1
Categories: Code Snippet, Tutorial
Silent Night: TRAMS 3D Printer Board for Holiday Tinkering Season TRINAMIC announces TMCC160 motionCookie™
Comments are currently closed.
One thought on “TMCL: how to implement a for loop”
Hello. I’ve implemented behavior similar to this in a program that’s meant to constantly run the motors to limit switches and count the number of times it completes a cycle. When I run the program through TMCL-PC.exe, I’d like to use the Local Variables window to “watch” my execution counter. Unfortunately, the Local Variable window is always showing a zero on Bank 2, Index 0. Do I have something incorrect? My code looks like:
MAIN:
SGP 0,2,0,0
MST 0,0
MST 1,1
LOOP:
RFS START,0,1
RFS START,1,1
MST 0,0
MST 1,1
CSUB ROTATE_L0
CSUB ROTATE_L1
WAIT TICKS,0,3000
CSUB CHECK_LEFT_LIMITS
WAIT TICKS,0,3000
CSUB ROTATE_R0
CSUB ROTATE_R1
WAIT TICKS,0,3000
CSUB CHECK_RIGHT_LIMITS
GGP 0,2,0
CALC ADD,1
AGP 0,2,0
JA LOOP
STOP
I know I have some extra parameters on some of these commands, like the SGP, for example. When I leave off the extra parameters, however, TMCL-PC.exe refuses to complile my code and claims that I’m “missing parameters”. I’ve added zeroes after carefully consulting the TCML Reference and finding that there’s some “Don’t Care” parameters.