Single transistor logic inverter

flatspike — jurgen.strydom on December 2, 2006 at 1:10 am

I recently designed myself into a corner and the only way out was to invert the logic output of the pin. I could not code the micro controller to simply output the correct value, because the pin was being used for two purposes. Making it favourable for the one would make it unfavourable for the other. The only solution I could come up with, with the least amount of trouble for me, was to get something to invert the logic of that particular pin. I had to somehow get it to output 5 volt when there is 0, and 0 volt when there is 5.

I thought about using a logic inverter chip (like the 74hc04), but they are huge and since I only needed one inverter I would waste allot of potential and space. After scanning some books I found a nice and easy way to build my own logic inverter with a single transistor. I really like this approach for use in my hobby projects where I have to etch my own circuits and drill my own holes, (Its not that I’m lazy :) ).

The basic idea is that the transistor acts as a switch in this circuit. By making the input low you turn off the switch and no current (ok VERY little current) flows, there is no voltage drop over the resistor and the output is high. When you turn the switch on by making the input high, you allow current to flow through the resistor and a voltage drop occurs, the output is now connected to ground and returns a low.

My design

I chose the final values of R1 as 10k Ohm, R2 as 5k Ohm, and for T1 I used the CBC549B transistor. (For those that wonder what the k in 10k is, it resembles a multiplication by 1000, so 5k would equal 5000).

I experimented allot with different values for the resistors R1 and R2 and this setup seems to work the best. At first I did not connect the single transistor inverter to any circuitry except ground and 5 volt to test the idea, and everything worked great. Upon connecting it to a PIC16F628 to test this design I discovered that the voltage at the out part was not even close to 5 volt, it hang around 1.91 volt. After some struggle I found that any pin of the PIC can potentially sink or supply about 25mA, I should have consulted the data sheet earlier I admit. This does not sound much but if you look at it, a 5 volt drop over a 10kOhm resistor would only allow 0.5 mA to flow, so even the slightest current flow to the pin would create quite a drop in voltage. I experimented with a allot of different values for R2, between 10kOhm and 100 Ohm, the lower the resistance the less of a problem the current stealing pin becomes when the transistor is turned off, but the higher the current pulled when turned on. So instead of messing around, this time I consulted the data sheet, and in it I saw a formula (hooray!). Logic one when input higher than (0.25*Vdd) + 0.8 volt, and for my circuit with a Vdd of 5.2 V this gave 2.1 Volt. So I made R2 a 5kOhm and here we are! I measured and the voltage is about 2.18 Volt. The current consumption is relatively low for this setup at about 1.5 mA when the transistor is turned on.

Circuit diagram

  • R1 - 10k Ohm
  • R2 - 5k Ohm
  • T1 - NPN transistor

Benefits

The main benefit is that you use less space than you would if you were using a chip. Because the logic inverter consists of 3 components you can place them scattered around your circuit board and use them to fill open spaces. Its easier to route a single sided circuit with 2 resistors that can jump over tracks than with a chip (you have more options).

Summary:

  • Easy to implement
  • Uses less space than the chip.
  • Less holes need to be drilled. (7 vs 14)
  • Components can be placed all around the circuit.
  • Resistors can jump over tracks. (useful on single sided circuit board layouts)

Drawbacks

If you need more than one logic inverter it would be best to use the chip. You would need to drill the same amount of holes for 2 transistor inverters as for one logic chip with 6 inverters. The chip is specially designed to be robust, predictable, stable and reliable. The amount of current consumed by the single transistor logic inverter is largely dependant on the values of R1, R2 and the amplification factor of the transistor. These are not attributes known for their accuracy.

Summary:

  • If you need more than one inverter it would be better to use the chip.
  • Amount of current consumed not the same for all situations / designs.

Final word

This solution worked for my setup, I cant guarantee it will work for yours. If you have anything to add or say please post me a comment! I messed around with different Resistor values to test for something that would work, I could have calculated it with the transistor equations but the unpredictable behaviour of the pin connected to the circuit convinced me otherwise. Last but not least I hope you find this solution useful. :)


Add to:
del.icio.us:Single transistor logic inverter  digg:Single transistor logic inverter  reddit:Single transistor logic inverter

Related:

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Flat Spike