reading in a voltage
i have a voltage of 700mV outputting from a sensor, i wish to have this value outputted to my LCd display, how do i get the javelin to take that value assumeably from a selected pin say pin 15 and have it ready to be outputted to the LCD?
Comments
This gives values 0 (=0V) to 255 (=5V)
so if read value N then
V = (N/255)*5
Calculating a value 0.00 to 5.00 (more decimals is pointless due to adc resolution)
value = (N/255)*500 = (N/51)*100 = 1.9608*N = N + 0.9608*N = N + (62966/65536)*N
Using the UnsignedIntMath class
static ADC myADC = new ADC(inpin,outpin);
int n = myADC.read(); //get value from adc
int value = n + UnsignedIntMath.umulf(n,(short)62966);
now value is in the range 0 to 500
if (value > 500) value = 500; //failsafe for rounding errors
lcd.writebyte((value/100) + '0'); //display integer part
lcd.writebyte('.'); //decimal point
lcd.writebyte((value%100)/10 + '0'); //first decimal
lcd.writebyte((value%10) + '0'); //second decimal
for 700mV N is approx. 36 and value is approx. 70
regards peter
I would like to interact with the Jav's ADC as well and as I can understand, it's a sigma-delta type ADC. A bit confused as to what I use for outpin in the example above?? inpin is signal to be measured??
Thanks.
regards peter