I tried this but amplitude is still 0.1 and I got error: Error: Only a single param - value pair supported.
changing amplitude and freq of sine voltage source
V1 1 0 DC 0 AC 1 0 SIN(0 0.1 192 0 0 0)
R1 1 0 1k2
.control
set nobreak
set nopage
let newamp = 5
let newfreq = 440
alter @v1[sin][0 $&newamp $&newfreq]
set newamp = 6
set newfreq = 1234
.endc
.tran 10u 10m 0
.print tran v(1)
.end
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you want to change amplitude in real time you could use a poly vcvs as an analog multiplier, from a secondary (multiplier) DC source that has a variable or time-varying value. Keep all of that ground-referred and do any level shifting, after you're happy with gain control.
I wonder if you could similarly use a multiplier as mixer, to alter applied frequency (might also need a co-scaled vcvs amplitude corrector?). I'd go with high side injection, low side might require more carrier cycles to stabilize?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have this netlist:
V1 1 0 DC 0 AC 0 0 SIN(0 1 440 0 0 0)
R1 1 0 1k2
I can change "AC 0" using alter command like this:
.control
alter V1 AC = 5
.endc
But is it possible to change VA and FREQ of SIN (...)? Something like:
.control
alter V1 VA = 5
alter V1 FREQ = 1234
.endc
ngspice-36
See manual, page 358.
I tried this but amplitude is still 0.1 and I got error: Error: Only a single param - value pair supported.
V1 1 0 DC 0 AC 1 0 SIN(0 0.1 192 0 0 0)
R1 1 0 1k2
.control
set nobreak
set nopage
let newamp = 5
let newfreq = 440
alter @v1[sin] [0 $&newamp $&newfreq]
set newamp = 6
set newfreq = 1234
.endc
.tran 10u 10m 0
.print tran v(1)
.end
You may change either amplitude or frequency, but not both.
Edit: See next post.
Last edit: Holger Vogt 2022-06-02
My previous post was not correct.
The manual states the following in chapter 17.5.3:
So the line in your netlist should read
alter @v1[sin] [ 0 $&newamp $&newfreq ]
(see the additional spaces).
Then everything should be o.k.
Thanks.
If you want to change amplitude in real time you could use a poly vcvs as an analog multiplier, from a secondary (multiplier) DC source that has a variable or time-varying value. Keep all of that ground-referred and do any level shifting, after you're happy with gain control.
I wonder if you could similarly use a multiplier as mixer, to alter applied frequency (might also need a co-scaled vcvs amplitude corrector?). I'd go with high side injection, low side might require more carrier cycles to stabilize?