3
\$\begingroup\$

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.

\$\endgroup\$
3
  • 4
    \$\begingroup\$ You need curly braces around tdel \$\endgroup\$ – PlasmaHH Oct 23 '17 at 9:05
  • \$\begingroup\$ To remove ambiguity in bracket types: {tdel} \$\endgroup\$ – loudnoises Oct 23 '17 at 10:27
  • \$\begingroup\$ @PlasmaHH Urgh. Thanks for the simple answer to the stupid question. I thought I'd tried that, but obviously I must have messed up something else at the same time and thought it didn't work. \$\endgroup\$ – chrisb2244 Oct 23 '17 at 11:28
1
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.