#11 Fourier frequency as parameter.

closed
Holger Vogt
None
5
2010-08-25
2010-06-15
Anonymous
No

Fourier frequency as parameter.

.param f=10k Vamp=1
Vac in 0 sin(0 {Vamp} {f} {0.5/f} 0) ac 1
...
.tran {1/(f*100)} {6/f} 0 {1/(f*100)}
.four {f} v(out) <- Not work!!!
fourier {f} v(out) <- Not work!!!

Whether it is possible to correct it?

Thank.
Alg.

Discussion

  • Holger Vogt
    Holger Vogt
    2010-06-16

    parameter substitution for .four command is not implemented.

    You may apply the following trick:

    * fourier plus param test
    .param f=9k Vamp=1

    Vac out 0 sin(0 {Vamp} {f} {0.5/f} 0)

    .tran {1/(f*100)} {6/f} 0 {1/(f*100)}

    * .four {f} v(out) $ parameter substitution in .four command not implemented!

    vfreq ftemp 0 {f} $ create a voltage output vector with "frequency value as voltage"

    .control
    run
    plot v(out)
    let fnew=v(ftemp) $ create a new vector with unique name
    let fvec=fnew[1] $ create a vector with a single value
    echo fundamental frequency: $&fvec $ print the mean of frequency value
    fourier $&fvec v(out) $ use this value
    .endc

    .end

    Regards

    Holger

     
  • Holger Vogt
    Holger Vogt
    2010-06-16

    • assigned_to: nobody --> h_vogt
     
  • Holger Vogt
    Holger Vogt
    2010-06-17

    Do a little bit of analog computing:
    start of file:

    *rms continuous

    *Vin in 0 DC 1 sin(0 1 50k 0 1k)
    Vin in 0 DC 1 sin(0 1 50k 0 0)

    .subckt vrms in out
    Bsqin sq 0 V = v(in) * v(in) $ square
    aint sq sqi v_int $ integrate
    .model v_int int(in_offset=0.0 gain=1.0
    + out_lower_limit=-1e12 out_upper_limit=1e12
    + limit_range=1e-9 out_ic=0.0)
    Bsqinti out 0 V = sqrt(v(sqi)/TIME) $ calculate rms
    .ends

    .subckt irms in out
    vcurrmess in out DC 0 $ measure current
    Bsqin sq 0 V = i(vcurmess) * i(vcurmess) $ square
    aint sq sqi v_int $ integrate
    .model v_int int(in_offset=0.0 gain=1.0
    + out_lower_limit=-1e12 out_upper_limit=1e12
    + limit_range=1e-9 out_ic=0.0)
    Bsqinti out 0 V = sqrt(v(sqi)/TIME) $ calculate rms
    .ends

    xrms in out vrms $ apply input voltage (arbitrary waveform), get rms

    .control
    tran 1u 1m
    plot in out
    .endc

    .end

    Holger

     
  • Holger Vogt
    Holger Vogt
    2010-06-17

    Sorry, may last comment went to the wrong list.

    Holger

     
  • Holger Vogt
    Holger Vogt
    2010-08-25

    • status: open --> closed