Shop OBEX P1 Docs P2 Docs Learn Events
12 volt input? — Parallax Forums

12 volt input?

ArchiverArchiver Posts: 46,084
edited 2002-09-22 03:18 in General Discussion
How do I safely detect a higher voltage input with my basic stamp.

For instance:

+12 ----[noparse][[/noparse]switch]-- 12v power supply's neg (gnd)
|
|
a input on my basic stamp

Now, I know that is not a safe hookup... how should it be done?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-09-21 22:49
    Assuming you just want to measure on or off, have a look at:
    http://www.wd5gnr.com/stampfaq.htm, click on Hardware (on the left) and
    look for the article titled: How can I read logic signals greater than
    5V?

    Al Williams
    AWC
    * Floating point math for the Stamp, PIC, SX, or any microcontroller
    http://www.al-williams.com/awce/pak1.htm


    >
    Original Message
    > From: GregT2 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Oh1OxwBEyVLOgVX4T6f_wsUnw7JWVfOQKHys9244xTgbKg31JogZKyJ2Ayi7PIi40pUUxWafZKgIpMI]gregt@t...[/url
    > Sent: Saturday, September 21, 2002 4:26 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] 12 volt input?
    >
    >
    > How do I safely detect a higher voltage input with my basic stamp.
    >
    > For instance:
    >
    > +12 ----[noparse][[/noparse]switch]-- 12v power supply's neg (gnd)
    > |
    > |
    > a input on my basic stamp
    >
    > Now, I know that is not a safe hookup... how should it be done?
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-21 22:54
    I would use an opto-isolator -- that way there is no chance of damaging the
    Stamp.

    Original Message

    > How do I safely detect a higher voltage input with my basic stamp.
    >
    > For instance:
    >
    > +12 ----[noparse][[/noparse]switch]-- 12v power supply's neg (gnd)
    > |
    > |
    > a input on my basic stamp
    >
    > Now, I know that is not a safe hookup... how should it be done?
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-21 23:08
    A simple voltage divider will do the trick:

    12V ----[noparse][[/noparse] 10 K ]
    +
    [noparse][[/noparse] 4.7 K ]---- Ground
    |
    +
    > Stamp pin


    -- Jon Williams
    -- Parallax


    In a message dated 9/21/02 4:25:29 PM Central Daylight Time,
    gregt@t... writes:


    > How do I safely detect a higher voltage input with my basic stamp.
    >
    > For instance:
    >
    > +12 ----[noparse][[/noparse]switch]-- 12v power supply's neg (gnd)
    > |
    > |
    > a input on my basic stamp
    >
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-21 23:12
    >How do I safely detect a higher voltage input with my basic stamp.
    >
    >For instance:
    >
    >+12 ----[noparse][[/noparse]switch]-- 12v power supply's neg (gnd)
    > |
    > |
    > a input on my basic stamp
    >
    >Now, I know that is not a safe hookup... how should it be done?

    You need a voltage divider to bring the 12 volts down to the Stamp level.

    1M 690k
    +12 on or off ---/\/\---o--/\/\---- ground
    |
    stamp pin P0

    if P0=1 then ON12

    An alternative would be an optoisolator:

    1k
    10k
    +12 on or off ---/\/\--| |--o-/\/\-- +5 Vdd
    | | |
    |opto | '
    P0
    | |
    12-
    | |
    Vss



    If you want to measure the actual voltage, use a capacitor and RCtime:

    1M 0.015uf
    +12 ---/\/\---o----||---- ground
    |
    stamp pin P0

    see http://www.emesys.com/BS2rct.htm#B_voltage
    for more detail.

    -- regards
    Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
    mailto:tracy@e...
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-21 23:28
    Thanks for the help, but im still confused.
    I figured myself to use resistors to drop the voltage (ohms law), but
    I'm having another problem. I think it's because I am using a
    seperate voltage source and ground then the stamp is.

    It seems to be confused about the input's state

    (1 = on, 0 = off) Here is a sample of my debug window:


    0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0

    Now when I connect the stamp's ground to the 12v 's ground, I can get
    the "on" position to work, but when the sensor is off it looks like
    it does above.

    This is a QS18VN6D optical sensor incase anyone knows anything about
    it.

    Greg
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-21 23:51
    In a message dated 9/21/02 6:29:50 PM Eastern Daylight Time,
    gregt@t... writes:


    > Thanks for the help, but im still confused.
    > I figured myself to use resistors to drop the voltage (ohms law), but
    > I'm having another problem. I think it's because I am using a
    > seperate voltage source and ground then the stamp is.
    >
    > It seems to be confused about the input's state
    >
    > (1 = on, 0 = off) Here is a sample of my debug window:
    >
    >
    > 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0
    >
    > Now when I connect the stamp's ground to the 12v 's ground, I can get
    > the "on" position to work, but when the sensor is off it looks like
    > it does above.
    >
    > This is a QS18VN6D optical sensor incase anyone knows anything about
    > it.
    >
    > Greg
    >

    Greg:

    Are you using the resistors in a voltage divider circuit, doing this will
    keep the current through the resistors constant and will also maintain the
    proper voltage into the input. It will be necessary to either use the same
    ground with the stamp as the one you are using with the 12V circuit, this
    shouldn't present a problem under normal circumstances, or, you will need to
    us an optical isolator chip to interface the 12 V with the Stamp. You can
    select an optical isolator that will allow you to use 12 V directly to it and
    then use the isolated output of the chip to drive the input.

    I hope this is of some help to you.

    Randy Abernathy
    4626 Old Stilesboro Road
    Acworth, GA 30101
    Ph / Fax: 770-974-5295
    E-mail: cnc002@a...

    We install, repair and service industrial CNC woodworking machinery. We
    specialize in SCMI, SCM Group U.S.A. CNC panel saws and CNC routers.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-22 01:44
    Using an opto-isolator would allow you to keep the grounds separate, if
    necessary.

    When you say "the sensor is off" do you mean you switch off the 12 volts, or
    the do you mean when the sensor is not detecting anything??

    According to the documentation, http://www.a-aelectric.com/pdfs/63908.pdf it
    looks like this unit has an NPN output capable of sinking up to 100 ma. In
    other words, you would normally have a load between the brown (bn) +12 wire
    and the black (bk) *or* White (wh) wires (depending on if you wanted to
    detect the presence or absence of an object) as shown in the leftmost
    diagram on page 4. The blue (bu) wire would be ground, and this would also
    be tied to Stamp ground.

    If you use a voltage divider as others have mentioned, it would be your
    load, and the total resistance would be such that the 100 ma limit would not
    be exceeded. However, you should shoot for a much lower current since
    dropping 12 volts at 100 ma would take some high-wattage resistors. I would
    shoot for a much lower current (1-2 ma) so you could use 1/4 or 1/8 watt
    resistors.

    I would make up a voltage divider and test it with a power supply only (no
    sensor or Stamp) to make sure things worked as planned before connecting it
    up. The values Jon Williams mentioned would be fine, although I would also
    insert a 330 ohm resistor between the Stamp pin and the voltage divider just
    to prevent accidents.


    Original Message


    > Thanks for the help, but im still confused.
    > I figured myself to use resistors to drop the voltage (ohms law), but
    > I'm having another problem. I think it's because I am using a
    > seperate voltage source and ground then the stamp is.
    >
    > It seems to be confused about the input's state
    >
    > (1 = on, 0 = off) Here is a sample of my debug window:
    >
    >
    > 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0
    >
    > Now when I connect the stamp's ground to the 12v 's ground, I can get
    > the "on" position to work, but when the sensor is off it looks like
    > it does above.
    >
    > This is a QS18VN6D optical sensor incase anyone knows anything about
    > it.
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-22 03:14
    Here is what I did, tell me if its bad.

    I connected the stamp and 12v supply's ground (-) together through a
    380ohm resistor. It works... but am i slowly destroying something?

    This sensor is like those things in stores that beep when someone
    walks in. They send out ir pulses, and recieve the reflections (or
    sense if there isn't one). With the use of a old bike reflector it
    works very well to tell if someone's been inside my room (or if a
    switch is on, set of a alarm).

    Thanks again for all the help, try and keep in mind that I dont
    understand terms like "opto-isolator" (though I figured it out).

    Greg

    --- In basicstamps@y..., Rodent <daweasel@s...> wrote:
    > Using an opto-isolator would allow you to keep the grounds
    separate, if
    > necessary.
    >
    > When you say "the sensor is off" do you mean you switch off the 12
    volts, or
    > the do you mean when the sensor is not detecting anything??
    >
    > According to the documentation, http://www.a-
    aelectric.com/pdfs/63908.pdf it
    > looks like this unit has an NPN output capable of sinking up to 100
    ma. In
    > other words, you would normally have a load between the brown (bn)
    +12 wire
    > and the black (bk) *or* White (wh) wires (depending on if you
    wanted to
    > detect the presence or absence of an object) as shown in the
    leftmost
    > diagram on page 4. The blue (bu) wire would be ground, and this
    would also
    > be tied to Stamp ground.
    >
    > If you use a voltage divider as others have mentioned, it would be
    your
    > load, and the total resistance would be such that the 100 ma limit
    would not
    > be exceeded. However, you should shoot for a much lower current
    since
    > dropping 12 volts at 100 ma would take some high-wattage resistors.
    I would
    > shoot for a much lower current (1-2 ma) so you could use 1/4 or 1/8
    watt
    > resistors.
    >
    > I would make up a voltage divider and test it with a power supply
    only (no
    > sensor or Stamp) to make sure things worked as planned before
    connecting it
    > up. The values Jon Williams mentioned would be fine, although I
    would also
    > insert a 330 ohm resistor between the Stamp pin and the voltage
    divider just
    > to prevent accidents.
    >
    >
    >
    Original Message
    >
    >
    > > Thanks for the help, but im still confused.
    > > I figured myself to use resistors to drop the voltage (ohms law),
    but
    > > I'm having another problem. I think it's because I am using a
    > > seperate voltage source and ground then the stamp is.
    > >
    > > It seems to be confused about the input's state
    > >
    > > (1 = on, 0 = off) Here is a sample of my debug window:
    > >
    > >
    > > 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0
    > >
    > > Now when I connect the stamp's ground to the 12v 's ground, I can
    get
    > > the "on" position to work, but when the sensor is off it looks
    like
    > > it does above.
    > >
    > > This is a QS18VN6D optical sensor incase anyone knows anything
    about
    > > it.
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-22 03:18
    Something is not right. I would use a voltmeter to make sure you don't have
    too high a voltage on the Stamp pin. I suspect the input voltage on your
    Stamp pin was too high and the resistor corrected it in a round-about way.

    Original Message


    > Here is what I did, tell me if its bad.
    >
    > I connected the stamp and 12v supply's ground (-) together through a
    > 380ohm resistor. It works... but am i slowly destroying something?
    >
    > This sensor is like those things in stores that beep when someone
    > walks in. They send out ir pulses, and recieve the reflections (or
    > sense if there isn't one). With the use of a old bike reflector it
    > works very well to tell if someone's been inside my room (or if a
    > switch is on, set of a alarm).
    >
    > Thanks again for all the help, try and keep in mind that I dont
    > understand terms like "opto-isolator" (though I figured it out).
    >
    > Greg
    >
    > --- In basicstamps@y..., Rodent <daweasel@s...> wrote:
    > > Using an opto-isolator would allow you to keep the grounds
    > separate, if
    > > necessary.
    > >
    > > When you say "the sensor is off" do you mean you switch off the 12
    > volts, or
    > > the do you mean when the sensor is not detecting anything??
    > >
    > > According to the documentation, http://www.a-
    > aelectric.com/pdfs/63908.pdf it
    > > looks like this unit has an NPN output capable of sinking up to 100
    > ma. In
    > > other words, you would normally have a load between the brown (bn)
    > +12 wire
    > > and the black (bk) *or* White (wh) wires (depending on if you
    > wanted to
    > > detect the presence or absence of an object) as shown in the
    > leftmost
    > > diagram on page 4. The blue (bu) wire would be ground, and this
    > would also
    > > be tied to Stamp ground.
    > >
    > > If you use a voltage divider as others have mentioned, it would be
    > your
    > > load, and the total resistance would be such that the 100 ma limit
    > would not
    > > be exceeded. However, you should shoot for a much lower current
    > since
    > > dropping 12 volts at 100 ma would take some high-wattage resistors.
    > I would
    > > shoot for a much lower current (1-2 ma) so you could use 1/4 or 1/8
    > watt
    > > resistors.
    > >
    > > I would make up a voltage divider and test it with a power supply
    > only (no
    > > sensor or Stamp) to make sure things worked as planned before
    > connecting it
    > > up. The values Jon Williams mentioned would be fine, although I
    > would also
    > > insert a 330 ohm resistor between the Stamp pin and the voltage
    > divider just
    > > to prevent accidents.
    > >
    > >
    > >
    Original Message
    > >
    > >
    > > > Thanks for the help, but im still confused.
    > > > I figured myself to use resistors to drop the voltage (ohms law),
    > but
    > > > I'm having another problem. I think it's because I am using a
    > > > seperate voltage source and ground then the stamp is.
    > > >
    > > > It seems to be confused about the input's state
    > > >
    > > > (1 = on, 0 = off) Here is a sample of my debug window:
    > > >
    > > >
    > > > 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0
    > > >
    > > > Now when I connect the stamp's ground to the 12v 's ground, I can
    > get
    > > > the "on" position to work, but when the sensor is off it looks
    > like
    > > > it does above.
    > > >
    > > > This is a QS18VN6D optical sensor incase anyone knows anything
    > about
    > > > it.
Sign In or Register to comment.