SLVA488B January   2014  – January 2021 DRV8434 , DRV8811 , DRV8818 , DRV8821 , DRV8824 , DRV8825

 

  1.   Trademarks
  2. 1Introduction and Problem Statement
  3. 2Stepper Motor Control High Level Functions
    1. 2.1 STEP Actuation: Acceleration, Speed Control and Deceleration Profiles
    2. 2.2 Accelerating the Motor
    3. 2.3 Stepper Speed
    4. 2.4 Decelerating the Motor
    5. 2.5 Speed Change
    6. 2.6 Position Control: Number Of Steps
    7. 2.7 Homing the Stepper
  4. 3I2C Protocol and Communications Engine
    1. 3.1 GPIO CONFIG
    2. 3.2 STEPPER CONFIG
    3. 3.3 GPIO OUT
    4. 3.4 Current Duty Cycle
    5. 3.5 START STEPPER
  5. 4Application Schematic
  6. 5Revision History

Stepper Speed

Stepper speed is carefully controlled by using Timer A1.0 and A1.2 as detailed previously. How the timer is being clocked is important to understand, as the 16- bit timer by itself is not capable of reproducing all the possible speeds applications around this topology may try to run at. For example, while the Timer A1 is being clocked at 16 MHz, fast stepping rates are easily obtained, while slow speeds cannot be generated.

As a result, it is imperative to modulate the clock speed by subdividing it. Luckily Timer A has a series of dividing factors which allow the timer clocking speed to be subdivided from 16 MHz down to as slow as 2 MHz.

The equation to compute how many clock cycles are needed to reproduce a particular stepping rate is:

Equation 1. # Clock Cycles = TIMER CLOCK FREQUENCY / STEP_RATE in Hz

A quick analysis on the results provided by the previous equation showed the stepping rate segregations on a per clock cycle count basis. If for a given timer clock frequency the resulting number of clock cycles was larger than 65535 then a further subdivision factor would be needed to reduce the clock count from saturating the timer register.

The function SpeedCompute is in charge of transforming a stepping rate in Hz into clock count. Depending on the speed, the timing source for Timer A1 is sub divided to slow down its incremental rate. If the requested stepping rate is less than 31, the function returns false in which case no rate is generated.

Although it may be desirable to obtain stepping rates lower than 31 full steps, this can still be achieved by utilizing a faster speed and configuring the DRV8824/25 device to operate in 32 degrees of microstepping. For example, if the programmed DesiredSpeed is 32 SPS, and the DRV8824/25 is configured to operate in 32 degrees of microstepping, the stepper will move 1 full step per second.

GUID-D6FC3E5D-78B9-4D4B-8170-A46FA841FB27-low.gifFigure 2-8 SpeedCompute Transform the Stepping Rate in Hz into a Clock Count Timer A1.1 - Can Use to Generate Accurate Timing Information
GUID-FBF318E2-E951-466B-B8A4-682E7B6AB374-low.gifFigure 2-9 Function ClockConfigure is Called Within the SpeedCompute Function to Modify the Divider Affecting Timer A1 Clock Speed

The functions SpeedCompute and ClockConfigure are called to set the StartSpeed, to set the new stepper speed on a per acceleration click occurrence and then when the DesiredSpeed is met. Once the programmed DesiredSpeed target is reached the stepper motor maintains said speed until a deceleration profile is commanded.