-2
\$\begingroup\$

I am trying to build a simple motor controller for a 3v hobby motor ( http://www.radioshack.com/product/index.jsp?productId=2102828 ) that I picked up at Radio Shack.

I am using the L293NE (Datasheet can be found at: http://focus.ti.com/lit/ds/symlink/l293.pdf) for the H Bridge and have the follow pins laid out

pin 1  -> +5v
pin 2  -> arduino pin 2
pin 3  -> motor + terminal
pin 4  -> ground
pin 5  -> ground
pin 6  -> Motor - terminal
pin 7  -> arduino pin 3
pin 8  -> +5v
pin 16 -> +5v

I wrote a small program and when I hook everything up to the +5 and ground on the arduino Duemilanove board, both forward and reverse work great.

Knowing I won't be able to use USB to supply power to the arduino once on my robot, I use a 9v battery and a 7805 Voltage regulator to bring this down to 5v. When I take the +5 from the 7805 to the arduino vin and connect the ground on the arduino to the ground on the breadboard, the motor will only work one way (say forwards) but not the other(say reverse). Any ideas?

I've already verified with the multimeter that all the pins, in the pinout above, are still getting +5v

EDIT: Update #1 : Grounding pins 9,10,12,13,15 doesn't make a difference. Also, the arduino doesn't freak out at any time while it is getting it's powered by the 7805. Switching the arduino back to usb power after being driven by the 7805, the motor works in both directions. Tells me the L293 is good. Looking into the possible current issues mentioned in the replies.

EDIT: Update #2 : There was a question how I have the 7805 powering the arduino. I have two breadboards as it makes it easier to switch. Breadboard 1 (BB1) has just the 7805 on it where the power rails hook up to the 9v battery. Bread board 2 (BB2) has just the L293 on it. This way I can easily swap out the power supply (either BB1 or the arduino) without having to mess with circuit of the L293. With that said... From the +5v pin on the 7805, I feed that to the + power rail on BB2. I feed the -rail of the BB2 back to the - rail on BB1. To power the arduino, I just run a wire from the +rail of BB2 to Vin on the arduino board and run Ground on the arduino back to the - rail on BB2.

\$\endgroup\$
1
\$\begingroup\$

Since what you changed was the power supply, I'd look at the 5 V rail and the battery voltage and see what they're doing. If they were doing the same thing as the USB-supplied rail, your system would work.

Here's a possibility: maybe the motor draws more current in one direction or the other. That makes the 9 V battery sag below the dropout voltage of the 7805 (around 7 V, I think?), which makes the output sag, which makes the Arduino freak out.

\$\endgroup\$
  • \$\begingroup\$ I wondered about supply sag too, but he didn't say the arduino freaked out, just that the motor didn't turn. It wouldn't be surprising, though, for that kind of motor to take more current to get started one direction than another. \$\endgroup\$ – JustJeff Jul 31 '10 at 15:49
  • \$\begingroup\$ This was exactly the case, from my measurements the difference was 10mA. \$\endgroup\$ – Scott Aug 1 '10 at 3:13
1
\$\begingroup\$

If it works one direction but not the other, that sounds like one of the control signals into the L293 is stuck. You might want to watch the level on L293 pins 2 and 7 while you toggle the arduino output 2 and output 3, to see if the levels track correctly.

Since you mentioned this was on a breadboard, you should always be on the look out for intermittent connections, maybe something got jostled when you changed your power around.

Also, it's good practice not to leave un-used inputs floating, as this can introduce noise into your circuit. In this case, you should probably ground L293 pins 9,10,12,13,15.

One other way this could happen would be if one of the drive transistors on one side of the H-bridge got blown, which is something to worry about if you happened to skip the clamping diodes on the motor. Have you had back to the works-both-ways configuration since getting it into this one-way behavior?

more ideas ..

Another thing to think about is the power distribution scheme. You have a 9V feeding a 7805, but from there, how does the wire run? Does it go first to the arduino, and from that point on to the L293? Or did you branch separate runs from the 7805 to the arduino and to the L293? Or maybe you went from the 7805 to the L293 first, then the arduino?

It's important because when both devices are sharing a supply path, voltage drops induced in the wiring by one device can affect the other one. This effect is less noticeable with just small digital circuits, which not tend to draw very much current, but when you introduce a motor it can definitely be a factor - especially when using small gauge wire.

The best way to distribute power in a setup like yours is to make separate runs (both the +V and the ground), one from the power supply to the arduino, another from the power supply to the L293. This way, current dumped into the return (ground) line by the L293 won't cause as much drop in the voltage the controller sees.

Also, if you look at the L293 documentation you linked, note that Vcc2 is the supply for the motor, while Vcc1 feeds the logic part of the L293. You could go the dual-battery route with this project. The 7805 could feed the arduino and the L293's Vcc1 (pin 16), while a second supply connected to the L293 Vcc2 (pin 8) would provide the current that drives the motor. The second supply could be an unregulated battery (or even your existing 9V), since motors don't much care about the flatness of the supply voltage, and you wouldn't be losing any power passing the relatively high motor current through a regulator drop.

One other thing - you're feeding a 3V motor with what theoretically is a 5V supply, which if everything works means your motor will be running a bit hot. It might be better to use a 6V motor and under-volt it than a 3V motor and over drive it.

\$\endgroup\$
  • \$\begingroup\$ Yeah, if at anytime I plug the arduino back into the USB and power the board through USB, the motor spins both ways again. This leads me to believe that the transistors on the H-Bridge are fine. I will check the circuit for the other things you mentioned and update the post with my findings. \$\endgroup\$ – Scott Jul 31 '10 at 13:34
  • \$\begingroup\$ As Pingswept observed, little hobby motors like those sometimes take more current in one direction than the other. You could try setting it for the direction that doesn't work, and manually give the motor a tweak to see if it starts. If it does start, it's probably a current delivery situation. \$\endgroup\$ – JustJeff Jul 31 '10 at 16:36
  • \$\begingroup\$ See update #1 and #2 of my question. I hope this is what you mean by making separate runs. \$\endgroup\$ – Scott Jul 31 '10 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.