Shop OBEX P1 Docs P2 Docs Learn Events
Can BS2 create continuity programmatically? — Parallax Forums

Can BS2 create continuity programmatically?

JC68JC68 Posts: 19
edited 2006-07-29 02:31 in BASIC Stamp
<!--StartFragment -->Can BS2 create continuity programmatically?

i have used my BS2 to blink a led, beep a speaker, spin a servo, etc but these all seem to send power to the i/o pin. (not sure if freqout and pulse are power)

i basically have a button (the continuity problem)·that i want my BS2 to activate via code / program.· i have soldered two wires, one on each side of the button in question, and when i physically cross these wires·by hand (touch red wire to black wire) the button activates and a drawer opens.

how can i have the BS2 activate the button?· i don't have any code really·because i am a little hesitant to hook up button to stamp for fear of frying the drawer and/or motor that it opens. but i thought maybe:

Main:
IN3 = 0 ' wire are
IN5 = 0 ' uncrossed
DEBUG "Opening Drawer..."
IN3 = 1 ' wires are
IN5 = 1 ' crossed
IN3 = 0 ' button up wires
IN5 = 0 ' are uncrossed
' Fast on off to simulate single push button (crossing red with black?)
DEBUG "Drawer Now Open"
PAUSE 5000
DEBUG "Closing Drawer..."
IN3 = 1
IN5 = 1
IN3 = 0
IN5 = 0
DEBUG "Drawer Closed"
END

Comments

  • FranklinFranklin Posts: 4,747
    edited 2006-07-28 20:52
    The thing you want to do is to create a short across the wires connected to the button. depending on what cuttent flows you could use a transistor, mosfet or relay. You would hook one side to vss or vdd and the other side to a pin then send a high or low depending on how you wired it. A better way would be to find out what the button was activating and power that direct (or with the transistor, mosfet or relay).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • JC68JC68 Posts: 19
    edited 2006-07-28 21:08
    thanks for your reply!· 8)

    "depending on what cuttent flows you could use a transistor, mosfet or relay."
    the current is that of a pc dvd drive 5v / 12v

    "A better way would be to find out what the button was activating and power that direct (or with the transistor, mosfet or relay)"

    i don't know if this is possible as the button activates the eject.·· doesn't the drives firmware decide what happens when the buttons pressed (open drawer), how long the motor runs, etc...?

    and for the record (don't know if it matters) i would ultimately want to put this with the PIR motion sensor to create the short across the wires.· but as a test i just went with a fast open.. pause.. close.. loop.
  • HarborHarbor Posts: 73
    edited 2006-07-28 23:12
    Transistors, whether mosfet or other kinds, are switches. They turn on or off the flow of current from 'emitter' to 'drain' by a 'gate'. (So they all have three connections, one for each role.) You could use a "solid state" switch of this sort if you needed very fast switching. In computers we use several million of these buggers, switching at up to a billion times a second, to create the processor and other functions.

    To open a CD drawer, that would be overkill. By nine or ten orders of magnitude. Drop by your nearest Radio Shack or other source of parts and buy a 5V reed relay. These do the same thing. Just a lot slower. The equivalent of the 'gate' is very small coil. When you apply 5V from a stamp pin to that coil, it creates a magnetic field that draws together two very small (hence 'reed') pieces of metal. That closes the connection. You have a switch.

    Relays come in ratings for difficult levels of current traveling through that circuit. Too much current you melt the contacts together and they won't turn off. Even more current and you simply melt the whole switch. If you ever want to turn on the motor of a garage door opener or the motor of a golf cart, come back and learn about that level of current. Again, not an issue with the drawer of a CD player.

    Buy any reed relay you like, so long as it says "5V Coil Rating" or something similar. Put a 220 ohm resistor from your Stamp pin to the indicated "plus pin" for the coil·on the relay. Connect the other pin from the coil to ground. Now the other two pins are your "crossed wires". There you have· it.
  • LSBLSB Posts: 175
    edited 2006-07-29 00:53
    Always awkward to jump in the middle, but I took JC68's post to ask how to read a switch. If I'm wrong, ignore...
    Wire in series Vdd----switch----10K----Vdd. From where switch and resister join, wire IN[noparse][[/noparse]PIN]; IN[noparse][[/noparse]PIN] will now take value from switch. Open switch reads a 0, closed reads 1, as:
    IF IN[noparse][[/noparse]PIN]=0 THEN
    {CODE}
    ELSE
    {CODE}
    ENDIF
    Complete diagram and description on page 62 of "Applied Robotics with the SumoBot" available at description of SumoBot.
    Again, sorry to muddy the water if I mis-read.
  • HarborHarbor Posts: 73
    edited 2006-07-29 02:31
    It was my impression that he wanted to substitute programmed control in a Stamp for the physical action of depressing a switch. That is, he wants to enable the circuit from his Stamp program. It is certainly true that reading the state of a switch would be much simpler than the circuit I described.
Sign In or Register to comment.