Figuring out why an actual circuit is not working like the simulated circuit - Page 1
Forum section: electronics / beginners

author: JoeN
author_rank: Frequent Contributor
timestamp: November 10, 2015, 05:30:18 am
content: This is my very first simulation! I posted about this circuit before, it was designed by Hans Camenzind and included in his book Designing Analog Circuits. I wanted to get this going as a discrete circuit. I have a simulation of it that says it should work. The waveform is a little different than Hans has it in his book but close enough for me. My circuit follows his design correctly, I think. I built two of these. Both of them behave the same. When 12V is applied, I get about 9.4V at the output, no periodic waveform. I guess it is up to me to start probing this mother and see where it begins diverting from the simulation, but I would love some pointers. Why, other than obviously screwing up the circuit in some way or assembling it incorrectly (which I am betting against), would a circuit like this one's behavior divert from the simulated results to such a large degree? Is there something obvious that I am missing?As Hans designed it:As I drew my schematic in LTSpice. I am using the surface mount version of these transistors and the resistor values are chosen to be standard values:LTSpice's results at the output terminal:

author: JoeN
author_rank: Frequent Contributor
timestamp: November 10, 2015, 05:35:55 am
content: For what it's worth, the DipTrace schematic and the PCB

author: KJDS
author_rank: Super Contributor
timestamp: November 10, 2015, 08:07:25 am
content: The first thing you'll need is to sort out power supply decoupling.

author: JoeN
author_rank: Frequent Contributor
timestamp: November 10, 2015, 09:50:53 am
content: Quote from: KJDS on November 10, 2015, 08:07:25 amI can throw a 10uF chip cap across those input terminals. Do you really think it may be that simple?I'm an idiot. I didn't see an IC. So I didn't think to decouple it (though it is an IC, just without the I). But somehow, I can't believe it will be that simple. Still, thanks for that idea. I will do that first thing.Edit: Nope, didn't work. But at least I have that "fixed".

author: KJDS
author_rank: Super Contributor
timestamp: November 10, 2015, 10:03:11 am
content: I'm going to assume that there's a solid ground plane on the back side of the board.You'll need to decouple every point that connects to Vcc.Then I suspect you'll need a collection of other caps to stop bits oscillating.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 10, 2015, 01:11:38 pm
content: The mirrors are extremely over-the-top. Four transistors (and more) is typical for precision mirrors when you are stuck with lateral PNP (hFE < 10), but 2N3906s outperform them considerably.Having no emitter resistors (in several places) is also a problem. It should still work, but expect lopsided waveforms, particularly at high current (= thermal imbalance) and low current (= Vbe mismatch).CML (current mode logic -- starting with a current sink at the bottom, and steering it through diff pairs until it reaches load resistors at the top) is prone to oscillation when tall stacks and long traces get involved. Routing is non-obvious: you want the traces to be high impedance to let the current flow relatively unimpeded, but sooner or later, you need low impedances (e.g., ground plane shielding) to keep things in order. The RF response is that of a series of cascode amplifiers, so expect high sensitivity for the transistors near the bottom (current sinks and first diff pairs). Reduce sensitivity by adding series base resistance (10-100 ohms) or a ferrite bead.As long as supply current is constant, supply bypass isn't a big deal, but do try to keep current paths nearby. That is, a current path starting with a current sink, should follow as near a common path as possible until it reaches the supply. Each time it splits (i.e., goes through a diff pair), keep those paths close together. That way, when the current paths switch state, the current is drawn from nearly the same location on the supply rail. Imagine hanging from a railing with one hand, then grabbing it with your other hand: you have to move over, but the less you move, the easier it is (and the less the rail will bounce in the process).Tim

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 10, 2015, 01:14:08 pm
content: Oh and I rememberspecifically noting thisin the previous thread:Q11 has two emitters.Your LTSpice has one, which is why the falling edge is so slow. In fact, it's almost complete luck that it falls at all. (The only reason it does, is because of base currents.)Mismatch in your real circuit means it probably won't work at all. Or maybe it will, depending on which transistors are warmer than others.Use two 2N3904s in parallel.Tim

author: free_electron
author_rank: Super Contributor
timestamp: November 10, 2015, 01:36:09 pm
content: Matched transistors.

author: KJDS
author_rank: Super Contributor
timestamp: November 10, 2015, 03:01:52 pm
content: Quote from: free_electron on November 10, 2015, 01:36:09 pmI suspect that's the least of the issues, too much gain, both at DC and at RF will both cause grief.It might be fun to assign different transistors to the spice model to see the effects of unmatched transistors, or possibly just changing some parameters on a random basis across the model, though it is probably better to break it down into different segments to see the effects of mismatch and temperature on a block by block basis.

author: JoeN
author_rank: Frequent Contributor
timestamp: November 10, 2015, 06:13:45 pm
content: Quote from: KJDS on November 10, 2015, 10:03:11 amThere isQuote from: KJDS on November 10, 2015, 10:03:11 amYou have to be kidding me, how then does any IC work? ICs don't contain a bunch of internal caps for every transistor and use typically only one for the whole circuit.Quote from: KJDS on November 10, 2015, 10:03:11 amSee my last comment.

author: JoeN
author_rank: Frequent Contributor
timestamp: November 10, 2015, 06:17:00 pm
content: Quote from: T3sl4co1l on November 10, 2015, 01:11:38 pmTell Hans. I assume he knew this was a problem but was being compensated for by matched transistors? Maybe I should simulate PNP transistors with hFE = 10?

author: JoeN
author_rank: Frequent Contributor
timestamp: November 10, 2015, 06:18:01 pm
content: Quote from: T3sl4co1l on November 10, 2015, 01:14:08 pmYou mean two transistors with the same nets for all three terminals, right? I could just stack another 2N3904 on top of that one? I can physically pull that off I think and test it with the board I have now. I will add that to the simulation and see what happens.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 10, 2015, 06:21:43 pm
content: Quote from: JoeN on November 10, 2015, 06:17:00 pmYes, both of those methods are completely absent, because they aren't required in monolithic circuitry. There are many gotchas in translating a monolithic circuit into discrete components!Quote from: JoeN on November 10, 2015, 06:18:01 pmYup!Tim

author: KJDS
author_rank: Super Contributor
timestamp: November 10, 2015, 06:51:27 pm
content: Quote from: JoeN on November 10, 2015, 06:13:45 pmHave you included the strays in your board layout into your model?That gets done in IC design, but line lengths are much much much smaller.

author: DimitriP
author_rank: Super Contributor
timestamp: November 10, 2015, 07:35:34 pm
content: Quote from: KJDS on November 10, 2015, 03:01:52 pmActionable advice using only 79 words in 8 lines!

author: JoeN
author_rank: Frequent Contributor
timestamp: November 11, 2015, 12:51:47 am
content: Quote from: T3sl4co1l on November 10, 2015, 06:21:43 pmDoing that gets results. It changes the waveform into something closer to a triangle, though it is not very clean anymore, and really increases the frequency. I will have to add that transistor and see if it does anything IRL.

author: JoeN
author_rank: Frequent Contributor
timestamp: November 11, 2015, 01:53:37 am
content: Your intuition was right. Doubling up Q11 makes the circuit work, though it isn't a quality triangle wave and the voltage swing is very small compared to the original specs or the original simulation.Second board same results @ ~122KHz

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 11, 2015, 12:44:03 pm
content: Hmm, it should still be on the same thresholds. Something else is going batty.Tim

author: eetech00
author_rank: Regular Contributor
timestamp: November 11, 2015, 02:38:05 pm
content: Can you post the LTspice .asc file?

author: JoeN
author_rank: Frequent Contributor
timestamp: November 11, 2015, 05:16:42 pm
content: Quote from: eetech00 on November 11, 2015, 02:38:05 pmSure, I would love some expert advice. This was my first simulation ever. So if I did something really stupid, it should not come as a surprise.

author: JoeN
author_rank: Frequent Contributor
timestamp: November 11, 2015, 05:26:55 pm
content: Here is my test board too if it matters. You can see Q11 is doubled up now and there is a little bit of a miss around it.

author: eetech00
author_rank: Regular Contributor
timestamp: November 12, 2015, 02:50:53 am
content: HiI as able to get the IC version of the circuit from the book working.I reduced the size of each transistor to about 1/10 the size as itwould be on a chip. You can see in the attached image a 1Mhz triangle wave.It is very close to the waveform the book shows.For you circuit...I would start by using lower gain transistors.good luck.

author: JoeN
author_rank: Frequent Contributor
timestamp: November 12, 2015, 04:07:05 am
content: Quote from: eetech00 on November 12, 2015, 02:50:53 amHey, thanks for all that. I am certainly learning something here. I have a bunch of questions though.1. You reverted the resistor values back to Hans' values. I was using standard values so I can actually get a chip resistor with that value. I will resimulate with your values, but do you think it matters much?2. Adding those output nets TRIANGLE, SQUARE, and R was just for convenience, right? That doesn't seem to affect anything. What is the need for the R "output"?3. Why did you move the voltage source from the right to the left? Any reason?Most importantly:4. How do you specify a transistor model to use for your transistor? When I right-click on any transistors all I can do is "Pick New Transistor" and then use the list of commercial choices. I see no way to pick "NP" or "PN" and I don't understand how you specified "NP .1" or "PN .1" or why those names instead of just "NP" or "PN". Knowing this would be extremely helpful, I can't figure it out.5. What transistors could I possibly use that have a close match to the simulation values you used for NP and PN? What might be a good choice?Thank you for all your help so far.

author: coppice
author_rank: Super Contributor
timestamp: November 12, 2015, 04:35:32 am
content: Quote from: JoeN on November 10, 2015, 06:13:45 pmDecoupling generally needs to be electrically close to the thing its decoupling. Everything in a low speed IC is pretty close to the Vcc pin, and a single decoupling capacitor (or a pair of high and low value ones) near the Vcc and Vss pins can work well. In a high IC decoupling between different areas of the chip becomes a problem, and a lot more care is needed with decoupling. In some fast ICs half the pins are Vcc and Vss. That's not just to carry high currents. Its also about decoupling. For a discrete circuit spread across a substantial area of PCB localised decoupling is usually necessary.

author: eetech00
author_rank: Regular Contributor
timestamp: November 12, 2015, 04:37:52 am
content: .

author: eetech00
author_rank: Regular Contributor
timestamp: November 12, 2015, 05:06:47 am
content: QuoteI changed the values back to the original just to check that the circuit actually worked as drawn in the book.One error was RBM6 (R14 on your schematic) it is shown as 17 ohms, should be 17k.QuoteYes...for convenience. No...Don't know what "R" is for.QuoteJust did....ignore it.QuoteI actually used a text editor to edit the .asc file. But if you rht-clk on the transistor model text, a dialog will pop up and allow you to change it, then just type: "NP .1", w/o quotes. Doing so specifies "NP" as the model and ".1" is the size (area) of the device. default = 1. The size is a multiplier and increases or reduces all params for the device. For example 'NP 2" is the same as placing two transistors in parallel. The book your using is meant for IC designs, so keep that it mind when analyzing the circuits. IC's don't use transistors like you buy of the shelf and many of the adjustments are made by varying the size of the BJT.QuoteI'll leave that for you to research..

author: JoeN
author_rank: Frequent Contributor
timestamp: November 12, 2015, 06:08:26 am
content: Quote from: eetech00 on November 12, 2015, 05:06:47 amIn the original post (see top of this post) I linked in Hans' schematic from his online book and that schematic has that resistor listed as 13K. I changed it to 12K to make it a standard value. I didn't use the value in the printed book or show the printed book's schematic. It's R14 in my schematic because it is R14 in Hans' schematic from the online corrected edition.Quote from: eetech00 on November 12, 2015, 05:06:47 amThat is what I figured but that box is read only on my machine. Maybe I will be editing the ASC file myself. I wonder why it is locked down. Maybe there is a parameter that needs to be set somewhere.Quote from: eetech00 on November 12, 2015, 05:06:47 amOK, thanks. I am just concerned there will be none to find. I would think that modern transistor designs are done to maximize gain.Thanks for everything. I will see what I can do with this.