What I thought was going to be an easy project is proving to be more of a learning experience than I anticipated.
Intended operation:
- PIC microcontroller feeds a +5 V signal to a transistor.
- The transistor allows current through, putting ~ +5.5V across the relay coil.
- The relay opens.
Actual operation:
- The circuit continually draws current (approx 25 mA) from +9 V battery even without a +5.0 V signal from microcontroller.
- Only a few volts are put across the relay coils when the transistor receives the +5.0 V signal. Most of the voltage (approx +7 V) is across the transistor!
The relay trips perfectly fine when I short out the collector and emitter leads of the transistor.
The transistor works perfectly fine when a +5 V source, LED, and resistor are connected to the collector lead instead of the relay.
The 5 volt relay has 56 ohms. 90mA
The transistor needs to switch 90mA C to E.
The base has a 10k resistor. 5V-0.7V=5.3V 5.3V/10k=0.5mA
Ib=0.5mA Ic=90mA so the current gain is 180mA which is too high.
Try changing the 10k base resistor to 3.3k or 2.2k. This will turn on the transistor better.
^ Yes, the 2N2222 is starved for base current, that's why it isn't turning on.
But the question about the "off" current is a little puzzling - what's the voltage read on that port pin when you are sending it a zero? Is there any difference between the way the emitter is grounded and Vss? You aren't messing with a TRIS register and making it an input, are you?