Micro-Cap simulation  - Page 1
Forum section: electronics / general

author: Tenderfoot
author_rank: Contributor
timestamp: May 27, 2024, 05:08:45 pm
content: I decided to learn how to use Micro-Cap and the first project that came to mind was a linear bench PSU, variable voltage and variable current limiting. Maybe this was a bad choice. What I have found is that at various settings the simulation output is nice and stable, but alter the settings a little, or alter a component value a little and the output goes mad. I'm aware that PSU design is trickier than it might look, so am I asking too much of Micro-Cap (or any simulation for that matter)?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 27, 2024, 07:09:10 pm
content: It is common for control loops to be stable in some configurations, and unstable in others. Modifying a single resistor, inductor or capacitor can be the difference between stable or unstable.There is a lot of math involved, and simulators are a part of the toolbox to figuring out whether the math is applied correctly, or just to experiment with how to get a control loop to be stable.If you were building the circuit in real life you may experience the same. Change the value of a small capacitor, and suddenly your whole circuit goes bonkers. Because of this, breadboards are not suitable for a lot of circuits. They always add capacitance due to the way they are designed, and this is not always within acceptable limits.

author: tggzzz
author_rank: Super Contributor
timestamp: May 27, 2024, 07:32:55 pm
content: Quote from: Tenderfoot on May 27, 2024, 05:08:45 pmThat is too vague for diagnosis, however...The first thing you need to understand is themathematicsof feedback and control theory. Those models will give you a solid framework for understanding the kinds of thing that can happen in general systems.After that, simulation can be useful doing thearithmeticfor specific examples.It is always worth remembering that all mathematical models are wrong, but some are useful.

author: nctnico
author_rank: Super Contributor
timestamp: May 27, 2024, 08:06:59 pm
content: Quote from: Tenderfoot on May 27, 2024, 05:08:45 pmWhat I don't like about Micro-Cap is that it continues to simulate the circuit even if you alter it to a state it won't work. Maybe that is your problem. I have not looked into configuring Micro-Cap to do a single shot simulation though.Where it comes to simulation a control loop, you'll need to use techniques to do a frequency sweep over the control loop in order to find the loop's frequency response and phase margin. Especially current limiting can be tricky.

author: thm_w
author_rank: Super Contributor
timestamp: May 27, 2024, 08:59:39 pm
content: Maybe you can post the circuit and files here, so specific advice could be given.

author: Tenderfoot
author_rank: Contributor
timestamp: May 28, 2024, 11:13:28 am
content: Thanks for your replies. I think I didn't make myself clear in my first post. Although I might like to get this PSU built and working, it was more about learning Micro-cap. I've never used a simulation app before, apart from some very basic LT Spice circuits. A couple of replies say I need to do the maths, well that's never going to happen. I wouldn't know where to start, and I'm certain it'd be way beyond me. So my question really is... am I wasting my time trying to get the circuit working in a random 'hit and hope' approach? I can post the circuit if anyone is really interested, though I'd be a little embarrassed, it's just a couple of opamps, sense resistor and pass transistors.

author: Sensorcat
author_rank: Regular Contributor
timestamp: May 28, 2024, 11:49:48 am
content: Quote from: Tenderfoot on May 28, 2024, 11:13:28 amIt depends what you expect. Best is to know the theory, the math, to be able to calculate a circuit before simulation. Without this, you can perhaps take known, proven circuits and adapt them somewhat, using an intuitive understanding of the function. But in general, there are far too many permutations to develop circuits in a random manner.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 28, 2024, 12:26:54 pm
content: You don't have to know all the math, but you do need a background of how control loops and their stability works. Things like bode plots, phase margin and how to interpret them from simulation results.With that background you can make guesstimates and tweaks to push your circuit towards stability and something that "works".

author: thm_w
author_rank: Super Contributor
timestamp: May 28, 2024, 07:55:50 pm
content: Quote from: Tenderfoot on May 28, 2024, 11:13:28 amWhen you go to a forum to ask a question, its best to provide as much relevant information and files as is reasonable.- Always post a schematic if you have one- Always post PCB layout if you have one- etc.

author: tggzzz
author_rank: Super Contributor
timestamp: May 28, 2024, 09:08:19 pm
content: Quote from: Tenderfoot on May 28, 2024, 11:13:28 amWe were all in that position at one time!Just as you did when learning how basic op-amp circuits work, so you can use a similar level of maths to gain a basic understanding of control systems. If you can understand tutorials that show you why de-compensated op-amps cannot be used as unity-gain amplifiers, then you will be able to understand basic control theory. After all, even simple op-amp circuits like inverting amplifiersarecontrol systems.Yes, control theory can become very complex and fine-grained, but much of the visible behaviour can be understood intuitively - based on a little maths.QuoteProbably, yes. That's true ofallcircuits.A simulator will answer the question it is asked, no more. It is up to the engineer's good taste to decidewhichquestions areworthasking. Most questions aren't!QuoteNormally I would say the circuit and simulation should be posted. However in this case I think you are right not to bother posting them. If posted, this thread would start examining individual trees, and fail to see the wood.

author: shapirus
author_rank: Super Contributor
timestamp: May 28, 2024, 09:37:58 pm
content: Quote from: Tenderfoot on May 28, 2024, 11:13:28 amDevil is in the details. Post it.Circuits like what you described are usually simulated just fine. Of course undesired oscillations are sometimes simulated too, and that's a good thing.

author: Tenderfoot
author_rank: Contributor
timestamp: May 29, 2024, 03:24:18 pm
content: Ok, I'll post the circuit for your amusement. I have several different versions as I played with values etc, so give me time to tidy things up before I post. Obviously it's in Micro-cap so what do you want, a jpeg, Micro-cap files? If you want the MC files, how do I post them?

author: shapirus
author_rank: Super Contributor
timestamp: May 29, 2024, 03:51:01 pm
content: Quote from: Tenderfoot on May 29, 2024, 03:24:18 pmA .png, at least. Well, it will still be converted to jpeg by the forum engine, but that's one less quality loss step than if it's a jpeg originally.Microcap files might still be of interest to someone, though. If you do attach them, a zip file is a usual way to do it. But a picture of the schematic is a minimum.

author: Tenderfoot
author_rank: Contributor
timestamp: May 29, 2024, 05:39:34 pm
content: Here's a couple of screenshots of my circuit. The switches on the o/p are to add different loads during simulation, odd resistor values are a result of stepping through different values, capacitors have been added at various places at times, opamp U2B has been configured as differential amp or simple comparator at times too. In the o/p trace the red indicates the circuit is in current limit. As you can see the o/p at 10 volts is unstable during and after the first current limit, if I set the o/p to 25 volts there is way less instability. Perhaps I've set the simulation up incorrectly, remember this is my first attempt at Micro-Cap or any simulation really.

author: shapirus
author_rank: Super Contributor
timestamp: May 29, 2024, 06:06:57 pm
content: What happens if you remove C2?

author: Tenderfoot
author_rank: Contributor
timestamp: May 29, 2024, 06:21:49 pm
content: Quote from: shapirus on May 29, 2024, 06:06:57 pmSlightly better but not 'good', tbh I didn't notice I'd left that in there.

author: nctnico
author_rank: Super Contributor
timestamp: May 29, 2024, 07:02:36 pm
content: I'd check the output of U1B for oscillations.

author: shapirus
author_rank: Super Contributor
timestamp: May 29, 2024, 07:22:42 pm
content: That's also quite a feedback loop you've got there.I would simplify all those pass transistors to something more basic and see if that would improve things. That's a general way of troubleshooting, especially with simulations: remove unnecessary parts until it starts to work correctly, then start adding them back to analyze what might be causing the issues.Additionally, try adding a small cap (tens-hundreds of pF as a starting point) in parallel with R60, if I understand your schematic correctly (which is not necessarily true).

author: nctnico
author_rank: Super Contributor
timestamp: May 29, 2024, 08:26:50 pm
content: Another potential problem could be around U2A. I don't know if the simulation model for U2Ais a 100% functional equivalent where it comes to overdriving the opamp, but if it is then U2 may cause havoc when it is overdriven. U2Aneeds to be a comparotor; definitely not an opamp. When an opamp is overdriven, the impedance of the inputs can get really low and all kinds of other weird effects can happen depending on how an opamp is constructed. Never use an opamp as a comparator!Edit: this goes for U2A which drives the LED

author: shapirus
author_rank: Super Contributor
timestamp: May 29, 2024, 08:40:10 pm
content: Quote from: nctnico on May 29, 2024, 08:26:50 pmAre you sure? It's the thing that actually maintains the output voltage, isn't it? I mean U2B specifically. It's wired as a differential amplifier to amplify the difference between the output voltage (the positive terminal of C_out) and the "Set voltage" VDC source.The bigger the difference, the harder it drives the base of Q1, which in turn pulls the base of Q2 more to ground, which in turn reduces the current flowing through Q3 and Q4, thereby reducing the output voltage and completing the feedback loop.@Tenderfoot, C1 is also not needed (unless I'm wrong) and can actually cause oscillation as it adds (a lot of) unwanted capacitance inside the feedback loop. Try removing it. Then C3... I'm not sure about it, but it won't hurt to remove it as well while you're troubleshooting the circuit.

author: nctnico
author_rank: Super Contributor
timestamp: May 29, 2024, 09:39:39 pm
content: Quote from: shapirus on May 29, 2024, 08:40:10 pmGood catch! I meant U2A which drives the LED. This is a comparator application for which you really shouldn't use an opamp.Capacitor C1 is likely necessary as this adds a low-pass filter to the feedback loop and thus makes it more stable. It would be nice if the OP can share the original circuit.

author: Tenderfoot
author_rank: Contributor
timestamp: May 29, 2024, 10:20:00 pm
content: Good catch! I meant U2A which drives the LED. This is a comparator application for which you really shouldn't use an opamp.It would be nice if the OP can share the original circuit.Is using an opamp as a comparator really such a sin? Well It's easy for me to remove it. As for 'the original circuit' this IS my original circuit, though I'm not claiming copyright on itFrustratingly, following a couple of suggestions, I got the thing working much better, then... it all went haywire. I have no idea what I did, but I now have a headache and I'm off to bed!

author: nctnico
author_rank: Super Contributor
timestamp: May 30, 2024, 12:44:09 pm
content: Quote from: Tenderfoot on May 29, 2024, 10:20:00 pmYes it ishttps://www.analog.com/en/resources/analog-dialogue/raqs/raq-issue-11.html

author: Tenderfoot
author_rank: Contributor
timestamp: May 31, 2024, 02:27:35 pm
content: It's time for me to quit on this, I'm spending too much time playing with trying to get this PSU to work. It's not a failure though. This was never about getting the PSU to work, I never expected it to, I was always aware they can be troublesome. It was about learning how to use Micro-Cap (which is why I posted in the CAD forum). I've discovered a lot about it's features, though there are still more that I don't understand yet. So, just a thank-you to all who responded with your suggestions, hints and tips. No doubt I'll be back with more questions in the future, but I'll try to make them more specific.

author: shapirus
author_rank: Super Contributor
timestamp: May 31, 2024, 04:08:05 pm
content: Quote from: Tenderfoot on May 31, 2024, 02:27:35 pmOne way or another, you may want to try a different simulation software the next time. For example, Kicad + ngspice (they're not ideal and have some rough corners, but both are actively developed). Microcap is abandoned, so it's probably not the best choice to invest time into.

author: tggzzz
author_rank: Super Contributor
timestamp: May 31, 2024, 04:42:21 pm
content: Quote from: shapirus on May 31, 2024, 04:08:05 pmMicrocap has/had a good reputation, and can work with IBIS files. I have not used it in anger.Apart from that, the main requirement of a simulator is that it has good device models available.LTSpice is widely used. It has a, um, quirky interface (but that's of lesser importance). It is easy to send your design to someone else, since the source file is standard ASCII text - as all Spices really should be

author: nctnico
author_rank: Super Contributor
timestamp: May 31, 2024, 04:48:29 pm
content: Quote from: shapirus on May 31, 2024, 04:08:05 pmThat is poor advise. Microcap is mature software, there is nothing to fix. Just be happy the author made it available for free after having made a living from Microcap for decades. And very likely Microcap is way better compared to using Kicad / ngspice or Ltspice.

author: Messtechniker
author_rank: Frequent Contributor
timestamp: May 31, 2024, 05:43:44 pm
content: Yes. MicroCap has a somewhat steep learning curve.You would probably be better off with a more simple circuit which is known to work.Or study one of the many examples.I started MC with a simple resistor ladder voltage divider, since I was at the time interestedin Monte Carlo simulations. Moved on from there.

author: JohnG
author_rank: Frequent Contributor
timestamp: June 03, 2024, 01:26:19 pm
content: Quote from: nctnico on May 31, 2024, 04:48:29 pmI am happy that the author made it available, but after a few goes at it, I went back to LTspice. A small reason was that I have been using LTspice for many years and have many things already done, including several scripts for optimization and so forth (which just process spice source files and data, using the CLI). A big reason was that I had many more convergence problems with Microcap, and this became a showstopper for me. These were mostly switching power converters that I had trouble with.Perhaps I could have figured this out, but I have so much time into LTspice that it wasn't worth it to me to switch to Microcap. However, I have found the latter to be a great source of models.John