Thursday, December 14, 2023

TMC2209 stepper driver module tutorial

My first stepper driver module was A4988 and recently I have decided to give TMC2209 a try hearing how silent and energy efficient it is. Driving the A4988 is simple - just set direction, pulse the step pin and the motor moves. You can do the same thing with TMC2209 but this thing can do much more. It has UART interface, registers, algorithms and an 83 pages datasheet. I might be slow but I had to read the datasheet 3 times to wrap my head around on what things can this thing do. In my opinion it is a very good stepper driver so I made a library for it and also this tutorial to better help in using the library. Although the IC presented in this tutorial is TMC2209, most information can still be applied to other TMC ICs.

Contents

 

TMC2209 description

The TMC2209 is an ultra-silent motor driver IC for two phase stepper motors, developed by trinamic. TMC2209 pinning is compatible to other drivers as well as to the TMC2208. 

TMC2209 stepper driver module tutorial
Multiple versions of modules can be found that are using this IC, however the stand-alone chip can be used for a DIY module that could provide some cost savings.

Features:

  • 2-phase stepper motors up to 2.8A coil current (peak), 2A RMS
  • STEP/DIR Interface with 8, 16, 32 or 64 microstep pin setting
  • Smooth Running 256 microsteps by MicroPlyer™ interpolation
  • StealthChop2™ silent motor operation
  • SpreadCycle™ highly dynamic motor control chopper
  • StallGuard4™ load and stall detection for StealthChop
  • CoolStep™ current control for energy savings up to 75%
  • Low RDSon, Low Heat-Up LS 170mΩ & HS 170mΩ (typ. at 25°C)
  • Voltage Range 4.75… 29V DC
  • Internal Sense Resistor option (no sense resistors required)
  • Passive Braking, Freewheeling, and automatic power down
  • Single Wire UART & OTP for advanced configuration options
  • Integrated Pulse Generator for standalone motion
 

Modes of operation

The way you decide how to interface with the driver, dictates how the pins will be connected. The TMC2209 can be used in three modes:

OPTION 1: Standalone STEP/DIR Driver (Legacy Mode)

In this mode a microcontroller is used to generate step and direction signals. Motor run-current either is fixed, or set by the CPU using the analog input VREF. The pin PDN_UART selects automatic standstill current reduction. Feedback from the driver to the CPU is granted by the INDEX and DIAG output signals. Enable or disable the motor using the ENN pin.

OPTION 2: Standalone STEP/DIR Driver with OTP pre-configuration

To enable additional options, either one-time program the driver’s OTP memory, or store configuration in the CPU and transfer it to the on-chip registers following each power-up. Operation uses the same signals as Option 1. Programming does not need to be done within the application - it can be executed during testing of the PCB! Alternatively, use bit-banging by CPU firmware to configure the driver. Multiple drivers can be programmed at the same time using a single TXD line.

 Note that once the OTP (One Time Programmable) memory is programmed it cannot be changed.

OPTION 3: STEP/DIR Driver with Full Diagnostics and Control

This mode can make use of all additional options available by using UART interface. PDN_UART is connected to the CPU UART interface.

Additional options:

  • Detailed diagnostics and thermal management
  • Passive braking and freewheeling for flexible, lowest power stop modes
  • More options for microstep resolution setting (fullstep to 256 microstep)
  • Software controlled motor current setting and more chopper options
  • Use StallGuard for sensorless homing and CoolStep for adaptive motor current and cool motor

This mode allows replacing all control lines like ENN, DIAG, INDEX, MS1, MS2, and analog current setting VREF by a single interface line. This way, only three signals are required for full control: STEP, DIR and PDN_UART. Even motion without external STEP pulses is provided by an internal programmable step pulse generator: Just set the desired motor velocity. However, no ramping is provided by the TMC2209.

TMC2209 module pinout


TMC2209 module pinout

Pin functions

IO GND - logic supply ground

IO VCC - logic supply voltage (3.3 to 5V)

M1A and M1B - motor coil 1

M2A and M2B - motor coil 2

MOT GND -  motor power ground

MOT VCC - motor supply voltage (5.5 to 28V). A minimum capacity of 100uF is recommended on the motor power rail. A higher voltage such as 18...24V is better than 12V, in terms of less noise and higher speed since at higher speeds the power supply needs to be higher than the motor back EMF that gets larger with increasing speed.

If the motor is running/moving, then it is not recommended to switch off the power supply or disconnect the motor. Always make sure that the motor stands still and the motor outputs are deactivated on shutting down, otherwise the driver IC can get damaged (because of back EMF). An emergency stop can be realized, when the EN pin is set to VIO (high). This will switch off all motor output drivers and will put the motor into freewheeling.

EN - enable, active low. The power stage becomes switched off (all motor outputs floating) when this pin becomes driven to a high level. Can be connected to ground in UART mode and disable the driver using software commands.

MS1 (AD0) and MS2 (AD1) - microstep resolution configuration or 2 bit UART address. These pins have internal pull-down resistors so they can be left floating if 1/8 microstep resolution is desired or UART address in 0.

For UART based configuration pin MS1 represents bit 0 and pin MS2, bit 2 of UART slave address resulting in an address range from 0 to 3.

TMC2209 MS1 and MS2 microstep configuration
TMC2209 microstep configuration using MS1 and MS2 pins

SPREAD - chopper mode selection: Low=StealthChop, High=SpreadCycle (internal pull-down resistors, may be left unconnected). Chopper mode can be selected by software in UART mode. If the operating mode (stealthChop or spreadCycle) cannot be set via UART correctly, then check if the SPREAD pin is not connected to any other signal because the operating mode will toggle, if the pin state (low or high) is changed.

PDN_UART - power down active low control input (low = enable automatic power down in standstill periods, high = disable automatic power down) or UART input/output.

When using the UART interface, the configuration pin should be disabled via GCONF.pdn_disable = 1. Program IHOLD as desired for standstill periods.

One of the PDN_UART is NC (Not Connected) depending on how the on-board jumper resistor is soldered.

STEP - step input. Only rising edges are active. Minimum input low/high time is 100ns.

DIR - direction input (internal pull-down resistor).

STEP and DIR are sampled and synchronized to the system clock (default 12MHzt). An internal analog filter removes glitches on the signals, such as those caused by long PCB traces.

INDEX - by default the index output gives one pulse per electrical rotation, i.e. one pulse per each four full-steps. 

In UART mode it can be set to trigger on over-temperature prewarning or to toggle on each step pulse from internal pulse generator.

DIAG - diagnostic and StallGuard output. High level upon stall detection or driver error. Reset error condition by EN=high.

An active DIAG output shows that the driver cannot work normally, or that a motor stall is detected, when StallGuard is enabled.

TMC2209 DIAG and INDEX outputs

VREF - analog reference voltage.

Note: on some modules DIAG, INDEX and VREF are on different pins.

Attaching the TMC2209 to a microcontroller UART

The UART interface on the TMC2209 uses a single bi-direction pin. The IC checks PDN_UART for correctly received datagrams with its own address continuously. It adapts to the baud rate based on the sync nibble. In case of a read access, it switches on its output drivers and sends its response using the same baud rate. The output becomes switched off four bit times after transfer of the last stop bit.

TMC22xx UART interface
TMC22xx UART interface

The UART RXD pin is connected directly to PDN_UART, while TXD pin must be connected through 1k resistor to the PDN_UART pin.

Setting the analog motor current

Before enabling the driver, it is important to set the motor current by scaling the voltage at the Vref pin using the potentiometer on the module. Using UART, the set current can be scaled down.

Setting Vref:

First make sure the EN pin is connected to VCC_IO to keep the motor disabled. Connect the negative multimeter probe to GND and the positive probe to a metallic screwdriver by using an alligator clip. This way you can see the reference voltage on the multimeter while turning the potentiometer since it is connected to VREF.

Do not set the drivers to the maximum rated current of the respective stepper motor. A good point to start is half of the rated current and if there are problems (like step losses) then set a higher current in 0.1A steps till everything works.

For NEMA 17 motors, the current is in general in the range of 0.5A to 0.8A RMS, which is a reference voltage (Vref) of 0.7V to 1.1V.

TMC2209 maximum current

The datasheet states that the maximum RMS current is 2A, however this also depends on the value of current sense resistors. On modules with 110 milliohms resistors, the maximum current is 1.77A RMS.

More about analog motor current control can be found in the datasheet at chapters 8 (Selecting Sense Resistors), 9 (Motor Current Control), 10 (Internal Sense Resistors).

Calculating Vref

Given the maximum voltage at Vref pin of 2.5V and maximum current of 1.77A RMS, Vref can be calculated as follows:

Vref = (Irms * 2.5V) / 1.77A

An online calculator can be found here.

The following formula also calculates Vref but doesn't assume a maximum current based on the sense resistors:

TMC2209 Vref formula current calculation based on Irms, Vfs, Rsense
Irms: desired RMS current

2.5V: maximum Vref voltage which is VCC / 2 = 5V / 2

Rsense: current sense resistor value

Vfs: full scale voltage as determined by vsense control bit (0.325V default)

This formula is implemented in the spreadsheet calculator that can be downloaded at the end of this page. Formula is derived from the datasheet formula:

TMC2209 Irms current calculation formula

Setting the digital motor current

Motor run and standstill current can be scaled down using IHOLD_IRUN register via UART

Register IHOLD_IRUN

IRUN (0 to 31). 31 is maximum current set by VREF. Current scale when motor is running. Scales coil current values as taken from the internal sine wave table. For high precision motor operation, work with a current scaling factor in the range 16 to 31, because scaling down the current values reduces the effective microstep resolution by making microsteps coarser.

Hint: Choose sense resistors in a way, that normal IRUN is 16 to 31 for best microstep performance.

IHOLD - Identical to IRUN, but for motor in stand still. This is usually half of IRUN. In combination with StealthChop mode, setting IHOLD=0 allows to choose freewheeling or coil short circuit (passive braking) for motor stand still.

Formula for RMS current calculation taking in consideration IRUN and IHOLD scaling, is provided by the datasheet as follows:

TMC2209 RMS current calculation formula using Irun Ihold values

Automatic Standstill Power Down

An automatic current reduction drastically reduces power dissipation and cooling requirements. Per default, the stand still current reduction is enabled by pulling PDN_UART input to GND. It reduces standstill power dissipation to less than 33% by going to slightly more than half of the run current.

Modify stand still current, delay time and decay via UART, or pre-programmed via internal OTP. Automatic freewheeling and passive motor braking are provided as an option for stand still. Passive braking reduces motor standstill power consumption to zero, while still providing effective dampening and braking!

TMC2209 automatic standstill power down

These power reduction methods are useful when the motor can hold it's position with less or no power.

Register TPOWERDOWN (0...255)

Sets the delay time from stand still detection to motor current power down. Time range is about 0 to 5.6 seconds. A minimum setting of 2 is required to allow automatic tuning of StealthChop PWM_OFFS_AUTO. 

To convert a time value (0 to 5.6s) to a register value (0 to 255) use the spreadsheet calculator at the end of the page.

IHOLDDELAY (0...15)

IHOLDDELAY is located inside IHOLD_IRUN register and is used to control the number of clock cycles for motor power down after standstill is detected and TPOWERDOWN has expired. The smooth transition avoids a motor jerk upon power down.

0 - instant power down.

1...15 - delay per current reduction step in multiple of 2^18 clocks.

To convert a register value (0 to 15) to a time value in seconds, use the spreadsheet calculator at the end of the page.

StealthChop2 & SpreadCycle Driver

StealthChop & SpreadCycle are two chopper technologies developed by Trinamic. These are basically ways to drive the motor, and each has advantages and disadvantages.

StealthChop

StealthChop is a voltage-chopper based principle. It especially guarantees that the motor is absolutely quiet in standstill and in slow motion, except for noise generated by ball bearings. Unlike other voltage mode choppers, StealthChop2 does not require any configuration. It automatically learns the best settings during the first motion after power up and further optimizes the settings in subsequent motions. An initial homing sequence is sufficient for learning. Optionally, initial learning parameters can be stored to OTP.

Benefits of using StealthChop2: 

- Significantly improved microstepping with low cost motors 

- Motor runs smooth and quiet 

- Absolutely no standby noise 

- Reduced mechanical resonance yields improved torque

StealthChop Automatic Tuning

StealthChop2 integrates an automatic tuning procedure (AT), which adapts the most important operating parameters to the motor automatically. This way, StealthChop2 allows high motor dynamics and supports powering down the motor to very low currents. Just two steps have to be respected by the motion controller for best results: Start with the motor in standstill, but powered with nominal run current (AT#1). Move the motor at a medium velocity, e.g. as part of a homing procedure (AT#2).

StealthChop Automatic Tuning

This two steps of automatic tuning could be implemented in a homing routine. However if you desire to fully optimize the StealthChop driver, there are some register values that can be optimized. All these can be found at chapter 6 of the datasheet.

Freewheeling and Passive Braking

StealthChop provides different options for motor standstill. These options can be enabled by setting the standstill current IHOLD to zero and choosing the desired option using the FREEWHEEL setting. The desired option becomes enabled after a time period specified by TPOWERDOWN and IHOLD_DELAY. With the freewheeling options, both freewheeling and passive braking can be realized. Passive braking is an effective eddy current motor braking, which consumes a minimum of energy, because no active current is driven into the coils. However, passive braking will allow slow turning of the motor when a continuous torque is applied.

TMC freewheeling and passive braking

SpreadCycle

For highest velocity applications, SpreadCycle is an option to StealthChop2. It can be enabled via SPREAD input pin or via UART and OTP. StealthChop2 and SpreadCycle may even be used in a combined configuration for the best of both worlds: StealthChop2 for no-noise stand still, silent and smooth performance, SpreadCycle at higher velocity for high dynamics and highest peak velocity at low vibration. The SpreadCycle will provide superior microstepping quality even with default settings.

While StealthChop is a voltage mode PWM controlled chopper, SpreadCycle is a cycle-by-cycle current control. Therefore, it can react extremely fast to changes in motor velocity or motor load. SpreadCycle will give better performance in medium to high velocity range for motors and applications which tend to resonance.

The chopper frequency is an important parameter for a chopped motor driver. A too low frequency might generate audible noise. A higher frequency reduces current ripple in the motor, but with a too high frequency magnetic losses may rise. Also power dissipation in the driver rises with increasing frequency due to the increased influence of switching slopes causing dynamic dissipation. Therefore, a compromise needs to be found. Most motors are optimally working in a frequency range of 16 kHz to 30 kHz. The chopper frequency is influenced by a number of parameter settings as well as by the motor inductivity and supply voltage.

For more detailed information on how to optimize SpreadCycle, see chapters 7 and 16 of the datasheet and Parameterization of spreadCycle - AN-001.

Combine StealthChop and SpreadCycle

For applications requiring high velocity motion, SpreadCycle may bring more stable operation in the upper velocity range. To combine no-noise operation with highest dynamic performance, the TMC2209 allows combining StealthChop and SpreadCycle based on a velocity threshold (Figure 6.7). A velocity threshold (TPWMTHRS) can be preprogrammed to OTP to support this mode even in standalone operation. With this, StealthChop is only active at low velocities.

As a first step, both chopper principles should be parameterized and optimized individually (SpreadCycle settings may be programmed to OTP memory). In a next step, a transfer velocity has to be fixed. For example, StealthChop operation is used for precise low speed positioning, while SpreadCycle shall be used for highly dynamic motion. TPWMTHRS determines the transition velocity. Read out TSTEP when moving at the desired velocity and program the resulting value to TPWMTHRS. Use a low transfer velocity to avoid a jerk at the switching point.

A jerk occurs when switching at higher velocities, because the back-EMF of the motor (which rises with the velocity) causes a phase shift of up to 90° between motor voltage and motor current. So when switching at higher velocities between voltage PWM and current PWM mode, this jerk will occur with increased intensity. A high jerk may even produce a temporary overcurrent condition (depending on the motor coil resistance). At low velocities (e.g. 1 to a few 10 RPM), it can be completely neglected for most motors. Therefore, consider the switching jerk when choosing TPWMTHRS. Set TPWMTHRS zero if you want to work with StealthChop only.

Register TPWMTHRS

Sets the upper velocity for StealthChop voltage PWM mode. 

TSTEP ≥ TPWMTHRS 

- StealthChop PWM mode is enabled, if configured.

When the velocity exceeds the limit set by TPWMTHRS, the driver switches to SpreadCycle. This also disables CoolStep and StallGuard.

0: Disabled. Work with StealthChop only.

StallGuard4 Load Measurement

StallGuard4 provides an accurate measurement of the load on the motor. It is developed for operation in conjunction with StealthChop. StallGuard can be used for stall detection as well as other uses at loads below those which stall the motor, such as CoolStep load-adaptive current reduction. The StallGuard4 measurement value changes linearly over a wide range of load, velocity, and current settings, as shown in Figure 11.1. When approaching maximum motor load, the value goes down to a motor-specific lower value. This corresponds to a load angle of 90° between the magnetic field of the coils and magnets in the rotor. This also is the most energy-efficient point of operation for the motor.

TMC StallGuard

SG_RESULT (0...510)

This is the StallGuard4 result. A higher reading indicates less mechanical load. A lower reading indicates a higher load and thus a higher load angle.

SGTHRS (0...255)

This value controls the StallGuard4 threshold level for stall detection. A higher value gives a higher sensitivity. A higher value makes StallGuard4 more sensitive and requires less torque to indicate a stall.

The double of this value is compared to SG_RESULT. The stall output becomes active if SG_RESULT fall below this value.

On stall detection, DIAG pin will be pulsed high. A pin interrupt could be used to take a certain action upon stall detection, like stopping the motor for example.

StallGuard4 vs. StallGuard2

StallGuard4 is optimized for operation with StealthChop, its predecessor StallGuard2 works with SpreadCycle. The function is similar: Both deliver a load value, going from a high value at low load, to a low value at high load. While StallGuard2 becomes tuned to show a “0”-reading for stall detection, StallGuard4 uses a comparison-value to trigger stall detection, rather than shifting SG_RESULT itself.

Tuning StallGuard4

The StallGuard4 value SG_RESULT is affected by motor-specific characteristics and application-specific demands on load, coil current, and velocity. Therefore, the easiest way to tune the StallGuard4 threshold SGTHRS for a specific motor type and operating conditions is interactive tuning in the actual application.

Procedure for tuning SGTHRS:

1. Operate the motor at the normal operation velocity for your application and monitor SG_RESULT. 

2. Apply slowly increasing mechanical load to the motor. Check the lowest value of SG_RESULT before the motor stalls. Use this value as starting value for SGTHRS (apply half of the value). 

3. Now monitor the StallGuard output signal via DIAG output (configure properly, also set TCOOLTHRS to match the lower velocity limit for operation) and stop the motor when a pulse is seen on the respective output. Make sure, that the motor is safely stopped whenever it is stalled. Increase SGTHRS if the motor becomes stopped before a stall occurs. 

4. The optimum setting is reached when a stall is safely detected and leads to a pulse at DIAG in the moment where the stall occurs. SGTHRS in most cases can be tuned for a certain motion velocity or a velocity range. Make sure, that the setting works reliable in a certain range (e.g. 80% to 120% of desired velocity) and also under extreme motor conditions (lowest and highest applicable temperature).

StallGuard4 Update Rate

The StallGuard4 measurement value SG_RESULT is updated with each full step of the motor. This is enough to safely detect a stall, because a stall always means the loss of four full steps.

Detecting a Motor Stall

To safely detect a motor stall, the stall threshold must be determined using a specific SGTHRS setting and a specific motor velocity or velocity range. Further, the motor current setting has a certain influence and should not be modified, once optimum values are determined. Therefore, the maximum load needs to be determined the motor can drive without stalling. At the same time, monitor SG_RESULT at this load. The stall threshold should be a value safely within the operating limits, to allow for parameter stray. More refined evaluation may also react to a change of SG_RESULT rather than comparing to a fixed threshold. This will rule out certain effects which influence the absolute value.

Limits of StallGuard4 Operation

StallGuard4 does not operate reliably at extreme motor velocities: Very low motor velocities (for many motors, less than one revolution per second) generate a low back EMF and make the measurement unstable and dependent on environment conditions (temperature, etc.). Other conditions will also lead to a poor response of the measurement value SG_RESULT to the motor load. Very high motor velocities, in which the full sinusoidal current is not driven into the motor coils also leads to poor response. These velocities are typically characterized by the motor back EMF exceeding the supply voltage.

CoolStep Operation

CoolStep technology makes use of StallGuard to adapt the current to the load. When load decreases, the current is also decreased.

Because a stepper motor application needs to work with a torque reserve of 30% to 50%, even a constant-load application allows significant energy savings because CoolStep automatically enables torque reserve when required. Reducing power consumption keeps the system cooler, increases motor life, and allows reducing cost in the power supply and cooling components.

Reducing motor current by half results in reducing power by a factor of four.

Setting up CoolStep

CoolStep is controlled by several parameters, but two are critical for understanding how it works:

SEMIN (0...15)

4-bit unsigned integer that sets a lower threshold. If SG_RESULT goes below this threshold, CoolStep increases the current to both coils. The 4-bit SEMIN value is scaled by 32 to cover the lower half of the range of the 10-bit SG value. (The name of this parameter is derived from SmartEnergy, which is an earlier name for CoolStep.)

0 - disable CoolStep

1...15 - threshold is SEMIN*32. Once SGTHRS has been determined, use 1/16*SGTHRS+1 as a starting point for SEMIN.

SEMAX (0...15)

4-bit unsigned integer that controls an upper threshold. If SG is sampled equal to or above this threshold enough times, CoolStep decreases the current to both coils. The upper threshold is (SEMIN + SEMAX + 1)*32.

threshold is (SEMIN+SEMAX+1)*32. 0 to 2 recommended.

When the load increases, SG_RESULT falls below SEMIN, and CoolStep increases the current. When the load decreases, SG_RESULT rises above (SEMIN + SEMAX + 1) * 32, and the current is reduced.

Following parameters also control CoolStep:

CoolStep parameters

Tuning CoolStep

CoolStep uses SG_RESULT to operate the motor near the optimum load angle of +90°. The basic setting to be tuned is SEMIN. Set SEMIN to a value which safely activates CoolStep current increment before the motor stalls. In case SGTHRS has been tuned before, a lower starting value is:

SEMIN = 1+SGTHRS/16.

The current increment speed is specified in SEUP, and the current decrement speed is specified in SEDN. They can be tuned separately because they are triggered by different events that may need different responses. The encodings for these parameters allow the coil currents to be increased much more quickly than decreased, because crossing the lower threshold is a more serious event that may require a faster response. If the response is too slow, the motor may stall. In contrast, a slow response to crossing the upper threshold does not risk anything more serious than missing an opportunity to save power.

CoolStep operates between limits controlled by the current scale parameter IRUN and the seimin bit.

Attention: When CoolStep increases motor current, spurious detection of motor stall may occur. For best results, disable CoolStep during StallGuard based homing. In case StallGuard is desired in combination with CoolStep, try increasing coolStep lower threshold SEMIN as required.

Response Time

For fast response to increasing motor load, use a high current increment step SEUP. If the motor load changes slowly, a lower current increment step can be used to avoid motor oscillations.

For more detailed information on how to optimize CoolStep and StallGuard, see chapters 11, 12 and 16 of the datasheet and Parameterization of StallGuard & CoolStep - AN-002.

CoolStep and StallGuard speed threshold

Because CoolStep is not able to measure the motor load in standstill and at very low RPM, a lower velocity threshold is provided for enabling CoolStep. It should be set to an application specific default value. Below this threshold the normal current setting via IRUN respectively IHOLD is valid.

The most common and most beneficial use is to adapt CoolStep for operation at the typical system target operation velocity and to set the velocity thresholds according. As acceleration and deceleration normally shall be quick, they will require the full motor current, while they have only a small contribution to overall power consumption due to their short duration.

To set a minimum speed threshold for CoolStep and StallGuard, use the TCOOLTHRS register.

Register TCOOLTHRS (1...2^20-1)

Specifies lower CoolStep velocity by comparing the threshold value to TSTEP.

This is the lower threshold velocity for switching on smart energy CoolStep and StallGuard to DIAG output. (unsigned). Set this parameter to disable CoolStep at low speeds, where it cannot work reliably. The stall output signal become enabled when exceeding this velocity. It becomes disabled again once the velocity falls below this threshold. 

TCOOLTHRS ≥ TSTEP > TPWMTHRS

- CoolStep is enabled, if configured (only with StealthChop) 

- Stall output signal on pin DIAG is enabled

Driver Diagnostic Flags

(Chapter 15 of the datasheet)

The TMC2209 drivers supply a complete set of diagnostic and protection capabilities, like short to GND protection, short to VS protection and undervoltage detection. A detection of an open load condition allows testing if a motor coil connection is interrupted. See the DRV_STATUS table for details.

Temperature Measurement

The driver integrates a four-level temperature sensor (pre-warning and thermal shutdown) for diagnostics and for protection of the IC against excess heat. The thresholds can be adapted by UART or OTP programming. Heat is mainly generated by the motor driver stages, and, at increased voltage, by the internal voltage regulator. Most critical situations, where the driver MOSFETs could be overheated, are avoided by the short to GND protection. For many applications, the overtemperature pre-warning will indicate an abnormal operation situation and can be used to initiate user warning or power reduction measures like motor current reduction. The thermal shutdown is just an emergency measure and temperature rising to the shutdown level should be prevented by design.

TMC temperature thresholds

After triggering the overtemperature sensor (ot flag), the driver remains switched off until the system temperature falls below the pre-warning level (otpw) to avoid continuous heating to the shutdown level.

Short Protection

The TMC2209 power stages are protected against a short circuit condition by an additional measurement of the current flowing through each of the power stage MOSFETs. This is important, as most short circuit conditions result from a motor cable insulation defect, e.g. when touching the conducting parts connected to the system ground. The short detection is protected against spurious triggering, e.g. by ESD discharges, by retrying three times before switching off the motor.

Once a short condition is safely detected, the corresponding driver bridge (A or B) becomes switched off, and the s2ga or s2gb flag, respectively s2vsa or s2vsb becomes set. In order to restart the motor, disable and re-enable the driver. Note, that short protection cannot protect the system and the power stages for all possible short events, as a short event is rather undefined and a complex network of external components may be involved. Therefore, short circuits should basically be avoided.

Open Load Diagnostics

Interrupted cables are a common cause for systems failing, e.g. when connectors are not firmly plugged. The TMC2209 detects open load conditions by checking, if it can reach the desired motor coil current. This way, also undervoltage conditions, high motor velocity settings or short and overtemperature conditions may cause triggering of the open load flag, and inform the user, that motor torque may suffer. In motor stand still, open load cannot always be measured, as the coils might eventually have zero current.

Open load detection is provided for system debugging. In order to safely detect an interrupted coil connection, read out the open load flags at low or nominal motor velocity operation, only. If possible, use SpreadCycle for testing, as it provides the most accurate test. However, the ola and olb flags have just informative character and do not cause any action of the driver.

Diagnostic Output

The diagnostic output DIAG and the index output INDEX provide important status information. An active DIAG output shows that the driver cannot work normally, or that a motor stall is detected, when StallGuard is enabled. The INDEX output signals the microstep counter zero position, to allow referencing (homing) a drive to a certain current pattern. The function set of the INDEX output can be modified by UART. Figure 15.1 shows the available signals and control bits.

TMC diagnostic output

DRV_STATUS – Driver Status Flags


TMC DRV_STATUS register - bits 16-31

TMC DRV_STATUS register - bits 8-15

TMC DRV_STATUS register - bits 0-7

Internal Step Pulse Generator

The TMC2209 family integrates a high-resolution step pulse generator, allowing motor motion via the UART interface. However, no velocity ramping is provided. Ramping is not required, if the target motion velocity is smaller than the start & stop frequency of the motor. For higher velocities, ramp up the frequency in small steps to accelerate the motor, and ramp down again to decelerate the motor.

Figure 14.1 shows an example motion profile ramping up the motion velocity in discrete steps. Choose the ramp velocity steps considerably smaller than the maximum start velocity of the motor, because motor torque drops at higher velocity, and motor load at higher velocity typically increases.

TMC2209 internal step pulse generator

Calculating VACTUAL to set the speed


TMC2209 Internal step pulse generator parameters

To monitor internal step pulse execution, program the INDEX output to provide step pulses (GCONF.index_step). It toggles upon each step. Use a timer input on your CPU to count pulses. Alternatively, regularly poll MSCNT to grasp steps done in the previous polling interval. It wraps around from 1023 to 0.

External Reset

The chip is loaded with default values during power on via its internal power-on reset. Some of the registers are initialized from the OTP at power up. In order to reset the chip to power on defaults, any of the supply voltages monitored by internal reset circuitry (VS, +5VOUT or VCC_IO) must be cycled. As +5VOUT is the output of the internal voltage regulator, it cannot be cycled via an external source except by cycling VS. It is easiest and safest to cycle VCC_IO in order to completely reset the chip. Also, current consumed from VCC_IO is low and therefore it has simple driving requirements. Due to the input protection diodes not allowing the digital inputs to rise above VCC_IO level, all inputs must be driven low during this reset operation. When this is not possible, an input protection resistor may be used to limit current flowing into the related inputs.


v1.0 TMC2209 calculator.ods LibreOffice spreadsheet ods file

TMC2209 datasheet v1.03.pdf

TMC2209 library

https://learn.watterott.com/silentstepstick More informations about TMC drivers
 

How to use A4988 stepper motor driver module

No comments:

Post a Comment