Integrated Dynamics

Integrated Dynamics

63M Downloads

Implement the RS Latch (Flip-Flop)

Gravlok opened this issue · 9 comments

commented
  • ➕ Feature request

It would be really nice to see RS Latch included in ID. It gives the user to create a hysteresis loop, useful ie. for power generation control. If would really work well with #418. Even Wikipedia says "This is done in nearly every programmable logic controller" ;)

commented

It's no problem to do with external block getting strong signal and adjacent machine working from it by weak signal, but I really want to see RS latch block implemented without needing to do Vanilla mechanic or tricky Delayer (it also crashed my game in strange way when I was debugging with screen what is going on with variables)

commented

Might be convenient to have some block that can do exactly this. Perhaps some time in the future, as you can indeed already do it with the Delayer.

commented

The Delayer already lets you do that: https://www.reddit.com/r/feedthebeast/comments/7h0w1c/comment/dqnjysm

That's pretty much the same way that PLCs do it, actually.

reddit
Integrated Dynamics Help... • r/feedthebeast
Set up a Delayer that holds a value from a single previous tick. Build a criterion like "shouldProduce := x < 95% and (x < 75% or...
commented

You can't do it with just logic; you do need the Delayer. To prevent infinite loops, variables aren't allowed to use their (non-delayed) value to calculate their value.

commented

Ahh, fair enough, I'm using a redstone output and have a redstone reader for feedback.

commented

It's not that hard to do with logic: active = (!active && startCondition) || (active && !stopCondition)

commented

The simple solution would be to add Logical Latches to the Logic Programmer.

I think what people want is to get the functionality of an EnderIO Power Monitor or a vanilla redstone "RS NOR Latch" without having to use external redstone or blocks. The delayer can be used to give you a similar result, but it uses different logic to perform that task.

A simple "Logical SR Latch" with Set (S) and Reset (R) inputs that outputs Q would work. As long as it toggles to True when Set is True and stays True even when Set is off, until Reset becomes True, it doesn't need to be more complex. The typical RS NOR latch we build is just the easiest way to get the function of a Logical SR Latch out of vanilla redstone anyhow,

Another useful one would be a "Logical T-Flop" that accepts a single input and toggles between staying True or staying False each time it gets an input. Again, we don't need all the function of a vanilla redstone T flip flop, just the logical equivalent.

commented

@josephcsible It's very possible I'm just stupid, but I can't figure out how to do what you're talking about. Namely, shouldProduce = !stopCondition && (startCondition || producedLastTick) - I can't seem to figure out how to boot-strap this self-reference with the delayer. How can I define producedLastTick without having already defined the variable for shouldProduce... which requires producedLastTick....

commented

You can get producedLastTick from the Delayer's list of previous outputs, which is available for use even before you give the Delayer an input.