Page 1 of 1

Counter + Reset?

Posted: Mon Jul 06, 2020 1:37 am
by Spades68
Train logic problem. One of the 'When' statements need a permanent counter circuit that can take increments and decrements, and the other 'When' statement needs a permanent counter that gets reset upon outputting a value.

Problem: I have an infinite amount of trains in a lane, waiting to be released into the train stop area.

The train stop area has 5 stops (T-5).

When: 1 train is released into the train stop area, a 'counter' is incremented by 1 (++)
When: 1 train arrives at a train stop, when the rail signal for that stop goes from RED (train entered stop) -> GREEN (train fully left stop), now decrement 'counter' by 1 (--)

IF T-5 >= counter THEN the rail signal that releases the trains == GREEN

Is this possible? Examples if so please, trying to learn :)

Re: Counter + Reset?

Posted: Mon Jul 06, 2020 2:03 am
by DaveMcW
Your specific problem can be solved without using a counter.

Set each train station to read train ID, and attach it to a decider combinator that outputs 1 if the ID is greater than 0. The output from the 5 decider combinators is your train count.

Re: Counter + Reset?

Posted: Mon Jul 06, 2020 2:41 am
by Spades68
DaveMcW wrote:
Mon Jul 06, 2020 2:03 am
Your specific problem can be solved without using a counter.

Set each train station to read train ID, and attach it to a decider combinator that outputs 1 if the ID is greater than 0. The output from the 5 decider combinators is your train count.
The problem I run into is when a train isn't in a slot, the filter will allow infinite trains through the queue UNTIL a train arrives at that slot. I need to the system to COUNT IN and COUNT OUT before allowing more in.

So for example: The train slot and the queue entrance are like 1 mile apart, so the amount of time between the first train getting released from the queue, until it fills that slot, the system will keep de-queuing as many trains as it can.