Reference

Last revision 2026/01/30

Troubleshooting

Stepper Motor

A stepper motor is a special electromagnetic motor which can convert pulse signals into corresponding angular displacement (or linear displacement). Ordinary motors continuously rotate, but in stepper motors there are two basic states: positioning and revolving. Once there is a pulse input, stepper motor will rotate a certain angle, which we call a "step".

Control Mode

The TMC260 driver chip has two different control modes: SPI and STEP/DIR interface.

The TMC260 requires configuration parameters and mode bits to be set through the SPI before the motor can be driven. The SPI also allows reading back status values and bits. This interface must be used to initialize parameters and modes necessary to enable driving the motor. This interface may also be used for directly setting the currents flowing through the motor coils, as an alternative to stepping the motor using the STEP and DIR signals, so the motor can be controlled through the SPI interface alone.

The STEP/DIR interface is a traditional motor control interface available for adapting existing designs to use TRINAMIC motor drivers. Using only the SPI interface requires slightly more CPU overhead to look up the sine tables and send out new current values for the coils.

Our developers didn’t find the specific formula in the datasheet to calculate this sine. We welcome you to join in development and help us.

The TMC260 driver chip has two different control modes: SPI and STEP/DIR interface.

SPI

The SPI (Serial Peripheral Interface) is a bit-serial interface synchronous to a bus clock. For every bit sent from the bus master to the bus slave, another bit is sent simultaneously from the slave to the master. Communication between an SPI master and the TMC260 or TMC261 slave always consists of sending one 20-bit command word and receiving one 20-bit status word.

The SPI command rate typically corresponds to the microstep rate at low velocities. At high velocities, the rate may be limited by CPU bandwidth to 10-100 thousand commands per second, so the application may need to change to fullstep resolution.

STEP/DIR

The STEP/DIR interface is enabled by default. On each active edge, the state sampled from the DIR input determines whether to step forward or back. Each step can be a fullstep or a microstep, in which there are 2, 4, 8, 16, 32, 64, 128, or 256 microsteps per fullstep. During microstepping, a step impulse with a low state on DIR increases the microstep counter and a high decreases the counter by an amount controlled by the microstep resolution. An internal table translates the counter value into the sine and cosine values which control the motor current for microstepping.

API Description

*TMC26XStepper(int number_of_steps, int cs_pin, int dir_pin, int step_pin, unsigned int current, unsigned int resistor)`

number_of_steps:Number of steps per rotation
cs_pin: CS: enable pin
dir_pin:Dir: direction pin
step_pin:Step: step pin
resistor:sense resistor current scaling default value is 15 ohms(or 150 mohms). It can be ignored when you don't need to use that.

*TMC26XSet_SPICS(int cs_pin)`

cs_pin:CS pin in SPI mode

*setConstantOffTimeChopper(char constant_off_time, char blank_time, char fast_decay_time_setting, char sine_wave_offset, unsigned char use_current_comparator)`

constant_off_time: Off time. This setting controls the duration of the slow decay time and limits the maximum chopper frequency. For most applications an off time within the range of 5μs to 20μs will fit.
blank_time:Blanking time.Blanking is the time when the input to the comparator is masked to block these spikes. Set from 0~54。
hysteresis_start: hysteresis start setting that this value is an offset to the hysteresis end value HEND.The range is 1~8
hysteresis_end:hysteresis end setting. Set the hysteresis end value from -3~12
hysteresis_decrement: hysteresis decrementer setting, this setting determines the slope of the hysteresis during on time and during fast decay time

*setCurrent(unsigned int current)`

current: set Current

*SPI_setCoilCurrent(int Current)`

Current: Coil Current in SPI mode set from 0 to 248

*setMicrosteps(int number_of_steps)`

number_of_steps: Microsteps each step set from 0 to 248

*setStallGuardThreshold(char stall_guard_threshold, char stall_guard_filter_enabled)`

stall_guard_threshold:Set threshold of StallGuard to get logical value of StallGuard
stall_guard_filter_enabled: stall guard filter enable(1),stall guard filter disenable(0)

*step(int steps_to_move)`

steps_to_move: Set the steps to move and use positive and negative to determine the direction in STEP/DIR mode

*setSpeed(unsigned int whatSpeed)`

whatSpeed: Set RPM (revolutions per minute) in STEP/DIR mode

*SPI_step(int spi_steps_to_move)`

spi_steps_to_move:Set the steps to move and use positive and negative to determine the direction in SPI mode

*SPI_setSpeed(unsigned int whatSpeed)`

whatSpeed:Set RPM (revolutions per minute) in SPI mode

*tmc26XStepper.move()`

Stepper starts to run n STEP/DIR mode

*tmc26XStepper.spi_start()`

Starts to run in SPI mode

Was this article helpful?

TOP