NGSpice: GNUCap: A simple halfwave rectifier fails.
While I'm not new to electronic circuits, I'm fairly new to EDA.
I have played around with Spice a very long time ago but really had no need for it. Now I do.
I've been trying to simulate a simple half wave rectifier for the last week or so and keep getting wrong results. Let me explain.
The first screenshot shows the circuit, a very very basic 1/2 wave rectifier, but as you can see from the second screenshot, while the voltage from the net labelled op is correct, the voltage across the resistor is inverted. Basic electronic theory tells you that this can never happen. Notice the pin labels on the resistor.
Now after trying and searching for almost two days, I inadvertently reversed the connections on the resistor and the output is now correct as shown in the third screenshot.
I thought it was the version of GNUCap I installed from the Debian repos. I built the lastest tarball but still the same result.
The circuit does not even simulate with NGSpice. The simulation runs forever while using 100% CPU. Again, I build the lastest NGSpice (25), but still the same result.
After trying searching for how a resistor is modeled in SPICE, and not getting anywhere, I'm at my wit's end.
Any help is greatly appreciated.
I don't see anything wrong here. Remeber voltages are reletive. Absolute voltages in spice simulations are relevent to the ground point.
So V_op = V_op - V_gnd
But the voltage across the resitor is not relative to gnd so it can be negative. So it all depends on how V_R1 is defined. Looking at your circuit if V_R1 is defined as:
V_R1 = V_R1p1 - V_R1p2
Then you will will get V_R1 = -V_op.
If V_R1 is defined as:
V_R1 = V_R1p2 - V_R1p1
Then you will get V_R1 = V_op.
I did try to recreate the problem in gSchem/GNUCap but could not (this is more due to not being used to these tools as much as anything else).
All that you said is true, but it still soes not explain why reversing the resistor gives a different result. Also, what version of gschem are you using and which resistor symbol did you use? I've noticed that resistor-2.sym from the Basic library does not simulate. I'm using 22.214.171.12400214 from the Debian repos. I think I'll build the latest and give that a try.
Also, consider this: Why doesn't the simulation run with NGSpice?
Another point: Consider the circuit shown in this screenshot. It's your basic precision half wave rectifier. With the given configuration of the diodes, the circuit should give a positive half-wave rectified signal at the net labeled Half. Instead, it gives a negative half-wave rectified signal. I've also tried this with KTechLab and the circuit simulates as expected. What gives?
Thanks for the response.
V(R) = V_Rp1 - VRp2
which in your case gives
V(R1) = V(GND) - V(op) or V(R1) = - V(op).
which is both what you expected and what you got, when you rotated the the resistor 180' you reversed the pins so you had:
V(R1) = V(op) - V(GND) or V(R1) = V(op).
To me this behaviour seems exactley as expected.
where rect() passes all positive value and filters all negative; and n_rect() passes all negative values and filters all positive values.
Would it be possible for you to upload the *.sch file for the half wave rectifier only. and the diode and op-amp models (I have been using the 1N4007 diode so far as thats what I had on my sysytem).
I'm afraid my experiance with gEDA is limited, I am more used to PSICE/LTSPICE/cadence (in order I started using them). I have only really used the gEDA suite quickley to see how it works.
Thank you so much for taking the time to help me with this. It's been quite a while since I've done any sort of circuit design, so this has taken me back to class. Back in my days there was no such thing as Spice etc. It was all breadboard and components, together with your slew of testing and measuring equipment. Again, I am sincerely grateful for all the help.
I've included the stuff in the attached archive. I've added the .txt extension to upload as a text file. I'm sure you know, but for anyone else coming across this thread, to untar:
Here's a link:
The comparator is not simulating in the circuit, although, it does on it's own, ie: if I disconnect Pin 4 from the output of the second opamp and put in a Sin 0 2 1 Spice source, it switches as expected.
BTW: I'm using gSpiceUI as a front-end to GNUCap. Thr archive includes the gnetlist output together with the simulation output as acdc.gnucap.tr.
Thanks a whole lot again.
|All times are GMT -5. The time now is 07:01 AM.|