I have the input power connected to 4 double AA, and 2 9V batteries in series. My total measured output was about 24 volts. I am powering the arduino independently from the board using USB. On the output from the motor driver I simply have it connected to a multimeter. I am only using 1 output on the motor driver at this time.
For my application I need the Arduino to allow 24 v through the driver when an event occurs( which will be very infrequently). I got that to work right and was able to see the +24 on the multimeter when the Arduino did its thing.
My issue is I left this running overnight, with the Arduino in a loop state that did not run the motor driver at all, and woke up to nearly dead batteries. My 24 volt has creeped down to about 16 and the 9v batteries are only outputting 5v, which were brand new yesterday.
It was my assumption that the motor driver would only draw from the input source when the arduino had set the pins to "high" and turned it on, thus limiting the drain and preserving the batteries. Am I incorrect? can someone help me to understand what happened? Lastly is there a way to preserve the battery bank power? i only need to run 24 volt on 1 output at most 2 times a day for 20 seconds.
It is fairly simple as I am just trying to prove I can do this before i invest into the components.
Here is the code
// motor one
int in1 = 9;
int in2 = 8;
int enA = 7;
int count = 1;
void setup()
{
// set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
Serial.begin(9600);
}
void Turnon ()
{
// turn on motor A
if (count == 1) {
Serial.println();
Serial.print ("opening start");
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, 255);
delay(6000);
analogWrite(enA, 0);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
Serial.println();
Serial.print("opened");
count ++;
}
}
void Turnoff()
{
if (count == 2)
{
Serial.println();
Serial.print ("Closing start");
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(enA, 255);
delay(6000);
analogWrite(enA, 0);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
Serial.println();
Serial.print("Closed");
count ++;
}
}
void loop()
{
Turnon ();
delay(1000);
Turnoff ();
delay(1000);
Serial.print(count);
}
I am using count to make the program run each loop that messes with the controller 1 time for testing. It then sits in the loop forever as count will = 3 and never go into one for the functions.
I uploaded a few pictures, though my workspace is terrible and the pictures are not great. I also did it in visio to make it a little cleaner, so hopefully i can show what I did. The arduino was run off of USB.
I gather from your response it is not expected behavior for the battery to drain that fast without the motor driver being engaged?
You should measure the quiescent current drain of the motor driver. There appears to be a regulator on the board, which you might be able to bypass for lower standby drain. It is indeed a bad idea to mix battery types.
In general unless the quiescent current drain is down to the microamp level, you'll drain batteries
noticably. High current circuitry is rarely if ever optimized for micropower - why would it be?
You may need to switch the 24V supply to the motor driver to achieve low quiescent drain.
From my understanding of your post is that the l298N driver is connected to your 24V batteries and and your Arduino board is powered by a USB. The fact that the L298N stays on by drawing power from your 24V batteries even with or without the motor running is quite obvious. The motor driver does not receive power from your Arduino. If you want your motors to run when the Arduino sends the signal, then i suggest that you use a relay switch to power your motor shield when you need to.
Or a p-channel MOSFET driven via a level-shifter circuit... Note that for >12V supplies your level
shifter has to be careful not to pull the gate more than 12V below the supply - a zener/resistor
divider is good for this sort of circuit.