Menu

Can I change frequency of SIN voltage source using "alter" command?

simpletk
2022-06-01
2022-06-04
  • simpletk

    simpletk - 2022-06-01

    I have this netlist:

    • first line is ignored
      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

     
  • Holger Vogt

    Holger Vogt - 2022-06-01

    See manual, page 358.

     
  • simpletk

    simpletk - 2022-06-01

    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
     
  • Holger Vogt

    Holger Vogt - 2022-06-02

    You may change either amplitude or frequency, but not both.

    Edit: See next post.

     

    Last edit: Holger Vogt 2022-06-02
  • Holger Vogt

    Holger Vogt - 2022-06-02

    My previous post was not correct.

    The manual states the following in chapter 17.5.3:

    For specifying a list of parameters as values, start it with ‘[’, followed by the values in
    the list, and end with ‘]’. Be sure to place a space between each of the values and before
    and after the ‘[’ and ‘]’.
    

    So the line in your netlist should read
    alter @v1[sin] [ 0 $&newamp $&newfreq ]
    (see the additional spaces).

    Then everything should be o.k.

     
  • simpletk

    simpletk - 2022-06-03

    Thanks.

     
  • dick freebird

    dick freebird - 2022-06-04

    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?

     

Log in to post a comment.