Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp variables — Parallax Forums

Basic Stamp variables

kc8ztjkc8ztj Posts: 6
edited 2010-04-03 23:19 in BASIC Stamp
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

Comments

  • rixterrixter Posts: 95
    edited 2010-04-03 00:49
    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
  • kc8ztjkc8ztj Posts: 6
    edited 2010-04-03 02:17
    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
  • ercoerco Posts: 20,256
    edited 2010-04-03 02:43
    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."
  • rixterrixter Posts: 95
    edited 2010-04-03 03:21
    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
  • kc8ztjkc8ztj Posts: 6
    edited 2010-04-03 03:23
    Ah that answers it. so a potentiometer would have to be connected some sort of ADC?
  • ercoerco Posts: 20,256
    edited 2010-04-03 04:02
    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."
  • divviwiliersshdivviwilierssh Posts: 1
    edited 2010-04-03 11:40
    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
  • ercoerco Posts: 20,256
    edited 2010-04-03 16:45
    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 Smile!"

    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."
  • kc8ztjkc8ztj Posts: 6
    edited 2010-04-03 23:19
    Well played! Yo
Sign In or Register to comment.