Trying to determine dc current - 12v lead acid battery charger


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190

    Default Trying to determine dc current - 12v lead acid battery charger

    Hi all,
    I had a 16f877 automatic battery charger all working on an lcd with voltage and current shown. This from the net some time ago. However the unit crashed and corrupted the code which is no longer available.

    I 'm in the process of writing my own code in PBP to suit the built board.

    So far all is good, I have the voltage readout, automatic startup on connection, switching to trickle charge as appropriate.

    Now I'm having trouble getting my head around determining the current. (Maybe because I've got a stinker of a head cold!)

    The board has two resistor divider adc inputs across a 0.1 ohm resistor on the output.

    I know if I connect a mutimeter set to volts on either side of the resistor I get a reading in mV directly proportional to the current. But for the life of me I can't figure the code out.

    I know it's I=V/R so i tried something like this:-

    amp = adc1 - adc2 ; subtracting output adc reading from the input adc
    mamp=(amp*100)/10 ; ohms law on mV result?
    LCDOUT $FE,$80,#mamp,"mA"

    This doesn't work, so where am I going wrong. The maths was there in the original code to make it work with this setup.

    Rob

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    First question is what adc1 and adc2 units are? Are they mV, V, or adc_counts? Translation would depend on that. But basically with a 0.1 ohm shunt you should see 0.1V drop for every amp of current. So if the unit of amps is volts, just multiply by 10 to get amps or multiply by 10000 to get milli-amps:

    A=V/0.1= V*10 or mA=(V*1000)/(0.1)=V*10000

    If the adc1 and adc2 results are in milli-amps, then divide by 100 for amps or multiply by 10 for millamps:

    A=(mV/0.1)/1000=mV/100 or mA=mV/0.1=mV*10
    Tim Barr

  3. #3
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Rob,
    You need to account for the ADC reference voltage and the number of bits. Assuming you are using the pic ADC, the ADC is 10 bits and is likely referenced to 5 volts.

    This gives: 5V/1024 = 0.0048828 Volts per bit (4.8828mV per bit).

    Now, as Tim mentioned, 100mV across the shunt = 1 Amp*.

    Putting that together, each bit from the result of adc1 – adc2 will represent .048828 Amps (48.828mA).

    Code:
    amp = adc1 – adc2
    mamp = amp * 4883
    LCDOUT $FE, $80, DEC mamp/100, ".", DEC2 mamp, "mA"

    *But, you mentioned “The board has two resistor divider adc inputs…” I would guess that these are dropping the voltages down to the input range of the pic. If this is the case, then you may not be getting 100mV per 1 Amp. For instance, if the voltage divider was set up to give 1/10 of the voltages before and after the shunt, you would end up with 10mV per 1 Amp getting to the ADC. So you will need to adjust the numbers above accordingly.

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Quote Originally Posted by SteveB View Post
    Putting that together, each bit from the result of adc1 – adc2 will represent .048828 Amps (48.828mA).
    Which isn't a whole lot of resolution.

    I'm not sure which PIC you're using, but I use the latest range of PIC16f182x ....certainly with that suite of PICs (& mybe others...dunno), you can tie the ADC internal 'positive reference' to an internal derived fixed reference voltage.....so you'd then get over 4x resolution if you made the ADC's positve ref the 1.024V internal reference (vs a PIC 5V supply voltage)

    Also just another way of looking at the above (which are obviously all correct, but sometimes it's nice to have another way of looking at things).

    1. First establish the voltage drop across your current sense resistor.....adc1-adc2 ... multiply this result by your ADC 'volts per bit' in play (therefore if 1.024V fixed ADC positive ref I mentioned & 10 bits, that's 1mV per ADC 'bit')
    2. Now you have the voltage drop ....you already know the resistor value, it's then just ohms law (I= measured voltage drop/0.1R) ....you'll need to scale the number up as PICbasic isn't keen on decimals.
    Last edited by HankMcSpank; - 21st June 2012 at 23:05.

  5. #5
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Thanks Guys,

    Getting my head around this now it's a bit clearer.

    I'm wondering if this was ever working correctly as I'm sure the LM317 used is in constant voltage mode. That would explain why I am getting such a small change from the adc count?

    Counts are typically 985 on one side, 961 on the other, giving me a count difference of 24 representing the voltage drop. The charger at the moment has a 1amp max output which I will be changing later to 5 amp using a LM338. Going from 300mA trickle to 1000mA charge at the moment only changes the count difference to 22, a change of 2 which doesn't seem right.

    I'm on a different computer to the one I program on, so I will load the code and schematic for all to see. The original link to this project is now dead, it had all the details plus the hex code.

    My coding style may not suit all but it usually gets the job done for me.

    Rob

  6. #6
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Hi Rob,

    Is the 0R1 shunt resistor connected on the high side or low side of the load?
    If it is on the low side then you should only need one ADCin measurement; the second leg of the shunt being directly connected to ground.
    The maths becomes very simple, measure the voltage drop across the shunt resistor and scale directly to Amps or MilliAmps as required.

    Cheers
    Barry
    VK2XBP

    Edit: Ignore my last post. I was typing this as you were sending the circuit diagram...
    Last edited by Aussie Barry; - 22nd June 2012 at 08:18.

  7. #7
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    OK, hopefully I've attached the code and pdf of the project.
    Attached Images Attached Images
    Attached Files Attached Files

  8. #8
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Clearer view of the schematic as the one in the pdf is cutoff at the output.
    Attached Images Attached Images  

  9. #9
    tvibakar's Avatar
    tvibakar Guest


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Hi all,
    I am new to this forum. This is my first thread in this forum. Kindly help me. I am using 12V 7.2Ah Amaron Quanta lead acid battery for an Emergency Lamp. I am using the following charging circuit which is attached with this post. In this charging circuit, 230 ac voltage is given as input to the 16-0-16 transformer. The output of transformer is filtered through rectifier diodes and then given as input to the LM317 of charging circuit. As of now transformer is needed to step down the ac input voltage. I need a charging circuit without a transformer. So kindly suggest me a circuit which consists of input rectification without a transformer. Please suggest it with a moderate cost. And also I need one more clarification. I am using "Constant Voltage" - trickle charging method to charge the battery. I am using a load of 2 lamps of total 110 W lamps which stand for around 50 minutes of full charged battery. The lamps will cut-off at 9.5-9.8 V. Then it takes around 16 hours to make the battery full charge. Could you please confirm me if I can charge the battery soon (min 6 hours). Is so at what rate I should use the load. Please help me in this situation.
    Name:  12V 7.2Ah battery Charging Circuit.png
Views: 25685
Size:  32.8 KB

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts