Jump to content

True Decimal Counter w/ New 7-Segment Displays


Recommended Posts

Hello fellow automation junkies,

Here is a true decimal (base-10) counter I threw together using the new Signal Counter automation buildings in ONI. The way the counters are designed don't particularly lend themselves to be cascaded very easily. The major issue lies in the fact that the counters output at "9" instead of when a rollover occurs (9->0). The other issue, is the counter goes back to "1" instead of "0" when exceeding the max value.

The solution to this problem was to memory the "9" output in the SR memory and make use of it on the next cycle by using the AND gate. Here is the step-by-step:

  1. Counter receives clock pulse and transitions 8->9
  2. Counter sets the memory ON and the output of the memory goes to the AND gate
  3. Next clock pulse goes to both the counter and the AND gate
    • Counter transitions 9->1
    • Output of AND gate resets 1st counter to "0"
    • Output of AND gate increments 2nd counter
    • Output of AND gate resets the memory
    • Output of AND gate tries to clock the next AND gate
       
Spoiler

image.png.44ac90124865f7e118ca30485105dea9.png

image.png.2c0983246c71938b083b5f9fae2a13ff.png

Due to the race condition existing between the output of the memory and the clock input, it's important that the ON time for the input is only 0.1 seconds. You can get a 1 second period by setting the OFF time to 0.9 seconds (0.1 + 0.9 = 1 second).

Spoiler

image.thumb.png.f69b98f0e09f8eb4b267398aa349985c.png

If you want access to the rollover events, simply use the outputs of the AND gates.

One more thing I wanted to mention for this. You can use any arbitrary input (like a weighted pressure plate, for example) as long as you use an edge detector, which will cut the signal pulse duration down to 0.1 seconds.

Spoiler

image.thumb.png.1d374f4f0e3e9e5a02014df1a016c7fd.png

image.thumb.png.d2dbb6e3c16deb5d38a02c117868c5c0.png

Anyways, I hope you like it. I'm sure you guys could come up with all sorts of cool uses for something like this. You can now count anything you want!


Update:
Something else I just realized, you can pretty easily create a seconds and minutes counter by setting the 2nd counter's max value to "5".

1 hour ago, thomathy007 said:

The major issue lies in the fact that the counters output at "9" instead of when a rollover occurs (9->0).

Leave the counter at default then it functions correctly as a true decimal counter. If you set the counter to 9 then it's a base 9 counter.

If you had seen the Klei live stream then you would have known this quirk of the counter. Sorry that you've wasted time on trying to fix a problem that doesn't exist because it's unclear in the building description still.

10 hours ago, Chipplyman said:

I expect a base 9 counter to go from 0 to 8 not 1 to 9. Is it intended that the output is wired to the reset? 

That's the caveat. It counts to 1 to 9 if set to 9. Only if set to default does it currently correctly function as any real base number counter, and then only as a decimal counter. It doesn't even function correctly as a binary counter as it starts at 0 when reset or built then counts to 2 and resets to 1.

The devs are looking into it they said on the live stream so expect it to not be an issue for long.

But I honestly don't see how they can solve the issue without changing the UI selection.

The problem is that if just used as a straight up single digit counter you want the output to go high and reset when the count is reached. Whereas when used as a multi-digit counter you want the output to go high and reset on the count after the set number is reached.

The simplest way to do this is to allow you to set both the number you start from and the number you want to count. So if set at 1 for the first number and 8 for the second number then it (starts at 0) counts 1 to 8 and on 8 output goes high and it resets to zero. If you instead set the first number to 0 and the second number to 7 then it should start at 0, count 1 to 7 and on the next input output goes high and reset to 0 as you'd expect a base 8 counter would.

That would mean that anyone just wanting a single digit counter can use the default 1 as the first number value, and only if you want a multi-digit counter you would select 0 as the first number.

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...