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.

DRV8833: Motor Speed Control with PWM

Part Number: DRV8833

Hi All,

I built a small rover robot and I'm using the DRV8833 Dual Motor Driver Carrier from Pololu (see schematic at end of post) to control my motors.  Initially I wrote a simple motor driver, that uses GPIO on my microcontroller to set AIN1, AIN2, BIN1 and BIN2 (0 or 1) as detailed in the datasheet (see Table 1). 

 

So that worked great and was able to control the rover's movement (left, right, forward, backward), albeit these movements were all performed at 100% full throttle.  I decided next to implement PWM so I could control the acceleration rate while speeding up and slowing down.  I configured my microcontroller to put out a 16 KHz PWM signal and implemented logic to set run the motors forward/reverse in fast decay mode according to table 2.  

I connected a logic analyzer to my motor driver inputs and outputs and verified I was getting the desired results (see below).  As expected the output waveform was directly proportional to my input and the correct outputs were being enabled.  I then reconnected my motors and was surprised to find that nothing happened (besides a high pitched wine).  Being a bit confused I decided to try the slow decay mode and see if that had any better results.   

PWM Control Fast Decay Mode (didn't work)


I then changed my logic so I would put PWM on one input and a logical 1 on the other pin, again according to Table 2 for slow decay.  I once again checked the motor driver waveforms using my logic analyzer and was surprised to see the output waveform now is an inverted version of my input.  Alas, I connected my motors and they actually ran, except now my speed up routine slows me down, and vice versa.

PWM Control Slow Decay (worked, but inverted PWM output)


So I have a few questions:  

  1. Why wouldn't the fast decay PWM drive mode work?  Especially since the output logic is correct to control the motor.
  2. Is the inversion from input to output expected when running the motor driver in slow decay mode?
  3. Am I doing something wrong here in the way I'm using PWM to control the motors?

 

 

 

  control two brushed DC

  • William,

    1. Why wouldn't the fast decay PWM drive mode work?  Especially since the output logic is correct to control the motor.

    The motor winding is a big inductor. The winding current direction is decided by the average voltage across the winding.

    According to the first fast decay mode test waveform,

    a. When AIN1 is low, AOUT1 still keeps for a little bit. That indicates the winding current is from AOUT2 to AOUT1. So, even all FETs are off, AOUT1 keeps high until the winding current is zero (not go through AOUT1's high side FET's body diode). This is normal.

    b. When you reconnect the motor, nothing happened. The winding current direction is decided by the average voltage across the winding. With 50% PWM duty cycle, the average voltage across the winding is zero in fast decay mode. So, please adjust PWM duty cycle and check the winding current direction.

    2. Is the inversion from input to output expected when running the motor driver in slow decay mode?

    "I then changed my logic so I would put PWM on one input and a logical 1 on the other pin, the output waveform now is an inverted version of my input."

    The waveform looks correct in slow decay mode. The motor winding is like a big inductor. When the current is built up from AOUT1 to AOUT2, AOUT1 is low, no matter the AOUT1's low side FET on or off because the winding current will go through AOUT1 low side FET's body diode and set AOUT1 low. That is what you see AIN1 is PWM, AOUT1 is low. At AIN1 low and AIN2 high, you get AOUT1 low and AOUT2 high.

    3. Am I doing something wrong here in the way I'm using PWM to control the motors?

    If you can add the winding current waveform with xINx and xOUTx, you can have a better understanding about the waveform.