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

## Bookmarks