Shop OBEX P1 Docs P2 Docs Learn Events
stumped — Parallax Forums

stumped

bryanfuelbryanfuel Posts: 5
edited 2009-02-09 17:14 in BASIC Stamp
i am trying to trip a relay with basic stamp homework board and the vdd will trip it but pin 2 set to high wont. I have already tested to see if my program is working to give pin 2 power and it should be enough to work. i get 5 volts from both sources but only vdd trips the relay. what am i doing wrong

Comments

  • technoobtechnoob Posts: 21
    edited 2009-02-08 07:37
    Im using a relay in the same manner to pulse a standard cheapo servo.· the relay is rated for 5v and works with a pin high command.· I pause for like 20 ms then go low then pause for 75 ms to get a "pulseout" kinda thing.·· I sue FOR· NEXT to run a VAR counter and·I·emulate pulse·durations.· the whole reason im doing this rather than pulseout command is because the servo is 9volt.· · Very inaccurate with the $2 servo, but its getting the job done.·

    Anyway,.··· If·Your relay·trips with vdd it should trip with a high command.··write a little three line section of code and check it again.····· ··

    good luck

    Hope this helps...



    Randy "technoob"
  • ercoerco Posts: 20,256
    edited 2009-02-08 08:05
    A stamp output pin can only put out 20 milliamps at 5 volts. Your 5V relay probably needs a lot more current·than that. Can't be done directly with most relays, as the output voltage drops below 5V.

    The Stamp HW board has built-in 220 ohm resistors on all output pins, so that limits your available current and hopefully prevented you from damaging pin 2 or any other pin you tried.

    One way to·trigger a larger 5V relay is to switch it with a 2N2222A transistor per the attached sketch. Sketch shows a flyback diode across the coil; use this, it saves stamps!·Generalized sketch·shows a 330 ohm resistor going to the stamp. Your BS2 HW board already has 220 ohms, so only add a 100-ohm resistor in series.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."

    Post Edited (erco) : 2/8/2009 3:38:53 PM GMT
  • SRLMSRLM Posts: 5,045
    edited 2009-02-08 08:10
    Unless you're using a special kind of relay, you'll need to take some protective measures. The stamp pin cannot source enough current to supply the relay. It's possible that you burned out the second pin.

    To fix the problem of not enough current, you'll want to use a transistor or two. Look on this page for information on how to do that. In addition, you'll want to add a protective diode on the motor line to stop the surge of reverse voltage when you turn off the relay.

    You can't control a relay like a servo. They are completely different. A relay take a relatively long time to go from one state to another, something that the control electronics takes care of for a servo. You might be able to open and close the relay at that speed (~50 Hz), but it depends on the relay.
  • SRLMSRLM Posts: 5,045
    edited 2009-02-08 08:11
    Well played, erco... [noparse]:)[/noparse] 5 minutes the victor.
  • $WMc%$WMc% Posts: 1,884
    edited 2009-02-08 21:00
    bryanfuel

    You should thank the Folks at Parallax for the 220ohm resisters and the zeners they placed on the I/O pins.Like "erco" mentioned the flyback voltage from the relay would zap the I/O pin,(Letting all the factory smoke out.) You got lucky this time with no damage to the I/O pin, But this careless practice will lead to burnt out I/O pins.

    I would read up on the hardware side of the $STAMPs I was useing, And what drivers I needed to use.


    ______________$WMc%_______

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • metron9metron9 Posts: 1,100
    edited 2009-02-09 03:21
    technoob said...


    Im using a relay in the same manner to pulse a standard cheapo servo.· the relay is rated for 5v and works with a pin high command.· I pause for like 20 ms then go low then pause for 75 ms to get a "pulseout" kinda thing.·· I sue FOR· NEXT to run a VAR counter and·I·emulate pulse·durations.· the whole reason im doing this rather than pulseout command is because the servo is 9volt.· · Very inaccurate with the $2 servo, but its getting the job done.·

    Anyway,.··· If·Your relay·trips with vdd it should trip with a high command.··write a little three line section of code and check it again.····· ··

    good luck

    Hope this helps...



    Randy "technoob"
    Amazing that actually works. Typically small relays have 5 to 15 mS on off time and specs of 1800 operations per hour, 30 times per min once every two seconds. Switching the relay on a continious basis 50 times per second is not a good idea.· At that rate the typical 5 million mechanical operations will be used up in just 27 hours. Typically the servo data line gets connected directly to a Uc pin you don't need a relay to drive the data input of a typical servo.





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • bryanfuelbryanfuel Posts: 5
    edited 2009-02-09 16:46
    I ended up getting the whole circuit to work. I replaced the relays with some reed relays that need 5v and 20mA to run. One of them is sticky though so i have to turn on the pin then repeatedly flick the relay until my light goes on. =P
  • ercoerco Posts: 20,256
    edited 2009-02-09 17:14
    I like those 5V, 20 mA reed relays for use with a real Stamp, but not a HW Board.·Your HW board has inline 220 ohm resistors which won't allow 20 mA to flow through a 250 ohm relay coil. You're probably getting·less than·3 volts across your relay because of that resistor. Your relays are not sticky, they're underpowered.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
Sign In or Register to comment.