We cannot really tell you why your simulations are failing without having all the information. However, rather than providing us with the circuit and all the waveforms it would be better if you debugged the situation yourself. I recommend you thinking about the value of
vy ?
rpuon and !
vy. Here you are treating
vy, a real number, as a boolean. It is logically false if its value is 0.000000000000000000, and true otherwise. Is that really the way you want to write this model?
Given that you are clearly struggling, here are a few issues with your model:
Code:@(cross(V(A) - vth, 0) )
vy = (V(A) > vth);
Why are you computing
vy here. You immediately overwrite with the next statement.
The next problem is here:
Code:if (V(A) > vth)
vy = vhi;
else
vy = vlo;
Why are you setting
vy to
vhi and
vlo.
vhi and
vlo no longer have any meaning in this model, and the fact that you are using them leads to the problem Geoffrey is pointing out.
Perhaps you should replace the above code with the following:
Code:@(cross(V(A) - vth, 0) )
;
vy = (V(A) > vth);
And while I am at it, why do you use
vy as the name of your variable. The value is not a voltage, and
y is meaningless. This poor choice of names is contributing to your problems. Perhaps you should use a name like
on. It is very descriptive of both the meaning and the type of the value.
-Ken