Shop OBEX P1 Docs P2 Docs Learn Events
Measure voltage polarity with io pin? — Parallax Forums

Measure voltage polarity with io pin?

BotdocterBotdocter Posts: 271
edited 2011-01-04 16:28 in Propeller 1
I have been searching through the prop manual, but wasn't able to find anything.

I need to measure the polarity of 5v. So one moment it will be +5V an then the next -5V. nothing in between just like a switch on and of.

i use the robot control board.

any help is welcome!

Comments

  • ErNaErNa Posts: 1,752
    edited 2011-01-04 11:34
    This is quite simple to do: connect an input to the voltage via 100k. Low input will show low voltage input, a negative voltage will be clamped by the input protection diode (internal), high shows a positive voltage > 1.2V
  • BotdocterBotdocter Posts: 271
    edited 2011-01-04 12:19
    Oops, i forgot to mention that there are accually three states. Disconnected, -5v, +5v.
    It is a weird decoder from a rc car that is used for sensing wheel direction.

    Disconnected is in the straight forward, -5v is left and +5v is right.
  • AribaAriba Posts: 2,690
    edited 2011-01-04 13:03
    Something like that:
    attachment.php?attachmentid=76937&d=1294174983
    380 x 143 - 2K
  • BotdocterBotdocter Posts: 271
    edited 2011-01-04 13:30
    indeed! i just thought of the same diagram only with diodes. so can you point me to a example for the spin code?
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-01-04 14:15
    hm - to be honest:

    I was asking myself "did botdocter code only a few codelines by himself?"
    My answer ist YES! for sure! But why is he asking then? I think it is quite simple

    pseudo-code

    if (ina[pin1] == 1) and (ina[pin2] == 0)
    open - no voltage

    if (ina[pin1] == 1) and (ina[pin2] == 1)
    +5V

    if (ina[pin1] == 0) and (ina[pin2] == 0)
    -5V
    best regards

    Stefan
  • BotdocterBotdocter Posts: 271
    edited 2011-01-04 14:55
    Thank you. This is very clear.

    I don't know exactly what you mean with this though:
    hm - to be honest:

    I was asking myself "did botdocter code only a few codelines by himself?"
    My answer ist YES! for sure! But why is he asking then? I think it is quite simple
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-01-04 16:28
    This is called sarcasm.
Sign In or Register to comment.