Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Control Relay - Question — Parallax Forums

BS2 Control Relay - Question

alyarosalyaros Posts: 9
edited 2010-11-12 18:19 in BASIC Stamp
Hi All
I'm trying to build a relay circuit that is controlled by Basic Stamp 2.

My problem:
I know how to build the relay circuit but i don't know how to control it by the basic stamp.
I attached an image file explaining what i have built so far.

my question is how to connect the Basic Stamp I\O Pin to the transistor Base Pin in order that it will activate the relay?

(Note that if i remove the transistor and connect the E And the B manually the relay works.)

but when i'm trying to add a transistor that will be controlled by the basic stamp - by connecting Pin 0 to the B (Base) the relay doesn't work.

i will appreciate your help,
Thanks
670 x 542 - 48K

Comments

  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2010-11-12 12:35
    There are some good examples in the old Nuts'N'Volts columns that Parallax has online. In particular this one should help:

    http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv6.pdf

    Robert
  • ZootZoot Posts: 2,227
    edited 2010-11-12 12:36
    Presuming your schematic and wiring are correct, it seems like it should work. I would connect a Stamp pin to the base of the transistor through a 470ohm resistor. Setting that pin to HIGH should saturate the transistor and turn on the relay.

    The only hitch I can think of is -- if the transistor is a big one, and needs a hefty base current to saturate it, then the Stamp pin may not have enough current to drive it. What kind of transistor is it?
  • alyarosalyaros Posts: 9
    edited 2010-11-12 12:42
    Transistor = 2N2222
    Back-Fly diode = 1N4005
    Relay 5V \ 250VAC, 8A
  • alyarosalyaros Posts: 9
    edited 2010-11-12 12:45
    i tried to connect PIN 0 to Transistor Base Using Resistor (470Ohm)
    The basic stamp program was:
    DO
    HIGH 0
    LOOP
    it doesn't work - the relay doesn't turn on.

    Maybe it is because the Stamp and the Relay are working with different Power sources?

    The connections are correct - i tested the circuit without the transistor - just bypassed it by connection E TO C and it worked.
  • ZootZoot Posts: 2,227
    edited 2010-11-12 12:46
    Are your grounds tied together? It doesn't matter if what the relay is turning on and off has a different power source, what matters is the common power to the relay coil. Judging by your schematic, it looks ok.

    Here's a test -- you said "manually" connecting the base worked? If tie the base of the transistor directly to 5v through a 470 resistor does it work? If it DOES then, perhaps your Stamp pin is bad. If it doesn't work, then something else is going on.

    Here is code that would turn the relay on and off every two seconds:
    DO
       HIGH 0
       PAUSE 2000
       LOW 0
       PAUSE 2000
    LOOP
    
  • alyarosalyaros Posts: 9
    edited 2010-11-12 12:47
    There are some good examples in the old Nuts'N'Volts columns that Parallax has online. In particular this one should help:

    http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv6.pdf

    Robert

    i read it , this is what i was trying to do.
    but it doesn't work - i assume i'm missing something...
    but i don't know what..
  • alyarosalyaros Posts: 9
    edited 2010-11-12 12:48
    Zoot wrote: »
    Are your grounds tied together?

    can you explain?
    how to tie all the ground together?
  • alyarosalyaros Posts: 9
    edited 2010-11-12 13:01
    Attached Updated Image.
    I Connected The Transistor Base to Pin 0 with a resistor.
    Pin 0 is constantly HIGH. (The pin is OK i can turn on a Other Test led using it)
    It Still Doesn't Work.

    I have 2 Power Sources (MARKED Green) in my circuit.
    Shouldn't they be connected some how??
    i am one step far from activating this circuit -
    i only need little Help :-)
    670 x 542 - 61K
  • Mike2545Mike2545 Posts: 433
    edited 2010-11-12 13:08
    I think he ment this to tie all grounds together
  • ZootZoot Posts: 2,227
    edited 2010-11-12 13:09
    Connect just the grounds of the relay/led circuit and the Stamp together.

    (like in Mike2545's drawing)
  • alyarosalyaros Posts: 9
    edited 2010-11-12 13:50
    Zoot wrote: »
    Connect just the grounds of the relay/led circuit and the Stamp together.

    (like in Mike2545's drawing)

    Should I connect the relay regulated GND to the basic stamp
    Regulated ground meaning the vss or to the GND cable that is coming from the wall transformar? Before the board of eductaiom voltage regulator ?
    Or it doesn't matter because they are all the same Gnd ?
  • Mike2545Mike2545 Posts: 433
    edited 2010-11-12 14:52
    Ground or 0 volts is a reference point; if you are sending a signal to the base of the transistor, those electrons need a path back, without a common ground they wont have a place to go. (Simplified version)
  • alyarosalyaros Posts: 9
    edited 2010-11-12 18:19
    In my last attempt I think i damaged Pin 0 and the Transistor.
    (pin 0 is stuck on High state - It's last state and i'm unable to program it to low
    meaning Low 0 doesn't affect the pin)

    but anyway, as soon as i get new Ones (Transistor at least) i will try to activate this circuit again.

    Thanks for you advice
    I think now my circuit will work.
Sign In or Register to comment.