Semi-complex circuit

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

Semi-complex circuit

Post by Melodi-of-Crystals »

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 -
- 3 rockets launched :lol:
- Two worlds made too large to load
- Five times jumpscared by biters when the sound was off
- Still think I can outrun the train (nope)
- Trying to find the maximum SPM of a switch

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

Re: Semi-complex circuit

Post by Tertius »

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
Smart Inserter
Posts: 2674
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Semi-complex circuit

Post by mmmPI »

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
Inserter
Inserter
Posts: 26
Joined: Wed Mar 08, 2023 1:18 pm
Contact:

Re: Semi-complex circuit

Post by Melodi-of-Crystals »

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 -
- 3 rockets launched :lol:
- Two worlds made too large to load
- Five times jumpscared by biters when the sound was off
- Still think I can outrun the train (nope)
- Trying to find the maximum SPM of a switch

Post Reply

Return to “Gameplay Help”