Main Content

Stepper Motor Driver

Driver for stepper motor

  • Library:
  • Simscape / Electrical / Electromechanical / Reluctance & Stepper

  • Stepper Motor Driver block

Description

The Stepper Motor Driver block represents a driver for a stepper motor. It creates the pulse trains, A and B, required to control the motor. This block initiates a step each time the voltage at the ENA port rises above the Enable threshold voltage parameter value.

If the voltage at the REV port is less than or equal to the Reverse threshold voltage parameter value, pulse A leads pulse B by 90 degrees. If the voltage at the REV port is greater than the Reverse threshold voltage value, pulse B leads pulse A by 90 degrees and the motor direction is reversed.

At time zero, pulse A is positive and pulse B is negative.

If you set the Stepping mode parameter to Half stepping, the Stepper Motor Driver block can produce the output waveforms required for half stepping. In this mode, there is an intermediate state between the full steps, in which just one of the A or the B half-windings is powered. As a result, the step size is half of the stepper motor’s full step size. At half steps, windings that are not powered are short-circuited. This approximates the effect of a freewheeling diode connected across the windings.

Microstepping

To advance the rotor of a fraction of a step instead of a full or half step, set the Stepping mode parameter to Microstepping. This mode enables circular current-controlled microstepping and increases the resolution in the position of the rotor. To select the fractional stepping resolution, specify the value of the Number of microsteps per step parameter.

The block initiates a micro-step each time the voltage at the ENA port rises above the value of the Enable threshold voltage parameter.

In microstepping mode, the current in each motor winding follows a discretized sinusoidal waveform. The amplitude of the current waveform is equal to the value of the Maximum continuous current per phase parameter.

To increase or decrease the current in each microstep, the driver applies a positive or negative over-voltage until the current matches the target value.

If you set the Power supply parameter to Internal, the applied over-voltage is equal to the value of the Supply voltage parameter. If you set the Power supply parameter to External the applied over-voltage is equal to the voltage between the VM and GND ports.

Averaged Mode

If you set the Simulation mode parameter to Averaged, both for a Stepper Motor Driver block and for the Stepper Motor block connected to it, then the individual steps are not simulated. This can be a good way to speed up simulation. The Averaged mode assumes that the external controller provides a step rate demand. This step rate demand is determined from the voltage applied between the ENA and REF ports on the Stepper Motor Driver block, by multiplying this voltage by the value of the Step rate sensitivity parameter. The rotation direction is set by the REF port in the same way as for the Stepping mode.

Averaged mode needs to communicate the step rate demand and also output voltage amplitude information to the Stepper Motor block. To do this, the step rate demand is applied as an equivalent voltage across the A+ and A- ports. Similarly the output voltage amplitude information is conveyed by applying a steady-state voltage across the B+ and B- ports with value equal to the Output voltage amplitude parameter.

Assumptions and Limitations

  • To use Averaged mode, the Stepper Motor Driver block must be directly connected to a Stepper Motor block also running in Averaged mode.

  • When changing from Stepping to Averaged mode and back, you must modify your upstream blocks that provide the input voltages to the Stepper Motor Driver block. One way to achieve this easily is to use Simulink® variant subsystems.

Ports

Conserving

expand all

Electrical conserving port associated with the A-phase positive terminal.

Electrical conserving port associated with the A-phase negative terminal.

Electrical conserving port associated with the B-phase positive terminal.

Electrical conserving port associated with the B-phase negative terminal.

Electrical conserving port associated with the step trigger input.

Electrical conserving port associated with the floating reference voltage.

Electrical conserving port associated with the motor direction input.

Electrical conserving port associated with the supply voltage.

Dependencies

To enable this port, set Power supply to External.

Electrical conserving port associated with the supply ground reference.

In external power supply mode, the A- and B- ports are internally connected to GND. You must provide positive supply voltages and the supply must always be connected (for example, you cannot put a series switch between supply and driver).

Dependencies

To enable this port, set Power supply to External.

Parameters

expand all

Use Averaged only if the block is connected directly to a Stepper Motor block also running in Averaged mode.

This parameter converts the voltage presented across the ENA and REF ports into a step rate demand.

Dependencies

To enable this parameter, set Simulation mode to Averaged.

When the voltage at the ENA port rises above this threshold, the Stepper Motor Driver block initiates a step.

Dependencies

To enable this parameter, set Simulation mode to Stepping.

When the voltage at the REV port rises above this threshold, pulse B leads pulse A by 90 degrees, and the motor direction is reversed.

Amplitude of the output pulse trains.

Dependencies

To enable this parameter, either:

  • Set Simulation mode to Averaged.

  • Set Simulation mode to Stepping and Power supply to Internal.

Voltage from external power supply.

Dependencies

To enable this parameter, set Stepping mode to Microstepping and Power supply to Internal.

Whether to enable Full stepping or Half stepping mode.

Dependencies

To enable this parameter, set Simulation mode to Averaged.

Whether to enable Full stepping, Half stepping, or Microstepping mode.

Dependencies

To enable this parameter, set Simulation mode to Stepping.

Number of microsteps per step. This value must be a positive power of two.

Dependencies

To enable this parameter, set Stepping mode to Microstepping.

Maximum continuous current per phase

Dependencies

To enable this parameter, set Stepping mode to Microstepping.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2008a