Page 1 of 1

RS Latch

Posted: Thu Dec 12, 2024 5:59 pm
by GreyFalcon70
I have tried to use the single latch and multiple others they did not work. Always ended up allowing unwanted results. So I offer this up. It works for what I do with it.

Image

The Latch allows trains to move forward only when lower limit is reached and continue until the upper limit is reached.

Please note the Red wire from the input to the output on the latch decider it is hard to see.

Image

Conditions for the circuit are shown.

Re: RS Latch

Posted: Thu Dec 12, 2024 8:03 pm
by Tertius
GreyFalcon70 wrote: Thu Dec 12, 2024 5:59 pm I have tried to use the single latch and multiple others they did not work. Always ended up allowing unwanted results.
It's difficult to guess what examples you tried to implement, but it's really easy to build a 1 combinator setup, if you make it up yourself.

Just forget what you read about latch and about set/reset.

The task at hand is to enable something if an input signal is above an upper limit and keep it enabled until the input signal goes below some lower limit.

With one decider combinator we have the functionality to produce an output if one or more conditions are satisfied, so we can do it with just one decider.
So what conditions do we have that should produce an output?
The first condition is the upper limit. The decider should output S=1 if [input signal] > upper limit
The second condition is the lower limit. The decider should not output anything if the signal is below the lower limit. We want the inverse: it should output S=1 if the signal is above or equal to the lower limit AND if the output is already active.
So to get the previous state, we need to read what we output the previous tick, which is implemented by connecting the output with the input in the decider.

So, as decider conditions, we need to set:
[input signal] > upper limit
OR
[input signal] >= lower limit
AND
S=1

As output, set
S=1

And that's all.


Example with lower limit 500 and upper limit 1000:
out.mp4
(2.09 MiB) Downloaded 62 times
(it's not that visible in the video: don't forget to connect the input and output of the decider with green wire.


Re: RS Latch

Posted: Fri Dec 13, 2024 12:02 am
by GreyFalcon70
Thanks for your post, however I tried your latch and it doesn't work. The latch does not maintain until the lower limit is reached. It releases the train before lower limit is reached.

Re: RS Latch

Posted: Fri Dec 13, 2024 12:34 am
by Tertius
Did you connect the input and the output of the combinator with green wire? That's almost invisible in the picture.

Re: RS Latch

Posted: Fri Dec 13, 2024 1:16 am
by GreyFalcon70
Yes.
For some reason, I don't know if it has something to do with the fact that I am controlling a chain signal but the train releases long before the lower limit is reached.
Image

My trains stay in the pen until the latch allows the chain signal to change to green.

Re: RS Latch

Posted: Fri Dec 13, 2024 9:59 am
by Tertius
I'm sorry, but I'm unable to guess your circuit setup from a huge screenshot, and I'm not familiar with the modded entities you use. You will need to work out this yourself.

If this was my base, I would create multiple unloading stations, dedicated to just one material. Actually, that's what I did ever since. Micro managing train traffic with circuit controlled signals is a waste of time in my opinion, because this stops working as soon as the tiniest thing is changed in the track and train layout.

You created the problem that you need to decide which of the 3 different cargo type trains is allowed to advance to the front station. With 3 dedicated differently named unloading stations, this would happen automatically without any circuits. That would be a robust setup that just works with no edge cases (edge cases always exist with circuit controlled things).