I'm changing resistance of resistor R1 and measure current from VU1. In this demo I start with resistance 1R so current is 9A, then I change resistance to 1G and current drops to zero, but at 15ms I change back to 1R and current should be 9A but it stays zero:
* first line is ignored
VU1 3 0 DC 9
RR1 3 0 R = pwl(time, 0,1, 7ms,1, 8ms,1G, 14ms,1G, 15ms,1)
* 0,1 = resistance starts at 1ohm, current should be 9A, this is ok
* 7ms,1 = at 7ms the resistance is still 1ohm, still 9A, this is ok
* 8ms,1G = at 8ms switch resistance to 1G, the current should drop to almost zero, this is ok
* 14ms,1G = at 14ms still 1G, still almost zero, this is ok
* 15ms,1 = at 15ms change to 1R, current should be 9A again but remains zero
.tran 100u 20m 0
.print tran time VU1#branch
.end
I found that when I add one extra point (16ms,1) it start working:
RR1 3 0 R = pwl(time, 0,1, 7ms,1, 8ms,1G, 14ms,1G, 15ms,1, 16ms, 1)
It seems that the last point is simply ignored.
The last point is not ignored, but is hit precisely. But then something interesting happens (which I had to figure out myself):
The resistor is calculated by V(3,0)/pwl(...).
Per design the B source pwl does not keep the last y value constant, but continues any y values beyond last x with the slope of last point to previous point. You may see this by adding and watching
B4 4 0 V = pwl(time, 0,1, 7ms,1, 8ms,1.1, 14ms,1.1, 15ms,1)
By adding another point, e.g. 16ms, 1, the user may set the slope to 0.
As the pwl of the resistor is in the denominator, and you have a very steep slope (approx. 1G/ms), the resistance value is quickly out of bounds, and the simulation fails beyond 15+x ms.
So it is inevitable to add another data couple to create a slope of 0 beyond 15ms, e.g. by 15.01m, 1.
Some examples in chapter 5.1.4 of the manual make use of the feature, but none uses 'time' as the expression.. We need a more detailed description of these issues, especially when using behavioral R, L, C (which internally all make use of the B source), and when using time instead of voltage of current as the 'driver'.
More detail was added to the manual in change [65ecb6a] by Holger Vogt.
Fixed in version 41.