D8s

Octas/cyber


Electronic D77 dice Project.

So, I figured that an electronic-dice project might be thematically appropriate for the CyberPunk variant of my Octas 8-sided-dice Table Top Role-Playing Game.

There are a number of ways this could be achieved. Going back to my own childhood (just after the dinosaurs died out), I recall buying and building an educational hobby kit for an 'electronic dice'. This used a 1-of-8 linear counter with the seventh output wired back to reset, causing it to cycle through outputs 1-6, and by running the counter too fast to see while the button is held pressed and freezing it when released, you have a simple but effective 1-6 random number generator.

Electronic circuit board.

For a 1-8 (or 0-7, it is just a matter of how you label the LEDs) you don't even need the reset line as a 4022 IC is already an 8-stage linear counter so will loop itself automatically. A linear count is perfectly functional, but a bit boring!

If you want to get fancy, you could feed a 3-bit binary counter into a BCD-decoder chip to drive a 7-segment display with Hindu-Arabic numerals as used in most of the world today (or for a 0-9 counter, to make a D99/D100 dice, use a pair of 4033 chips which have the counter, decoder and LED-drive transistors integrated, but no built-in way to not count in tens).

I chose the dot pattern on the Octas dice deliberately to stay away from culture-specific symbology, though, so that way isn't for me! And my distinctive dice have since become a fairly important part of the identity of the Octas games.

So, I was going to give up since my options were either uninteresting or inappropriate.

I have no idea how my brain works these things out, as I never seem to be around when it does it, but about three years after I designed the origional physical dice as a 3D-print self-teaching exercise, something dawned on me.

Sketch of circuit showing how LEDs can be simply wired.

This was entirely unplanned, of course: my dot-pattern was done that way purely for reasons of symmetry and the associated aesthetics. But it turns out that the thing is already in binary anyway! So no need for a custom decoder chip which I don't have my own personal silicon-chip foundry to make anyway!

So it is looking like all I need is a single 6 (or more) bit binary counter chip, a clock-oscillator, some transistors and a couple of resistors and capacitors. And the LEDs, of course!

The CD4060 integrated circuit is a 14-bit binary counter that exposes 10 bits on its external pins (I only need six of these anyway). It also includes a built-in clock oscillator, which saves me from needing to provide extra circuitry for that.

The external transistors are needed because the binary-counter chip can't output enough power to properly drive a single LED, let alone four on bits 3 and 6.

Dick Smith Fun Way kits were notorious for over-driving the ICs to save on buffer transistors, which made the LEDs dim and would likely eventually damage the chips, but they were only learning kits, not consumer products, so I give them a pass. I try to hold myself to a higher standard though!

And some resistors to properly power-limit the LEDs so they are not over-driven by the transistors to quickly burn out!

Oh, and the LEDs themselves of course. I think I'll go with early-2000's-tech blue ones. You, of course, can use whatever colour you like!

Blue LEDs were invented in the mid-90's and consumer-electronics companies went a bit ga-ga over putting them in everything for about a decade!

Intense blue light in the evening is now known to disrupt sleep patterns.



Circuit Design.

I used KiCad (open source) to do the circuit diagram.

circuit diagram

R1, R2, and C1 drive the inbuilt-oscillator clock.

SW1 blocks the clock signal while the button is released, which halts the oscillator and hence the counting. Pressing it re-connects the clock signal to run the counter (too fast to see). The two single pin-headers either side are just me being lazy and manually adding extra pads to support multiple switch types without creating a new custom switch-layout!

The 1k-ohm resistors feeding the transistors stop their inputs being overloaded, and the transistors themselves switch the LEDs. The LED's have their own banks of 150-ohm current-limit resistors too.

Resistor Network.

I deliberately didn't use a pair of packaged 7-resistor nets here both because discrete resistors just look better in this particular context, and I want all parts used to be as readily-available as possible.


Power is a 5VDC supply. Maximum current for the circuit should be a little under 300mA (all 14 LEDs lit, plus a bit for the circuitry). I have two pin-header rows there, one 4x 2.5mm for a standard cable-header, and another 5x2.0mm as I have some USB cables from dead mice that will fit that to supply standard 5V USB power. Either can be used, and the other ignored.

Technically, the 4000-series chip on this board can handle up to 20V, but if you change the input voltage, be sure to re-calculate the LED-current resistors across the top as they will need to change!

C2 (in the power-input block) is a small electrolytic power-smoothing capacitor, just so currents on the power bus don't jolt about about so much as LEDs switch in and out rapidly while the counter is cycling. Probably optional, but it's just polite! I haven't specified the value as it isn't too important, and I will just be using whatever I have on-hand in the dozen-or-so-µF range.

Note that on the 14-bit counter chip, I have juggled my output bits around a little. This was to simplify PCB layout, and won't have any adverse effect on the operation of the dice, since we are not actually using the counter to count in sequence. Having the bits out of order actually makes it harder to cheat by 'tapping' the button quickly to try to advance the counter by only a few steps rather than holding it long enough to get a properly random result. .... Also, I ended up with output-bit Q9 (the slowest-changing and so most-strobey bit) on a single-LED channel, where it is hopefully less seizure-inducing than it would be blasting out of 4 LEDs!


Testing on a Breadboard.

It is always a good idea to test out ideas and designs (particularly hair-brained ones) prior to committing money to having circuit boards printed. The easiest way to do this is a breadboard, which is a block of plastic with a grid of holes under which is a bunch of horizontal or vertical connecting wires. This allows you to connect up electronic parts ad-hoc and quickly re-arrange or swap components if you made any design mistakes.

So, I gathered all my parts together (I only had to buy the 4060 chip as I had all the other components already on hand). Then I assembled it all. And it worked! It was running through its number-sequence a little slowly at first, so I had to play around with the values of C1 and R1 to get the oscillator running as fast as possible without going too fast and jamming the chip!

I only wired the high dice LEDs for my test, as I needed to verify the slowest-cycling LEDs were still too fast to predict. The other LED-set are identical circuitry, so I am happy to trust they will work too. My messy patch-wiring was already hairy enough! (Also note, the LEDs do not strobe as strongly in real life as my phone camera makes it look here!)


IMPORTANT! Below has not been tested yet. I will be having the board printed and then assembling the parts on it in the next month-or-so. Stay tuned....

Final PCB.

Breadboads are ideal for testing, but are not well-suited for a finished product (though - done neatly - breadboard work can be an artform in itself!) A Printed Circuit Board (PCB) is ideal for a finished device, especially if you intend to actually use it regularly! KiCad has the facilities to turn the circuit diagram into a PCB. (No, I'm not going to teach you how to do that here. You need a proper training tutorial - or a willingness to just sit down and brute-force your way through it, like I did, in the snow - if you need that!)

printed circuit board

I did actually get it all on a single-sided PCB, but then decided I wanted all the circuit-traces on the top of the board so they could be seen when the device is in-use (since this is cyber, and circuit-traces are part of the aesthetic!) So I moved all the traces to the top layer, and since I have to still have a bottom layer to solder to, I made that also my ground plane (removing the ground traces from the top layer, as they were - by far - the most convoluted and messy-looking!) At my board-manufacturer, a single- and double-sided PCB cost the same anyway.

And here is what KiCad estimates the board will look like:

3D-render of printed circuit board

The four holes between the top resistor banks are for cable-ties to secure the power cable. I also have two pin-header pad-sets for power, one is for a standard 2.5mm-spacing header and the other a 2mm header for some USB-C cables from dead computer-lab mice I have spare in my parts-salvage box (only using them for power, leaving the data and sense lines not-connected).

Alternate PCB layout.

I also tried laying out the board with the LED and resistor banks swapped, but it looked too top-heavy. Having that top margin above the LED clusters does make a notable visual difference!


Then off to PCB-Way with my files, and after a quick bit of back-and-forth with their helpful technical-sales staff (because I don't do this nearly often enough to get everything right first go!), I ordered 5 boards, the minimum quantity, on the cheapest production process, costing only $US1 each (plus shipping).

The board-submission process is still a bit involved, so I will go into some detail in the below white-box section.

Submitting a PCB design for manufacture.

This section is not sponsored, I have just had a lot of positive experiences with PCB-Way, so tend to use them by default.

First, see if your PCB manufacturer has an export plugin for KiCAD! Getting the multiple engineering files exported, and zipped into a bundle for upload is a tedious and knowledge-dense process, and will be slightly different for every manufacturer. Having a little button to do it all for you will save you a lot of time and hassle.

PCB-Way does provide such a plug-in. In KiCADv9.x go to the [Tools] menu and select [Plugin and Content Manager]. Choose the [Fabrication plugins] tab and select the export plugins you want. In the picture below, the top (selected) one will open a ready-to submit job on PCB-Way's website in your default browser. The other will just generate a local zip file of everything you need for you to submit manually. Finally, click the [Apply Pending Changes] button at the bottom to install your selected plug-ins.

Selecting extra export tools.

Now, in your board-layout window, you will have an extra button or two to automate the export process.

Extra export buttons.

And a fun little gotcha! KiCAD defaults to an 80x100mm board which is a very common size and often much cheaper to manufacture. (Presumably) due to rounding-errors between millimetres (metric) and mils (imperial: one thousandth of an inch), when you export the board to PCB-Way, it ends up as 80.04x100.04mm. This causes you to be quoted the 'custom sizing' rate which is almost 5x the price! Edit off the .04mm from each dimension to get the much cheaper pricing (and likely reduce wasted materials at their end).

Fixing the costly rounding error.

And another little gotcha (isn't industrial manufacturing fun!) is that the Edge Cuts layer in the board-layout system gets converted to a different layer on export to Gerber format, and this will confuse PCB-Way (and likely other manufacturers). While this layer is very useful for properly laying out the board, it is probably a good idea to disable or delete it prior to export. Otherwise just add a note to the job (or the query you get regarding the job) that the outside box is the board edges.

I don't believe this is so much a problem with PCB-Way but the many-decades-in-use Gerber industrial file formats being less a 'standard' and more a 'convention' with everyone just a little bit different and slightly incompatible (rather like CE/IT manufacturers seem to treat HDMI!).

PCB-Way's production engineers will try very hard to make sure everything is just the way you intended before even letting you pay them, which is one reason I like them.

In my case, I also pre-warned them that my 'mounting holes' are not mounting holes (just holes, not for putting screws through) and the multiple over-layed switch and power plug parts are inside each-others' defined keep-out spaces intentionally, so they would know not to worry about those either (and I accept any associated risks with this non-standard part of my design).

I also changed the default 'solder mask' colour to black, since that will determine the colour of the surface of the board. It cost the same, and for this board it is a better colour, for contrasting with the LEDs, as well as just looking cyber-cool.

And finally, check your shipping options. I was happy to wait a few weeks, so got the cheapest one. Your (and your order's) mileage may vary!

[Picture of delivered PCBs]

And electronics assembly.

[Picture of soldering parts on to PCBs]

IC-socket

If you are newer to soldering components, I recommend spending an extra dollar buying a 16-pin-DIP IC-socket to solder to the board and then plugging the Integrated Circuit in to that, rather than soldering the IC directly, as the parts are a bit heat-sensitive.

Also take care handling the pins, as 4000-series CMOS chips are somewhat sensitive to ⚡static electricity⚡ damage. A zap too small for you to even feel, can kill them! 💀 Working on an anti-static mat, is ideal.


One physical modification I made to my components was carefully filing the round tops off all of my LEDs. This removes the 'lens' effect that this rounding is intended to create, and the matt surface makes them much more visible from a far-wider viewing angle and not blinding from right in front of them!

[Picture of filing of an LED-lens]

filed LED

Particularly in transparent LEDs, you can easily see the little LED-chip inside, and it is half way down the plastic shell, so as long as you stay well away from that, you can file off the rounded top without issue.


LEDs are also designed to be mounted 5mm above the circuit board, and have spurs on their legs to stop them being over-inserted in their holes. For my own dice, I cut the legs just above these spurs so I could mount them right on the board. This allows the assembled board to be thinner, top to bottom, and also stops the LEDs getting bent over if the bare board is rough-handled or dropped. It does come at the expense of slightly increasing the chance of damaging the LEDs during soldering, as the actual LED chip inside is now 5mm closer to heat from the soldering. It works for me, but you can do it however you prefer!

[Picture of snipping LED legs inset in picture of board-seated LEDs]

During assembly, be aware of polarised components, that only go in one way:

I have all the polarity markings in the silk-screen printed to the component side of the PCB (as well as most component values) to make assembly easy.

And if you need a reference for the colour code markings on the resistors, websearch 'resistor colour codes' or go strait to Wikipedia. .... See also: XKCD 227.

Next, I used some small cable-ties through the four holes at the top of the board to secure my power cable.

[Picture of cable-ties]

Because this board is intended to be 'bare' since displaying it is part of the whole idea, after soldering and testing, I coated the back with a few layers of spray-varnish to seal it a bit against static electricity when being moved or handled.

[Picture of varnishing]

Then I stuck some rubber feet on the bottom, so it will be stable on a desk and the now-varnished solder blobs on the underside have some clearance so the varnish doesn't wear off again!

Gluing on a rectangle of rubber from an old mouse-mat or wet-suit (it's the same stuff!) is also a good option to combine 'feet' and underside-protection.

[Picture of feet, and ideally of rubber-mat version, too]

And the device is finished.

[A short WebM video of it in operation]

Also, I made these first-run boards using the absolute-cheapest process available, and once I have verified they truly work as I expect and have made any final layout tweaks, I will probably do a second run with more expensive options, such as a thicker PCB (since the boards are intended to be free-standing on rubber feet, not in a case), and paying the five bucks to have PCB-Way's board-manufacture tracking-serial-number not printed on it (again because the board itself is for visual display).

Also, my KiCad files:

[A zip of my tested KiCad files. CC-Attrib licence, probably.]


[Return to main Octas/cyber page]

[or my page about 3D-printing Octas dice]