Menu

#76 .CSPARAM behavior changed?

v1.0 (example)
open
nobody
None
5
2025-03-09
2025-03-09
No

NGSPICE 44. Did something change for .CSPARAM ? The usage below is discussed in the manual, Chapt. 2.12, p66.

.TITLE prinverter (Rashid ex. 13.2)

.csparam fs = 21.5kHz
.param Ts = 1/21.5k

V1 in 0 SIN(0 1 {fs})
.tran 0 10ms 0 10u

.control
      run
      listing e
      fourier $&fs v(in)
.endc
.end

Output on Windows 11 from PowerShell:

PS D:\spice\mhx\MAGNETICS> spice64w .\test.cir
******
** ngspice-44 : Circuit level simulation program
** Compiled with KLU Direct Linear Solver
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Copyright 2001-2024, The ngspice team.
** Please get your ngspice manual from https://ngspice.sourceforge.io/docs.html
** Please file your bug-reports at https://ngspice.sourceforge.io/bugrep.html
** Creation Date: Feb  9 2025   13:57:26
******
Warning: no graphics interface!
 You may use command 'gnuplot'
 if GnuPlot is installed.

Note: No compatibility mode selected!


Circuit: prinverter (Rashid ex. 13.2)

Netlist line no. 6:
Undefined parameter [fs]
Netlist line no. 6:
Cannot compute substitute
Numparam expansion errors: Run Spice anyway? y/n ?
n

ERROR: fatal error in ngspice, exit(1)
PS D:\spice\mhx\MAGNETICS>

Discussion

  • Holger Vogt

    Holger Vogt - 2025-03-09

    There is no change.

    .csparam does not define parameters. It just sends parameters into a .control section.

    Thus line 6

    V1 in 0 SIN(0 1 {fs})
    

    is prone to failure asfs has not been defined as a parameter.

     
    • marcel hendrix

      marcel hendrix - 2025-03-09

      There is no change.

      .csparam does not define parameters. It just sends parameters into a .control section.

      Thanks, I have always struggled with understanding (or better, remembering) this. Reading it again, this is also what the manual says and has always said.

      When I have time, I'll dig around to see if I can find out what the fundamental reason is that only one of the following lines works

        fourier $&fs v(in)     $ yes
       *fourier {fs} v(in)     $ no
       *fourier fs   v(in)     $ no
      

      while the following three are all ok

      ngspice 44 -> print $&fs
      21500
      ngspice 45 -> print fs
      fs = 2.150000e+04
      ngspice 46 -> print {fs}
      fs = 2.150000e+04
      
       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.