TMCL: how to implement a for loop

This program demonstrates how to implement a for loop
For more details look at TMCL_reference.pdf

Before use: Restore Factory Defaults

 

One Comment

  • Andrew Reply

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *