Electronic – LTSpice “Error:undefined symbol in:” problem

ltspice

Below is my schematic for a relay SPDT symbol I’m creating. I've posted this question in the Digikey forums, but I am not sure they actually answer LTSpice questions

Relay-SPDT

You may notice I’m not yet very proficient with LTSpice. Getting past that, You’ll notice the spice directive on the top right corner. What I’m trying to do is this:

  1. Regardless of what voltage POS is, V4 = 5 unless POS=<0

:: Here I thought the expression u(POS) * 5 would work because u() returns 0 or 1 depending if the parameter is 0 or > 0

  1. Since it is SPDT both electronic switches (ADG1201) have the same input COM1 but each has a different Output. The switch turns on when Mom = 5. So U1[In] =0 and U2[In]=5 when Mom = 5. Also, U1[In]=5 and U2[In]=0 when Mom=0

:: Here I tried to modify the expressions with the .func statement along with If statements.

In my test Circuit, the Spice Error log reads:

Questionable use of curly braces in “v4 n004 0 {z}”
Error: undefined symbol in: “[z]”
Questionable use of curly braces in “v5 n006 0 {y}”
Error: undefined symbol in: “[y]”
Questionable use of curly braces in “v6 n005 0 {x}”
Error: undefined symbol in: “”
Questionable use of curly braces in “v4 0 {fnvoltmod(v(pos))}”
Error: undefined symbol in: “(if((v)>0,z=u((v(pos)))*5))”
Questionable use of curly braces in “v5 0 {fndecy(mom)}”
Error: undefined symbol in: “(if(([mom])>0,y=0,y=5))”
Questionable use of curly braces in “v6 0 {fndecx(mom)}”
Error: undefined symbol in: “(if(([mom])>0,x=5,x=0))”
Fatal Error: Multiple instances of “V:x1:4”

How do I accomplish what I am doing using Spice directives?

I wouldn’t ask this question if I hadn’t already searched the web for an answer. I think I don’t understand how to use Spice Directives on a schematic properly. I’ve read the LTSpice help and expanded help on the wiki site – but I can’t seem to find schematic rules with spice directives.

In short, please help me understand.

Best Answer

I'm sure there is better way to achieve your goal of modeling switching behavior, but here is an example of using behavioral voltage, "bv", with output dependent on the voltage of another node and dependent on custom function.

Example Schematic