Hi
I have built a project with Atmega328 to control 4 motors using bluetooth HC-06. This project controls a car with four motors using a phone via the bluetooth interface (well known project with different versions).
My schematic is attached. A picture about the PCB is also attached.
I’m using a Serial terminal app from my phone to communicate to the HC-06. Think about two signals that I’m sending ‘F’ to move the car forward and ‘S’ to stop the car.
Code simply looks like:
void loop() {
if(btSerial.available() > 0){
inputFromSerial = btSerial.read();
}
if (inputFromSerial == 'F') {
MotorMoveForward();
}
else if (inputFromSerial == 'S'){
MotorStop();
}
}
I have a problem with the project. There is a voltage drop which cases the Arduino to reset. I have done different experiments.
- First experiment: voltage drop when I connect the PCB to 12 volt power supply.
Instructions:
1.1) Connect the power supply to the PCB
1.2) HC-06 blinks
1.3) I open the app in the phone, connect to the HC-06, the phone is connected, the HC-06 stops to blink (an indication that it is connected)
1.4) I send the ‘F’ character to the Bluetooth, the motors move forward for a fraction of a second and then the motors stop moving. The HC-06 disconnects.
1.5) I connected and oscilloscope to the different points in the PCB. Marked with red arrows in the schematic and are numbered from 1-3. See pictures from the osciliscope for the three different cases. As you can see, there is a voltage drop on the main power supply input, but also on the 5V wire which is the output of the voltage regulator.
I don’t know what is the reason of the voltage drop. It causes Atmega to reset.
- Second experiment: connect the PCB to 9V rechargeable battery.
In this case, when I perform exactly the above steps, but when I send the ‘F’ character to the HC-06, the four motors move forward for few seconds (lets say 5-10 seconds) but then the Arduino get reset and I loose connection with the HC-06 and the motors continue to move forward.
If I want to stop the motors, I have either to disconnect the battery, or connect again to the HC-06 and then send the ‘S’ (Stop) character. Only then the motors stop moving.
The reason I’m confident that there is a reset in the Atmega is that I programmer the microcontroller to beep on the buzzer at the setup stage, so whenever there is a reset, I hear the beep from the buzzer indicating the microcontroller reset pin went down.
As I said earlier, I confirmed that on the oscilloscope. The voltage drop causes the reset.
- Third experiment: I isolated the impact of the HC-06 so I programmed the Atmega to move the motors in a loop and checked whether it will reset. But it DID NOT.
Here is a psedo code:
void loop() {
// Move forward
MotorMoveForward();
delay(500);
MotorStop();
delay(1000);
MotorMoveRight();
delay(500);
MotorStop();
delay(1000);
MotorMoveLeft();
delay(500);
MotorStop();
delay(1000);
MotorMoveBackward();
delay(500);
MotorStop();
delay(1000);
}
and the car worked flawlessly. for about two minutes it continued to move forward, turn right and left and move vbackwards, exactly as expected, without any disconnects, till I switched the 9V power off.
So I’m confused why I’m getting the voltage drop when I communicated with the HC-06. What would be in the HC-06 communication that causes the voltage drop? Is it really the HC-06? or there is something wrong that it doesn’t manifist when I run the project automatically, but for some reason, that I don’t know, the problem becomes bigger when HC-06 communication is involved.
Couldn’t it be related to the fact that I’m triggering some delays between the moves, is the reason that it doesn’t disconnect?
I tried adding extra 10uF capacitors in addition to the 100uF. didn’t work. I added couple of them. It didn’t work.
I replaced the two LD293DNE with other ones (thought they might be corrupted), but same probelm.
Is it a problem of reverse current? Isn’t the LD293DNE assumed to protect the circuit from backward current?
any advice is much appreciated.
Thanks in advance