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

Position Control: Number Of Steps

The closed loop capabilities of a stepper are not limited to accurately controlling the speed. Since in essence the controller is counting the very same steps which are being generated, knowledge of step position is continuously being updated. Every time a step is executed, the variable StepPosition is updated according to step rotation direction. For example, if the motor is rotating clockwise (DIR = HI), the StepPosition variable is incremented, whereas if the motor is rotating counterclockwise (DIR = LO), then the StepPosition variable is decremented.

Note:

The notions of motor rotation as clockwise or counterclockwise are directly dependent to how the motor was wired and the motor itself.

The variable StepPosition can be read in real time to obtain information as to where the motor is at any given point in time.

On this application note, however, the controller is always operating in Position Control mode. The variable NumberOfSteps is programmed to hold the entire number of steps which will be executed. Since this is a 32-bit variable, the total number of steps could be a significantly large number, in which case the motor would in essence be operating in free running mode. However, if the NumberOfSteps count is small, then the motor will stop once the total NumbeOfSteps have been executed.

The previous mechanism is achieved by counting how many steps have been executed and comparing this number to the NumberOfSteps command. This is taken care of on the Timer A0.2 ISR as shown in Figure 2-10.

Notice this ISR is in charge of a few tasks we have described earlier and which are of crucial importance to generating accurate stepping information. These tasks are:

  1. Generation of the STEP pulse by configuring when the STEP clear takes place. Timer A0.0 is in charge of returning the STEP signal to LO.
  2. Configuring the TIMERA0.2 to generate the next step according to the current step rate, or StepperSpeedTMR, which is the timer equivalent of the current rate in Hz.
  3. Determining whether the current generated step is the last step to execute. This happens when ExecutedSteps is equal to NumberOfSteps.
  4. If the current generated step is equal to StepsToStop value, then the engine is commanded to start a deceleration profile.
  5. Update StepPosition according to motor direction.

GUID-9E62032E-1E7B-4355-89A5-9D2736116357-low.gifFigure 2-10 Timer A0.2 ISR