DC Motor Driver 1 1

From RepRapWiki
Jump to: navigation, search
Cache-2172322579 b7e3cc73a8.jpg

This board allows you to control up to 2 small DC motors individually. Each motor can be driven at a maximum of 750 mA. It supports both direction and speed control. It is designed to be interfaced with a microcontroller such as the Arduino, or even something like a Basic Stamp. Whatever you can choose, it should be able to work with this board as it has a simple and easy to use interface.

Contents

Get It!

There are currently no known kit sellers. For help on collecting the parts, see below.

Files

Cache-2172530783 fc88be70f6.jpg

You can download the release file from SourceForge that has a bunch of helpful files for this board. It contains:

  • GERBER files for getting it manufactured
  • PDF files of the schematic, copper layers, and silkscreen
  • Eagle source files for modification
  • 3D rendered image as well as POVRay scene file


Schematic

Cache-2488640062 0e8577c638.jpg

Interface

Input

The PWM Driver has 5 input pins + Power:

Pin Function
POWER This is a power input connector. We use a polarized disk-drive style power connector found on nearly every ATX power supply in existence. If you want to directly connect your own power, the board required 12v input.
GND It's recommended to connect this to the ground on your Arduino to share a common ground.
DIR_A This pin controls the direction of the motor controller. A high signal tells the motor to rotate forward, and a low signal tells the motor to rotate backwards. The actual direction depends on how you have your motor wired up.
PWM_A This pin controls the speed of your motor's rotation. You need to supply it a PWM signal, which determines the speed.
DIR_B This is identical to DIR_A, except it controls the second motor.
PWM_B This is identical to PWM_A, except it controls the second motor.

Output

Each motor output is rated for up to 750 mA. If you wire up a motor that draws more current than that, you risk blowing out the L293D. If you plan on doing this, its suggested you socket the L293D so you can easily replace it, should it overheat and fail.

Pin Function
channel a/b This is the output for the respective motor input pins. Each output has two pins: depending on the direction the motor is being driven, the polarity will change. You will need to experiment to determine the proper way to wire your motor up to get it to rotate in the correct direction. There are only two possibilities, so don't worry. =)

Circuit Board

Cache-2173111044 b8b2203d81.jpg

Currently, there are no known vendors of this PCB, so you have to make your own or order custom made ones from a prototype PCB manufacturer. The image shows the professionally manufactured PCB once sold by the RepRap Research Foundation.

Components

Cache-2173111414 1247cc9da2.jpg

Refer to the parts.reprap.org for information on where to get the stuff you need.

DC Motor Driver v1.1
Part Name Quantity Type
PCB DC Motor Driver v1.1 PCB 1 pcb
C1-C6 100 nF ceramic capacitor 6 component
C7,C8 100 uF electrolytic capacitor 2 component
IC1 L293D 1 component
IC1A 16 pin DIP socket 1 component
IC2 74HC00N 1 component
IC2A 14 pin DIP socket 1 component
IC3 78L05 1 component
LED1-5 5mm green LED 5 component
POWER 4 pin molex connector 1 component
R1-R4 100K ohm resistor 4 component
R5-R7 560 ohm resistor 3 component
X2/X3 4 pin .200" terminal block 1 component
Cat 6 cable 2 wire

Known Bugs

There are no known bugs at this time. If you find any, please contact us in the forums.

Build Process

Cache-2173111622 8ab1f037bc.jpg

R1-R4 brown-black-yellow

Solder the resistors to the board. They are all 100 Kohm resistors, and the orientation does not matter. Make sure to clip the component leads after you have soldered them into the board.

DC Motor Driver 1 1-dsc04621.jpg

R5-R7 green-blue-brown

Solder the resistors to the board. They are all 560 ohm resistors, and the orientation does not matter. Make sure to clip the component leads after you have soldered them into the board.

DC Motor Driver 1 1-dsc04622.jpg

DIP Sockets

These are the sockets to put the chips into. You solder the sockets in first (without chips!) to protect yourself from: soldering in a chip backwards, damaging a chip from the heat from the soldering process, and as insurance in case you blow a chip. Match the dimple on one end of the socket with the dimple on the silkscreen and solder it in.

DC Motor Driver 1 1-dsc04623.jpg

C1-C6

These are the 100nF (0.1uF) ceramic capacitors. They all fit into the rectangular silkscreens. The polarity doesn't matter with these components, so just put them in and solder them. Clip the legs close to the board after you are done.

DC Motor Driver 1 1-dsc04624.jpg

IC3

This is the L7805, a voltage regulator. It takes 12v and turns it into 5v. Bend the middle leg out a little bit, and line the flat side up with the flat line on the silkscreen. Push it in as far as you feel comfortable, and solder it into place.

LED1-LED5

These are various indicator LEDs. There is a flat part on each LED. Line that up with the flat part on the silkscreen. Polarity is important here. Push it all the way in, and solder it into place.

DC Motor Driver 1 1-dsc04626.jpg

Power Connector

This is the 4 pin connector that has 2 angled sides inside the connector. Match up these sides with the silkscreen and solder the connector to the board. This is where you will hook it up to the power supply.

DC Motor Driver 1 1-dsc04627.jpg

C7, C8

These are the 100uF electrolytic capacitors. These have a specific orientation, so make sure you insert them the right way. The board has a + sign near one hole, and the capacitor has a - sign along one side to identify it. Make sure you insert the insert the component accordingly (- lead goes into the - hole)

DC Motor Driver 1 1-dsc04628.jpg

Motor Outputs

This is the big screw terminal. Insert it with the openings for wires facing the outside of the board. Solder it into place.

Cache-2172322417 abfe65b871.jpg

Input Wires

Take 2-3 feet of Cat 6 ethernet cable, and remove 3 twisted pairs from it. Trim 1/4" from the end of each of the wires, and insert them into the respective holes for the pins. Then solder each wire into its hole. Trim the ends if required.

Color Input
GND Brown
DIR_A Blue
PWM_A White/Blue
DIR_B Orange
PWM_B White/Orange


Cache-2172322515 92528048b3.jpg

74HC00N

This is the logic chip. It has 14 pins and fits into the smaller socket. You will want to match up the dimple on one end with the dimple on the socket/silkscreen. Take care with the legs. You will insert it by first lightly inserting one set of legs into the socket, slightly pushing on the chip to bend the pins so that the other row of pins can be inserted into the socket. Once all pins are in the socket, push down on the chip to fully insert it. Take care to not damage the chip legs!!

Cache-2172322639 d1c1d872a2.jpg

L293D

This is the motor driver chip. It has 16 pins and fits in the larger socket. Follow the directions above on how to insert it.

Test Your Board

Now we have to test the board. Its very easy, and consists of a few steps.

Test Power

Cache-2172322703 322e685d10.jpg

Plug your board into a standard ATX power supply and turn the power supply on. The POWER led should light up. If it doesnt, check that you soldered the resistor in correctly (I forgot mine first try... oops!)

Wire up test devices

Cache-2172444543 2a9c6c0688.jpg

You will want to wire up two motors to the board to test both channels. If you only have one motor, you can still test it, but you'll have to test them each individually. The orientation of your motor doesn't matter, as long as it can be driven in both directions, and it pulls less than 750 mA of power.

Connect Board to Arduino.

This part is very easy. Strip 1/4" from the end of the input wires (You used Cat6 ethernet innards right???) Now, insert the end of each input into the correct pin on the Arduino, and then connect the Ground pin to Ground on Arduino. Use the table below to determine what pins to hook up to what:

PWM Pin Arduino Pin
DIR_A 4
PWM_A 5
DIR_B 8
PWM_B 9
GND Ground



Upload Firmware to Arduino

Now, feel free to turn on the power to your power suppply. Next, open the Arduino software, copy/paste the code below into the program and upload it. After the firmware has compiled and uploaded, the Arduino will restart and the exerciser will begin shortly.

int dir_pin_a = 4;
int speed_pin_a = 5;
int dir_pin_b = 8;
int speed_pin_b = 9;

int i;

void setup()
{
   pinMode(dir_pin_a, OUTPUT);
   pinMode(speed_pin_a, OUTPUT);
   pinMode(dir_pin_b, OUTPUT);
   pinMode(speed_pin_b, OUTPUT);
   
   Serial.begin(9600);

   //make the motors rotate in opposite directions so show that they're working independantly.
   digitalWrite(dir_pin_a, HIGH);
   digitalWrite(dir_pin_b, LOW);
}

void loop()
{
   Serial.println("Speeding motors up to max.");
   
   for (i=0; i<=255; i++)
   {
      analogWrite(speed_pin_a, i);
      analogWrite(speed_pin_b, i);
      
      delay(100);
   }

        Serial.println("Motors at max.");
        delay(1000);
   Serial.println("Slowing down to 0;");

   for (i=255; i>=0; i--)
   {
      analogWrite(speed_pin_a, i);
      analogWrite(speed_pin_b, i);
      
      delay(100);
   }

   Serial.println("Motors stopped.");
        delay(1000);
        Serial.println("Switching directions.");

   digitalWrite(dir_pin_a, !digitalRead(dir_pin_a));
   digitalWrite(dir_pin_b, !digitalRead(dir_pin_b));
}

The basic way the motor exerciser works is this:

  • Both motors will rotate in opposite directions.
  • Both motors will gradually speed up to maximum speed.
  • Both motors will gradually slow back down to a stopped state.
  • Both motors will then switch directions and repeat the program.

Connect Power to Board

Simply take your hacked PC power supply and plug a power connector into board. There is no power indicator, but as long as nothing starts smoking, you should be fine.

Troubleshooting

  1. First, check to see that you have supplied power to the board.
  2. If that doesn't work, check that you have the board wired up correctly to the Arduino.
  3. If the motors do not move at all, then check your circuit for shorts and dry joints.
  4. If only one motor turns, or they turn in the same direction, check the orientation of how the motors are wired.


Cool Hacks!!!

(Note: these are pictured with an old v1.0 board, but the setup is exactly the same.)

Drive a Stepper Motor

Cache-1759830918 ae59f13f46.jpg

This board can also be used to drive a stepper motor. It can only handle small motors, so make sure your stepper motor wont pull more than 750 mA. If you have a small stepper motor that you want to drive, then this board is perfect for it: small, cheap, and easy. Here is what the pins functions are:

Pin Function
GND It's recommended to connect this to the ground on your Arduino to share a common ground.
DIR_A This pin is pin #1 for the 2 wire stepper control.
DIR_B This pin is pin #2 for the 2 wire stepper control.
PWM_A / PWM_B These pins become the enable pins. When they are set to high, the motor has full torque, and when they are low it will turn freely. You should wire them together, and treat it as a single input. You can also use PWM on this pin to give a variable level of torque.

That's how it works, now here's how to do it:

First, wire up the stepper to your board: one coil to one motor output, and the other coil to the other output. If you wire one up backwards, simply reverse the leads on one (and just one) motor output, and it should drive correctly. If you have a bipolar stepper motor, its easy... just wire up the wires one to one. If you have a unipolar stepper, its a bit trickier, but if you google, its possible to wire it up as a bipolar motor as well.

Cache-1759831242 10430da3ac.jpg

Next, you'll want to wire your DC Motor Driver board to your Arduino. Here's how you do it:

PWM Pin Arduino Pin
DIR_A 8
PWM_A +5v
DIR_B 9
PWM_B +5v
GND Ground

After that, you'll want to program your Arduino with some 'exerciser' code to test the board and make sure everything is working. Copy and paste the code below into your Arduino program, upload the program to the Arduino, then apply power to your DC Motor Driver board.

/*
 Stepper Motor Controller
 language: Wiring/Arduino

 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 and 9 of the Arduino.

 The motor moves 100 steps in one direction, then 100 in the other.

 Created 11 Mar. 2007 by Tom Igoe
 Modified 7 Apr. 2007 by Tom Igoe
 Modified 25 Oct. 2007 by Zach Smith

*/

#include <Stepper.h>

// change this depending on the number of steps per revolution of your motor
#define motorSteps 200

// define the pins that the motor is attached to. You can use any digital I/O pins.
#define motorPin1 8
#define motorPin2 9

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1, motorPin2); 

void setup()
{
   Serial.begin(9600);
   Serial.println('Starting stepper exerciser.');
}

void loop()
{
   int i;

   for (i=25; i<=60; i+=5)
   {
      //set our new motor speed
      Serial.print("Speed ");
      Serial.println(i);
      myStepper.setSpeed(i);

      // Step forward 200 steps:
      Serial.println("Forward");
      myStepper.step(200);
      delay(500);

      // Step backward 200 steps:
      Serial.println("Backward");
      myStepper.step(-200);
      delay(500); 

   }

   for (i=60; i>=25; i-=5)
   {
      //set our new motor speed
      Serial.print("Speed ");
      Serial.println(i);
      myStepper.setSpeed(i);

      // Step forward 200 steps:
      Serial.println("Forward");
      myStepper.step(200);
      delay(500);

      // Step backward 200 steps:
      Serial.println("Backward");
      myStepper.step(-200);
      delay(500); 
   }
}

If everything goes well, after a short pause your Arduino will start sending the correct stepping signals and your motor will rotate in a test pattern. Here's a basic description of what it will do:

  • Rotate forward 200 steps
  • Rotate backward 200 steps
  • Increase or decrease speed

The exerciser will test speeds from 25 RPM to 60 RPM and then back down.

History

Changelog

  • changed to screw terminal outputs
  • added diagnostic LEDs
  • added power LED
  • laid out board a bit better

Previous Versions