Electronic – Use variable in SPICE parameter list

ltspicespice

I'm using LTSpice XVII to try and simulate a circuit.

I've created a schematic which uses a Pulse voltage source to simulate a rotary encoder as follows:
enter image description here

As you can see in the PULSE component, I'm trying to specify the delay as a variable that can be set. I'd also prefer to be able to set the frequency via the period and timing values, but I'll start with baby steps.

Is this completely impossible, or am I just doing it wrongly?

If I replace 'tdel' with 0 directly, the component works 'correctly', but all copies of the component will be the same, which makes it difficult to test offsets or vary the frequency to check response when adding capacitors or similar.

Best Answer

All parameters need curly braces around them, this lets the compiler know that it's a parameter. Another tip is to check the netlist by going to view->spice netlist to see what spice code the graphical interface is 'compiling'

The .param directive allows the creation of user-defined variables. This is useful for associating a name with a value for the sake of clarity and parameterizing subcircuits so that abstract circuits can be saved in libraries.

The .param statement can be included inside a subcircuit definition to limit the scope the parameter value to that subcircuit.

To invoke parameter substitution and expression evaluation, enclose the expression in curly braces. The enclosed expression will be replaced with the floating-point value.
Source: http://ltwiki.org/index.php?title=PARAM_User_defined_parameters