continuous battery monitoring during charging as well as discharging

Thread Starter

viznu3391

Joined Dec 10, 2015
16
Hi,

My application is basically a power monitoring system in which inverter voltage(RMS),current(RMS) and battery voltage,current are measured. 24V battery is being used in the application. I am using PIC16F877A microcontroller for measuring and do the rest of the functions based on the readings. ADC code is working fine. It is measuring the battery voltage correctly if it is isolated from charging or discharging. But whenever I connect the battery to charging and inverter circuit the ADC is measuring only a constant value, in my case 25.7V even if the battery is charging. but multimeter is reading incremental voltage as battery charges. I am using a simple voltage divider to step down the voltage to a microcontroller level voltage.I have added a 100nF cap to ADC input but didn't help. Is there anything I need to consider in circuit side or firmware side to do accurate measurement. How can I measure the battery terminal voltage while it is charging considering all the EMI and noise

Thanks
 

Attachments

dl324

Joined Mar 30, 2015
16,839
It's your first post and I have the honor of welcoming you to AAC. Welcome!

What are the resistor values, PIC supply voltage, and voltage range of the AC input?

And thanks for posting a schematic.
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
Thanks Dennis.

PIC is given with 5V supply which is derived from battery. Battery voltage range is from 23-28 V. Actually I'm measuring parameters of three AC terminals. two of them is of 230 VAC range and one is 110 VAC. Previously there was no low pass filter and the voltage across R98 goes directly to controller ADC pin. Attached is the circuit I'm going to use for battery voltage measurement where DC VOLTAGE goes to the controller ADC.ADC is configured for using internal Vref.

Is the new circuit correct?
 

Attachments

Picbuster

Joined Dec 2, 2013
1,047
Just placing a voltmeter on a battery connected to a charger is not the best way.

You should measure the current and its direction as well.
That information will produce load/ unload current and will together with the voltage reading say something about the status of the battery. Enhance this with a fet to switch-off the charger allowing you to calculate status and unload cycle at measured load.
 

dl324

Joined Mar 30, 2015
16,839
You should measure the current and its direction as well.
That information will produce load/ unload current and will together with the voltage reading say something about the status of the battery. Enhance this with a fet to switch-off the charger allowing you to calculate status and unload cycle at measured load.
You're jumping the gun. OP is asking for assistance in reading the correct voltage.
 

dl324

Joined Mar 30, 2015
16,839
Attached is the circuit I'm going to use for battery voltage measurement where DC VOLTAGE goes to the controller ADC.ADC is configured for using internal Vref.
Give the specs for the ADC port. Can it accept voltages at either supply rail?
 

Lestraveled

Joined May 19, 2014
1,946
The PIC ADC has a 10 bit result, split between two registers. Is it possible that you aren't reading the registers correctly? Have you exercised the ADC range with a power supply?
 

Lestraveled

Joined May 19, 2014
1,946
The LM358 is not a rail to rail op-amp. This will prevent you from measuring the full range of the battery. I suggest you use a part like a LMC6482. This will work to within millivolts of the rails.
 

Dodgydave

Joined Jun 22, 2012
11,284
Can you post the section of programme of the ADC reader.

Just use two resistors for a divider, no op amp needed.
 
Last edited:

dl324

Joined Mar 30, 2015
16,839
The LM358 is not a rail to rail op-amp. This will prevent you from measuring the full range of the battery.
While that's another problem, the OP was asking for assistance in finding out why he was always reading 25.7V.

I'm still waiting for him to describe how the reference voltages were set. I didn't want to read the datasheet, but the lack of information required it...
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
While that's another problem, the OP was asking for assistance in finding out why he was always reading 25.7V.

I'm still waiting for him to describe how the reference voltages were set. I didn't want to read the datasheet, but the lack of information required it...
Sorry for the delay. I am using internal Vref that is basically the microcontroller Vcc(5V).
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
The PIC ADC has a 10 bit result, split between two registers. Is it possible that you aren't reading the registers correctly? Have you exercised the ADC range with a power supply?
I am completely sure that ADC is working correctly as i could read different voltages correctly unless it is not connected to a battery charger or inverter.
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
Just placing a voltmeter on a battery connected to a charger is not the best way.

You should measure the current and its direction as well.
That information will produce load/ unload current and will together with the voltage reading say something about the status of the battery. Enhance this with a fet to switch-off the charger allowing you to calculate status and unload cycle at measured load.
I am using a hall effect sensor for measuring the current which can give direction as well. So you mean to say that whenever I want to measure the voltage I need yo to disconnect the charging circuitry using a fet?
 

Lestraveled

Joined May 19, 2014
1,946
OK, more probing questions:
- Is there a change of state in the PIC when the charger or inverter is connected. (Does the PIC control the charging/inverter?)
- When you say the PIC reads 25.7V when charging/inverting, is this reading frozen, as in no bits changing?
- What are the values of the current scaling resistors (R1,R2)?
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
1.No. PIC here does only monitoring. Monitors battery voltage, inverter voltage, battery current, inverter current etc. The monitored value is then send to a remote server using gprs modem.
2. Yes the reading is frozen.
3. R1 is 100K and R2 is 10k
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
Battery voltage can be measured correctly using a general purpose multimeter. That's why I am confused to suspect the hardware or firmware since the ADC is reading voltages correctly while it is not charging/inverting.
Or is it because of any kind of interference due to AC voltages which are used for measuring using ADC?
 

Lestraveled

Joined May 19, 2014
1,946
.......Or is it because of any kind of interference due to AC voltages which are used for measuring using ADC?
I was going to start asking question about that.
- Do the reading from the inverter and charger appear to be good.
- Disconnect the sensors one at a time and see what happens to the battery readings.
 
Top