TMCL: Using the stallGuard Interrupt

TMCL is the simple way to implement your motion control application. With this series of simple coding examples we want to provide you an easy start.

This program demonstrates the stall detection with stallGuard2™. Motor 0 will run until it is stalled, then MCL program flow will be interrupted and the interrupt handling routine (here: returnToZero) will be called. After the detection of a stall the motor will run to postion zero. For more details concerning stallGuard2™ look at Applikation Note AN002_stallGuard2.pdf – http://www.trinamic.com/design-center/application-notes.

Before use: Restore Factory Defaults

For more details look at TMCL_reference.pdf  at http://www.trinamic.com/software-tools/tmcl-ide

This sample is tested with TMCM-1140, TMCM-1161, TMCM-6110.

3 Comments

  • Jameer

    Hi,
    Im currently working with the TMCM 1021 module. I’m programming it to stop the motor on stall. It does not seem to work with your above stated interrupt routine. Can you help me understand it with a simple program to show how it works?
    Your help will be much appreciated. Thanks.

  • Corné Bekkers

    Please note that for using stallGuard to find the reference position, you normally do not need the interrupt at all. Just run the motor until it has been automatically stopped by stallGuard. You can check this either by polling the actual speed or the stallGuard flag (axis parameter #207). Then, zero the position and switch off stallGuard (by setting parameter #181 to zero). Like this:

    SAP 6, 0, 64 //Change this value to fit your needs
    SAP 174, 0, 2 //Change this value to fit your needs (with the help of the stallGuard2 tool)
    SAP 181, 0, 500 //Minimum speed for stop on stall (change as needed)

    //Run until obstructed
    ROR 0, 1000 //Let the motor run until obstructed (or ROL as needed)
    Loop: GAP 207, 0 //See if the motor has been stopped due to a stall
    JC ZE, Loop

    //Set actual position as the zero position
    SAP 0, 0, 0
    SAP 1, 0, 0

    //Switch off stallGuard
    SAP 181, 0, 0

    So, stallGuard gets activated just with parameter #181. If this parameter is zero, then the automatic stop-on-stall is switched off. If it is >0 then stop-on-stall will be active when the actual velocity is greater then this value.

  • Parovel

    Hello,
    I confirm the program with the correction works on a TMCM 6110 module. I am using the stallGuard feature and monitoring the reply from the module however the GAP 207, 0 command does not give the right answer. What method you suggest as alternative to detect the stall in real-time?

Leave a Reply

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