ADI Trinamic Blog

We transform digital information into physical motion.

 
  • Newsletter
  • Blog Ethics
  • Legal/Impressum
  • Main Website
Menu
  • Newsletter
  • Blog Ethics
  • Legal/Impressum
  • Main Website
  • TMCL: how to implement a for loop

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

    SGP 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

     

    Share this:

    • Twitter
    • Facebook
    • LinkedIn
    • Pinterest
    • Print
    • Email

    Related

    December 17, 2015 / Jonas P. Proeger / 1

    Categories: Code Snippet, Tutorial

    Tags: loop, TMCL

    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”

    • Andrew says:
      September 15, 2016 at 7:28 pm

      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.

Recent Posts

  • Guest Blog: UBC Thunderbots
  • Guest Blog: TURAG
  • Guest Blog: School of Engineering Telecom Physics University of Strasbourg
  • Guest Blog: STAR Dresden
  • Pushing the Limits of Stepper Motor Control in 3D Printing

Social

  • View trinamic.mc’s profile on Facebook
  • View Trinamic_MC’s profile on Twitter
  • View trinamic’s profile on GitHub
  • View UC4SHA5_GAw1Wbm2T2NWpWbA’s profile on YouTube

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Newsletter

 

Info

Waterloohain 5
22769 Hamburg
+49 40 514 806 40

Tags

3D printer 3d printing arduino BLDC cDriver code code snippet coolStep drive Driver ease of use ethercat eval kit evaluation kit Field Oriented Control FOC GUI guide heliostat How-To IC linear stage motion controller motor driver open source hardware programming rtmi servo servo controller IC setup silentstepstick stealthChop stepper stepper motor stepper motor driver stepper motor driver ic stepper motors technology TMC4671 tmc5130 TMCL TMCL-IDE TRINAMIC TRINAMIC Motion Control tuning

Tag Cloud

    3D printer 3d printing arduino BLDC cDriver code code snippet coolStep drive Driver ease of use ethercat eval kit evaluation kit Field Oriented Control FOC GUI guide heliostat How-To IC linear stage motion controller motor driver open source hardware programming rtmi servo servo controller IC setup silentstepstick stealthChop stepper stepper motor stepper motor driver stepper motor driver ic stepper motors technology TMC4671 tmc5130 TMCL TMCL-IDE TRINAMIC TRINAMIC Motion Control tuning

Pages

  • Blog Ethics
  • Newsletter
  • Player Embed
  • Search Videos
  • User Videos
  • Video Category
  • Video Tag

Categories

  • Competition
  • Guest blog
  • Industry News
  • Jobs
  • Myths about Motors
  • Open Source Hardware
  • Products
  • Projects
    • DIY
    • University Projects
  • Research
  • Social
  • Software
  • technology
  • Trade Shows
  • Tutorial
    • Code Snippet
  • Uncategorized

Copyright © 2015 TRINAMIC BlogTheme created by PWT. Powered by WordPress.org

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.