Shop OBEX P1 Docs P2 Docs Learn Events
STAMP 1 Correct bias resistors for transistor switch — Parallax Forums

STAMP 1 Correct bias resistors for transistor switch

KatyBriKatyBri Posts: 171
edited 2012-11-02 16:01 in BASIC Stamp
Hello,

I need to drive a relay using a transistor switch hooked to an output pin of a STAMP BS1. Seams like a simple thing. But, when looking around the Internet at the resistors used, there is a huge variety shown. I'm not sure which is correct. So I found some calculations to determine the resistor between the STAMP's output pin and the transistors base which turns on the transistor when a high logic level is present (R1); as well as a base-to-emitter resistor which is supposed to guarantee the transistor will shut off with a low logic level (R2). Many examples I found do not even use the base-to-emitter resistor.

I am using a 2N2222A NPN transistor in a grounded emitter configuration. The relay is in between the collector and 5 vdc supply. The relay has a protective diode.

I'm not sure I have the Minimum Base Current correct either since the STAMP pin can only source 20ma max. I don't know what to use for it.

So, here are the calculations I did. If someone, who really knows how to do these calculations, would let me know if they are correct I would appreciate it.

Supply voltage = 5vdc

Load: 40ma for relay = 40 ma (0.04 A)

Minimum HFE of 2N2222A NPN transistor = 50

Minimum Base Current = load/min HFE= 40 ma / 50 = 0.8 ma (0.0008 A)

Maximum Current Required = 40 ma (for relay)
Supply Voltage = 5 vdc

R1= Supply Voltage / (Maximum Current Required / Minimum HFE * 1.3)
R1= 5vdc / (.04A / 50 HFE * 1.3) = 4807.692 ohms


The STAMP1 project board has 200 ohm resistors on it so subtract this value from R1
R1= 4807.692 ohms - 200 ohms = 4607.692 ohms closest available resistor = 4.7 Kohm
note: the .3 in 1.3 adds 30% more current to make sure the transistor stays saturated and on.

R2 = R1 * 10 = 46077 ohm closest available resistor = 47Kohm

Thanks

Comments

  • ercoerco Posts: 20,257
    edited 2012-11-02 13:37
    Glad to have another relay user on board!

    47K is way too high, I doubt if the relay will trigger much over 1K . I usually use 330 ohms to drive a relay transistor like that. You want to saturate the transistor to switch fully on.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-02 13:50
    Read Nuts and Volts Column #6 (here in Volume #1). It's written originally for the BS1, but would work just as well with the BS2.
  • KatyBriKatyBri Posts: 171
    edited 2012-11-02 16:01
    Thanks Mike.
Sign In or Register to comment.