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

Homing the Stepper

The concept of preserving stepper position is in essence flawed if we do not know the system’s start position. This is true for any motor system in which the closed loop feedback is relative, versus absolute. As a result, it is important we start counting our steps from a known position. Said position is often referred to as HOME.

The application note incorporates a HOME sensor input which is flexible enough to accommodate both sensor polarities (e.g. asserted HI or asserted LO). A typical HOME sensor implementation is to have an optical sensor and a flag at the stepper motor shaft. When the flag meets the optical sensor slit, then the stepper motor stops and this position is from now on referred to as HOME. Internally, the controller clears the StepPosition variable.

Since the motor can be started at any given position, the HOME sensor could be found to be at either state. Hence, initially, the state is to be considered unknown. The typical homing implementation calls for a transition from HI to LO or a transition from LO to HI as chosen by the application.

In order to easily capture the chosen transition, the HOME sensor was allocated to a GPIO pin with a Pin On Change Interrupt. Since the pin can be configured to raise the ISR flag either with a rising or a falling edge, we can capture on either edge. Whereas the typical polling function would require some sort of a state machine to filter out the wrong transition, this hardware interrupt works exceptionally well, rendering the amount of code to be considerably tiny.Figure 2-11 shows the ISR for the PORT1 Pin On Change Interrupt vector. The reader will notice this code is in charge of clearing the StepPosition variable, as well as stopping the motor.

GUID-58419B78-1C67-4A67-8BD1-1683EE428EC9-low.gifFigure 2-11 Port 1 Pin On Change Interrupt Service Routine