QSpice (8) --Examples and Command Probe usage
QSpice (8) --Examples and Command Probe usage
Hello uu, based on the experience of learning Spice before, I believe it will not be a problem for us to build a circuit by ourselves now. The best way to learn is to get moving, use things, encounter some problems and solve them. I believe you will be able to master it quickly.
Today we will use the Probe by building a capacitance measurement circuit (changing the capacitance to change the 555 output frequency and the MCU detecting the 555 output frequency to determine the capacitance value) as an example to use other commands.
Although there are not many devices in QSpice, there is 555 (symbol&ip--analog--NE555). We can use 555 to build an astable circuit. The circuit is shown in Figure 1 below, referring to the TI NE555 manual. We just need to build the circuit according to this.
Figure 1: NE555 astable circuit
The frequency here is determined by RA|RB|C. Assuming that we keep the resistance unchanged and only change the capacitance to change the frequency, the calculation method is as follows:
Figure 2: 555 frequency capacitance calculation
CalcPad formula:
Freq = 100 kHz
RA = 10 kΩ
RB = 10 kΩ
C = ( 1.44 / Freq ) / ( RA + 2 * RB ) | nF
|
Now that we have the parameters and the circuit, we can build the circuit in Qspice as follows:
Figure 3: Qspice astable schematic
|Tips: QSpice can paste pictures directly into the schematic diagram|
When we simulate, we usually need to click on the port to add the simulated waveform to the simulation observation window. We can use .Probe to add the waveform. If it is a voltage waveform, it is V(xxx). xxx represents the network name. If it is a current waveform, it is I(xxx). If you want to see multiple waveforms, you need to use ", " to separate them. Don't be stupid enough to copy "". The above example observes the OUT voltage waveform and C1 current waveform. The simulation code is as follows, and the simulation result is shown in Figure 4:
Simulation code:
.subckt X1L E555 COM TRIG OUT RESET CONT THRES DISCH VCC S1 DISCH COM N01 COM Ron=10 Roff=1G Vt=2 Vh=-1 R1 VCC CONT 5K R2 CONT N02 5K R3 N02 COM 5K ? VCC COM N03 ?THRES CONT ??????????HMITT ? VCC COM N06 ?N02 TRIG ??????????HMITT ? VCC COM ?N04 RESET ?????????OR ? VCC COM N05 ?N04 N03 ???????OR ? VCC COM ?N01 N06 N05 ??????????SR-FLOP Trise=1?Ttol=10n IC=0 UVLO=2.5 S2 OUT VCC COM N01 Ron=12.5 Roff=1G Vt=-2 Vh=-1 S3 COM OUT N01 COM Ron=10 Roff=1G Vt=2 Vh=-1 C1 THRES COM 5p Rpar=.3G
C2 TRIG COM 5p
R4 VCC TRIG 30Meg C3 RESET COM 5p Rpar=150K R5 VCC RESET 37.5K SHORTED .ends NE555 X1 0 N01 OUT N03 N04 N01 N02 N03 X1L E555 C1 N01 0 0.48n R1 N02 N01 10K R2 N03 N02 10K V1 N03 0 5 C2 N04 0 10n R3 N03 OUT 10K .TRAN 8m .Probe V(OUT) ,I(C1) .end |
Figure 4: Simulation results
Zooming in on the waveform, we find that the result is not the frequency we calculated, and there is still a little gap:
Figure 4: Enlarged simulation result - frequency 73.945KHz
If we look at the NE555 manual, we can see how it takes values. We choose a value of RA+2RB=144Kohm to observe the output frequency under different capacitances. After all, we are just measuring the capacitance value. In order to make the frequency and capacitance correspond better, I chose the value of 144Kohm. 1nF is equal to 10Khz, 10nF=1Khz. Let's use the Step and param commands to simulate it.
Figure 5: NE555 frequency comparison table
Figure 6: Modified circuit
Figure 7: Steps to select simulation
After the adjustment in Figure 6, the simulation waveform can basically match the frequency. The smaller the capacitance, the higher the frequency and the greater the deviation. If you really want to do it, it is recommended to divide it into grades. When the capacitance is small, use a 144Kohm resistor. When the capacitance is large, you can use a 14.4Kohm resistor. Use Relay to cut it. The on-resistance of Relay will be smaller. However, if you pursue volume, you can consider using an analog switch. However, the resistance of the analog switch is not very linear. But the capacitance does not need to be very accurate anyway, just look at it roughly, and the analog switch should be more suitable.
The final simulation code is as follows:
.subckt X1L E555 COM TRIG OUT RESET CONT THRES DISCH VCC
S1 DISCH COM N01 COM Ron=10 Roff=1G Vt=2 Vh=-1 R1 VCC CONT 5K R2 CONT N02 5K R3 N02 COM 5K ? VCC COM N03 ?THRES CONT ??????????HMITT ? VCC COM N06 ?N02 TRIG ??????????HMITT ? VCC COM ?N04 RESET ?????????OR ? VCC COM N05 ?N04 N03 ???????OR ? VCC COM ?N01 N06 N05 ??????????SR-FLOP Trise=1?Ttol=10n IC=0 UVLO=2.5 S2 OUT VCC COM N01 Ron=12.5 Roff=1G Vt=-2 Vh=-1 S3 COM OUT N01 COM Ron=10 Roff=1G Vt=2 Vh=-1 C1 THRES COM 5p Rpar=.3G C2 TRIG COM 5p R4 VCC TRIG 30Meg C3 RESET COM 5p Rpar=150K R5 VCC RESET 37.5K SHORTED .ends NE555 X1 0 N01 OUT N03 N04 N01 N02 N03 X1L E555 C1 N01 0 {X} R1 N02 N01 22K R2 N03 N02 100K V1 N03 0 5 C2 N04 0 10n R3 N03 OUT 10K .TRAN 80m .Probe V(OUT) .step param X list 1n 10n 100n .end
|
Have a nice weekend~