## Semi-complex circuit

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Melodi-of-Crystals
Burner Inserter
Posts: 15
Joined: Wed Mar 08, 2023 1:18 pm
Contact:

### Semi-complex circuit

Is there a way to create a circuit that detects when a variable changes, and output what direction it changed in?

Most of my base right now is just waiting for bots and construction, so I built visual trackers of how much of the robotics network is in action. But I'm trying to build a simpler version that just tracks when the available number of bots goes up or down and flashes a light or something simple like that.

Might be generally useless in this case but can likely be incorporated into other builds eventually.
Nintendo switch - 1 rocket launched

Tertius
Filter Inserter
Posts: 390
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

### Re: Semi-complex circuit

The most simple solution is one arithmetic combinator that does operation * -1 with EACH as input and as output.
Connect the value you want to watch to its input with a green wire.
Connect its output to a power pole or to some other device input with a red wire.
Additionally, connect the value you want to watch directly to the pole/to the other device input with green wire.

Now the power pole/the other device has the input (green wire) and the negated input (red wire).

The negated input is 1 tick late. Both sum themselves up, so if there is some change in the input, the summed value is the difference of the current signal and the previous signal.
If the watched value goes up, the sum is positive, and if the value goes down, the sum is negative. It's zero, if there is no change.

Due to the EACH operator, the difference is computed for each input signal at the same time.

If you connect a lamp to the output that will light up if the output is positive, you will see a flash. To get some kind of meter with multiple lamps, give each lamp a condition with increasing numbers: the first lamp with ANYTHING > 0, the next ANYTHING > 5, the next ANYTHING > 10. The last lamp will flash only if the diff is > 10, while the first lamp will flash at each change.

mmmPI
Smart Inserter
Posts: 2052
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

### Re: Semi-complex circuit

Tertius wrote:
Fri Mar 17, 2023 3:51 pm
The most simple solution is one arithmetic combinator that does operation * -1 with EACH as input and as output.
I agree this is how to detect when a variable changes. Creates a 1 tick delay between the signal and its negative version so that when the variable changes, you have non-zero sum during 1 tick.

Making the signal negative using an arithmetic combinator also happen to delay the signal by 1 tick.

Then one could feed the original signal and the negative version on a power pole as Tertius explained.

One could also use 2 decider combinator, in the case where you monitor a signal X, one decider combinator could be set to ouput 1 "RED" if X is negative, and the other 1 "GREEN" if X is positive. Their input being both the original signal and its negative version for each decider. This gives a clear indication of the direction of the change. If X is the number of available robot and you connect lamps to the output of the decider combinators to "use color", every departure will create a red flash, every landing at roboport a green one.

I don't know how useful it is,but if you connect several combinators doing each +0 => each in a row, with each their own lamp, passing the colored flash that will create somewhat of a lane-record or make the flash move and maybe easier to see with the persistance depending on the activity of the robots

Melodi-of-Crystals
Burner Inserter
Posts: 15
Joined: Wed Mar 08, 2023 1:18 pm
Contact:

### Re: Semi-complex circuit

Thanks to both of you, I got this circuit added and could watch the network usage really well. Finally got my first rocket launched!
Nintendo switch - 1 rocket launched