Hi,
Just as Joe says, the two resistors forms a voltage divider that "divides" the voltage fed to it by the ratio between the two resistors. The upper one is 2.2 times larger than the lower one so will loose 2.2 times as many volts over that one than over the lower one. Or if you wish to put ohms law to the test:
The total resistance is 3.2k, with a voltage of 15V there will be a current of (I = U / R) 4.6875mA flowing thru the two resistors. Now that current will produce a voltage over the lower resistor of (U = I*R) 4.6875V.
Since the PIC's AD pin is connected in parallel with the lower resistor the PIC will "see" a voltage between 0 and 4.6875V when the voltage from the solar PV is between 0 and 15V.
Now, in the code I showed you we set the ADCON1 register in a way that the ADC uses the PIC's powersupply as a reference voltage. What that means is that whatever the powersupply voltage is at the moment will produce the max reading from the ADC, so for the above to work it's important that the powersupply is stable at 5.0V.
We also said
What that does is set the ADC code to give you a resolution of 10bits, or put another way, the result from the ADC will be between 0 - 1023. That is 0V on the input will give you 0 in SolarVoltage and 5V in will give you 1023 in SolarVoltage. The display will show that value, not the voltage.Code:DEFINE ADC_BITS 10
To get the display to show actuall volts you need to scale the value. With a powersupply of 5.0V each bit in the ADC result is 0.00488V (5/1024) so if the display shows 958 the voltage at the PIC pin is ~4.67V which in turn corresponds to ~15V from the solar PV. (See the voltage divider)
Are you going to display the "real" voltage or just using the value to decide when to start the motor? If the later then you don't need to scale it at all, just use it as it is.
The DEFINE ADC_CLOCK 3 tells the ADC module inside the PIC what clock source to use. It has nothing to do with the Xtal you are using to drive the PIC.
/Henrik Olsson.
Bookmarks