Let's Make Robots!

motor board connecting with Arduino board ... need some help

Hi all need a little help ..... got my first bit of stuff from yourduino .... and very happy ..... part of which was a arduino board (mega 1280 http://arduino-direct.com/sunshop/index.php?l=product_detail&p=9) and got a motor board (http://arduino-direct.com/sunshop/index.php?l=product_detail&p=127)

also got  some other things like a small servo, stepper motor and board, and a starter kit ......  I have got the servo working even got it hooked up with the pontimeter to make it move ... plus got the stepper motor and board working ... also tried out using the infrared receiver sensors following this guide http://letsmakerobots.com/node/29634 will have to work on this though as i found it a little tricky.

Now this is where i need the help .....  Hooking the motor board up to the arduino board .... 

First off ive being using the arduino board hooked up to the laptop .... dont want to do this using the motor board and motors .....

so i now have a 9v battrie connected to the battery adaptor .... just tried it and it works.

now all i need to do is hook the motor board to the arduino board ... How do i do this 

and connect up a seprate supply for the motor board. 

Do i hook the motor board supply up to the arduino board or to the motor board and what voltage can i use .... eg only small motors 3v to 5v rating so would 4.5 v be ok ... 

just need to hook it up and run a programm to see them working .... not working on a robot yet

Just a little nervous about this as i dont want to damage the arduino board .... so whereas i tried out all the other things myself ... just want to be extra careful with this.

your help would be appreciated .... just a bit confused trying to follow the documentation online

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

This should get you started.

Start off with no power connected.

Connect 5v and ground from your arduino to 5v and ground on your motor board

Pull off the jumpers on the motor board that connect the enable and 5v pins.

Make the following connections:

Arduino pin 10 to motorboard pin ENA

Arduino pin 13 to motorboard pin IN1

Arduino pin 12 to motorboard pin IN2

Arduino pin  9 to motorboard pin ENB

Arduino pin 11 to motorboard pin IN3

Arduino pin 8 to motorboard pin IN4

The above connections mimic the control connections for YourDuino's motorshield tutorial.  Now you can use the sample code from http://arduino-info.wikispaces.com/ArduinoShieldL298N to work out your own sketch.

Connect your power supply.  Positive goes to VCC, negative goes to ground.  Do not use the same 9 volt battery that is powering your Arduino on your motorboard.  If you use a heavier battery, say a 7.2v nimh battery pack, you could connect the Arduino and the motorboard to the same supply.  Since you have the Arduino working with the 9v battery, it's probably safer to leave it that way and use a separate supply for the motorboard.

As for not using your laptop as the control, device, there are lots of examples that use joysticks, potentiometers, push buttons and whatever that you can adapt.

 

there is an on board regulator on that driver the 5V you see is an output it is conected to the Enable pins of the chip 

and he is using the laptop to power the arduino not as a control device :P

 

One line of my instructions was to disconnect the enable pins from the 5 volts.  Otherwise you can't connect a pwm line.  They're connected via jumper blocks to pins marked 5v on either side.  I did totally miss the 5 volts as an output tho.  Odd because I DID see the 5 volt regulator on the board.  My bad.  But I thought he said he was using a 9v battery to power the Arduino.

ok first off both of the arduino and the motor driver have power regulators on them witch is always nice so you can use up to 15V for the arduino and the motor driver can take up to 26V .i use a 11.1V lipo connected to the power input of both the arduino and the motor driver board in parallel, with that set up i run small 12V gear-head motors (stall current no grater than 2.5 amps that is the continuous output current for each channel on the driver chip )   if you wont you can use 2 power supply's 9V for the arduino and 6V for the motor driver. the 6V  for the motor driver should be a lager capacity battery because motors suck the amps (connect the grounds of both battery's to complete the circuit )    

4.5V's is not enough for the on bored power regulator of your motor driver or the Arduino,6V's is recommended as a minimum  

i gather you know the rest of the hook up to the arduino for control if not let us know 

Sorry guys still confused ..............  so i added a photo .... so first have two sets of small battries i want to connect to motor board (giving 6v) ...  so do i connect to 5v under blue box with screws and then to gnd or vcc .... when i connect here i get a 5v power led lighting up (but motor dosent move). I know this is very low but is it enough to test with .... also motors are low volts. 

what are the 5v connections above with the Ena and Enb connections for ....

i have a 9v connnected to arduino board to run the board .....  this would give me a seperate supply for each board which is what i want.

do i need to connect a gnd on arduino board to gnd on motor board ....

If i get the power connections sorted first ill then work on the connections needed from arduino board to motor board to control it

also there is a little switch on the right of the blue power connections ..... whats this for 

Thanks again guys 

arduino and motor board

You need to connect the positive from the motor's battery to the Vcc screw connector, the negative to the GND screw connector. From the Arduino, plug a wire into the 5V pin and the other end to the 5V screw connector on the motor driver board, then another wire from the GND pin on Arduino to the GND screw connector on the motor driver. That's how the power is routed.

To control the motors, you can use 2 or 3 pins from Arduino:

- 2 pins: leave the Ena jumpers connected to the 5V and plug a wire into a PWM port of the Arduino (for example pin D5) to in1 of the motor driver board. Another wire from a regular digital pin to the in2. These 2 will control out1 and out2. Connect another wire into a second PWM port of the Arduino (for example pin D6) to the in3 and a wire from a digital pin to the in4, which will control out3 and out4 (respectively the motor you have now plugged). To make the motor spin, set the digital pin to LOW and send a analogWrite(0-255) to the PWM pin. The value of the analogWrite adjusts the speed of the motor, higher makes it run faster. To make the motor spin in reverse, set the digital pin to HIGH and send a analogWrite(255-0) to the PWM pin. The lower value makes the motor spin faster (inverse PWM). To make the motor brake set the PWM pin to the same value as the direction (in) pin (0 = LOW, 255=HIGH). 

- 3 pins: remove the Ena jumpers and connect the Ena1 to the Arduino PWM pin, then use 2 digital pins for the in1 and in2 that will set the direction of the motor. Same for the second motor. To make the motor spin, set one in pin to HIGH and the other to LOW, then send a analogWrite to the Ena pin. Higher value spins faster. To make the motor spin in reverse, set the in pins the other way (LOW and HIGH) then send a analogWrite to the Ena pin, higer value spins faster. To stop (brake) set both in pins to LOW and Ena to 255. If you set the Ena pin to 0, the motors will be disconnected and let spin freely (coast).

ChuckCrunch pointed out that there is a 5 volt regulator on the motor driver board, which would seem to make the screw terminal an output, but actually the onboard regulator is switchable.  So, if he switches the 5 volt regulator out, it would be proper (and easier) to connect the Arduino 5 volts to the motor driver board.  But he still needs to connect the grounds, and all of the control wiring.

Nice one ..... got a motor running ...... Thanks all ..... now one more thing should keep me going for a while ..... Got the motor to turn at one speed for a few seconds then turn in the opposite direction at a slower speed for a few seconds then loop and repeat .... but i couldnt figure out how you stated to stop it.  So im posting the code i used and if you could print the line i need to get the motor to stop id be very happy (want to get motor to spin then stop then change direction)

 

int Ain1 = 5;

int Ain2 = 52;

int Ain3 = 6;

int Ain4 = 50;

void setup()

{

pinMode(Ain4, OUTPUT);

}

void loop()

{

digitalWrite(Ain4, LOW);

analogWrite(6, 100);

delay(5000);

digitalWrite(Ain4, HIGH);

analogWrite(6, 50);

delay(5000);

}

not the prettyiest code but its new to me so just glad it worked

nice 1 reread your post and figured out what you ment to get motor to stop .............. here is updated code and it works ..... Yessssssssss .......

 

 

int Ain1 = 5;

int Ain2 = 52;

int Ain3 = 6;

int Ain4 = 50;

void setup()

{

pinMode(Ain4, OUTPUT);

}

void loop()

{

digitalWrite(Ain4, LOW);

analogWrite(6, 100);

delay(5000);

analogWrite(6, 0);

delay(500);

digitalWrite(Ain4, HIGH);

analogWrite(6, 50);

delay(5000);

analogWrite(6, 255);

delay(500);

 

}