transistors bjt

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
Build something simple, useful, and practical.

Knowing and understanding how transistor circuits work is useful.

Now move on to working with common ICs, such as LMC555 timer, op amps such as LM324, voltage regulators such as LM7805.
i started with the 555 right now, then i will switch to others when i fully understand this
 

crutschow

Joined Mar 14, 2008
38,506
ok i give an example:
1) Lets say i wanna build a XNOR gate with transistors, how can i do that with knowing only how ''transistors works'' and basic configurations? like even if i know that i gotta copy a configuration that already exists and understand it no? but maybe someone more experienced knows how to build it from scratch, with knowing only what a XNOR gate needs to do

or its normal that u copy such circuits? and dont build anything really from scratch?
Okay, it happens that about the only digital circuit I've built from scratch with transistors for low power applications is an XOR, (such as lighting a tail-light).
Unfortunately the computer I run LTspice on, which has the schematics for that, is down.

But basically, you look at the transistor switching (digital) operation where it is off with no base-emitter signal, and saturated on when it has a signal (note that it's the base-emitter signal/voltage and polarity that's determines this, not just the base signal) and then, for an XNOR, try to configure a circuit that gives no output when either transistor is on, but an output when neither or both are on.
I came up with several configurations to do that for the XOR, some involving the use of additional diodes.
Note that an XNOR is just an XOR with an inverter on its output

You can use both NPN and PNP transistors, which may (or may not) help.
If you connect a PNP's emitter to a positive supply, then its output is the supply voltage (to its load) when you pull the base towards ground with a resistor, and off when the base voltage equals the supply voltage.

It's rather like solving a puzzle with more than one solution, and usually takes some time and dead-end circuits, before you get one that works.
It's a good exercise circuit to start with.

Have fun. :)
 
Last edited:
ok i give an example:
1) Lets say i wanna build a XNOR gate with transistors, how can i do that with knowing only how ''transistors works'' and basic configurations? like even if i know that i gotta copy a configuration that already exists and understand it no? but maybe someone more experienced knows how to build it from scratch, with knowing only what a XNOR gate needs to do

or its normal that u copy such circuits? and dont build anything really from scratch?
Here's an example building a XNOR gate with BJTs. My background in computer science so my method is a bit different than what you might typically see around here. I'll use the short version of the "sum of products" (SOP) algorithm to realise the circuit.

Original expression of XNOR:
Y = (A x B) + (A' x B')

This reads as Y is equal to 1 if (and only if):
(A AND B = 1) OR (NOT A AND NOT B = 1)

These are the logical conditions for the circuit to produce the XNOR truth table. Since we are only working with AND, OR and NOT gates, we need to find a way to express each sub-expression (inside brackets) using these gates. Luckily this example is already simplified and all we need to do is construct the expression one step at a time:

1) (A x B) - 1 AND gate
2) (A' x B') - 1 AND gate, 2 NOT gates
3) (A x B) + (A' x B') - 1 OR gate

Here's what we get. I labelled the boolean transformations as they are at the output of each gate.

xnor.png
Now that we have the boolean logic, we can replace the logic gates with real BJT circuits. I'll leave this an exercise for you. Use this as a reference to build your gates. Falstad circuit simulator works well for this example.

gates.png

https://www.falstad.com/circuit/

Paste this code into the "Import from text" option in the File menu to prove to yourself the expression is correct.

Code:
$ 1 0.000005 10.20027730826997 50 5 50 5e-11
150 240 192 336 192 0 2 0 5
150 240 304 336 304 0 2 5 5
152 368 256 480 256 0 2 5 5
L 96 176 64 176 0 0 false 5 0
L 96 208 64 208 0 0 false 5 0
M 480 256 608 256 0 2.5
I 144 288 208 288 0 0.5 5
I 144 320 208 320 0 0.5 5
w 96 176 144 176 0
w 144 288 144 176 0
w 240 176 144 176 0
w 208 288 240 288 0
w 96 208 96 320 0
w 96 320 144 320 0
w 208 320 240 320 0
w 96 208 240 208 0
w 368 240 368 192 0
w 368 192 336 192 0
w 368 272 368 304 0
w 368 304 336 304 0
x 18 216 34 219 4 24 B
x 18 180 34 183 4 24 A
x 215 271 235 274 4 24 A'
x 217 355 237 358 4 24 B'
x 334 170 391 173 4 24 A\sx\sB
x 331 351 397 354 4 24 A'\sx\sB'
x 438 304 621 307 4 24 (A\sx\sB)\s\p\s(A'\sx\sB')
 

crutschow

Joined Mar 14, 2008
38,506
I don't need (or want) advice on how to answer the questions on this forum.
You don't like my approach to doing the answers, don't read them. :rolleyes:
 

AnalogKid

Joined Aug 1, 2013
12,129
I personally find it much easier to learn something when someone gives a complete and practical solution
As opposed to what you posted, which was something guaranteed *not* to work.

In the same amount of time you could have whipped up a schematic like this.
OR - you could have taken even less time to post schematics that were correct.
ak
 

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
This is why I tried to get you to provide a worked example. I personally find it much easier to learn something when someone gives a complete and practical solution compared to reading about it in bits and pieces. It's especially relevant for an expert in mixed signals like yourself. If you leave it to ol' Art, it's going to be half baked and riddled with errors. Besides, aren't you retired with nothing better to do? Doing trivial exercises like this to completion will help keep your mind sharp. :)





That's why I said to use the image as a reference! You guys are killing me with some of these comments gwhahaha. In the same amount of time you could have whipped up a schematic like this. Well, this actually took me 3 minutes. Just image what you could do with 3 minutes or hell, 5 minutes!

View attachment 350070
Ye i got what u meant, like the overall schematic , u wanted to represent the logic gates modelling transistors as switch, clearly to make the circuit work u gotta modify it by adding the resistors like u did afterwards, dont worry, i got what u meant :D
 

LvW

Joined Jun 13, 2013
2,027
Ye i got what u meant, like the overall schematic , u wanted to represent the logic gates modelling transistors as switch, clearly to make the circuit work u gotta modify it by adding the resistors like u did afterwards, dont worry, i got what u meant :D
Before going into details and designing gates with BJTs, may I ask a question?
Do you know how and why a BJT can work as a switch?
Do you know how saturation is defined and how this state can be realized?
 
You're not my peer or your "bud" and it was not a review but a criticism of my post
If that's bullying, you are certainly easy to bully.

.
I'm definitely your peer and review is synonymous to criticism. Trying to gaslight me on this instead of returning to the topic IS bullying. Some of you regular members really blow my mind with the ego trips. I said my piece, do what you want.

chill guys we just trying to learn together so no worries
Would you like me to finish the XNOR example? And sorry about the drama.
 

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
I'm definitely your peer and review is synonymous to criticism. Trying to gaslight me on this instead of returning to the topic IS bullying. Some of you regular members really blow my mind with the ego trips. I said my piece, do what you want.



Would you like me to finish the XNOR example? And sorry about the drama.
sure thanks, if i understood correctly now what we gotta think about is how to connect a stage to next one? right?
 
sure thanks, if i understood correctly now what we gotta think about is how to connect a stage to next one? right?
Yup, but part of the challenge is making sure each BJT is properly biased. For fun I built the circuit using PNP transistors which is mirror opposite of NPN transistors.

Notice how I had to make the OR gate resistors 100k otherwise these inputs sink too much current and the output can never go high. Try 10k resistors and you'll see it doesn't work.

This problem gets increasingly worse as more logic gates are chained together. Can you figure out why this happens and how MOSFETs are mostly immune to this effect? Also, why didn't I include base resistors on the lower AND gate?

Feel free to ask questions about anything that is unclear.

bjt-pnp-xnor-gate.png

Falstad:
$ 1 0.000005 10.20027730826997 50 5 50 5e-11
150 3504 1936 3600 1936 0 2 0 5
150 3504 2048 3600 2048 0 2 5 5
152 3632 2000 3744 2000 0 2 5 5
L 3360 1920 3328 1920 0 0 false 5 0
L 3360 1952 3328 1952 0 0 false 5 0
M 3744 2000 3872 2000 0 2.5
I 3408 2032 3472 2032 0 0.5 5
I 3408 2064 3472 2064 0 0.5 5
w 3360 1920 3408 1920 0
w 3408 2032 3408 1920 0
w 3504 1920 3408 1920 0
w 3472 2032 3504 2032 0
w 3360 1952 3360 2064 0
w 3360 2064 3408 2064 0
w 3472 2064 3504 2064 0
w 3360 1952 3504 1952 0
w 3632 1984 3632 1936 0
w 3632 1936 3600 1936 0
w 3632 2016 3632 2048 0
w 3632 2048 3600 2048 0
x 3282 1960 3298 1963 4 24 B
x 3282 1924 3298 1927 4 24 A
x 3479 2015 3499 2018 4 24 A'
x 3481 2099 3501 2102 4 24 B'
x 3598 1914 3655 1917 4 24 A\sx\sB
x 3595 2095 3661 2098 4 24 A'\sx\sB'
x 3702 2048 3885 2051 4 24 (A\sx\sB)\s\p\s(A'\sx\sB')
L 3264 2272 3232 2272 0 0 false 5 0
w 3664 2592 3664 2576 0
w 3664 2528 3664 2544 0
w 3664 2640 3696 2640 0
r 3664 2704 3664 2656 0 1000
g 3664 2704 3664 2720 0 0
w 3664 2592 3664 2608 0
R 3664 2528 3664 2496 0 0 40 5 0 0 0.5
w 3664 2656 3664 2640 0
r 3392 2688 3440 2688 0 10000
r 3472 2768 3472 2720 0 1000
g 3472 2768 3472 2784 0 0
w 3472 2704 3504 2704 0
L 3264 2336 3232 2336 0 0 false 5 0
w 3472 2656 3472 2672 0
R 3472 2656 3472 2624 0 0 40 5 0 0 0.5
w 3472 2720 3472 2704 0
w 3584 2560 3552 2560 0
w 3584 2624 3552 2624 0
w 3504 2704 3552 2704 0
w 3552 2272 3296 2272 0
w 3392 2688 3264 2688 0
w 3808 2384 3744 2384 0
w 3696 2640 3744 2640 0
w 3808 2480 3744 2480 0
w 3744 2544 3744 2480 0
w 3504 2480 3552 2480 0
w 3472 2496 3472 2480 0
R 3472 2432 3472 2400 0 0 40 5 0 0 0.5
w 3472 2432 3472 2448 0
w 3472 2480 3504 2480 0
g 3472 2544 3472 2560 0 0
r 3472 2544 3472 2496 0 1000
r 3392 2464 3440 2464 0 10000
w 3552 2480 3552 2560 0
w 3552 2704 3552 2624 0
w 3392 2464 3296 2464 0
w 3296 2464 3296 2272 0
w 3552 2336 3264 2336 0
w 3264 2272 3296 2272 0
w 3264 2336 3264 2688 0
w 3696 2352 3744 2352 0
w 3584 2336 3552 2336 0
w 3584 2272 3552 2272 0
w 3664 2368 3664 2352 0
R 3664 2240 3664 2208 0 0 40 5 0 0 0.5
w 3664 2304 3664 2320 0
g 3664 2416 3664 2432 0 0
r 3664 2416 3664 2368 0 1000
r 3584 2336 3632 2336 0 10000
w 3664 2352 3696 2352 0
w 3664 2240 3664 2256 0
w 3664 2304 3664 2288 0
r 3584 2272 3632 2272 0 10000
w 3744 2544 3744 2640 0
w 3744 2384 3744 2352 0
t 3440 2464 3472 2464 0 -1 -0.5704734583421978 -0.6405266451515876 100 default
t 3440 2688 3472 2688 0 -1 -0.5704734583395101 -0.6405266451686886 100 default
t 3632 2560 3664 2560 0 -1 1.0752955162358235 -0.07005318680938988 100 default
t 3632 2624 3664 2624 0 -1 4.908241893701599 1.075295516216035 100 default
t 3632 2272 3664 2272 0 -1 -0.5702231747909634 -0.6420694509370017 100 default
t 3632 2336 3664 2336 0 -1 -0.570039908265386 -0.6401395462960311 100 default
w 3584 2560 3632 2560 0
w 3584 2624 3632 2624 0
M 3952 2352 3984 2352 0 2.5
t 3856 2480 3888 2480 0 -1 2.192195982272632 -0.6156078077066556 100 default
t 3856 2384 3888 2384 0 -1 4.8580535878677065 2.050249797888419 100 default
w 3920 2352 3920 2464 0
w 3888 2464 3920 2464 0
g 3888 2496 3888 2512 0 0
R 3920 2288 3920 2256 0 0 40 5 0 0 0.5
w 3920 2352 3952 2352 0
w 3920 2336 3920 2352 0
w 3888 2352 3920 2352 0
w 3888 2352 3888 2368 0
g 3888 2400 3888 2416 0 0
r 3920 2336 3920 2288 0 1000
r 3808 2480 3856 2480 0 100000
r 3808 2384 3856 2384 0 100000
 

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
Before going into details and designing gates with BJTs, may I ask a question?
Do you know how and why a BJT can work as a switch?
Do you know how saturation is defined and how this state can be realized?
It can function as switch cus it controls the current beetwen collector and emitter, to act as switch u gotta operate beetwen the 2 regions: cutoff and saturation ( active doesnt interest us cus we dont need an amplification ).

Lets start with the cutoff:
to obtain the transistor working in cutoff u gotta have a vbe below 0.7 ( no base current means no collector current, so there is now current flowing and the transistors acts like an open switch, to understand that u could also check the curve of the transistor itself ( by looking at the values u understand whats needed to obtain that condition )

to obtain the transistor working in saturation region u gotta have a vbe above 0.7 ( maximum current flows beetwen collector and emitter
 

LvW

Joined Jun 13, 2013
2,027
to obtain the transistor working in saturation region u gotta have a vbe above 0.7 ( maximum current flows beetwen collector and emitter
I think, it is not a bad idea to know how a BJT works (in the amplification region and in saturation) before studying circuits.

Here is the correct definition for saturation:
When the B-C junction starts to be forward biased the BJT enters the saturation region.
That means: The current Ic (and withit the voltage drop Ic*Rc) must be large enough to forward bias the B-C junction.
In this case, we have Vc<Vb and Vce<Vbe.
As a result, the base current now consists of two components (two junctions forward biased): Ibe and Ibc.
As a result, the current into the base will be much larger than anticipated by the factor B (which considers Ibe only).
Rule of thumb: Design base biasing so that Ib will be app. (5....10)% of Ic.

Note that this drastically increased base current Ib is the RESULT (a good indication) of saturation and NOT its CAUSE (as stated in some publications).
A current is always the result of a voltage - not vice versa.

(By the way - reading what you wrote ( "to obtain the transistor working in cutoff u gotta have a vbe below 0.7" ) I`ve got the impression that you think the value of 0.7V would be a kind of "threshold". This is not the case: The BJTs collector current is an exponential function of Vbe - and the voltage of Vbe=0.7V is something like an approximate value for some milliamps.)
 
Last edited:
Top