Shop OBEX P1 Docs P2 Docs Learn Events
Analog Input on BS2pe w/28301 daughterboard — Parallax Forums

Analog Input on BS2pe w/28301 daughterboard

maxsmartmaxsmart Posts: 4
edited 2010-04-08 04:37 in BASIC Stamp
How do you perform analog input on the bs2pe?· I have the 28301 daughterboard, which I think is required, and a LM34 temperature sensor.· How do I take a reading from the LM34?· What pin do I connect it to?· A0,A1,A2,A3?· Did I even need the 28301 daughterboard (the I/O daughterboard)?· I have been told I need to use something called the AVR, but that doesn't seem to be mentioned anywhere in the programming manual.·

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-04-06 00:46
    Q: How do you perform analog input on the bs2pe?
    A: See the documentation for the GPIO3 coprocessor firmware, which is preinstalled on the MoBo.

    Q: How do I take a reading from the LM34?
    A: Connect V+ to Vdd, Gnd to Vss, and Vout to the coprocessor input.

    Q: What pin do I connect it to? A0,A1,A2,A3?
    A: Either A0 or A1.

    Q: Did I even need the 28301 daughterboard (the I/O daughterboard)?
    A: No. You could have used the Proto-DB, which is less expensive and provides holes to solder the sensor into. (I don't recommend poking component leads directly into the daughterboard sockets, though.)

    Q: I have been told I need to use something called the AVR, but that doesn't seem to be mentioned anywhere in the programming manual.
    A: The PBASIC manual does not cover AVR programming. The AVR firmware driver docs are listed with their respective daughterboards. But the default GPIO3 is what you want to use.

    -Phil
  • maxsmartmaxsmart Posts: 4
    edited 2010-04-07 20:14
    OK, I plugged a .5v test voltage into the A0 pins on the IO Daughterboard.
    Here is my function, GetReading:

    GetReading:
    OWOUT Owio, 0, [noparse][[/noparse]%00001011]
    DO
    OWIN Owio, 4, [noparse][[/noparse]Busy]
    LOOP WHILE Busy
    OWIN Owio, 0, [noparse][[/noparse]Voltage.HIGHBYTE, Voltage.LOWBYTE]
    DEBUG DEC Voltage
    RETURN

    When I run this function repeatedly in a loop, the value bounces around a bit then settles on Voltage=390. I change the test voltage to 0v (ground) and the reading remains the same. What am I doing wrong? Thanks!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-04-07 22:58
    Which socket is the 28301 daughterboard plugged into, and what value are you using for Owio?

    Please list your entire program between [noparse][[/noparse]code] and [noparse][[/noparse]/code] tags.

    -Phil
  • maxsmartmaxsmart Posts: 4
    edited 2010-04-08 04:01
    OK, I was messing around with it and now I can't get it to give me a reading at all. What should Owio be? Here's my code:
    ' {$STAMP BS2pe}
    ' {$PBASIC 2.5}
    
    Voltage   VAR Word
    Busy      VAR Bit
    
    Owio      PIN 0
    
      Main:
      GOSUB GetReading
      PAUSE 500
      GOTO Main
      END
    
    GetReading:
      OWOUT Owio, 0, [noparse][[/noparse]%00001011]
      DO
        OWIN Owio, 4, [noparse][[/noparse]Busy]
      LOOP WHILE Busy
      PAUSE 25
      OWIN Owio, 0, [noparse][[/noparse]Voltage.HIGHBYTE, Voltage.LOWBYTE]
      DEBUG DEC Voltage
      RETURN
    
    
  • maxsmartmaxsmart Posts: 4
    edited 2010-04-08 04:24
    Never mind on that, it's working all of a sudden. I changed Owio back to pin 10, and all of a sudden the readings are more resonable. Now my question is how do I change the reference voltage being used? Thanks again!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-04-08 04:37
    You have two choices for reference voltage: Vdd (be it 3.3V or 5V) and 1.1V. See page 9 of the GPIO3 reference manual for a summary of how to select between them.

    -Phil
Sign In or Register to comment.