Factorio - Seven Segment Display Tutorial

Channel:
Subscribers:
915
Published on ● Video Link: https://www.youtube.com/watch?v=93KZPZSkgjE



Factorio
Game:
Factorio (2020)
Category:
Tutorial
Duration: 1:15:25
5,832 views
104


In this video, I show how to make a relatively simple seven segment display in Factorio. This, while simple to understand, uses a lot of components (more than 20 combinators per digit). I then explain the process I when through to reduce this to only 4 combinators per digit.

You will need a basic understanding of Factorio's circuit network to follow along.

Blueprint Book: https://factorioprints.com/view/-LCBqlZMQrvROJunHaAU

Informational pages:
https://en.wikipedia.org/wiki/Seven-segment_display
https://en.wikipedia.org/wiki/Modulo_operation
https://en.wikipedia.org/wiki/32-bit
https://en.wikipedia.org/wiki/Two%27s_complement
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts

Basically, we start off with a single digit seven segment display that has 10 constant combinators (for the numbers 0-9) that each has the correct signals to turn on the correct segments to display the coresponding number, with 10 decider combinators that only foward along the signal for the number currently being input.

From there we expand from one digit, to three digits, adding two arithmetic combinators to pull a single digit out of a multi-digit number, displaying each digit on one of the seven segment display.

However, this leaves leading zeros for small numbers that don't use all the digits. I show how to eliminate the leading zeros with one decider combinator and a small bit of re-wiring.

I then show how to re-use the constant combinarots for multiple digits. This reduces the number of combinators to 13 per digit plus 10, for a multi-digit display. This is still a lot of combinators. We are using 10 combinators to stor the signals needed for the 10 different digits. If there was a way to encode the states for each digit into one number per signal, we could replace the 10 constant combinatorswith one combinator, and the 10 deciders per digit with a circuit to decode the compressed signals for whichever digit we want to display.

It turns out that this is possible. We can encode the state for each signal into the bits that make up the number we assign to the signal for that segment. Then by right shifting and ANDing with 1, we can extract if that segment should be on or off. This would make the decode take two arithmetic combinators. We can actually do better than that. instead of putting the signal bits and the lower bit positions in the encoded number, we can put then into the upper bits. Then, by shifting left and checking for negative numbers, we can tell if the highest bit is 1 or 0 by seeing if the result is negative or positive. the left shift automatically discards and higher bits, making the binary AND operation unnecessary.

So having come up with a way to compress the signals into one combinator, I go ahead and build the circuit that uses these compressed signals. The comes out to be 4 combinators per digit. Most digits have a divide and a mod (%) combinators that isolate a single digit, a shift left combinator that uses that digit to decode the signals to display that digit, and finally a decider combinator that is used to eliminate leading zeros. The first digit lacks this decider, but it does have the constant combinator that contains the encoded signals. then, we just need one additional arithmetic combinator to convert the signal we want (either a particular item, or the everything signal) to the 'A' signal that the display expects.

Not shown in the video, but included in the blueprint book is a version of this blueprint that contains one more combinator per digit that allows passing a color to the display for the digits to light up in that color. The combinator is needed to precent the signals from each of the digits from mixing.

I then briefly go over how I went from a seven segment display, to 5x5 and 5x7 matrix displays. It's basically the same process as the seven segment display, but instead of having seven signals, we are now using signals for each individual pixel, so 25 or 35 depending on the display size. However, we are now also using more then 10 characters. The encoding we used for the seven segment display is actually capable of supporting 32 different 'characters' as it is encoded into a 32 bit number, but for text, more than 32 characters are needed (37 for A-Z, 0-9 and space, at least). So for the text displays, I need severs sets of 32 character encoded signals, and the decoder need to get more complex to pick the correct set of signals to decode. However, this isn't too much of a complication comparativly as is works out to still be fewer combinators for each character of the full ASCII text display than we used for the first single digit seven segment display of this tutorial.

Please leave a comment if you have any questions or comments and I'll try my best to address them!







Tags:
Factorio
seven segment display
circuit network
tutorial



Other Statistics

Factorio Statistics For TroZ

Currently, TroZ has 27,023 views for Factorio across 126 videos. The game makes up over 4 days of published video on his channel, or 20.78% of the total watchable video for Factorio on TroZ's YouTube channel.