Using the A/D for Monitoring a Solor Cell and Battery


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Chuck,

    This should help out. I Hope.

    In the sample voltage divider shown below. If the input is 25Vdc then the output voltage will be about 4.38 Vdc.
    With 10-bit A/D you should get an ADCin of around 898.
    If you first scale that A/D value up to match the voltage divider ratio, you can then calculate the voltage the same way you would if you were reading 0-5 V.

    The ratio of the voltage divider is (R1+R2)/R2.
    To scale up the A/D reading you just multiply the value times the total resistance of the divider (R1+R2) then divide that number by R2.

    898 * 5700 / 1000 = 5118
    This is what the A/D would be if it could actually read 0-25 volts directly.

    Now then, for 1 decimal place, multiply that by 50 and divide by 1023.
    For 2 decimal places, multiply by 500 instead.

    5118 * 50 / 1023 = 250 or 25.0Vdc

    The program below is one way to do it in PBP.

    HTH,
    Darrel



    Code:
    Res1   Var Word
    Res2   Var Word
    Rt     Var Word
    Volts  Var Word
    AD     Var Word 
    
    Loop:
       ADCin  0, AD
       Res1 = 4700          ' Change these to match your Voltage divider
       Res2 = 1000          ' resistor values for the Solar Cell
       Gosub CalcVoltage
       LCDout $FE,2,"Solar= ",DEC Volts/10,".",DEC1 Volts Dig 0," Vdc"
       
       ADCin  1, AD
       Res1 = 2200          ' Change these to match your Voltage divider
       Res2 = 1000          ' resistor values for the Battery
       Gosub CalcVoltage
       LCDout $FE,$C0,"Batt = ",DEC Volts/10,".",DEC1 Volts Dig 0," Vdc"
       
    goto Loop
       
    CalcVoltage:
        Rt = Res1 + Res2        ' Total resistance of Voltage Divider
        Volts = AD * Rt         ' Scale the AD reading accordingly
        Volts = DIV32 Res2
        Volts = Volts * 50      ' Convert AD to Voltage
        Volts = DIV32 1023
    Return
    Last edited by Darrel Taylor; - 30th January 2014 at 02:32.

Similar Threads

  1. A/d 16f88
    By Steves in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st May 2009, 01:19
  2. Of battery discharge curves
    By ardhuru in forum General
    Replies: 0
    Last Post: - 21st January 2009, 16:24
  3. 12f675 A/d Miseries
    By MARAD75 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 16th December 2008, 02:16
  4. Low battery signal from an RTC
    By ardhuru in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th March 2008, 17:13
  5. Need advice on A/D
    By james in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th August 2007, 19:30

Members who have read this thread : 1

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