Voltage controlled resistor using IF() doesn't work at steady 0V

Hi,
I have simple test circuit like below to create a voltage controlled resistor using IF(x,y,z) function.

The test waveforms are like below. What’s weird is that it seems QSpice dislikes steady 0V in IF() function, at which it will yield some infinite output instead of stay low. Is this a minor bug or is there something wrong in my setup? Thanks.

Sorry as a new user I can’t upload files. The 3 values in my simulation is like below if anyone interested to repeat it.

PWL 0 -1 0.2 -1 0.5 3 0.6 3 0.9 -1 1 0
R=IF(V(Vtest)>1.8,1,IF(V(Vtest)>0.3, 2, 1))
R=IF(V(Vtest)>1.8,1m,IF(V(Vtest)>0, 1K*V(Vtest), 1m))

You are calculating 0 divided by 0 when V(test)=0V.
If you export data in .csv, you should realize the calculated result is NaN for 0/0.
Possibly the simulation timestep not exactly at 0V, 0A in 1st and 2nd zero crossing and you only notice that in 0V steady state in your simulation.

1 Like

Thanks Kelvin! I didn’t realize the problem is the division at plot. Wish you a nice day.