Basic Power Question - I think

New to everything but programming. I built a robot based on this tutorial:

http://communityofrobots.com/tutorial/kawal/how-make-your-first-robot-using-arduino

But I have added a back-up IR sensor, two tactile buttons for bump sensors, and a piezo speaker. As you can see, a 9V is powering Arduino and the 5V from Arduino is the power on the breadboard.

The 6V AA pack is powering the servo and the motor controller. The tactile buttons are on the breadboard power and the piezo is wired according to the Tone tutorial here:

http://arduino.cc/en/Tutorial/tone

I have to admit I don't really understand how all the power works, since pins on the motor controller go to both the 5V from Arduino and the 6V from the battery pack.

In any case, it all works. Since I have 4 more digital pins, I wanted to wire in 4 LEDs, 2 in front and 2 in back. So I bought a bag of LEDs and wired them up like this tutorial:

http://arduino.cc/en/Tutorial/Blink?from=Tutorial.BlinkingLED

When the LEDs are are their own dedicated Arduino (not the robots), they work just fine with the blinking sketch. However, when on the robot, they light up, but barely. The only time they light up is the two up front light when moving forward, and two in back light up when moving backwards.

So, everything works... just that I want my LEDs brighter. I'm thinking I'm just short on power, but not sure what to do.

What should I do?

since pins on the motor controller go to both the 5V from Arduino and the 6V from the battery pack.

That bit is wrong, can you describe in more detail how this is wired.

If you are using the power in jack of the Arduino and feeding it 6V then this is not enough to produce 5V to power the processor. This might explain your dim LEDs. You need to power things with the correct voltage for them to work correctly.

So, I don't understand the power.

The way I'm looking at the community of robots tutorial, the 5V from the Arduino is connected to the power on the breadboard. That crosses to the other side of the breadboard Then the 6V is connecting to the Servo motor and to the motor controller. The pin opposite on the motor controller is on the power on the breadboard (also true of 2 other motor controller pins). Isn't that the 5V from the Arduino?

The way I'm looking at the community of robots tutorial,

Can you provide a link please.

Isn't that the 5V from the Arduino?

Yes it is if the arduino is powered in some other way. That pin can be used as both an input and an output.

Are you saying that this goes to the servos? In which case the servos are being powered by 5V and not 6V.

Are you saying the +5V line is connected to the +6V line? In which case that is very bad and will end up damaging something.

The grounds of all supplies however should be all wired together or common as they say.

The original link is in my first post, but for reference, here it is again:

http://communityofrobots.com/tutorial/kawal/how-make-your-first-robot-using-arduino

You have to scroll about 1/2 way down the page to see the Fritzing wiring diagram.

Look at the motor controller. 3 pins are on the 5V from the Arduino (right?), since the 5V from the Arduino is on the power strip on the breadboard. Then there is one more pin on the motor controller that is on the 6V (4 x 1.5V) pack.

Grumpy_Mike:

since pins on the motor controller go to both the 5V from Arduino and the 6V from the battery pack.

That bit is wrong, can you describe in more detail how this is wired.

I had a look at the OP's link and the Fritzing, and the comtroller is a 293 so yep there are logic and motor voltage inputs, so it's actually correct afaics.

@joseph:

Have a look at the L293 datasheet, and all will become clear.

There are two levels of connection to such a chip: the logic and the motor's power. The purpose of such a chip is to control the power to the motor: motors run at different voltages, but the chip runs at 5V. SO..... there are some connections at the 5V logic level, and one at the voltage of the motor which happens to be 6V in your case. The 293 allows that to be as high as 36V.

Looking at the Fritzing, and referring to the 293 as it lies horizontally there, the pins of interest are:

  • top left is pin 16 and datasheet tells us this is Vcc1 which is the logic supply to work the chip, so 5V (4.5 to 7, in fact)
  • bottom right is pin 8 Vcc2 which is the motor supply, 6V in this case but could be up to 36 for big motors
  • bottom left is pin 1, which enables one motor. Without this, the inputs at pins 2 and 7 (from Arduino i/o pins) will have no effect: the enable essentially turns the motor on. It does not power the motor: it opens the gates inside the chip to let the motor power from Vcc2 through. It's a 5V logic pin.
  • top right is pin 9 which enables the other motor. So same thinking as for pin 1: its associated input pins from the Arduino are 10 and 15

In this case then, both DC motors and the servo are connected to the 6V battery pack. The 5V from the Arduino runs the 293 chip and thus enables the DC motors (but does not power them!) and also powers the sensor. The 5V is regulated from the 9V to the Arduino, by the Arduino's onboard regulator.

Hope that's clear?

To advise on the LEDs, you would need to provide the code for how you incorporated them into the motor code and also give us a schematic of the final wiring please....

If you are using a 9V battery like that then check the voltage when it is plugged in by measuring what you get between the arduino Vin and Gnd pins.

My guess is that it is discharged and not giving the 6.5V needed to correctly power the arduino. These types of batteries have a very low capacity and so thy have a very short lifetime.

Thanks guys.

JimboZA, thanks for the great description on the way that chip works. Since this is my first ever robot, I just bought what the tutorial suggested and went to wiring. Most everything came from RobotShop, and most of that came in simple plastic bags, with very little other information about what they contained, other that what was obvious, like a motor, a wheel, and the chip.

I am just learning Fritzing, but I need to learn it because I want to turn what I have into a single PCB. From this discussion, I think it is a good idea to put it all together in that app, because it would really help you great folks when I need help.

As Grumpy_Mike knew with just sheer experience is that the 9V is now only putting out 7.2V, so it could be that I'm not getting enough power out of the Arduino.

So last question on this. If I wanted the Arduino to have a dedicated 9V and the power on the breadboard to have its own dedicated power, is it as simple as wiring in another 9V battery but with a 6 ohm resistor to take it down to 6V?

is it as simple as wiring in another 9V battery but with a 6 ohm resistor to take it down to 6V?

No. You are best to use a step down switching regulator to get the most out of your battery. Get one of these:- http://www.pololu.com/category/84/regulators-and-power-supplies with a 5V output and feed the 5V directly into the arduino's 5V pin.

JimboZA, thanks for the great description on the way that chip works.

Pleasure... one thing I didn't say, but which you probably realised, is that those 4 wires from the Arduino i/o pins control the direction of the motor.

Assuming one motor is enabled by 5V on 293's pin1, the polarity of the inputs from the Arduino into pins 2 and 7 dictates the polarity of the outputs to the motor on 293's pins 3 and 6. A high / low input will mean a high / low output and motion in one direction (let's call that forward, whatever that means); low / high input => low / high output and reverse spin.

Same for other motor on its associated pins.

So your next question will be "what about speed control"?

There's a command analogWrite which gives a "pseudo" voltage between high and low, so the motor runs below full speed. You give the command analogWrite instead of digitalWrite. This is called Pulse Width Modulation.

Sorry it took me a couple of days to get back to this. Here is how I have the robot wired now.

When I try to add LEDs (I want to add 4 where 2 light up when it is driving forward, and 2 when driving backward). It is the LEDs that don't power so well.

I thought this would help most.

I don't want to add another 6V battery pack, so am wondering if I can take the Arduino 5V off the breadboard replaced by a 9V dropped to 6V?

http://www.javajoemorgan.com/Robot/MyFirstRobot_bb.jpg

You pic isn’t really there… it shows as in my attachment below. Doesn’t become a hand or do anything on mouseover.

Capture.PNG

Hmmm, not sure how to upload an image. Try the link. Maybe the attachment will work.

OH for ***** sake. Read the how to use this forum sticky.

That picture is STUPIDLY LARGE, how is anyone supposed to see that? Click on it and find out if you don't know what I am talking about.

When I try to add LEDs (I want to add 4 where 2 light up when it is driving forward, and 2 when driving backward). It is the LEDs that don't power so well.

So why on earth are there no LEDs in that diagram? How do you expect us to tell you what is wrong with the way you wire up the LEDs when you don't show us how you have done it.

Also post latest code.

Mike's right: I opened that huge pic and went "Aaaaaaaaaaaaaaargh" and gave up trying to pan across it. Couple of hundred k is good, and should fit on screen with no panning.

Sorry guys. I exported my image and opened it, but, it opened in my image editing software, which automatically scales the image and I paid no attention to its size.

Here is the robot with the LEDs the way I wired them. (Note, I didn’t actually attach them to the breadboard this way, but needed a clear place to put them so you could see).

The code for the LEDs is virtually identical to that in the tutorial here:

Except, I bundled it into a C++ object for much easier use. The code works, and the wiring of the LEDs work as I have them. My proof of that is that I have another Arduino and breadboard with nothing on them that I use for testing single components and code without worry of anything else interfering with it. The LEDs work just fine when on the stand alone. They also work on the robot, but light up so dimly that unless you look straight into the top of the light, you can’t tell.

So the LEDs are on pins 10, 11, 12 and 13 it seems, which in itself is not a problem.

Lets's see the code then: did you set those pins as output?

I’m using the attached C++ code, then, excerpt of the robot code ( assuming you don’t want to see it all ):

#include <SinglePinObject.h>
#include <LED.h>

LED rightFrontLED;
LED leftBackLED;
LED rightBackLED;
LED leftBackLED;

void setup() {
//…
rightFrontLED.setAttachmentPin(10, false); // false is OUTPUT See SinglePinObject.cpp
leftFrontLED.setAttachmentPin(11, false);
rightBackLED.setAttachmentPin(12, false);
leftBackLED.setAttachmentPin(13, false);
//…
}

void loop() {
//… basically… I’m a 30 -year veteran of prrogramming… so…
if (/* movingForward */) {
rightFrontLED.turnOn();
leftFrontLED.turnOn();
}

if (/* movingBackward */) {
riightBackLED.turnOn();
leftBackLED.turnOn();
}

if (/* stopped */) {
rightFrontLED.turnOff();
leftFrontLED.turnOff();
rightBackLED.turnOff();
leftBackLED.turnOff();
}
}

LED.h (427 Bytes)

LED.cpp (1.58 KB)

SinglePinObject.h (740 Bytes)

SinglePinObject.cpp (2.74 KB)

I've never used either of those libraries., although it seems they set the pins as output. Further than that I can't say.

Might be an idea just to write a short sketch to do nothing but set those LED pins as outputs with pinMode and turn them on with digitalWrite without the libraries.

I would guess its a programming logic oversight.

What are the conditions you absracted out with /* movingForward */ etc.

It may be that your conditions are such that while running this code in a loop your LEDs are in fact turning on, but then they may be turning back off and a quick rate, thus you would inadvertently be controlling the brightness of your LED by using a pseudo PWM (non interrupt driven) which could be why they are dim but still lit up.

So what is the full code.