We can do this with a control command, and a for cycle, varying the three value of resistance, and making an AC simulation and measurement of the cut-off frequency for each value of R.
* RC filter - variable resistor
Vin 1 0 DC 0 AC 1
R 1 2 1k
C 2 0 10n
.CONTROL
foreach val 1k 10k 100k
alter R=$val
echo executing analysis with R=$val
ac dec 600 1 10meg
meas ac fc WHEN v(2)=0.707
end
write sig_plot.raw db(ac1.v(2)) db(ac2.v(2)) db(ac3.v(2))
+ph(ac1.v(2)) ph(ac2.v(2)) ph(ac3.v(2))
quit
.ENDC
.END
The command "foreach" is a for cycle that change the value of the variable "val" for each cycle. Then the value of the component "R" is changed by the command "alter" and is made the AC simulation for that specific value of resistance.
The vectors of the different AC simulations, will be saved as "ac1.* ac2.* etc", then after the for cycle we can save in a raw file the magnitude and phase of the vectors for a Bode plot. This time I have used gaw to see the graphs, that is the updated version of gwave.
The value that I have obtained with the command "meas" are:
$$f_{c1} = 15.91 kHz,\quad f_{c2} = 1.59 kHz,\quad f_{c3} = 159 Hz$$ exactly the same that can be figure out with the formula:$$f_c=\frac{1}{2 \pi R C}$$
That's all even for this time. The circuit was simple, but I think was the best to show how make an AC analysis and varying the value of a component in the same time.
spice file, raw file, output file.
That's all even for this time. The circuit was simple, but I think was the best to show how make an AC analysis and varying the value of a component in the same time.
spice file, raw file, output file.
No comments:
Post a Comment