Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
Problem when powering mbed LPC1768 robot using external batteries
Hello all,
I have built a prototype robot using Dagu magician kit and HCSR04 sensor.
Also, I wrote the following program to test the robot :
#include "mbed.h" #include "hcsr04.h" #include "Motor.h" Serial pc(USBTX, USBRX); HCSR04 usensor(p25,p26);//trig pin,echo pin Motor A(p23, p5, p6); // pwm, fwd, rev Motor B(p24, p7, p8); float dist=0.0; float norm_speed = 0.5; int main() { while(1) { usensor.start(); wait(0.2); dist=usensor.get_dist_cm(); printf("Distance = %f\n", dist); if (dist<5.0) { A.speed(0.0); B.speed(0.0); } if (dist>5.0) { A.speed(0.9); B.speed(0.9); } } }
All of it works very fine when I power the motor using 4 AA batteries (via L293D motor driver) and connect mbed to USB port. But when I remove the USB connection and power mbed using the 4 AA batteries (Vin pin, Ground pin), it doesn't work. Should I use a 9V battery? Any suggestions?
Thanks in advance, Lakshmanan.
1 Answer
9 years, 3 months ago.
Powersupply for motors is tricky because of the electric noise they generate. Some good decoupling is needed. Also note that the VU 5V is only available when you use USB power. The 5V output does not work when you use Vin supply. It seems from the picture above that your HCSR04 is connected to VU and so it wont work with Vin.
Your supply is not reliable enough: too many contacts . Try a separate battery supply for the Mbed , with a common ground for the mbed and the motor batteries.
posted by Robert Spilleboudt 04 Apr 2015