kiriti:
Hello,
I want to monitor the level of Lead acid batteries in our Solar vehicle
The solar panels intermittently charge the batteries, ie they are always wired for charging but voltage fluctuates a bit i guess because the car will be moving and angle of incidence of sunlight changes
The battery is being discharged by the BLDC
I want to know the exact or appropriate filter for filtering out charging and discharging voltages and read the battery voltage
i can read the voltage directly with arduino analog pin but the battery level may not be correct as the voltage fluctuates because of charging and i will end up with a false battery level
There are two distinctly different things you need to worry about.
#1 is your voltage REFERENCE. The analog voltage reading you get is referenced to either the Arduino supply voltage (5 volts) or an internal reference inside the AVR chip (selected by using the "analogReference()" function). The Arduino has a built in 5 volt regulator, so having a stable power supply (i.e. a stable reference) should not be a problem.
#2 is rapid fluctuations in your battery voltage. To filter those out, the easiest thing to do is average a lot of readings. You can do something like this:
#define average 1000;
uint16_t x;
uint32_t accumulator = 0;
for (x = 0; x < average; x++) {
accumulator += analogRead (YOUR_PORT);
}
return (accumulator / average);
To average over longer time periods, either increase the "average" define or add a small delay inside the loop. Just be sure that the number of times you sample doesn't overflow the accumulator.
The technique of digital averaging works very well, is easily "adjustable" and doesn't require any external "filtering" components.
Lastly, if you are connecting your A/D input to a lead acid battery, and if you are in an electrically hostile environment, you would be wise to use a pair of diodes to clamp the A/D inputs between VCC and GND, and also place a small capacitor across the A/D input and GND to filter out any short duration high voltage spikes.
Hope this helps.