Page 1 of 1

First time using circuit network: making a "master" power switch

Posted: Tue Nov 09, 2021 4:03 pm
by dougabugg
I haven't used the circuit network that much, just copying some stuff from the wiki for petroleum/oil management when needed. I have a factory with multiple power generation sources spread out over the map. One of my "game play techniques" is to sometimes turn off my entire factory to reduce pollution so that biters won't be constantly invading, giving me time to upgrade sections, repair defenses, etc.

My goal is to easily have a way to "toggle" the electricity supply to my factory. At first, I just placed and removed an electric pole, then I started using a single "power switch", but now I have multiple power generation sources separated by a large distance, so I wanted a way to be able to remotely "toggle" all of them at the same time. I have some radars running off of solar/accumulators, and that allows me to select a distant power switch and toggle it on and off. I ran a green wire between my power sources, and set all the power switches to enable/disable if they receive a "check signal". Using a constant combinator, I have all my power sources and switches synchronized.

But I ran into difficulty remotely controlling the "check signal". You can select a distant power switch and toggle it from the map if there's a radar near by, but you can't select a distant constant combinator to toggle it's output. To create a method of toggling the check signal remotely, I ended up creating a "master" power switch, which when enabled, causes an inserter to remove a single item from a chest and onto a belt, and a second inserter continuously moves the item back to the beginning of the belt. When the master power switch is disabled, the interters are no longer powered, and the item is allowed to continue along a belt to another (always powered) inserter that puts the item back in the chest. Then a decider combinator outputs the check signal only if the chest is empty.

This solution works for my needs, but it doesn't feel very... elegant. Is this a good design for implementing a "master" power switch? Is there a better way to implement this?

Thanks!

Re: First time using circuit network: making a "master" power switch

Posted: Tue Nov 09, 2021 4:23 pm
by mmmPI
I think i understood the problem you are facing.

I'm not quite sure i understand the system you describe.

From what i understand you used a power switch and some belt/inserter logic to generate a signal "check" that allows you to toggle ON/OFF certain part of your factory to allow for pollution to be absorbed and defense to get some rest.

I think it's a fun solution :)

I'm not sure it's a "better" way but you can also use train as switch. If you use 2 loco facing opposite direction on a double headed piece of track with a station ON and OFF on each end. Then you can set the train stop to "read train" and output a signal check.( with as number the train ID but it has no consequence). It allow to generate a signal check from something remotely controlable.

You can refine it further and instead of having a 2 position ON/OFF make different station to send the train to generate any signal. ( It helps if your train-switch is able to get to any position from any position).

Re: First time using circuit network: making a "master" power switch

Posted: Tue Nov 09, 2021 4:49 pm
by dougabugg
Ah, using trains is a great idea! You can access them even without a radar, and they wouldn't waste electricity like inserters do. I haven't played around with connecting train stations to the circuit network, I will try them out in the future though, thanks!

Re: First time using circuit network: making a "master" power switch

Posted: Tue Nov 09, 2021 11:51 pm
by DaveMcW
You can also create blueprints with a constant combinator on and off, and place them to change it. This requires radar.

Re: First time using circuit network: making a "master" power switch

Posted: Wed Nov 10, 2021 1:31 am
by Tertius
I understand you need to toggle some circuit signal remotely and need to use a power switch for toggling, because a power switch can be toggled remotely, while a constant combinator cannot.
You need to translate the "I have power" state into a circuit signal.

This is a possible solution with circuit components only:
Screenshot 2021-11-10 022035.png
Screenshot 2021-11-10 022035.png (67.58 KiB) Viewed 6074 times


It works like this:
It checks if a counter is still counting.
The combinator to the right plus the constant combinator is an endless counter.
The middle combinator multiplies the counter value with -1
The combinator to the left is adding the original counter value with the negated value at its input. The resulting value is always +1, because the latency of the negation is 1 tick and the counter increases by 1 every tick. This combinator decouples the counter/multiplier and feeds the resulting value of 1 input into the network.

If you switch off the power switch, the counter stops counting. Since there isn't any more the difference of 1 at the middle combinator, the sum is 0 after 1 tick and that value is fed into the network. If you switch the power switch back on, the difference is again 1.
That means: signal=1: power switch on, signal=0: power switch off.

I'm wondering if this can be done with 2 combinators, but I didn't find a way that late in the night.

Re: First time using circuit network: making a "master" power switch

Posted: Thu Nov 11, 2021 12:47 am
by dougabugg
Thanks for suggestions! The blueprint placement is a useful and interesting trick/work around, and I like the powered-counter idea, maybe I'll try building that

Re: First time using circuit network: making a "master" power switch

Posted: Thu Nov 11, 2021 6:56 am
by GrumpyJoe
Since you can toggle a switch remotely and you are used to that, you could use (non constant) combinators that require power behind such a switch, to add a signal to the green wire.

Re: First time using circuit network: making a "master" power switch

Posted: Thu Nov 11, 2021 10:47 am
by disentius
Hm... How about placing an accumulator behind a powerswitch (the master) and make sure its power is used, a radar would do. then read the A value and send that to the network, and set all other power switches to enable if A > 99.

Re: First time using circuit network: making a "master" power switch

Posted: Thu Nov 11, 2021 12:01 pm
by Tertius
GrumpyJoe wrote: Thu Nov 11, 2021 6:56 am Since you can toggle a switch remotely and you are used to that, you could use (non constant) combinators that require power behind such a switch, to add a signal to the green wire.
A regular combinator doesn't stop output signals if power is lost. It just stops operating and outputs the last set of signals it generated until power is restored. It just freezes. There is no device that just stops output some signal if power is lost - if there were any, this thread wouldn't exist. You have to get this information indirectly.

A power detector within a pole, activated on demand just like the control that becomes available if you connect a belt with a wire, would be nice that would output a value of 0..100..∞ in percent of how much power demand can be satisfied. 0 is off, 1..99 is a brownout, and if above 100%, there is surplus power that could be stored in an accumulator if one were connected. I bet there is a mod for this.

Re: First time using circuit network: making a "master" power switch

Posted: Thu Nov 11, 2021 1:26 pm
by mrvn
Tertius wrote: Thu Nov 11, 2021 12:01 pm
GrumpyJoe wrote: Thu Nov 11, 2021 6:56 am Since you can toggle a switch remotely and you are used to that, you could use (non constant) combinators that require power behind such a switch, to add a signal to the green wire.
A regular combinator doesn't stop output signals if power is lost. It just stops operating and outputs the last set of signals it generated until power is restored. It just freezes. There is no device that just stops output some signal if power is lost - if there were any, this thread wouldn't exist. You have to get this information indirectly.

A power detector within a pole, activated on demand just like the control that becomes available if you connect a belt with a wire, would be nice that would output a value of 0..100..∞ in percent of how much power demand can be satisfied. 0 is off, 1..99 is a brownout, and if above 100%, there is surplus power that could be stored in an accumulator if one were connected. I bet there is a mod for this.
Accumulators output their power level. That's the only think that measures electricity in vanilla.

Re: First time using circuit network: making a "master" power switch

Posted: Fri Nov 12, 2021 6:46 pm
by dougabugg
Yup, I was so dissapointed that combinators continue to output their "previous signal state" when they lose power, lol. it would have made my setup so simple! Right now, I'm happily using the powered-counter solution posted by Tertius. I'm still wrapping my head around the circuit network mechanics of factorio (red vs green wire, tick latency, auto-summation of signal counts, etc), but I was able to "rebuild" their solution by analyzing the blueprint they pasted. Fascinating stuff!

Re: First time using circuit network: making a "master" power switch

Posted: Sat Nov 13, 2021 8:39 am
by adam_bise
Trains are definitely the way to go.

When you're dealing with a low power situation you need things that work without power such as fluids and train stops
ms.png
ms.png (1.64 MiB) Viewed 5857 times
The master switch combinator controls the remote power switch and turns on the light wirelessly.



Oh, and you can detect no power with a pump between tanks.

Fill one tank to 25k, leave the other empty. Then connect the two tanks with minimal UG pipes and a pump. Connect the two tanks again with several regular pipes forming a circle. The drag from the pipes will make one tank significantly higher than the other. Enable a train stop when the high tanks fluid signal dips below its normal high level.

Another thing I like to do is make an outpost go to sleep when it is not being used. For example, an ore site which delivers ore to enabled train stops. When all of the buffer chests are full and there are no receiving trains, the whole outpost shuts off. Then I measure light oil in a tank and add zero to its signal in a combinator. When enemies approach, flame turrets drain some of the light oil from a tank, while the combinator is frozen at its last signal.

The power switch itself doesn't need power to compare signals, so I compare light oil in the tank vs the frozen signal, and if it's different enable power and kick off a timer.

Re: First time using circuit network: making a "master" power switch

Posted: Sat Nov 13, 2021 1:43 pm
by adam_bise
Here I stamped BP and removed extra switches.
ms2.png
ms2.png (1.4 MiB) Viewed 5831 times