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: 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

    // *** Values that have to be adapted *** //
    stallGuardValue = 2  			//-64 = highest sensitivity ... 63 = lowest sensitivity
    vmax = 2000						//max. speed (0 ... 2047)
    amax = 1000						//max. acceleration (0 ... 2047)
    cmax = 100						//max. current (0 ... 255)
    
    // *** Initialization / Set up axis parameter *** //
    SAP 1, 0, 0    					//reset actual position to 0
    SAP 4, 0, vmax   				//set max. positioning speed
    SAP 5, 0, amax					//set max. acceleration
    SAP 6, 0, cmax    				//set max. current
    
    // *** stallGuard™ initialization *** //
    SAP 173, 0, 1    				//set stallGuard™ filter disable
    SAP 174, 0, stallGuardValue  	//stallGuard™ threshold
    SAP 181, 0, 1900  				//min. speed for motor to be stopped by stallGuard™
    
    // *** Interrupt initialization *** //
    VECT 15, returnToZero 			//defines the interrupt vector for the stallGuard™ interrupt
    EI 15 							//enable stall interrupt
    EI 255 							//globally switch on interrupt processing
    
    // *** Main Loop *** //
    loop:
    	GAP 3, 0					//get current speed
    	JC NZ, loop					//jump to loop if speed not zero
    	ROL 0, vmax					//turn motor left at vmax
    	JA loop						//jump to loop
    
    // *** Interrupt routine *** //
    returnToZero:
    	MVP ABS, 0, 0				//turn motor 0 to postion zero
    	WAIT POS, 0, 0				//wait until position zero reached
    	WAIT TICKS, 0, 500			//wait 5 seconds. 500 * 10ms
    	RETI						//end of interrupt
    

    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.

    Share this:

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

    Related

    December 5, 2015 / Jonas P. Proeger / 5

    Categories: Code Snippet, Tutorial

    Tags: interrupt, sensorless, stallGuard, TMCL

    TMCL: Door Contact with Position Mode TMCL: Interrupt Input Change

    Comments are currently closed.

    5 thoughts on “TMCL: Using the stallGuard Interrupt”

    • Jameer says:
      June 20, 2016 at 4:29 am

      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 says:
      January 11, 2018 at 11:06 am

      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 says:
      February 22, 2018 at 12:37 pm

      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?

    • Purva says:
      October 28, 2019 at 2:58 pm

      How to use above program for reversing the direction after every interrupt

    • Lars Jaskulski says:
      January 13, 2020 at 11:55 am

      Hi Purva,

      Thanks for your feedback and input. Do you need help in realizing this? If so, please let us know and we support you.

      Best regards,
      Lars

Recent Posts

  • 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
  • POWER STEERING

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.