PDA

View Full Version : Basic Stamp variables



kc8ztj
04-03-2010, 08:03 AM
I have a question about varialbes in the Basic Stamp 2 OEM. I know that Pbasic will only let you work with positive interger numbers from I have been able to read. If this is so, then what happens with analolg values at say an input. Is the BS2 limited to just digital inputs as a result?

Thanks in advance

rixter
04-03-2010, 08:49 AM
There is an approximate voltage that determines whether an input is regarded as a logical "1" or "0". This ends up being around 1.3 volts I believe. It is for this reason that it is most important that you don't let pins intended as inputs on any chip to "float". You are certain to get some unpredictable results unless you "force" the pins high or low so you know their logical state at all times. Check out the BUTTON command for some additional info on this concept. There are arguments that for switches it is better to pull high due to the point where the logical 1/0 sits, although I've always pulled low and had no issues.

rixter

kc8ztj
04-03-2010, 10:17 AM
rixter, thanks for the response. So an input of say, 3.3 volts will be read as 3 volts. Would that hold true if the same pin had voltage say 3.7 volts? Does the Stamp truncate the fractional values?

Thanks again

erco
04-03-2010, 10:43 AM
No, the Stamp doesn't have any built-in A/D converters, so it can't read any voltages directly . Without external hardware, the inputs are digital. Below ~1.3V, a pin will read 0. Above ~1.3V, it will read 1. And don't go above Vdd, or 5V!

You can use RCTime with an external cap & resistor combo to read a DC voltage, or interface a more sophisticated A/D converter for improved accuracy.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you build it, they will come."

rixter
04-03-2010, 11:21 AM
This time erco beat me to the punch.... and he is spot on. Some other microprocessors such as the PICAXE, BX24 and others have ADC ability on some of their pins. For the BS2 you'll have to come up with other tricks or use an external ADC.

rixter

kc8ztj
04-03-2010, 11:23 AM
Ah that answers it. so a potentiometer would have to be connected some sort of ADC?

erco
04-03-2010, 12:02 PM
No sir, reading a pot is exactly what RCTime does best! You're just a capacitor away from a solution! If you have the WAM text, it gives all the info you need.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you build it, they will come."

divviwilierssh
04-03-2010, 07:40 PM
You do not have to worry over long queues towards the counter since your would-be purchases can be finalized in just a few clicks. More so, many people find online shopping hassle-free. For them, sites work similarly like catalogues since product descriptions are also listed and are easily seen. The shoebuy.com coupon, on the other hand, gives huge discounts on certain shoe items.


Shoebuy Promotional Code (http://www.articlesbase.com/shopping-articles/get-exclusive-shoebuy-coupon-codes-amp-shoebuy-promotional-codes-2086623.html)

erco
04-04-2010, 12:45 AM
kc8ztj: Re-reading my last post, I regret that I missed a perfect opportunity to use my favorite Hollywood gangsta phrase, so please indulge me.

You got da Stamp, you got da pot, an' you only missin' one thang, so...

"POP A CAP IN ITZ RAGGEDY ARSE!"

It's much more dramatic if you point with a two-finger gun-type hand gesture.

The same opportunity often comes up when people forget to use motor filter caps, so practice that phrase & gesture for your own opportunities to help people.

Yo, Yo, from erco

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you build it, they will come."

kc8ztj
04-04-2010, 07:19 AM
Well played! Yo