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


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    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.

  2. #2
    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.

  3. #3
    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

  4. #4
    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.

  5. #5
    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

    300ma x 0.1R = 30mV

    1000ma x 0.1R = 100mV

    Your PIC is on a 5V regulator, so assuming 10 bit ADC = 5V/1024 = 0.0048828125V per ADC 'bit'.

    30mV divided 0.0048828125V = ADC reading of 6 for 300mA current (through your sense resistor)

    100mV divided by 0.0048828125V = ADC reading of 20 for 1000mA current (through your sense resistor)

    As mentioned earlier, that's insufficient resolution - you can get 4x more by making your PIC's positve reference the PIC's internal 1.024V fixed reference voltage. (probably still not enough, so I'd consider making the sense resistor 0.2 ohms etc)
    current (through your sense resistor).

    Also, how does each side of the sense resistor 'tap off' connect to your PIC ADC pins, becuause they are sitting at 12V?
    Last edited by HankMcSpank; - 22nd June 2012 at 08:42.

  6. #6
    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 Hank,

    I've come to the conclusion the LCD output current value originally was either dummy or flawed.

    The ADC divider circuits are shown seperate just below the output on the schematic. Note the arrowbox symbols are breaks in circuit diagram, the diagram is the original authors for whom I cannot give credit as all references are now dead.

    Rob

  7. #7
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

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

    Try MAX4080...

  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

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

  9. #9
    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  

  10. #10
    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

    I originally blindly built this unit before realising only the hex was available at the time. I've since changed computers a few times and the code was lost.

    Now it's a project for me as I'm experimenting (playing ) with car batteries. I want to go on and design a versatile charger with data storage for downloading charge discharge/curves along with control of a desulphator unit. I've a couple of 24LC16b chips which I can I2C for storage, along with a Max232 for PC connection.

    I've managed to recover one battery that had sulphated after being left for a month during Feb when temps were below freezing. Normally indoors and float charged necessity meant it was left out connected to a non used vehicle. The battery was only a year old and current replacement costs meant I wasn't going to let it die without a fight.
    Last edited by tasmod; - 22nd June 2012 at 08:30. Reason: Typos

  11. #11
    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 thanks Barry.

    Rob
    G4NQX

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