The L293D motor driver and Makeblock

Today I tried to connect the Makeblock vehicle to the Arduino. There are several things to be kept in mind when attaching a dc motor to the Arduino. First the arduino must be protected from high voltage and current and second the logic of controlling the dc motor must be implemented in electronics:

First the Arduino isn’t able to supply the dc motor with neither the voltage nor the current needed. So this has to be done by using a transistor, pwm and an external power supply like e.g. a 9V battery. Because of that the used pins must be protected from the high voltage and current of the external power supply which should be done by using diodes. In fact even the dc motor itself can induct voltage too high for the Arduino so it must be protected using flyback diodes.

The second part is controlling the dc motor. You want to be able to stop the motor, control the speed of the motor using pwm and control the direction of the motor with e.g. another digital pin.

The best way to solve both is using a motor driver. Motor drivers are ICs which allow easy plugging of a dc motor. They are implemented as H-bridges. They protect the Arduino from high voltage and current and implement the low level logic for using pwm, stopping the motor and setting the direction of the motor. One of these motor drivers is the L293D which I use to connect the Makeblock vehicle to the Arduino and a 9V block battery.

So how to do this? The makeblock kit is shipped with two 6V 185 RPM dc motor which has a power consumption up to 2A. As a motor driver I use the L293D as stated before and added a 9V block battery. Why do these parts work together?

First thing to check is the voltage:

The 9v battery can supply a voltage of 9V. The L293D can work with 4.5V to 36V as you can read in the datasheet. The dc motor can cope with a voltage of 6V. It is noticed first that the battery will work well with the L293D because it’s in the range of 4.5V and 36V. But the dc motor won’t cope with 9V. We have to take in account that there’s a voltage drop at the L293D of about 2.5V as described here and here. The actual voltage must be 9V – 2.5V = 6.5V volt. In my case there also is the resistance of the cables and the breadbord, so the actual measured voltage is 5.6V. With this voltage it’s safe to connect the dc motor which can cope with up to 6V.

The second thing to check is the current:

The no load current of the dc motor is 200mA. If there’s a torque of about 1.5kg/cm acting on the dc motor, the motor consumes less than or equal 650mA. If there’s a torque of about 4.5kg/cm acting on the dc motor, the motor consumes more than or equal 2.0A. The L293D can cope with a current of 1.2A. The 6LR61 9V battery can supply the motor with up to 700mA. So what does this mean? The highest current is consumed when there are about 4.5kg/cm acting on the dc motor. If this current will be consumed by the dc motor the L293D will be damaged because it’s capable of working at max 1.2A. But there won’t be that much current because of the battery. The battery can only supply the dc motor with up to 700mA so there won’t be more amperes than the battery can deliver. Because of that there’s no risk of damaging the L293D because it can easily cope with 700mA. The only risk taken, as far as I know, is damaging the battery. I think this is a risk you can take, because simply usual 9V batteries are cheap and the basic use of the vehicle will be far away from a torque of 4.5kg/cm. To verify the data of the specs I measured the current while no load (result is 210mA) and the current while maximum load (770mA). It nearly fits to the values stated before.

[[UPDATE (23.09.2014):

The setup worked for a short while, but after adding a bit more load on the vehicle the current of one (!) dc motor gets up to 1.6A. I tested this by putting 3 9V blocks in parallel which can supply up to 2.1A in total and attach them directly to the dc motor. So the batteries can supply the motor with enough current to run even with a higher torque applied to it. But the L293D can’t. As per spec sheet the L293D can cope with a maximum of 1.2A which is insufficient for the dc motors. In addition I read here that H-Bridge drivers are not energy efficient. The voltage drop is much higher than with MOSFET-drivers. Because the L293D is insufficient, I will look for a new driver. I will check these articles (comparison of motor drivers and dc motor calculations)  and then choose a new one. I will post a new blog entry aftery buying and testing the new one. Stay tuned! ]]

To put it in a nutshell the voltage and the current of the dc motor, the L293D and the 9V battery are compatible to each other.

So now we get away from theory to connect everything physically:

Circuit diagram: (created with Fritzing)



L293D circuit diagram

In practice:

IMG_20140915_225122 Makeblock and the L293D 1 Makeblock and the L293D 5 Makeblock and the L293D 4 Makeblock and the L293D 3 Makeblock and the L293D 2

In addition you’ll need the appropriate sketch to get things run. It’s really simple, just:

#include <Arduino.h>

extern HardwareSerial Serial;

int ENABLE_1 = 5;
int INPUT_1 = 0;
int INPUT_2 = 1;

void setup() {

pinMode(ENABLE_1, OUTPUT);
pinMode(INPUT_1, OUTPUT);
pinMode(INPUT_2, OUTPUT);

void loop() {
analogWrite(ENABLE_1, 240);
digitalWrite(INPUT_1, LOW);
digitalWrite(INPUT_2, HIGH);

This sketch is just used to check whether everything is connected correctly. It’s not memory efficient, nor providing a senseful API or other basic programming stuff. These topics will be covered in my next posts where I want to figure out how to move the Makeblock vehicle with the precision of centimeters.

If you want further information about the electronics relating to dc motors and motor drivers check this post (german) or this post.

Stay tuned for my further investigation about how to move the makeblock vehicle exactly.

(Comments are welcome!)



4 responses to “The L293D motor driver and Makeblock

  1. Pingback: Using the DRV8833 motor driver | Dev Stuff·

Leave a Reply

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

You are commenting using your 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