Hi,
If ADCIN works on the same pins you're trying to use for POT and/or RCTIME then my guess is that when trying POT/RCTIME you're forgetting to switch the pins from analog to digital inputs. POT/RCTIME both need the pin to be in "digital mode" and they default to analog on startup.
Code:
ANSEL = 0 'Turn off ADC functionallity on all analog pins
CMCON = 7 'Turn off comparator functionallity.
When scaling values you need to make sure that the result of the calculation fits in the variable to which you assign it. As you know, a value of 1023 won't fit in a BYTE variable, you need a WORD. The result of multiplying 1023 by anything above 0.25 won't fit in a BYTE either so the result variable must be WORD as well.
Scaling 50 to 105 is the same as multiplying by 2.1, PBP doesn't do floating point, ie you can't program Result = ADCValue * 2.1 but you can do something like:
Code:
Result VAR WORD 'Must use a 16bit variable here
Result = ADCValue * 21 'Result is now 0-21483
Result = Result / 10 'Result is now 0-2048
/Henrik.
Bookmarks