Shop OBEX P1 Docs P2 Docs Learn Events
BoeBot Arduino works on USB, but not when USB removed — Parallax Forums

BoeBot Arduino works on USB, but not when USB removed

westcavewestcave Posts: 2
edited 2012-05-13 12:15 in Robotics
I am completing the chapter 5 whisker navigation. The bot moves forward until a whisker is touched, then it reverses and turns. However, it only works while connected via USB. As soon as I remove the USB and run off of battery power, it still moves forward, but when a whisker is touched, the piezo beeps and the wheels simply stop turning for a few seconds before starting to move ahead again. If I plug in the USB cable again, then it works again. I'm checking the batteries now, any other ideas of what might be wrong?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-13 11:12
    It's probably the batteries. The wheel servo motors can draw quite a bit of current, especially when starting to move. When running off USB, this can be a problem if the USB port can't supply the peak current needed, but often it'll work fine. When the USB is disconnected, the batteries have to supply the power, but they can weaken so they'll supply the Arduino itself, but the voltage drops quickly below the reset threshold of the Arduino when the motors start. A good way to test for this is to attach an LED (and current limiting resistor) to an I/O pin and have it turn on for a 1/2 second during your program's initialization. You'll see that the LED comes on when the whisker is touched as the motors try to reverse, draw lots of current briefly, cause the battery voltage to drop precipitously, and causes the Arduino to reset and start the program over again from the beginning.

    Fresh alkaline batteries or NiMH rechargables are best.
  • westcavewestcave Posts: 2
    edited 2012-05-13 12:15
    Yep. That was the issue. Fresh batteries makes everything work well. I was just confused that the motors would work in one direction but not in reverse. The batteries were strong enough to spin the servos in one direction, but not strong enough to stop and reverse the servos. When it attempted to do that, the voltage would drop too far. It makes sense now why the piezo was beeping every time... the sketch was restarting every time the whiskers were touched.

    Thanks!
Sign In or Register to comment.