Simple Discrete Op-Amp - Page 1
Forum section: electronics / beginners

author: mawyatt
author_rank: Super Contributor
timestamp: June 22, 2024, 02:29:32 am
content: Here's a simple 5 transistor, 2 resistor Op-Amp that some folks might find useful to learn about the inner workings of transistor Op-Amps.Sure this isn't a good Op-Amp, has bad offset, high bias current, low Open-Loop Gain, poor bandwidth, poor output stage, and so on. Almost any 10 cent one is better but it's discrete & simple as a good learning tool for those interested in playing around with the way Op-Amps work from the inside rather than "Black Boxes"!!Most any transistors will work, we selected 2N3904, 2N3906s and a couple 1K resistors and +-5V supplies is all that's needed for the core Op-Amp. Feedback is with a pair of 10K resistors for a non-inverting gain of 2 (6dBV).Some simulations with the default LTspice models are included, as well as actual circuit responses showing a 2X Gain as mentioned and Open-Loop utilizing an Isolation Transformer.Note in the LTspice schematic that VOL is a test voltage source for the Open Loop Gain measurement, and this is where the Isolation Transformer secondary is connected for actual measurements.Anyway hope some folks have fun with thisEdit: Added Pulse responses.Best,

author: Andy Chee
author_rank: Super Contributor
timestamp: June 22, 2024, 03:12:53 am
content: Don't forget the giant 741 opamp:https://shop.evilmadscientist.com/productsmenu/762https://cdn.evilmadscientist.com/catalog/emskits/741/kitv2/imglrg/1@2x.jpg

author: Kleinstein
author_rank: Super Contributor
timestamp: June 22, 2024, 07:10:43 am
content: The amplifier version is really basic. The output range is limited by the input common mode voltage: the output can't go much (some 1 V) below the input voltage.So one should really add one more amplifier stage.To simplify things the current mirror could be dropt and a constant current source used for the LTP to keep at least reasonable CM rejecton.Another point missing is compensation.

author: mawyatt
author_rank: Super Contributor
timestamp: June 22, 2024, 12:50:50 pm
content: Quote from: Kleinstein on June 22, 2024, 07:10:43 amAs we stated, the entire point of this is to allow a beginner to develop and improve theSimplecircuit while gaining anUnderstandingof basic internal Op-Amp behavior, not a full blown Op-Amp implementation with discrete components like mentioned by Andy above for the classic 741 (check out the complexity of that with 20 transistors, 11 resistors, 2 diodes)Best,

author: RoGeorge
author_rank: Super Contributor
timestamp: June 22, 2024, 02:24:25 pm
content: I think such simple circuits are an absolute joy to play with.This Op-Amp is so simple it has only 3 internal nodes.When I was a kid, it was always a nightmare to find all the required values for R and C. This opamp has 2 of 1k resistors. Anybody with a kit of R and BJT will have all the components, and it takes only minutes to fit all in a breadboard. Guaranteed it will work.Then, once the circuit was built, a curious beginner might want to experiment and learn more. For example, why does Q6 has the base-collector short circuited?And such, find out that's a current-mirror, and if even more curious, learn about Gilbert's translinear principle, and so on. Or, why there is an R2? Or why there is a VOL? And there's a lot more to discover there. Many other question will pop, once one takes the bait and build the circuit.I still remember how a "10 minutes" build of a "Simple Sinusoidal Oscillator"https://www.eevblog.com/forum/projects/simple-sinusoidal-oscillators/led to a month of all kind of experiments and learning, apart from the oscillator itself: an LTspice trick to fast start an oscillator, some insights about injection locking, core saturation, etc. At some point even stepped into Linux programming and AM modulators. Fun journey for a "simple" oscillator, thank you!What might not be clear for a beginner:- the opamp itself (same circuit without R1, R2, R6, VOL)- the mention of an injection transformer called Isolation Transformer (an online search will probably return mains-isolation transformers)- since there are instruments printscreens attached (indicates the circuit was built in practice), I would have also attached a picture with the built circuit, and the .asc LTspice file, too

author: Zero999
author_rank: Super Contributor
timestamp: June 22, 2024, 03:02:34 pm
content: Quote from: mawyatt on June 22, 2024, 12:50:50 pmHave you actually built it though?I've made a discrete op-amp before on a breadboard. It was a little more complicated than this one and worked quite well.The circuit drawn from memory, so I'm not sure what the exact values were, especially Cc, which I think I tweaked, until it was stable.

author: mawyatt
author_rank: Super Contributor
timestamp: June 22, 2024, 03:08:40 pm
content: @ RoGeorgeHere's the image and LTspice .asc file of a cleaned up version. Yes the transformer is an "Injection Transfomer" which Isolates but can be confused with the more common Mains Isolation type. We can include details of the setup if folks wish.The pair of Yellow Caps are just 0.1uF decoupling for the +-5V VDC inputs from long leads to PS.Edit: Note the upper left corner of the circuit image, yes it's a back of the envelope schematic sketchAnyway, thanks for pointing out these short comingsBest

author: mawyatt
author_rank: Super Contributor
timestamp: June 22, 2024, 03:10:30 pm
content: Quote from: Zero999 on June 22, 2024, 03:02:34 pmSure, where do you think the scope traces images came fromAlso, see above just added.BTW your circuit is a good example of extending the Simple Basic Op-Amp structure with better performance, and what we hope beginning folks will discover and appreciate rather than treating an Op-amp as a 5-pin chip!!Edit: Added a couple plots with the emitter bias (R3) changed to 10K which reduced input referred offset to under 3mv.Best,

author: mawyatt
author_rank: Super Contributor
timestamp: June 23, 2024, 07:13:33 pm
content: For those interested here we have added 2 transistors to improve overall Op-Amp performance. The NPN emitter follower output is changed to a PNP and the output now is a Class B with some "Crossover Distortion" and can swing almost rail to rail. With the added PNP gain stage, then frequency compensation is achieved with a shunt capacitor across the PNP base and collector as shown.Here's some results using a 2N3906 for Q4 and Q7 as B772 PNP TO-126 and Q2 as RD-9FE NPN TO-126 for the Class B Output stage we had laying around, compensation capacitor was 100pF.Power supplies are +-5V, note the output swing 8VPP @ 10KHz with 100 ohm load (#21). You can see the Crossover Distortion on the Output (Yellow Trace) and the Bases drive (Magenta Trace) (#22).The other plot (#23) shows the load at 10 ohms, yes just 10 ohms, and producing 6VPP!! The Input Referred DC offset is ~3.5mv.Anyway, hope some folks find this simple Op-Amp worthwhile to experiment with and add additional "features"Best,

author: RoGeorge
author_rank: Super Contributor
timestamp: June 23, 2024, 07:58:04 pm
content: In the 7 transistors schematic, the BE junction of Q5 will always keep the collector of Q1 at Vcc-0.6V, also the collector of Q3 is always at Vcc-0.6V at all times, because of the Q6 connected as a diode. How come that it is working at all?Is there a typo in the schematic, or am I missing something?

author: magic
author_rank: Super Contributor
timestamp: June 23, 2024, 08:42:58 pm
content: It's Q4, not Q5, and why wouldn't it work?Input resistance of Q4 base is β/gm which works out to ~1kΩ here. Quite a lot more than zero, so the exact value of "0.6 volts" varies with input stage current and the input stage can control Q4 just fine. That being said, 1kΩ is a heavy load compared to output impedance of the input stage and reduces its gain a lot. Most real world applications add an emitter follower in front of Q4 to increase input impedance of the 2nd stage and get more gain at Q1 collector. The EF also prevents the poorly controlled and signal-dependent Cbc of Q4 from appearing in parallel with C1.

author: RoGeorge
author_rank: Super Contributor
timestamp: June 23, 2024, 09:43:56 pm
content: Quote from: magic on June 23, 2024, 08:42:58 pmIndeed, I was thinking about Q4, not Q5, sorry.I've thought of rBEonly after asking, but still, doesn't feel right. Q5 is always at approx 0V BC, don't know how much of a current mirror it can make with the Q4's rBEin parallel with Q5's CE.gmvaries with Ic, and Ic in this differential pair is dictated by the common mode voltage and R3. Without a good current-mirror (considering the diff pair is working mostly because of rBEof the current-mirror transistors), and with one rBEon the left and approx. two rBEin parallel on the right side of the pair (all 3 varying with the common mode input), it should give big offset, and only 50% common mode rejection.It's almost 1 AM here, and anyway my intuition about analog circuits in general, and about BJTs in particular, was never good enough. Q5 CE parallel with another BE looks wrong to me, will simulate tomorrow to get a better understanding.

author: mawyatt
author_rank: Super Contributor
timestamp: June 23, 2024, 10:24:05 pm
content: Spend some time analyzing it carefully, then grab some transistors and play around, you'll discover it works as shown.Sure, not the best Op-Amp implementation, but with only 7 transistors, 2 resistors and 1 capacitor, and works with just about any transistors, pretty simpleSee if you can improve on the performance, and keep things simple!!BTW R5 at 1K is to allow a low enough base bias resistance to allow Q7 to pull the load current to VEE, and this handles 10 ohms load fine (with the mentioned TO-126 transistors). You can increase R5 for more Open-Loop gain but less base drive for Q7.Anyway, creating some "hands on" interest in how Op-Amps work from the inside out is the intent, not creating a high performing complex version.Best,

author: coppercone2
author_rank: Super Contributor
timestamp: June 23, 2024, 10:31:45 pm
content: nutube op amp hybrid card

author: mawyatt
author_rank: Super Contributor
timestamp: June 23, 2024, 11:07:32 pm
content: Yep, so many interesting analog circuits one can be created with just a few transistors. Great learning experience for folks.Another is the Peltz Sine-wave Oscillator we posted about some time ago. Uses 2 transistors, 1 resistor, an inductor, capacitor, and even operates down to ~0.7 supply volts!!https://www.eevblog.com/forum/projects/simple-sinusoidal-oscillators/Best,

author: MathWizard
author_rank: Super Contributor
timestamp: June 24, 2024, 01:53:12 am
content: Yeah thank MW it's a cool circuit, the original 1. In LTSpice I made a version with BC547B/557B, and I found that with 8.2k and 8.2k for the inverting bias resistors, that now the magic zone, as a diff. amp, with Vinv=GND, the VNonInv range is now from -10mV to +10mV, and then the right hand side BJT's flip from the lower 1 being saturated, to the top 1 being saturated.I can calculate some of the DC currents and voltages, but only when I break up the circuit, or set some values. To do the small signal analysis from -10mV to 10mV for VNonInv, I want better #'s from DC values.I'm not using the full Eber's-Moll eqn's, do you have to use them ? I'd don't like just using 0.7V as a starting guess, but I know I should. But I've NEVER seen anyone go through iterations of a bunch of Vbe's and see if it matches right in a bunch of matrix equations.Presented with Maywatts 1st OP-Amp circuit, configured as a Diff. Amp, with only the 1k on the output, and Vn=Vp=GND, how would you guys calculate everything ? Where's some good pdf's on this stuff ? I have some on current mirrors and diff. pairs, but I'm sure none of them would explain this, or use anything besides Vbe=0.7V, and so it would not be very accurate vs LTSPice.Before all this I was just digging into op-amp DC non-idealialities, like input bias currents and off set voltages. That's fun too.Just the lower 2 transistors, I'm just trying some iterations for the sum of 2 base currents, and with the node eqn of the emitters with the exponentials in it, in a spreadsheet for, I get IB_left=6.919uA, IB_right=7.908uA. LTS has ~6.7uA and 7.5uA, so I guess thats ok then.

author: RoGeorge
author_rank: Super Contributor
timestamp: June 24, 2024, 04:30:40 pm
content: Quote from: mawyatt on June 23, 2024, 10:24:05 pmChallenge accepted!Yes, I was wrong, spent some time simulating the 7 transistors version in open loop (no feedback at all), and without the final transistors, only to build some intuition about Q4. Once I've got over it, started to improve.First that bothered me was that the tail current of the differential pair is dictated by the common mode voltage. This brings second harmonic distorts for large input signals, and might limit the input range, too. A current source in the tail would fix that, but at the cost of 2 more transistors. Though at small signal it doesn't matter much.Then, I've noticed that, for some reason, the smallest offset voltage after Q4 and the biggest overall gain were happening when R5 was chosen such that the Ic through Q4 matches Itail. That seems to be true no matter the I tail (still no feedback loop, and still without the power stage). Why is that so?Once I've found this empirical rule, to match Itailwith the I through Q4, I've decided to add a current mirror instead of R3, and to copy its current with yet another transistor that will feed Q4 instead of using R5 (so, added Q8, Q9, Q10). Q10 is also a benefit for the overall voltage gain, because the bigger the impedance of the final stage, the more voltage gain, and emitter repeaters have high input impedance. Once added, it all started to work surprisingly well even without any feedback loop.Now it was time to deal with the crossover distortions. First I thought it could be 2 diodes between the bases of the final transistors, but then I've remembered about a funny topology I've asked about a while ago, and been told it's called a diamond buffer. That will be 2 more transistors (instead of 2 diodes), but a diamond buffer will also improve the impedance seen by Q4 (so bigger gain), and will avoid thermal runaways and idle currents specific to AB class.TL;DR, instead of 7 transistors, 2 resistor and 1 capacitor, added 5 more transistors and 1 more resistor, and got very good performance even without a feedback loop.Pros:- very low distortions- very low offset voltage- no crossover distortions- about 100dB DC gain, very good common mode input rejection, etc.- can work at +/-2.5V, maybe lower, with a little tuning of the 3 resistorsCons:- no over-current/short-circuit output protection- doesn't have yet an internal voltage reference, the current source is derived from the power source with just a resistor, that would be something an integrated opamp usually has while this doesn't- not sure if it qualifies as a RRIO opamp, but has wide input and output voltage swing- not sure if 12 transistors isn't too many for a simple opampI wonder if these 12 transistors resembles any existing op-amp. So far only did very little simulation/tuning for corner cases, and only with perfectly matched transistors. Are there any flaws such that in practice this circuit won't be a good choice?

author: mawyatt
author_rank: Super Contributor
timestamp: June 24, 2024, 05:11:15 pm
content: Nice work!! Take a look at your Phase MarginBest,

author: magic
author_rank: Super Contributor
timestamp: June 24, 2024, 07:06:52 pm
content: Quote from: RoGeorge on June 24, 2024, 04:30:40 pmGain: because transconductance of a differential pair falls off a cliff when the pair shifts out of balance.Offset: if all else is equal, Vbe are equal if and only if Ic are equal. So look where the collector currents go.Quote from: RoGeorge on June 24, 2024, 04:30:40 pmRight about gain.But as for bias current, change "BC337-25" to "BC337-25 temp=70" and see what happens...

author: RoGeorge
author_rank: Super Contributor
timestamp: June 24, 2024, 07:19:29 pm
content: Quote from: mawyatt on June 24, 2024, 05:11:15 pmThank you, should have been 1nF compensation for a stable unity gain (determined empirical from the LTspice plot).The plan was to use this opamp at A=10 or more, to finish a project shelved some years ago, a bat-detector.https://www.eevblog.com/forum/projects/want-to-hear-the-bat-flying-in-my-front-yard/Zero999 summoned that project's memory about a month ago.The discrete opamp can be made to work from a single Li-Ion cell (3-4V), and the current-mirror in the diff tail can be used as a multiplier, so to shift down the bat's ultrasounds into something audible. Then the rest of the opamp is good as a headset amplifier.Apart from the opapmp, it has to be an additional 50-100kHz adjustable oscillator. Low pass RC filters should be easy to add inside the opamp, probably before the diamond buffer, but I didn't try. Not sure if I can get without an automatic volume control, and use only the headset's potentiometer for volume control.Quote from: MathWizard on June 24, 2024, 01:53:12 amSearch for "Analogue IC design, the current-mode approach" book, and read "Chapter 2: Current-mode Circuits From A Translinear Viewpoint: A Tutorial".There is also a video lecture from the author, (read the textbook chapter first, the text tutorial goes into more details):Bipolar Translinear Circuits, lecture by Barrie GilbertComputer History Museumhttps://youtu.be/LQNJVtcFrCc

author: RoGeorge
author_rank: Super Contributor
timestamp: June 24, 2024, 07:40:04 pm
content: Quote from: magic on June 24, 2024, 07:06:52 pmThank you, now it finally makes sense. As for the thermal runaway, I was remembering it wrong. Will put the pre-final transistors on the same radiator with the final ones.

author: MathWizard
author_rank: Super Contributor
timestamp: June 25, 2024, 09:17:47 pm
content: I made a breadboard version of the 5BJT version, and it works more or less like the LTSpice version, as a diff. amp it makes a nice since wave between 0-3.6V. But I'm surprised how quick the output starting dropping off past 10kHz, I don't think I had any extra capacitance of any size. I need to make the AC model, see what it looks like.None of my textbooks go into enough detail on this stuff, I guess I need higher level books. I just buy old old textB's, but in good shape.

author: mawyatt
author_rank: Super Contributor
timestamp: June 25, 2024, 10:38:57 pm
content: Power this from+- 5 Voltsand you should see a response well beyond 10KHz with the gain set to 2X as shown in our schematic in post #6.Best,

author: RoGeorge
author_rank: Super Contributor
timestamp: June 26, 2024, 12:34:13 pm
content: Was trying to better match the transistor pairs yesterday, and the differential bamboozled me again.Went overboard, and made a fixture to match BJTs using a differential (such a fixture was on my wish list for a long time). The idea was to inject common mode signal, and to measure the differential output with a DMM. The smaller, the better. For identical BJTs should be zero.At first I've connected the ACin straight to the base of the transistors (Rb=0), only to notice the output was not very sensitive with the BJT differences in Beta.Didn't see that coming. Then I've added a 10k in series with the base of each BJT, and it became sensitive enough. With base resistors, it was easy to spot differences in almost identical transistor, for example Beta 408 vs 410 mismatch was measurable.In simulation it is easy to compare the influence of Rb upon the sensitivity to transistor mismatches. These traces are the output for 1ohm, 1k 5k 10k 100k in series with the base with the transistors almost identical (Beta 400 vs 401).The bigger the Rb, the higher the offset, but not much happens above 5k.In practice, turned out that there is no need for a common mode ACin. The DC out offset is easier to measure, and, at least for my batch of BJTs, the smallest DC offset was always indicating the BJT pairs with the highest CMRR.I suspect that that was not just a coincidence, and measuring beta alone (at a single point) would be enough to match BJTs, as long as they are the same model. Could this be true in general?What annoys me the most is that this fixture is very impractical to use.Lots of alligators and instruments needed for a measurement, and it requires too many insertions in the socket if it were to blindly plug/unplug transistors from a batch. The batch of transistors has to be sorted by beta first, and only the closest in beta to be verified additionally with the differential, or else it will all take too long.Takes a lot of time to find the best pairs, reading the DMM and writing down the values, or else risking to forget which transistor was which.Then, sometimes the measurement drifts with time, not sure yet who's fault that is. For example the DC offset can slowly go few mV, up to tens of mV, back and forth. Probably not just thermal drift. And, when a new transistor is inserted, it heats a little from the hand (the effect is clearly visible in the DC offset). It needs 5-10 seconds or so to reach thermal equilibrium.Do I overthink the matching? Can I get along with just the universal tester (it tells Beta and Vbe in a single point), or do I need a dedicated curve tracer?

author: mawyatt
author_rank: Super Contributor
timestamp: June 26, 2024, 01:30:18 pm
content: Nice setup!!If the individual transistors "were" from the same wafer then some correlation would be expected, however without knowing "where" the devices originated, one might expect to need matching over a couple Ie ranges.The drift is likely temperature/air flow induced and probably should be covered for better results if you want to go to that effort.BTW did you match the resistors and use lower TC types, especially Rb and Rc, the others shouldn't matter?Best,

author: RoGeorge
author_rank: Super Contributor
timestamp: June 26, 2024, 03:19:03 pm
content: The resistors are Chinese metal film from the same lot, binned with a 5 digits DMM. The 10k in the base were +/-1 ohm (10.013, 10.014) and about the same tolerance for the 1k resistors in collector.As a double check, when the transistors are swapped the DC offset changes its sign, probably less than 1-2mV is caused by resistors mismatch, while the best matched BJT pair found so far produces about 9mV of DC offset.The TC of the resistors seems good enough. When touched with the finger (through a plastic bag) the offset stays about the same.The transistors, however, go crazy with the temperature difference. I knew Is changes with temperature, but I never measured how much would that mean in practice. By simply touching the capsule through a ziplock bag, the offset can change by many tens of mV.The pair of BF458 (TO-126) I am measuring now started with 8mV DC offset, slowly raised for about 5 minutes, and reached thermal equilibrium at about 40mV. But if I touch one transistor the DC offset slowly grows from +40mV to 100...150mV. That's more than 300% offset increase!If I touch the other transistor, the DC offset changes with about the same amount towards the other direction, to negative values.Now it makes sense why precision opamps are designed to have a thermal axis of symmetry, and with the critical components carefully arranged with respect to the thermal axis.

author: magic
author_rank: Super Contributor
timestamp: June 26, 2024, 04:21:42 pm
content: Quote from: RoGeorge on June 26, 2024, 12:34:13 pmβ only affects input current, so a mismatch shows up when there are unequal voltage drops across significant base resistors.A difference with shorted bases is mainly due to Vbe mismatch. Suppose it's 18mV, then you get 1:2 instead of 1:1 current split and it easily shows up when the tail current varies due to varying Ree voltage. Typically transistors from one batch are matched to a few mV, though.Vbe and β are independent errors and they may add or cancel out, and the cancellation may stop working if you change source impedance, tail current or temperature. It's a good idea to untangle them and measure each independently.

author: mawyatt
author_rank: Super Contributor
timestamp: June 26, 2024, 07:19:47 pm
content: By touching the transistor you likely changed the temperature >10C. The transistor delta Vbe/T is about -2mv/C, so one would expect a significant change as you've discovered!!As mentioned a delta Vbe of 18mv produces a 2X Ic change, 60mv produces 10X, so equalizing device temperatures is very important.This is why George Erdi's brilliant Cross Coupled Quad became a baseline in IC design as it reduced temperature and IC process gradient effects simultaneouslyBest,

author: langwadt
author_rank: Super Contributor
timestamp: June 26, 2024, 11:23:57 pm
content: try adding a resistor in each emitter