??? 07/22/04 00:06 Read: times Msg Score: +1 +1 Informative |
#74649 - RE: Relay interface problem Responding to: ???'s previous message |
This is a common design problem. My usual solution is to use inverters (such as 74hc04) and a ULN2003. Note than on port0 you will still need the pullup resistor of around 100k. How do come to this resistor value? It comes down to how much current the input of the load device is - in this case it is a 74hc04 which needs very little current and because we expect the frequency to be low (as we're driving relays) we don't have to worry too much about capacitance. In the case of your transistor, the resistor has to allow enough current to flow to turn on the transistor. Your BC547 has a current gain of around 300 (see transistor spec 'hfe'). So ,for example, your relay consumes 300mA, you will need to supply 1mA into the base of the transistor, so at 5V your base resistor would calculate out to be R = V/I = (5- 0.7)/0.001 = 4300 Ohms. The 0.7v is for the base-emitter voltage drop of the transistor. Your example has a 1k and 22k resistor so the current into your transistor base I= V/R = (5-0.7) / 23000 = 187uA. Multiply this by the gain of the transistor and you get a collector load of about 56mA. I've simplified this explanation, I suggest you do some reading on transistor circuits to get the full picture. |