L293D Motor Driver IC connected to two small size dc motors.
MPU-9150 using i2c
Xbee v1.1 arduino shield by seeed
Li-po battery, 7.4 volts, 2200 mah.
all components are tested separately, they all are working fine, the sensor readings showing data on serial monitor, the l293 drives the motors, xbee sends wireless serial data on pc, and li-po is also working fine.
i have checked the wiring alot of times. it all seems to be correct.
the problem arises when i connect all of them together, since i am using a single power source, i power the l293d with the Li-po and the Arduino also with the Li-po.
When the L293D is powered using Li-po and it starts drawing current from the battery, the serial monitor/arduino gets stuck. it doesnt show sensor readings anymore, while the dc motors start spinning. and they continue to spin, until i break connection with the battery.
without the l293d powered, the sensor readings are working fine, everything is going normal, as it should, but as soon as the l293d is connected, arduino is stuck..
i have searched alot of forums for this, found some info, perhaps something to do analog and digital ground? mpu-9150 is digital ground. so that is why it stops the arduino mega as the l293d starts drawing current. all hell breaks loose.
can anybody please help me with this? it is giving me headaches ever since!
Try this simple thing : Use separate power supplies
Power your arduino through USB and L293D from your Li-Po.. After this test tell us if you notice any changes
i have tried using two sources.
one instance i connected the usb to arduino, and the lipo to the l293d.
PROBLEM PERSISTS
and then i connected the 9volt battery to arduino, and lipo to the l293d.
PROBLEM PERSISTS
and yes all my grounds are connected. i have checked, here is a diagram showing the circuit, what does decoupling capacitor mean?
where should i place it? Please on the diagram if someone can guide.
Talal:
it doesnt show sensor readings anymore, while the dc motors start spinning. and they continue to spin, until i break connection with the battery.
I read your initial post again, i think this doesn't seems to be a wiring problem!!!
previously i had L293D, but then i thought the current is limiting or somethings not working. so i switched to L298N motor shield.
i tried to RUN THE MOTORS separately, it worked. it goes forwards backwards, right or left. but with the sensor connected. although the MOTORS keep on running, the code stops, it just stops displaying on serial monitor, the led stops blinking, the motors are in a forever loop to run in one direction.
Inside your loop you are constantly calling the function DriveF(255); which means your motors will keep rotating forever..
It was as simple as that.. Correct me if i am wrong XD XD XD
yes true, but inside the LOOP function i also have the read accelerometer option, so what it should do is it should read the accelerometer, drive the robot, read accelerometer, drive the robot.
ATTACHED with this is the screenshot i took of the serial monitor, at dist:0.35 it STOPS the readings, no more real time data coming in. the motors keep rotating.
according to my if else condition, when dist=1 it should stop the motors.
When you initialize a variable like that : float veli; then the variable equals to a random float number..
Thats why your distance is not reliable.. Initialize it with zero? Really? Come on, then this
dist=veli*dt+(0.5)*(average)*(dt*dt);
|---->0
Will become zero too!!! 8) 8) 8) I cant understand the use of variable veli, just figure out the initial value of it...
Hope i helped, let me know if you have more problems...
Just test your code... I can't do that for you!!! XD XD XD
it seems the current is being drawn by h-bridge through the microcontroller, for some reason in the world yet uknown, although only grounds are common, and PWM is provided by arduino, it seems current is being drawn.
thats why the serial monitor and arduino hangs.
i think i need to buy a optocoupler, to isolate the circuits.
I think we figured out why your motors spin forever... Because of wrong Code..!
The distance sensor is also not reliable because of bad programming too...!
Did you try to resolve anything of the above? You should go step by step.. You can't resolve everything at once !!!!
Still i cant understand what you mean by "arduino hangs" !!! What happens to arduino ? If serial monitor wont display anything this doesn't mean that arduino stuck !!! It could be part of bad programming too !!!
I would advise you to take the distance sensor out.. Write down a simple code just trying to move dc motors and leave anything not essential out...