Shop OBEX P1 Docs P2 Docs Learn Events
reading voltage w/o RCTIME? — Parallax Forums

reading voltage w/o RCTIME?

tahlorntahlorn Posts: 18
edited 2008-04-14 03:07 in BASIC Stamp
Greetings again.

Working with the BS2. I plan to have a program start when a device gives an input pin a voltage (will be 0.6V). Just needs to know that there is or isn't voltage appliked, not how much.
Everything I have found says to use RCTIME and an A/D converter. The signal is not analog, but digital. I am just looking for a simple solution to go in an IF THEN statement, and the RCTIME seems it needs too much setup for my single simple application.

Can anyone help me, or point me to some sample code?

Thanks in advance!

Comments

  • tahlorntahlorn Posts: 18
    edited 2008-04-09 22:37
    OK, think I got it. Without using full proper code speak:

    if INPUT1 = 1
    then
    OUTPUT2 = 1
    else
    OUTPUT2 = 0

    and I have to use an op amp or transistor to boost the 0.6V to 1.4V at the INPUT1, as that is the threshold voltage. Ja?
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-09 22:41
    Are you saying you want it to recoginize when you go from 0vdc to 0.6vdc? What is the inactive voltage for the input device? Where does it come from?
  • FranklinFranklin Posts: 4,747
    edited 2008-04-10 02:03
    I'd go for a bit more boost but the idea is correct. Check the BS manual for the exact voltage to make an input high (I don't know off hand)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • alphyalphy Posts: 12
    edited 2008-04-10 15:03
    If in3=1 then 'do stuff
  • tahlorntahlorn Posts: 18
    edited 2008-04-10 15:25
    jmalaysia,
    Input is coming from a distance sensor, that will output 0V with no obstruction and 0.6Vdc when there is an obstruction.

    Franklin,
    from what I saw, it is 1.4V. Though would be safe to boost it further.

    My only issue is finding a transistor with a base-emitter voltage low enough for 0.6V to do anything, and I prefer a transistor over a OpAmp as it is simpler to wire up.

    alphy,
    Danke! I know basic logic and such, but the actual names is what gets me. And now I know (and knowing is half the battle).
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-04-10 17:16
    The turn on voltage of a transistor will be less than 0.6 volt if you use a high value resistor in the collector. For example, try a generic 2N3904 NPN transistor with a 5 Meg resistor from collector to +5 volts. Connect the emitter to ground, and 1 k from base to the input signal. That should turn on at around 0.5 volt.

    The 0.6 volt threshold is a rule-of-thumb value that applies for collector currents on the order of 1 milliamp. But the controlling voltage from base to emitter is really governed by the exponential Ebers-Moll model, and for the 2N3904, the ON voltage at 25 degC is typically (from the Fairchild data sheet)
    Vbe = 0.66 + 0.06 * log (Ic) with Ic in mA and Vbe in volts.
    When Ic=1 microamp (0.001 mA), it comes out to 0.48 volts.

    You could also find a germanium transistor, which would intrinsically have a lower threshold voltage. Or, an Op amp with a voltage divider is not really hard to wire up. Same number of components really, and better control over the threshold.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-04-10 18:28
    It almost sounds like you're trying to use an open collector sensor without a pullup resistor. If so, a simple pullup resistor may be all you need. Can you tell us what the device is?

    -Phil
  • tahlorntahlorn Posts: 18
    edited 2008-04-10 18:37
    http://www.hobbyengineering.com/H1760.html
    Ir Sensor, with a 31" trigger distance, digital signal, 0V or 0.6V dependent upon obstructed or unobstructed.
    Wanting the output voltage of 0.6V to be a trigger to the BS, somehow. I don't care how, as long as it happens.
    I am having a dickens of a time finding a transistor with a base-emitter voltage of 0.6V or less, otherwise I would be using that.
    Any information on what you think would work is always welcome! Be as detailed as you would like.
    Thanks!
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-10 18:47
    I looked at the data sheet you linked to and it says the HIGH output is a MINIMUM of Vcc-.3vdc, and the LOW output is a MAXIMUM of .6vdc, meaning it is putting out ready made highs and lows if you run it with a 5vdc source.
  • tahlorntahlorn Posts: 18
    edited 2008-04-10 21:47
    Sorry for being dense- so you are saying I read the output voltage value incorrectly on the data sheet, and it will give me sufficient hi/low voltage signals as is?
    I used one of these a while ago with a different MC, different application. I just seemed to have forgotten everything from then.
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-10 22:07
    Yes, if you power it with 5vdc it will output a minimum of 4.7vdc for HIGH and and maximum of .6vdc for LOW, which is groovy for direct connection to a stamp pin.
  • tahlorntahlorn Posts: 18
    edited 2008-04-10 23:05
    *head to worktable* Alright, that makes much more sense. I was thinking it should give me back around my 5V, so was baffled why it was saying 0.6V, but not directly TELLING me that the output was that. thanks for clearing that up for me!

    -still a newbie
  • tahlorntahlorn Posts: 18
    edited 2008-04-13 23:47
    Well, got the sensor, and seems that it does give +5V/0V depending in obstruction or not. Only issue is that that is the voltage from the source voltage to the signal line, NOT signal to ground. Signal to ground give me 0V, obstructed or not. So hooking the signal line straight to the input won't work, as it sees a difference of 0V, no matter what. Got the statements and program done and it works, I just now need to figure out this wiring. Grrrrrrrr. Life would have been so much easier if it was a ground to signal difference. Feel free to make suggestions, otherwise thanks for the previous help, and I hope I won't release the magic smoke.
  • FranklinFranklin Posts: 4,747
    edited 2008-04-14 00:56
    www.acroname.com/robotics/info/articles/sharp/sharp.html
    www.acroname.com/robotics/parts/SharpGP2Y0D02YK.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-04-14 01:13
    Grrrrrr... it IS ground referenced.

    Grrrrrr... the output pin needs to be pulled to Vdd/+5V, like Uncle Phil told you.

    So, Grrrrrr...
    1. Get a 10k resistor and connect it with one end to the Sharp output and the other to Vdd/+5V and then
    2. connect the output-to-10k junction to the Stamp input

    sharp.jpg
  • tahlorntahlorn Posts: 18
    edited 2008-04-14 03:07
    Thanks y'all. I was figuring I would need to do something like this, thanks for spelling it out for me. And with that, this be the last I shall bother y'all on the subject. Thanks again!

    EDIT: It works! Yeah, needed to put a 10k resistor in line there like was stated above. I don;t get the full 5V as I am using a lot of the power on other things as well, but it is enough to read as a high. Thanks again!

    Post Edited (tahlorn) : 4/16/2008 12:02:08 AM GMT
Sign In or Register to comment.