diff --git a/src/com/lushprojects/circuitjs1/client/SchmittElm.java b/src/com/lushprojects/circuitjs1/client/SchmittElm.java index 9b639516..ce1edfc5 100644 --- a/src/com/lushprojects/circuitjs1/client/SchmittElm.java +++ b/src/com/lushprojects/circuitjs1/client/SchmittElm.java @@ -31,8 +31,13 @@ public SchmittElm(int xa, int ya, int xb, int yb, int f, } int getDumpType() { return 182; } + + double lastOutputVoltage; + + void startIteration() { + lastOutputVoltage = volts[1]; + } void doStep() { - double v0 = volts[1]; double out; if(state) {//Output is high @@ -60,7 +65,7 @@ void doStep() { } double maxStep = slewRate * sim.timeStep * 1e9; - out = Math.max(Math.min(v0+maxStep, out), v0-maxStep); + out = Math.max(Math.min(lastOutputVoltage+maxStep, out), lastOutputVoltage-maxStep); sim.updateVoltageSource(0, nodes[1], voltSource, out); }