RC Circuit
vin 1 0 1.0
r1 1 2 1MEG
c1 2 0 1uF
.ic V(1)=0 V(2)=0
.tran .001s 5s
.end
We're going to outsource the first line to a separate file, vin_piecewise.spice.in, containing the following line
vin 1 0 PWL(0 0 .1 1 2.0 1 2.1 0 3.0 0 3.1 1 4.0 1 4.1 0)
so the original file is now:
RC Circuit
.include vin_piecewise.spice.in
r1 1 2 1MEG
c1 2 0 1uF
.ic V(1)=0 V(2)=0
.tran .001s 5s
.end
Which after running yields the following:
So why did we take the PWL statement in a separate file? We didn't need to, but the nice thing about this is that we have now put ourselves in a position for easy scripting. We can now simply write to the .in file, rerun spice in batch mode, and get the output! The next post will use python to do just that.
No comments:
Post a Comment