Hello, I am am mechanical engineering student, and rather new to arduino. I receved the Sunfounder arduino mega 2560 kit as a gift and I looking to make a very small walking robot as my first real project past the out of the box tutorials.
For this robot i am using the unmarked small motor's included with my kit, when powered directly with a 1.5v AA type battery the motor is more then strong enough to move the legs and body.
But when i run power to the motor from the arduino, (connected to USB power) it isn't able to move at all.
I was wondering, how i would be able to safely connect a AA battery to my circuit to give my motors the added juice they need to make my robot walk?
My circuit is using a L293D motor chip, in a similar setup to the super kit 2.0 lesson 7 DC Motor Control tutorial, the motor specs as per the site are as follows.
DC Motor Specifications
Voltage: 3-6V
Main Size: length 25mm, thickness 15mm, width 20mm
Motor Shaft Length: 9mm, Shaft Diameter 2mm
Rated Voltage: 3v
Reference Current: 0.35-0.4A
3v Rotating Speed: 13000 RPM
I apologize if this is something of a stupid question. I was hard pressed to find information that i was able to digest in my search for an answer. Thanks in advance for any reply.
I think I see why the computer is not able to power the motor. Since motors are inductive, it takes a large, quick spike of current to get the motor running. This is sometime referred to as a "kickstart" current, and is much higher than the normal operating current, which you listed as 0.35-0.4A. With this, my guess is that the kickstart current is around 0.6-0.65A. The USB port can only provide 0.5A before the connection is broken to prevent damage.
In order to control the motor with the Arduino, but not power the motor through the Arduino, you will need some type of interface device, such as the L293D chip you mentioned. This will allow you to control the direction the motor will turn.
Each AA battery "contains" 1.5V and 2-3Ah. For the L293D chip you have, the power to the motors needs to be 4.5V-36V, so you will need to have at least three AA batteries in series to provide the necessary voltage to the motors.
I have attached a picture showing the recommended configuration as per the L293D Datasheet
I used Paint to make it so it's not going to look good
Ok so, small problem. It would seem that connecting the 3 batteries to the board in this fashion causes the arduino to shut off.
The computer registers it as though I had unplugged the USB (plays the unplugged device tone and pops up that the USB has been unplugged) and the lights on the board go off. Even with one battery connected as you suggested gives this effect, and likewise disconnecting the batteries causes the board to turn back on and reconnect to the computer.
I think you are correct in how the power should be applied, could this be a USB issue?
An Arduino cannot be powered from the USB and a battery at the same time. Attempting to do so will cause voltage at certain points to be much higher than they should be. Make sure your battery is not powering the Arduino when you plug it into a computer for programming.
Upon further inspection I don't think my last reply is related to the issue.
I did some more digging through the datasheet, and I may have found another error in my original schematic. It seems that the power for the motors cannot be less than the logic supply. Currently the logic supply is 5V and the power is 4.5V. This could create an overcurrent condition which is why the board "disconnects" from your computer. Try hooking up the power from the batteries to the two pins on the top of the black chip instead of coming from the Arduino, and disconnect the wire from the Arduino 5V pin. This should allow all the power needed to come from the battery, and just the signal from the Arduino to control the direction.
TheEngi:
I was wondering, how i would be able to safely connect a AA battery to my circuit to give my motors the added juice they need to make my robot walk?
That is not the right question.
You need to make a simple pencil diagram showing how you have everything connected and post a photo of the drawing. Especially important is how you are powering the motors.
Also post the program you tried.
From your description it may be that you are trying to power the motors from the Arduino 5v pin. That won't work because the 5v pin cannot provide enough current and you may damage your Arduino. Motors need a separate power supply with a common GND with the Arduino.
Hey Robin, can you look over the schematic I posted here earlier to see if I did something wrong? I'm fairly sure it is correct as per the datasheet, but the board was experiencing an over-current condition and shutting off.
I am sorry robin, Attached is a drawing of my circuit, after adding the batteries in the way BOS suggested. It does work, but only gets about 1/8th of a rotation on the motor before it stops moving and just hums. I am assuming its still a lack of power issue. I will try to post the code in the next post, I am getting an error that the request is too large
the idea is to have two simple buttons, one to turn the motor clockwise, one to turn the motor counterclockwise. in the final version i will just be doubling everything across the chip to drive a second motor.
const int motorIn1 = 9; // the one pin of the motor attach to pin 9
const int motorIn2 = 10; // the another pin of the motor attach to pin 10
const int fwdSwitch = 2; // forward button
const int bckSwitch = 3; // back button
const int speed = 200;
/***************************************/
void setup()
{
pinMode(motorIn1,OUTPUT);
pinMode(motorIn2,OUTPUT);
pinMode(fwdSwitch,INPUT);
pinMode(bckSwitch,INPUT);
I don't think you should power VCC1 with a voltage that is lower than the Arduino voltage. The datasheet says the max logic voltage should not exceed VCC1.
Try a very simple program that just makes the motor run in one direction with a PWM value of 150 without any input from a user.
The hand drawn wiring diagram posted in replies #9 and #11 does not show a common ground connection, so that can't work.
Try 6V or higher for the motor power supply. The ancient L239D is a terrible choice for a motor driver, as it can lose up to 4V internally. The low voltage motor drivers from Pololu are vastly better for this project.
Motor spins when i do this and have 3 or 4 batteries connected, no changes to the circuit.
//
const int motorIn1 = 9; // the one pin of the motor attach to pin 9
const int motorIn2 = 10; // the another pin of the motor attach to pin 10
const int speed = 150;
//
void setup()
{
pinMode(motorIn1,OUTPUT);
pinMode(motorIn2,OUTPUT);
}
/****************************************/
void loop()
jremington:
The hand drawn wiring diagram posted in replies #9 and #11 does not show a common ground connection, so that can't work.
Is there no common ground, because I'm pretty sure I see one.
jremington:
Try 6V or higher for the motor power supply. The ancient L239D is a terrible choice for a motor driver, as it can lose up to 4V internally. The low voltage motor drivers from Pololu are vastly better for this project.
I do agree with you on this one. There is a great motor shield by Pololu that is designed to work with an Arduino. It can control two motors using PWM for speed and a digital pin for direction. It can power two motors independently, and has a port for a nice battery. It can also be used by other microcontrollers if you end up not wanting to use the Mega.
Yes and no, I know the circuit works, and i know the program works. But 4 batteries doesn't spin the motor when the buttons are connected. Is the solution just more batteries?