Guide: Cannon Circuitry

From Space Exploration
Jump to navigation Jump to search

by Wiwiweb, last verified valid for 0.6.120

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[edit]

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[edit]

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 subtract the quantity in the chest from the quantity we want using an arithmetic combinator. This gives us "What we need".

If you've never used circuits before, please note that combinators have 2 sides where you can connect wires: The input side, and the output side. Make sure to connect wires to the correct side. If you connect both together, you'll create a loop, which is useful for advanced circuitry but won't be used for this guide and will probably give you wild values.

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.

Chest-side circuit.

Cannon-side[edit]

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.

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.

Cannon-side circuit.

The big trap: Brownouts[edit]

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! 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 would see "What we have = 0" and will fire at will! (0 < 500 is true)

Notice how in the proper setup explained previously, where we send "What we need" instead, if the signal drops to 0, the inserter will not be enabled ("We don't need anything", 0 > 0 is false). This is what makes it brownout-proof.

Small improvement using a constant combinator[edit]

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 subtraction 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.

We switch the inserter's conditions to "signal < 0" Using a constant combinator with negative values

Enjoy the constant sound of cannons firing!