Shop OBEX P1 Docs P2 Docs Learn Events
How to use BS2 to control motors, lamps, etc — Parallax Forums

How to use BS2 to control motors, lamps, etc

EliTeEliTe Posts: 6
edited 2005-04-13 15:27 in BASIC Stamp
Hello everyone,
··················· this is my first forum so i hope i get a few responses.· I have been trying to desing an RKE ( Remote Keyless Entry) system.··So far I have successfully encoded, transmitted·, receieved, and decoded my signal.··I wanted to take the outputs of my decoder ( roughly 20mA ) and feed it into the BS2's input pins.··Next have the BS2·start the correct device based on the switch inputs.· I was hoping to·drive a motor and lamp.· I know the stamp doesnt provide enough current to drive these devices.··I know I·will probably need something like a relay but I am·still a·little uncertain because·I am not familiar in this area.· I would appreciate any help or suggestions I can get.· Thanksss.

p.s Would the BS2 be damaged if I provided 20mA current on 4 input pins simultaneously?

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-04-12 21:57
    Ok first off if the BS pin is set to input, it will not consume 20mA, if you instead mean that they are outputs then yes I would not drive 4 simultaneously. You need to either use a bipolar or mosfet transistor to drive heavy loads, be sure you connect them properly because you can still burn out your stamp (especially with bipolar, there is another post in this forum where the user fried his stamp by just connecting the transistor without a resistor to limit the base current). For the neophyte I strongly suggest using a mosfet, since the gate is a high impedance terminal (high impedance=low current to drive), you will not fry your stamp unless your making a really bone-headed mistake (just remember to add a high value resistor between the gate and drain ~10K). Even if your goal is to drive a relay, you still must use a means to drive it because it too will take too much current to activate than the stamp can handle.

    Post Edited (Paul Baker) : 4/12/2005 10:00:59 PM GMT
  • EliTeEliTe Posts: 6
    edited 2005-04-13 00:15
    Thanks for the response. I'll clairfy about the input and output pins to the stamp. What i was thinking was to have four inputs into the stamp ( from the decoder). Then I would write a program to watch each of the four inputs. Based on the inputs the stamp would provide a voltage to the corresponding output pin. Each of the ouput pin would be connected to a device e.g a motor, lamp etc. I read the forum for the user who burned his chip so I want to make sure I do not repeat the mistake. From what I understood I should connect a 1k resistor to each stamp output pin and have this go into the base of the 2N222 transistor. Should the collector be connected to the voltage supply for the motor and emitter to the ground? Thanks again.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-13 02:56
    EliTe said...(trimmed)
    sure I do not repeat the mistake. From what I understood I should connect a 1k resistor to each stamp output pin and have this go into the base of the 2N222 transistor. Should the collector be connected to the voltage supply for the motor and emitter to the ground? Thanks again.
    Hello,

    ·· The 1K resistor to the 2N2222 applied for the type of load in the message.· Let me clarify...If you are trying to drive a 5V-24V Relay, 5V-30V Lamp,·Super Bright LED/LCD Backlight, Speaker·or Small motor, small signal transistors such as the 2N2222 and 2N3904 are a cheap way to drive them.· And you should always use a resistor between the base of the transistor and the Stamp pin.· I always recommend 1K because it provides more protection in a fault situation than a 220 ohm resistor does when switching more than 5V.· The emitter of these NPN transistors go to ground, and the collector goes between the load device and it's positive voltage.· Your application may require a protective diode (Such as driving relays).

    ·· Now, if you need to drive a high-current device, you would need either a MOSFET, Power Transistor or Current Driver chip, such as the ULN2xxx series.· Some of these are safer choices to use when in doubt.· I don't want anyone to see all these posts and think 2Nxxxx transistors are the solution to all problems.· Jon Williams will often recommend the ULN chips, and others will recommend the FETs given a particular application.

    ·· When in doubt post your intended devices here and people will recommend the various drivers for handling the given load.· There's no one solution that covers everything, although there are several that come close.· Take care!


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • EliTeEliTe Posts: 6
    edited 2005-04-13 13:38
    Hey Chris,
    Thanks for the advice. I looked at the Nuts and Vol Column #6 where they discussed using the ULN2003 ( as you suggested). Seems like it's what I need. So just to make sure, I should insert the output of my BS2 into ULN2003 and have a motor ( most likely a stepper motor but any will do at the moment ) connected to ULN2003's output. Should I still use resistors on the input and output BS2 pins just to be safe? Also a quick question about the motor connection. Will I connect the output of the ULN2003 as the motors ground and ULN2003 power supply ( pin 9 ) as the motor's power supply? Thanks again for the advice. Really appreciate it.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-13 15:27
    Hello,

    ·· You don't need resistors between the Stamp I/O pins and the ULN2003.· Also, the ULN2003 connects outputs to ground, so you will still need to supply the positive voltage to the device.· So, to answer your second question, yes.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.