PRC digital timer display?

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Algester

New Member
Jul 29, 2019
378
0
0
I have been checking with the PRC functions but I cant seem to get to understand how the seven segment encoder and decompose integer to decimal functions work
I do know that integer to decimal would be able to split the numbers into the single decimal places but how does it work with the seven segment encoder
 
Last edited:

mathchamp

New Member
Jul 29, 2019
153
0
0
Generally a seven segment encoder takes a four bit binary integer and converts it into a seven bit output where each bit corresponds to one of the "segments" on the seven segment display (https://en.wikipedia.org/wiki/Seven-segment_display). For example, if you input 0 (0b0000), there are two possibilities. The first is that the output for the middle segment (G) is 0 and the rest (A, B, C, D, E, and F) are 1. The second is that the output for the middle segment is 1 and the rest are 0.

In real life, which one depends on the type of seven segment display it was designed to drive (e.g. common anode vs. common cathode). Basically, the result is that, if the encoder output is correctly connected to the display, the segments corresponding to the digit "0" light up (or, for an LCD, darken). In game, you basically want to know whether you require a logic 0 or a logic 1 to correspond to a "lit" segment.

A seven segment encoder can be built from discrete logic gates (so you can even build one in Vanilla with just redstone), but, in real life, a seven-segment encoder is usually an integrated circuit (i.e. all the gates on one silicon wafer). In MFR, the seven-segment encoder circuit is the virtual equivalent to a real-life seven-segment encoder IC.


Integer to decimal would basically repeatedly integer divide the number by 10 and keep the remainder as the digit, until the quotient is zero. So for example, if the number is 538, you divide by 10, and get the quotient 53 and remainder 8, so the one's digit is 8 (0b1000). You divide by 10 again, the quotient is 5 and the remainder is 3 (0b0011), so the ten's digit is 3. You divide by 10 again, the quotient is 0 and the remainder is 5 (0b0101), so the hundred's digit is 5. The thousand's digit, etc. are zero. Each digit is fed to a separate seven-segment encoder which is connected to the corresponding display.

So, say you have four digits. You then have one Decompose and four Encoders. You feed your integer to the input of the Decompose, and the decimal outputs become the inputs to your Encoders (D0 for the ones place, D1 for the tens place, D2 for the hundreds place, D3 for the thousands place). For each encoder, you can then run the seven outputs to your display (which can be redstone lamps, pistons, or whatever). Although if you have more than a few digits you'll probably run out of rednet channels and sides so in that case you can have one PRC do the decimal conversion and have a few PRCs containing a few encoders each, and send the digits from the decomposer PRC to the encoder PRCs through rednet cables.
 
  • Like
Reactions: desht