Shop OBEX P1 Docs P2 Docs Learn Events
reading in a voltage — Parallax Forums

reading in a voltage

JamesJames Posts: 15
edited 2006-11-29 15:09 in General Discussion
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

  • Ali E.Ali E. Posts: 23
    edited 2006-11-29 03:17
    don't you need an A/D cenverter to convert values from sensor to digital numbers?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-11-29 10:37
    You can use the ADC vp.
    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
  • yvesByvesB Posts: 22
    edited 2006-11-29 14:41
    Complete Noob to the Javalin but been doing the Basic Stamps for awhile.

    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.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-11-29 14:59
    Javelin stamp manual chapter 4, page 55
    regards peter

  • yvesByvesB Posts: 22
    edited 2006-11-29 15:09
    Thanks for that·blush.gif ...I will be reading it again more closely. smilewinkgrin.gif
Sign In or Register to comment.