PDA

View Full Version : Analog Input on BS2pe w/28301 daughterboard



maxsmart
04-06-2010, 04:57 AM
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.

Phil Pilgrim (PhiPi)
04-06-2010, 07:46 AM
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

maxsmart
04-08-2010, 03:14 AM
OK, I plugged a .5v test voltage into the A0 pins on the IO Daughterboard.
Here is my function, GetReading:

GetReading:
OWOUT Owio, 0, [%00001011]
DO
OWIN Owio, 4, [Busy]
LOOP WHILE Busy
OWIN Owio, 0, [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)
04-08-2010, 05:58 AM
Which socket is the 28301 daughterboard plugged into, and what value are you using for Owio?

Please list your entire program between
and tags.

-Phil

maxsmart
04-08-2010, 11:01 AM
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, [%00001011]
DO
OWIN Owio, 4, [Busy]
LOOP WHILE Busy
PAUSE 25
OWIN Owio, 0, [Voltage.HIGHBYTE, Voltage.LOWBYTE]
DEBUG DEC Voltage
RETURN

maxsmart
04-08-2010, 11:24 AM
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)
04-08-2010, 11:37 AM
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