continuous battery monitoring during charging as well as discharging

Discussion in 'General Electronics Chat' started by viznu3391, Dec 10, 2015.

  1. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    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
     
  2. dl324

    Distinguished Member

    Mar 30, 2015
    3,235
    619
    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.
     
  3. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    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?
     
  4. Picbuster

    Member

    Dec 2, 2013
    373
    50
    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.
     
  5. dl324

    Distinguished Member

    Mar 30, 2015
    3,235
    619
    You're jumping the gun. OP is asking for assistance in reading the correct voltage.
     
    viznu3391 likes this.
  6. dl324

    Distinguished Member

    Mar 30, 2015
    3,235
    619
    Give the specs for the ADC port. Can it accept voltages at either supply rail?
     
  7. Lestraveled

    Well-Known Member

    May 19, 2014
    1,957
    1,215
    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?
     
  8. Lestraveled

    Well-Known Member

    May 19, 2014
    1,957
    1,215
    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.
     
  9. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,969
    744
    Can you post the section of programme of the ADC reader.

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

    Distinguished Member

    Mar 30, 2015
    3,235
    619
    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...
     
  11. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    Sorry for the delay. I am using internal Vref that is basically the microcontroller Vcc(5V).
     
  12. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    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.
     
  13. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    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?
     
  14. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    When the battery is charging ADC is measuring only a constant value.
     
  15. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    I'll post it. But this is how I configured the ADC. Internal Vref, -ve Vref is Ground, taking at least 50 samples and averaging.
     
  16. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    No. ADC can measure only positive voltage since I am using internal Vref
     
  17. Lestraveled

    Well-Known Member

    May 19, 2014
    1,957
    1,215
    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)?
     
  18. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    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
     
  19. viznu3391

    Thread Starter New Member

    Dec 10, 2015
    16
    0
    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?
     
  20. Lestraveled

    Well-Known Member

    May 19, 2014
    1,957
    1,215
    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.
     
Loading...