Quote Originally Posted by aratti View Post
Code:
From your code:

ADCIN 1,ntc
tb0=ntc
if tb0>=16170 then
tb1=tb0-16170 
ELSE 
tb0=0
ENDIF
Since ntc could be 0 or 1023 maximum, the condition if tb0>=16170 then is always false so tbo will be always zero and tb1 will be never setted with your required calculation tb1=tb0-16170.

Cheers

Al.
The code works for me because the value of my ADC varies from 0 to 65525 (it's a 10-bit ADC, but with bits shifted to a 16-bit value).