Constructing a simple emergency light kit

This is my first adventure in the electronics world and, as I'm a CS student, you can expect a lot of associations that maybe aren't that right.

The main feature of my circuit is:

If there isn't energy coming from the transformer (220v to 9v), turn on the leds (using a 6v battery), else, let the leds off.

Recently I met transistors and it seems to me that a pnp transistor would do the job. You can see a diagram that I'm going to use to explain what I thought (to make it simple, I'm not showing the transformer and the rectifier bridge):

So, if there isn't energy coming from the transformer part and, as I'm (trying to, actually) reducing the voltage from the battery in the base of the TIP127. The voltage in the base will be lower than the emitter, which will turn the leds on.

Doubt

• Unfortunately, I discovered that the idea of using a resistor to reduce the voltage from the battery won't work. Do you have any suggestion to put me in the right direction?

This is my first circuit. I'm pretty sure that it have a lot of design problems. Any kind of suggestion or critic will be appreciated!

For your first circuit, you did pretty good. However, as it is, the left side of the circuit is not electrically connected to the right side of the circuit (using the transistor base as the dividing line). They need to share a ground connection, or they will not interact appropriately. The negative terminal of the battery should be connected to the common return of the transformer circuit (the 9V side).

Secondly, you are using a PNP BJT. This type of transistor is current controlled, meaning you typically need a resistor connecting the voltage source to the transistor base to control the current - a 1k resistor is appropriate here. Also, you are right in thinking that a LO voltage would saturate the PNP transistor to turn it on; however, you have it "pulled high" with the resistor R2. So if the main power goes out, the base will be pulled HI by R2 because I'm not sure as though the main power going off will do anything to the transistor. Lack of power does not usually equal zero volts; more commonly it equals high impedance. You should use R2 to pull the transistor base LO to the negative battery terminal - a 10k or even 100k resistor is more appropriate here. That way, when the main power is ON, the base will see the 9V (through a 1k resistor) and be OFF. When the power goes out, the "weak pull down resistor" R2 will pull the base LO, turning the transistor ON. More commonly, you would do as you did - use R2 to pull the base up to ensure it is turned off. To turn it on, you would connect it directly to 0V, but you aren't doing that.

Lastly, I know you purposely didn't show it, but if you are using a transformer and a bridge rectifier, this will convert the AC voltage to a pulse, not a DC voltage. It will also need a capacitor to smooth the pulse out. Otherwise, the voltage will still be returning to 0 with every cycle of the AC line, hence, the circuit would pulse on and off repeatedly (50 or 60Hz, depending on your main power frequency) - seen as the LED on, but dimmed. This is explained well in the other answer.

Be careful with that high of a power source - it can really do some damage to you! Otherwise, the best way for you to learn how these things work is to play around with the circuit. If something doesn't work quite right, turn off the power, move a resistor somewhere else or replace it with a different value, and turn it back on to see if it does what you want it to do. Have fun with it!

• Kurt, you're absolutely right! I just made the changes that you suggested (connected the battery to the common return, R2 [10k] to the transformer end point and removed the link between the battery and the transistor) and it's working as expected. I would really like to thank you for your awesome answer! We need more experts like you. Commented Apr 8, 2013 at 1:31
• Congrats. I'm glad it's working for you. Learning more about hardware could really help you in your software designs if you are ever programming anything connected to a physical device such as microcontroller firmware or a peripheral driver. Commented Apr 8, 2013 at 9:01

Looks pretty good, but keep in mind the transformer is an AC signal, and will oscillate between +9V and -9V. Therefore, it could be "on" but still result in base current during the low parts.

The way stuff like this is often done is to take the absolute value of the output of the 9V transformer, using a circuit configuration known as a full wave rectifier, and then you would use a resistor and a capacitor configured as a low pass filter to smooth out the remaining waveform to near its rms value.

This picture from http://en.wikipedia.org/wiki/Rectifier shows the config and the result

• Thanks Scott! You have a very good point, I'm definitely going to implement the capacitor! Commented Apr 8, 2013 at 1:36