Go Down

Topic: Problem Reading Battery voltage (Read 131 times) previous topic - next topic

Ankit_Sultania

Jan 13, 2018, 11:54 am Last Edit: Jan 13, 2018, 12:05 pm by Ankit_Sultania
I am trying to read the voltage of a battery which i am using to power my toy car , battery is 13.6V so i am converting it down to 5v using buck converter and then powering the arduino and other stuff (total 200mA current, when motors not powered).

i have a voltage divider at the battery which is Read by an analog Pin . (shown in the figure)


Code: [Select]
  ADCSRA =  bit (ADEN); 
  ADCSRA|=B00000111;  // Prescaler of 128 , higest time for coversion to increase accuracy and keep r value high
  ADMUX =B01000011;   // i have changed reference from 11, 01
  bitSet (ADCSRA, ADSC);  // start a conversion 
  while (bit_is_set(ADCSRA, ADSC)){ }
 v_lifepo4=ADC;
v_lifepo4=v_lifepo4*0.0245136;


what i have tried.

1. reducing the value of the voltage divider resistors
2. increasing the time of reading the voltage
3. using internal 1.1V as reference voltage

Note:- i am giving the input at 5V insted of Vin

But i don't get the correct voltage   :'(

Problems:-
1.7805 does not give 5V output (its 4.94V when connect to 13.6V at input side).
2. its the main reason i think , after buck converter voltage is 4.96V , but at the arduino input voltage drops to 4.75V. There is only a jumper wire in between.
but for a 0.2V voltage Drop at 0.2A current the resistance of the wire should be 1 ohm.
Can the resistance of a jumper wire be 1 Ohm or 0.7 ohm ?? Or am i doing something wrong ?  (The jumpers are not of good quality) 

                 
                 

 

 

be80be

What you have drawn will not read the battery right  the voltage divider only goes to .680 volts
You need to make divider that reads I would use 15 volts top and 5 at output.
10 k and 5 resistor
when you charge the battery it be like 14 volts something close to it.
The code you posted is not needed. It's not going to be better then the adc read does.


   

Ankit_Sultania

i know it goes only upto 0.66 V = 2.2/49.2 *14.4( battery max voltage) , the voltage divider is correct , i am using the internal 1.1 V reference voltage for the ADC . ( it is different in  the code , i have mentioned it there also ).
 before  this i was using a different voltage divider for the 5v reference .

be80be

#3
Jan 13, 2018, 02:00 pm Last Edit: Jan 13, 2018, 02:23 pm by be80be
Ok guess you got it then
But it don't work how your thinking

So your battery is reading 14.73 volts is that the case

be80be

#4
Jan 13, 2018, 03:27 pm Last Edit: Jan 13, 2018, 03:28 pm by be80be
Quote
voltage divider is correct
It's not you want with the max voltage  so  the output  matchs the adc so you want 1.1 volts for 14.4 input if your using 1.1

You losing about half of the adc range plus a math nightmare

Ankit_Sultania

Quote
You losing about half of the adc range plus a math nightmare
can you explain ...
i know that i am losing half the adc range , its fine as i don't need very high precision and i and few resistors to make the divider.

yes it is reading higher than desired and it is in the range 14.8V to 15.1V .

i am fine with an error of 0.1V.

how did you get the 14.73V ??

also the Aref pin reads 1.09V 



be80be

I was trying to figure how you was thinking that 47k and 2.2 would give you a reading that of your battery voltage  seeing it can only output 648 mV to the adc pin

be80be

#7
Jan 13, 2018, 06:25 pm Last Edit: Jan 13, 2018, 06:29 pm by be80be
This is more like what you need 

Can the resistance of a jumper wire be 1 Ohm or 0.7 ohm ?? Or am i doing something wrong ?  (The jumpers are not of good quality) 

Yes even way higher

Go Up