Using the DRV8833 motor driver

Hey everybody,

today I will describe how to use the DRV8833 motor driver. Perhaps you read my post about the L293D where I explained why I have to use another motor driver. The problem was simply the maximum current the L293D is able to cope with and in addition there’s a high voltage drop at the L293D which isn’t very helpful. So I chose another motor driver which can handle more current – the DRV8833 as a motor driver shield built by Pololu.

As stated before the new motor driver should provide less voltage drop and higher maximum current. Here are the values regarding supported voltage and maximum current:

Motor driver: DRV8833
Motor channels: 2
Minimum operating voltage: 2.7 V
Maximum operating voltage: 10.8 V
Continuous output current per channel: 1.2 A2
Peak output current per channel: 2 A
Continuous paralleled output current: 2.4 A2
Reverse voltage protection?: Y

As you can see the DRV8833 can cope with a current of 2.4A peak total. You see that this is less than 2×1.6A=3.2A which I mentioned in my previos post about the L293D. But as stated before I don’t need the full current of the dc motors because my project is not about driving fast but simply drive, so the DRV8833 should be sufficient.

Cabling

As usually I wanted to do a Fritzing diagram, but there’s no part for the DRV8833 available, but I found a diagram at the Pololu website which shows the cabling. You can look it up in the spec-sheet additionally.

 

Pololu DRV8833 Cabling

Pololu DRV8833 Cabling

 

Please note: don’t put the pins labeled in grey to ground – really bad things happen if you do so (I burned my breadboard and a jumperwire, I could see the rubber of the jumperwire flow 😀 …)

Here are some pictures about how I cabled it in the real world. Please ignore the accelerometer.

car motor driver left car motor driver right car motor driver front

car motor driver bottom

car motor driver bottom

car motor driver back

car motor driver back

 

Code and PWM

After cabling was done, I had to adjust the pwm to correctly control the motor. This is the code:

#include 

extern HardwareSerial Serial;

int BIN_1 = 3;
int BIN_2 = 5;
int AIN_1 = 6;
int AIN_2 = 9;
int MAX_PWM_VOLTAGE = 240;

void setup() {
    pinMode(BIN_1, OUTPUT);
    pinMode(BIN_2, OUTPUT);
    pinMode(AIN_1, OUTPUT);
    pinMode(AIN_2, OUTPUT);
}

void loop() {
    
    digitalWrite(BIN_2, LOW);
    digitalWrite(AIN_2, LOW);
    analogWrite(BIN_1, MAX_PWM_VOLTAGE);
    analogWrite(AIN_1, MAX_PWM_VOLTAGE);
    delay(2000);
    
    digitalWrite(BIN_1, LOW);
    digitalWrite(AIN_2, LOW);
    analogWrite(BIN_2, MAX_PWM_VOLTAGE);
    analogWrite(AIN_1, MAX_PWM_VOLTAGE);
    delay(2000);
    
    digitalWrite(BIN_2, LOW);
    digitalWrite(AIN_1, LOW);
    analogWrite(BIN_1, MAX_PWM_VOLTAGE);
    analogWrite(AIN_2, MAX_PWM_VOLTAGE);
    delay(2000);
    
    digitalWrite(BIN_1, LOW);
    digitalWrite(AIN_1, LOW);
    analogWrite(BIN_2, MAX_PWM_VOLTAGE);
    analogWrite(AIN_2, MAX_PWM_VOLTAGE);
    delay(2000);
}

The problem was finding the right pwm value. As of my calculations the value should have been something like 2/3 * 256. I thought: my batteries provide 9V, my motors can cope with 6V, so just use 2/3 * 9V = 6V. This simply didn’t work because there’s a voltage drop in my cabling. I think this is a bit related to the usual resistance of cables and contacts, but in addition is due to my moderate soldering skills ;). So the value with 100% correct cabling with nearly no resistence should have been 2/3*256 ~ 171 in Arduino pwm. In my case I had to use 240.

So far for the voltage.

The code itself is really straight forward. It’s just giving the maximum power to every combination of the two motors, like both forwards, both backwards, one forwards – one backwards and the other way round.

Current

What I was interested in most was the actual current provided. So I did an experiment:

  1. Both motors with no torque applied, 6xAA batteries
  2. One motor stalled and one motor with no torque applied, 6xAA batteries
  3. Both motors stalled, 6xAA batteries
  4. Both motors stalled, 6xAA batteries and 1 9V block in parallel

The results are the following:

1. Both motors with no torque applied, 6xAA batteries

no motor stalled

no motor stalled

no motor stalled current

no motor stalled current

2. One motor stalled and one motor with no torque applied, 6xAA batteries

one motor stalled

one motor stalled 6AA current

one motor stalled 6AA current

3. Both motors stalled, 6xAA batteries

two motors stalled

two motors stalled

 

two motors stalled 6AA current

two motors stalled 6AA current

4. Both motors stalled, 6xAA batteries and 1 9V block in parallel

two motors stalled 6AA and block current

two motors stalled 6AA and block current

 

The measurement was taken at the battieries, so the multimeter shows the current of both motors in total.

1. As you can see the current with no torque applied is about 600mA. This is a bit more than expected, because the dc motors should only draw 200mA per motor. But this doesn’t matter. (Details about the provided Makeblock motors can be found here)

2. If one motor is stalled, the current goes up to 1.5A. As stated in my previous post one dc motor draws 2A if it’s stalled. So the total current should have been 2A + 200mA = 2.2A, but the current is only 1.5A. That’s because the DRV8833 is limited to 1.2A per channel. Because of that the calculation must be 1.2A + 200mA = 1.4A. This is near to 1.5A –  so this makes sense.

3. The next value is 1.7A when both motors are stalled. In this case not the limit of the DRV8833 is hit, but the limit of the batteries. The 6xAA can provide about 1.5A, which is even less than 1.7A. I don’t know where the difference of 200mA comes from, but it doesn’t really matter for any further working with the motors.

4. Because the batteries are a limiting factor I added another 9V block. The idea was: 6xAA provide 1.5A, a 9V block provide 700mA, so both put in parallel should provide 2.2A. This could be correct, but I hit another limitation, I think. The actual current measured is 2A and not 2.2A. Because I thought the batteries were the problem, I added two other 9V blocks and put them in parallel. This should have lead to a current of 1.5A + 3*700mA = 3.6A, but I also measured 2A. I’m not quite sure what exactly happens, my idea about this limitation is related to the resistance of the cables and perhaps my not too perfect soldering skills. The DRV8833 is not the limiting factor as it can cope with 2.4A.

To put in a nutshell, with 6xAA and a 9V block put in parallel the motors are supplied with 2A. This is just enough. The motors are really strong with 2A in total and can move the vehicle easily.

You can see it in my video:

As you see the vehicle move, you will mention that the vehicle is moving fast enough, but not really correctly. This is a problem I’m still working on. The motors don’t apply an equal torque on the wheels. This means one motor has more power than the other. I’m not sure on which level I should correct that. The first idea is to correct the mechanics, as there’s perhaps more friction. The second idea is on the electronic level by using a PID controller. Another idea is one the Arduino logic level by adjusting the PWM. The last idea is adjusting this problem by using the inertial navigation system which I have to create for my project using the raspberry pi anyway. I think I will use the last method (as it’s the one I’m most familiar with, because it’s Java coding 😉 )

This is everything I have to tell about using the DRV8833 to drive my Makeblock vehicle. If there are things not clear, there are things to be optimized or just questions – leave a comment.

 

Regards

Uli

 

13 responses to “Using the DRV8833 motor driver

  1. Pingback: Connecting the ADXL337 to the Arduino | Dev Stuff·

  2. I have the same chip I use with Raspberry Pi to control 2 motors. What I found frustrating is that one motor somehow runs automatically when the battery is connected, i.e. on boot. Is there a way to save the sleep mode without the Arduino/Raspberry Pi, so it only goes HIGH when we set it to high?

    Like

    • Hi Dipto,

      that’s strange. I would do the following:

      – check if the chip is correctly connected to ground,
      – use a pull-down resistor on all A-IN and B-IN pins.

      But I have to say I’m more into programming than electronics.

      I only had a similar issue when I used pins of the pi which are default high.

      Hope that helps!

      Regards
      Uli

      Like

  3. Hi,
    I’m using DRV8833 to drive two “standard” yellow arduino motors. The problem I’m facing is that one of the motors keeps crashing arduino. Even after I added a separate battery to power motors, after a while arduino crashes (although separate battery somewhat helped). It works perfectly when I disconnect the culprit motor.

    Both motors have ceramic capacitors soldered on. Adding inductivity didn’t give any noticeable effect. Any idea what else I could try to make it work?
    Thanks,

    Like

  4. Hi Ulrich
    I bought an Arduino Robot Starter Kit from China, from Banggood. It is well made but there are no assembly instructions or software with it. I complained to Banggood and they just wrote on the web page
    http://www.banggood.com/Robot-M-Kit-Smart-Car-Robot-Kit-For-Arduino-Open-Source-p-1019178.html?cur_warehouse=CN
    “Note: This is a DIY kit, without instruction supply. We’re sorry for the inconvenience.”

    Never to turn down a challenge I have built it, based only on the photo on that web page, and I have set about finding some software. It has an Arduino Uno clone, and a YFRobot Motor Driver Shield, but not the one in the picture, this has a DRV8833 chip and a speaker and a LDR and plugs for six servos. There are a few extra components, LEDs, a bluetooth receiver, an IR receiver, and IR remote control pad, so obviously they were trying to make a robotics starter kit and forgot you need software. Or maybe it is only in Chinese.

    I found your DRV8833 software on this blog, discovered that the motor shield is marked AIN1, AIN2, BIN1, and BIN2 on pins 5,6, 9 and 10. So I put those pin numbers into your code and the robot worked first time. It raced round the floor. Its very fast – a 6 x AA batteries with 7.9v at the Arduino input.

    Thanks a million; it gives me somewhere to start, I can add the LCD bits (the LCD screen has a I2C interface soldered to it) and the IR and Bluetooth and it will be very interesting!

    All the best

    Andrew

    Liked by 1 person

  5. Pingback: drv8871 notes – tlfong01.blog·

  6. Pingback: drv8833 notes – tlfong01.blog·

  7. Pingback: drv8833 drv8871 – tlfong01.blog·

  8. Pingback: DRV8833 troubleshooting – tlfong01.blog·

  9. Pingback: DRV8833 Troubleshooting Notes – tlfong01.blog·

  10. Pingback: How to troubleshoot a DRV8833 motor driver module problem? – tlfong01.blog·

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s