Guide: Cannon Circuitry

by Wiwiweb#7381 as of 0.5.123

Cannons can be a great way to transport items during early game or when needed in small quantities. But cannons are also dumb and will shoot indiscriminately, even when the recipient chest is full, causing untold damage!

We can avoid this with circuitry! Compared to rockets, cannon circuitry is much simpler, but there are some pitfalls to avoid.

This guide assumes you are a circuit beginner, and will guide you through the steps by explaining how they work. The goal is to show you the idea cannon setup, but also to teach you a little more about Factorio circuitry.

= Simple setup =

The idea is simple: We want to create a signal containing the items we need at the destination. "What we want" - "What we have" = "What we need"

We will send that signal to the cannon, using signal transmitters.

Then, we only shoot the cannon if there's anything we need.

Chest-side
We will count the quantity of items in the recipient chest ("What we have"), then take the amount we want in the chest ("What we want" which is an arbitrary value. For example, 500), then substract the quantity in the chest from the quantity we want using an arithmetic combinator. This gives us "What we need".

In the picture below, we also wire the signal to a pole. By hovering over a pole, we can see the value of the signal, which here would be our "500 - chest" value. This is optional but very useful for debugging circuits.



Cannon-side
On the cannon-side, we receive the "What we need" value that we created earlier. Cannons are dumb, so we cannot wire cannons directly, but we can wire the inserter that gives capsules to the cannon.

Simply enable the inserter when we need something, that is, when the value is greater than 0. You can do this directly in the inserter, without any combinator.

Note even after the inserter stops, the cannon will have a couple capsules left in inventory and will shoot a few more times. Make sure you set your required quantity to have enough empty space in the chest to accept a few extra shots.



= The big trap: Brownouts =

You may be wondering why we don't simply wire the chest to the signal transmitter directly (Sending "What we have") and set the inserter to only insert when the chest has less than what we want (signal < 500).

That will work perfectly fine in normal circumstances. But then, try removing the power pole powering your signal transmitter and see what happens...

Uh oh!

The issue is that if your signal transmitter or receiver ever loses power, even for a brief moment, all signals received will drop to 0. Suddenly, your inserter sees "0 < 500" and will fire at will!

Notice how in the proper setup explained previously, if the signal drops to 0, the inserter will not be enabled (0 > 0 is false). This is what makes it brownout-proof.

= Small improvement using a constant combinator =

You will of course need more than one cannon for your logistics. You could copy the setup above and have one arithmetic combinator for each cannon. But we can use a property of constant combinators to make a simpler setup.

When multiple signals of the same type are wired together, their values are added. We can use values in a constant combinators as our "request" values, negated to reproduce the substraction we did earlier.

Chest content + negative request values = Chest content - request values = negative "What we need"

This can let you have all of your request values for all your different item types with only a single constant combinator!

Because of this trick, our sent signal is now inverted compared to what we had before. Make sure to also invert the inserter conditions so that they only fire on a negative signal.

Just as before, inserters will still be disabled on a 0 signal, so we are still safe from brownouts.



Enjoy the constant sound of cannons firing!