Locale Icon
English
  • Forums

    Popular Forums

    • LTspice
    • RF and Microwave
    • Video
    • Power Management
    • Precision ADCs
    • FPGA Reference Designs
    • Linux Software Drivers

    Product Forums

    • Amplifiers
    • Microcontrollers
    • Clock and Timing
    • Data Converters
    • Direct Digital Synthesis (DDS)
    • Energy Monitoring and Metering
    • Interface and Isolation
    • MEMS Inertial Sensors
    • Power Management
    • Processors and DSP
    • Switches/Multiplexers
    • Temperature Sensors
    • Voltage References
    View All

    Application Forums

    • A2B
    • Audio
    • Automated Test Equipment (ATE)
    • Condition-Based Monitoring
    • Depth, Perception & Ranging Technologies
    • Embedded Vision Sensing Library
    • Motor Control Hardware Platforms
    • Precision Technology Signal Chains Library
    • Video
    • Wireless Sensor Networks Reference Library

    Design Center Forums

    • ACE Evaluation Software
    • ADEF System Platforms
    • Design Tools and Calculators
    • FPGA Reference Designs
    • Linux Software Drivers
    • Microcontroller no-OS Drivers
    • Power Studio Designer
    • Power Studio Planner
    • Reference Designs
    • Robot Operating System (ROS) SDK
    • Signal Chain Power (SCP)
    • Software Interface Tools
    • System Demonstration Platform (SDP) Support
  • Learn

    Highlighted Webinar

    Maximize Your Power Regulator: Key Considerations for Thermal Performance

    Power regulators with integrated switches deliver a compact, efficient way to supply power. Yet as modern circuits drive toward ever-higher power densities...

    Places

    • ADI Academy
    • ADI Webinars
    • Video Annex
    • Virtual Classroom

    Libraries

    • 3D ToF Depth Sensing Library
    • Continuous-Wave CMOS Time of Flight (TOF) Library
    • Embedded Vision Sensing Library
    • Gigabit Multimedia Serial Link (GMSL) Library
    • Optical Sensing Library
    • Precision Technology Signal Chains Library
    • Software Modules and SDKs Library
    • Supervisory Circuits Library
    • Wireless Sensor Networks Library

    Latest Webinars

    • Power Management Fundamentals II Session 6: Key Layout Considerations for Power
    • A 16T/16R X-Band Direct Sampling Phased Array Subsystem using Apollo MxFE
    • Power Management Fundamentals II Session 5: Deeper Look into Power Protection
    • Power Management Fundamentals II Session 4: Isolated Converters Explained
    • Maximize Your Power Regulator: Key Considerations for Thermal Performance
    View All Webinars
  • Community Hub

    Challenge Yourself!

      KCC's Quizzes AQQ295 about an audio logarithmic volume controller using linear pot - a proposal from Tim O'Brien

      1. Quote of the month: "Think like a proton. Always positive" - Unknown 2. New quiz of the month: AQQ295 about a audio logarithmic volume controller...

    View All

    What's Brewing

      Read a Blog, Take this Quiz for Another Chance to Win a Gift Card!

      Important: Read the blog first . The quiz questions are all based on the content from the blog: Let's Take a Field-Bus Trip Your field-bus engines...

    View All

    Places

    • Community Help
    • Logic Lounge
    • Super User Program
    • Analog Dialogue Quiz

    Resources

    • EZ Code of Conduct
    • EZ How To Help Articles
    • Getting Started Guide
    • ADI: Words Matter
    • Community Help Videos
    View All
  • Blogs

    Highlighted Blogs

    Understanding Voltage Domain Isolation in Field-Bus Systems

    By Christopher Nunes In the world of industrial communication, mastering voltage domain isolation is the key to building safer, smarter systems. Last...

     

    Ethernet-APL’s Impact on Functional, Intrinsic, and Cyber Safety

    Power limitations have always plagued process sensors, whether because of intrinsic safety requirements (safety achieved through power limitation) or because...

    Latest Blogs

    • Balancing Enhanced Radar Resolution with FPGA-Based Pulse Compression
    • ​​ISO 26262 Essentials: Ensuring Confidence in Your Software Tools ​
    • Step-by-Step: Implementing a Complete DSP Chain for Signal Analysis
    • Galvanic Isolation in SMPS: Ensuring Safety and Protection: Part 1 of 4
    • Mature, Not Old! The Longevity of 4 – 20 mA
    Read All Blogs

    ADI Blogs

    • EZ Spotlight
    • The Engineering Mind
  • ContentZone

    Visit ContentZone

    ContentZone

    Technical articles. Blogs. Videos. Your ADI content, all in one place.

    View ContentZone

    Featured Content

    Featured Content Title

    Blurb About Content

    View Content By Industry

    • Aerospace and Defense Systems
    • Automotive Solutions
    • Consumer Technology Solutions
    • Data Center Solutions
    • Energy Solutions
    • Healthcare Solutions
    • Industrial Automation Technology Solutions
    • Instrumentation and Measurement Solutions
    • Intelligent Building Solutions
    • Wireless Communication Solutions

    View Content By Technology

    • A2B Audio Bus
    • ADI OtoSense Predictive Maintenance Solutions
    • Dynamic Speaker Management
    • Gallium Nitride (GaN) Technology
    • Gigabit Multimedia Serial Link (GMSL)
    • Industrial Vision
    • Power Solutions
    • Precision Technology
    • RF
    • Sensor Interfaces
    • SmartMesh
EngineerZone
EngineerZone
Motor Control Hardware Platforms
  • Log In
  • User
  • Site
  • Search
OR
Ask a Question
Motor Control Hardware Platforms
Motor Control Hardware Platforms
Documents How do I use the StallGuard interrupt?
  • Forums
  • FAQs/ Docs
  • Members
  • Tags
  • Cancel
  • Documents
  • +ADIMonitor: FAQ
  • +Arduino: FAQ
  • +CM40x: FAQ
  • +Code Examples: FAQ
  • +Firmware: FAQ
  • +HPPWM: FAQ
  • +Motor Control: FAQ
  • +Motors: FAQ
  • +PCB Guidelines: FAQ
  • +Platform Schematics: FAQ
  • +Raspberry Pi: FAQ
  • +Specific Products: FAQ
  • +Technical: FAQ
  • -TMCL: FAQ
    • Can I load a TMCL file to a module without using the TMCL-IDE?
    • How can I change from CANopen firmware to TMCL firmware?
    • How can I change the ID of a module?
    • How can I enable autostart?
    • How do I control a module or Evaluation Kit with Matlab?
    • How do I implement a FOR loop in TMCL?
    • How do I implement Timer Interrupt in TMCL?
    • How do I send a TMCL program to the module?
    • How do I set an interrupt input change?
    • How do I use the StallGuard interrupt?
    • How do I use the X-register?
    • Is there a TMCL code library?
    • What is TMCL?
    • Where can I find the TMCL creator?
  • Topic: FAQ
  • Trinamic Customs: FAQ

How do I use 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 stallGuard2Tm. 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 position zero. For more details concerning stallGuard2Tm look at Application 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

// *** stallGuardTm initialization *** //
SAP 173, 0, 1 //set stallGuardTm filter disable
SAP 174, 0, stallGuardValue //stallGuardTm threshold
SAP 181, 0, 1900 //min. speed for motor to be stopped by stallGuardTm

// *** Interrupt initialization *** //
VECT 15, returnToZero //defines the interrupt vector for the stallGuardTm 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
  • Share
  • History
  • More
  • Cancel
 
Related Content
  • How do I use the TMCL StallGuard interrupt?
    MSDAPI
    Trinamic's TMCL is the simple way to implement your motion control application. With this simple coding example, we want to provide you with an easy start. This program demonstrates the stall detection...
  • TMCL: Using the stallGuard Interrupt
    TMCL: Using the stallGuard Interrupt
    EZ Blogs - 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...
  • Inquiry on how to code TMCL Language for coordinate setting(TMCM-6214)
    jpaulhwang
    Hi all, I want to set the coordinates using the TMCM-6214 and TMCL Language. first of all, I want to make a coordinates shown as below. I using the 2 motor(x axis-1ea, y axis-1ea) and I want the...
 
Related Content
  • How do I use the TMCL StallGuard interrupt?
    MSDAPI
    Trinamic's TMCL is the simple way to implement your motion control application. With this simple coding example, we want to provide you with an easy start. This program demonstrates the stall detection...
  • TMCL: Using the stallGuard Interrupt
    TMCL: Using the stallGuard Interrupt
    EZ Blogs - 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...
  • Inquiry on how to code TMCL Language for coordinate setting(TMCM-6214)
    jpaulhwang
    Hi all, I want to set the coordinates using the TMCM-6214 and TMCL Language. first of all, I want to make a coordinates shown as below. I using the 2 motor(x axis-1ea, y axis-1ea) and I want the...
analog-devices logo

About Analog Devices

  • Who We Are
  • Careers
  • Newsroom
  • What We Do (Signals+)
  • Investor RelationsExternalLink
  • Quality & Reliability
  • Sales and Distribution
  • What's New on Analog.com
  • Contact Us

Find Help

  • Support
  • Resources
  • WikiExternalLink
  • Analog Dialogue
  • ADI Developer PortalExternalLink

myAnalog

Interested in the latest news and articles about ADI products, design tools, training, and events?

Go to myAnalog
  • Instagram page
  • Twitter page
  • Linkedin page
  • Youtube page
  • Facebook
  • Legal and Risk
  • Accessibility
  • Privacy Policy
  • Privacy Settings
  • Cookie Settings

©2025 Analog Devices, Inc. All Rights Reserved

analog-devices

About Analog Devices

Down Up
  • Who We Are
  • Careers
  • Newsroom
  • What We Do (Signals+)
  • Investor RelationsExternalLink
  • Quality & Reliability
  • Sales and Distribution
  • What's New on Analog.com
  • Contact Us

Find Help

Down Up
  • Support
  • Resources
  • WikiExternalLink
  • Analog Dialogue
  • ADI Developer PortalExternalLink

myAnalog

Interested in the latest news and articles about ADI products, design tools, training, and events?

Go to myAnalog
Instagram page Facebook Twitter page Linkedin page Youtube page
  • Legal and Risk
  • Accessibility
  • Privacy Policy
  • Privacy Settings
  • Cookie Settings

©2025 Analog Devices, Inc. All Rights Reserved