Commit a483af3
Fix SCR oscillation: use latching trigger/hold logic like TriacElm
The previous combined formula (ig/triggerI + ia/holdingI > 1) re-evaluated
the on/off state every timestep without hysteresis. With a series resistor,
the anode current would hover near the threshold: the SCR would turn on,
current would rise, then the voltage drop across the series resistor would
reduce anode current below the threshold, turning it off again -- causing
oscillation between two states.
Replace with separate trigger and hold conditions:
- Gate current exceeding triggerI latches the SCR on (state = true)
- Anode current dropping below holdingI turns it off (state = false)
This matches the latching behavior of a real SCR and the pattern already
used by TriacElm. An SCR with a series resistor should latch on and remain
on once triggered, which is what LTspice shows for the same circuit.
Also reset state to false in reset() for proper initialization.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 3315aba commit a483af3
1 file changed
+11
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
225 | | - | |
226 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
227 | 232 | | |
228 | | - | |
229 | | - | |
230 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
| |||
0 commit comments