RS latch oscillates.
TheBlueTroll opened this issue ยท 5 comments
Minecraft Version: 1.18.1
SuperCircuitMaker Version: 0.1.1
Description of issue:
when using a RS latch made of 2 red stone torches on a circuit, pulsing a side causes it to oscillate, instead of just switching states.
Steps to Reproduce:
build circuit as shown, switch off lever.
expected result: switch state from lever side on to other side on.
notes: longer pulses then 1 tick work as expected.
Seems like this is a actual difference to SCM 1. Even though the same behaviour can be found there with the operators.
The solution there always was to extend new signals to the number of operators inside the loop.
For some reason I like the new way, as it would be cohesive with the operators.
But I really dislike, that the solution would consume a 2x2 space with a subtractor and Quartz Resonator,
as there is currently no component to extend a signal, just to delay it.
An other alternative would be to implement a duty cycle to the ender pulsar, but that would make things to easy.
Not sure what to do about this, honestly. Tick by tick, this is what's happening:
[Tick 2] Signal turns off, and the torch reacts, resulting in both lines being off:
[Tick 3] The torches have no reason to stay off, so they turn back on again:
[Tick 4] These two states keep repeating:
From my testing it seems the old ender pulsar was active for 2 ticks instead of 1, which I think may've been a design choice I made to mitigate this exact problem.
That said, as dkranke pointed out, this setup needs a 2-tick pulse because of the combined delay of both torches (1+1).
If you were to chain more of them, you'd need an even longer pulse (you can test this with vanilla redstone as well, as something very similar happens there).
Granted, this is the most common torch latch arrangement you'll find - just 2 torches, so it might be worth giving it special treatment.
I'll need to give it some thought. My options right now are:
- Keep it as is - pulsars now emit a 1-tick pulse (reasonable case-agnostic option, but requires manual pulse extension)
- Go back to 2-tick pulses (fixes timing for this setup, but not others)
- Go back to 2-tick pulses, and add a "precision" 1-tick pulsar (same as previous, but allows for 1-tick pulses if needed)
- Add duty cycle selector for pulsars (maybe a bit OP? but definitely very useful)
- Add pulse extender component (the same setup can be built in a 2x2 with a lever and a pulsar/resonator)
I'd be tempted to pick 2+5 or 3+5, but most of this might very well be made obsolete by ASICs once they get added, so I don't really know.
Thoughts?
I really like option 1+5 or 3+5. But I really would prefer 1 over 3, as a 2-tick pulsar would be a extra component for just a single specific usecase, the 2-ticks component could be made later as a ASIC version.
Regarding the pulse extender component I hope it will have analog support as the Quartz Resonator.
Also a bit off-topic but assuming you have some way of circuit debugger (to create these images), could that be made into a tool that everybody could use? Freezing/slowing down circuits could be quite useful for everyone to find issues with their circuits.
Step-by-step circuit debugging is planned and will be implemented later.
I took those screenshots by disabling circuit ticking altogether and calling the tick()
method manually lol
That the RS-latch oscillates is not only a mod thing it is the problem of irl RS-latches too. The way around this is to let the set and reset only happen with a clock. The result is e.g. a JK-latch but this is a bit more complicated ( there is less complicated clocked rs-latch but it has problems too). I found this article but it is in german. This is my source but there are better ones i think.