This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV8823: how to implement microstepping

Part Number: DRV8823
Other Parts Discussed in Thread: DRV8824

Hi TI,

We've been using the driver for a few years now to control a stepper motor in full step mode.  Recently we've encountered an issue with resonance and would like to implement microstepping to minimize the effect.  After reviewing both the datasheet as well as slva416.pdf:  "High Resolution Microstepping Driver With the DRV88xx Series", it's not completely clear to us how to do this.

For full steps, very simply, we write these 16-bit control words to the drv8823 via the SPI interface:

u16 gMotorPhaseBits[4]=       // PHASEBITS to be written to drv8823 stepper motor driver
{
  0b1111101011100000,         //  1 111   0 111
  0b1011101011100000,         //  0 111   0 111
  0b1011101111100000,         //  0 111   1 111  
  0b1111101111100000,         //  1 111   1 111

}

I assume I can expand this table to interleave the microsteps between each phase bit change, but not clear if I'm supposed to increase the current and then decrease before moving to the next phase; increase one while decreasing the other?  Here is a new table, for what I assume I should do to microstep in 1/2 steps.  Can you please tell me if I'm on the right track?

u16 gMotorPhaseBits[8]=       // PHASEBITS to be written to drv8823 stepper motor driver
{
  0b1100001000000000,         //  1 000   0 000
  0b1111101011100000,         //  1 111   0 111
 
  0b1000001000000000,         //  0 000   0 000
  0b1011101011100000,         //  0 111   0 111
 
  0b1000001100000000,         //  0 000   1 000
  0b1011101111100000,         //  0 111   1 111  
 
  0b1100001100000000,         //  1 000   1 000
  0b1111101111100000,         //  1 111   1 111

}

In addition, with respect to resonance, is it better to use slow decay vs fast decay mode?  Any other information you can provide regarding microstepping and resonance is appreciated.

Thanks,

Gordon S.

  • Hi Gordon,

    When operating 1/2 step or other levels of microstepping, the RMS current is typically reduced to 71% of the desired value.

    Please refer to Table 2 of the DRV8824 datasheet. This table shows how 1/2, 1/4, and 1/8 steps can be implemented using the 3 bit current control of the DRV8823.

    To compensate for the lower RMS current, the xxVREF may need to be increased.

    With respect to resonance:

    Typically slow decay is used for increasing currents (0 to 100% and 0 to -100%) and mixed decay is used for decreasing currents. Please consider starting with this.

    If there are issues with loss of current regulation (the current may be higher than expected), please consider using mixed decay at all times.

  • Hi Rick,

    Thanks for the quick response.  Based on table 2 of the DRV8824 datasheet, this is the new table that we implemented today (I had to reverse the steps for correct rotation direction in our specific system).  At first I interpreted 0% from table 2 to mean that A or B should be disabled but when I ran the code the motor did not turn very smoothly.  I modified the table to leave A and B enabled for every step and set the current bits to 000 for 0% - when I ran this version, the motor turned much more smoothly which I take as a good sign.

    Does this implementation seem reasonable?

    I observed AOUT1, AOUT2, BOUT1 and BOUT2 on a scope. When I ran with the Decay bit cleared (slow decay), when AOUT1 or BOUT1 are on or pulsing, AOUT2 or BOUT2 are off, and vice-versa.  When I ran with the Decay bit set (mixed decay), I see the PWM pulses are always present on every output. Does that indicate something is wrong?

    Thanks again for your help!

                                  //      LSb                                                                                MSb     Unused
    u16 gMotorPhaseBits[8]=       //      A or C    A or C   A or C        A or C   B or D    B or D   B or D        B or D  Address Address
    {                             //      Enable    Phase    Current       Decay    Enable    Phase    Current       Decay   Bit     Bits
      0b1101101001100000,         // (7)  1 (ON)    1 (+)    011 ( +71%)   0        1 (ON)    0 (-)    011 ( -71%)   0       0       000  
      0b1000001011100000,         // (6)  0 (OFF)   0 ( )    xxx (   0%)   0        1 (ON)    0 (-)    111 (-100%)   0       0       000  
      0b1001101001100000,         // (5)  1 (ON)    0 (-)    011 ( -71%)   0        1 (ON)    0 (-)    011 ( -71%)   0       0       000
      0b1011101100000000,         // (4)  1 (ON)    0 (-)    111 (-100%)   0        0 (OFF)   1 ( )    xxx (   0%)   0       0       000
      0b1001101101100000,         // (3)  1 (ON)    0 (-)    011 ( -71%)   0        1 (ON)    1 (+)    011 ( +71%)   0       0       000
      0b1100001111100000,         // (2)  0 (OFF)   1 ( )    xxx (   0%)   0        1 (ON)    1 (+)    111 (+100%)   0       0       000
      0b1101101101100000,         // (1)  1 (ON)    1 (+)    011 ( +71%)   0        1 (ON)    1 (+)    011 ( +71%)   0       0       000
      0b1111101000000000,         // (0)  1 (ON)    1 (+)    111 (+100%)   0        0 (OFF)   0        xxx (   0%)   0       0       000

    }

  • Hi Rick,

    Sorry, I'm new: I posted a reply when I think I was supposed to click "this did not resolve my issue".  I hope I didn't screw up the thread.  This was my reply:

    Hi Rick,

    Thanks for the quick response.  Based on table 2 of the DRV8824 datasheet, this is the new table that we implemented today (I had to reverse the steps for correct rotation direction in our specific system).  At first I interpreted 0% from table 2 to mean that A or B should be disabled but when I ran the code the motor did not turn very smoothly.  I modified the table to leave A and B enabled for every step and set the current bits to 000 for 0% - when I ran this version, the motor turned much more smoothly which I take as a good sign.

    Does this implementation seem reasonable?

    I observed AOUT1, AOUT2, BOUT1 and BOUT2 on a scope. When I ran with the Decay bit cleared (slow decay), when AOUT1 or BOUT1 are on or pulsing, AOUT2 or BOUT2 are off, and vice-versa.  When I ran with the Decay bit set (mixed decay), I see the PWM pulses are always present on every output. Does that indicate something is wrong?

    Thanks again for your help!

                                  //      LSb                                                                                MSb     Unused
    u16 gMotorPhaseBits[8]=       //      A or C    A or C   A or C        A or C   B or D    B or D   B or D        B or D  Address Address
    {                             //      Enable    Phase    Current       Decay    Enable    Phase    Current       Decay   Bit     Bits
      0b1101101001100000,         // (7)  1 (ON)    1 (+)    011 ( +71%)   0        1 (ON)    0 (-)    011 ( -71%)   0       0       000  
      0b1000001011100000,         // (6)  0 (OFF)   0 ( )    xxx (   0%)   0        1 (ON)    0 (-)    111 (-100%)   0       0       000  
      0b1001101001100000,         // (5)  1 (ON)    0 (-)    011 ( -71%)   0        1 (ON)    0 (-)    011 ( -71%)   0       0       000
      0b1011101100000000,         // (4)  1 (ON)    0 (-)    111 (-100%)   0        0 (OFF)   1 ( )    xxx (   0%)   0       0       000
      0b1001101101100000,         // (3)  1 (ON)    0 (-)    011 ( -71%)   0        1 (ON)    1 (+)    011 ( +71%)   0       0       000
      0b1100001111100000,         // (2)  0 (OFF)   1 ( )    xxx (   0%)   0        1 (ON)    1 (+)    111 (+100%)   0       0       000
      0b1101101101100000,         // (1)  1 (ON)    1 (+)    011 ( +71%)   0        1 (ON)    1 (+)    011 ( +71%)   0       0       000
      0b1111101000000000,         // (0)  1 (ON)    1 (+)    111 (+100%)   0        0 (OFF)   0        xxx (   0%)   0       0       000

    }

  • Hi Gordon,

    No worries. The thread is still valid.

    Gordo said:

    Thanks for the quick response.  Based on table 2 of the DRV8824 datasheet, this is the new table that we implemented today (I had to reverse the steps for correct rotation direction in our specific system).  At first I interpreted 0% from table 2 to mean that A or B should be disabled but when I ran the code the motor did not turn very smoothly.  I modified the table to leave A and B enabled for every step and set the current bits to 000 for 0% - when I ran this version, the motor turned much more smoothly which I take as a good sign.

    Does this implementation seem reasonable?

    Yes, this implementation is reasonable. This is very similar to how we use a device with external PH/EN inputs and two VREF inputs to drive high levels of microstepping.

    Gordo said:
    I observed AOUT1, AOUT2, BOUT1 and BOUT2 on a scope. When I ran with the Decay bit cleared (slow decay), when AOUT1 or BOUT1 are on or pulsing, AOUT2 or BOUT2 are off, and vice-versa.  When I ran with the Decay bit set (mixed decay), I see the PWM pulses are always present on every output. Does that indicate something is wrong?

    Nothing is wrong. The current is being regulated using the internal controls.

    When using slow decay, one output switches from high to low while the other remains low.

    When using mixed decay, the outputs will reverse polarity for some time and then both will go low.

  • Hi Rick,

    Rick Duncan said:
    Yes, this implementation is reasonable. This is very similar to how we use a device with external PH/EN inputs and two VREF inputs to drive high levels of microstepping.

    I have a couple of specific questions about the table I posted in the previous response:

    1) We are disabling the A/B output (turning the H-bridge OFF) where Table 2 in DRV8824 specified current=0%.  Is that the correct thing to do for half, quarter and eighth microstepping?  (initially I set the current to 0b000 but according to Table 2 in DRV8823 that sets it to 20% not 0%.)

    2) In the same table I provided, I show that if the H-bridge is disabled then it doesn't matter what the phase (x) or current (xxx) are set to.  Is that assumption correct?

    Maybe both implementations are technically correct, but I'm trying to find the best one.

    Thanks again for your help!

  • Hi Gordon,

    Gordo said:
    1) We are disabling the A/B output (turning the H-bridge OFF) where Table 2 in DRV8824 specified current=0%.  Is that the correct thing to do for half, quarter and eighth microstepping?  (initially I set the current to 0b000 but according to Table 2 in DRV8823 that sets it to 20% not 0%.)

    Yes, it is correct to do. By disabling, the current will go to 0% using the fast decay path of Figure 12. But the current will flow through the body diodes instead of the FETs.

    Gordo said:
    2) In the same table I provided, I show that if the H-bridge is disabled then it doesn't matter what the phase (x) or current (xxx) are set to.  Is that assumption correct?

    Yes, this is also correct.

  • Hi Rick,

    Can you please give us some more detail on fast vs slow decay?  Right now we set it to one or the other mode before executing a motor move, and the actual performance does not seem to vary (much) between the two.

    "Typically slow decay is used for increasing currents (0 to 100% and 0 to -100%) and mixed decay is used for decreasing currents."

    Are you saying that we should change the decay mode as we are stepping?

    What would you recommend for qrtr microstepping vs full or eighth microstepping?

    What should we look for to confirm this is working optimally?  What affect does it have on the motor (increased torque by a certain %, avoids resonance, etc.)?

    Please consider starting with this."

    Are there alternatives?

    Thanks,

    Gordon.

  • Hi Gordon,

    If there are no issues, slow decay provides more torque than mixed decay. But slow decay can lead to loss of current regulation at high voltages.

    That is why mixed decay is also available.

    As an example of loss of regulation, please refer to Current Distortion Pattern 4 of 

     

    The current is an extreme example of slow for increasing and mixed for decreasing.

    At high voltages, the system may inject more current during the blanking time than it can remove during the slow decay time. When this happens, loss of current regulation is observed.

    To check for proper operation:

    If you have a current probe, please observe the current as the motor runs.The current should show half sine waves with the currents of the increasing and decreasing sections roughly equal. 

    If you do not, you can watch the voltage on the sense resistor. Ideally you would like to see half sine waves with the voltage of the increasing and decreasing sections roughly equal.

    In mixed decay, the waveforms should roughly match. In slow decay, it is more difficult to match due to the back EMF of the motor.

    So the compromise is to use slow decay for increasing and mixed decay for decreasing currents.

    I would recommend quarter steps, but this is because I do not know the system capabilities. If the system can provide properly timed serial commands, there should be no problem with either 1/4/ or 1/8. But system interrupts and speed of the motor can strain the system.

    Resonance is usually observed around 100 to 300 full steps per second. Using 1/4 microstepping typically avoids resonance.