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!

R3 is there to drain leakage current out of the oscillator circuit when the button is released. Without it, the clock still 'ticks' every couple of seconds while the button is open.

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 2x 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!)


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.

I learned circuit-design as part of a 2-year trade-school electronics certificate, though that was back when we did it with wax pencils on paper vellum, unless you worked for same big fancy international corporation with graphical computers! I self-taught myself eCAD later by brute-forcing it until I worked it out. These days we have online tutorials, which I recommend instead!

Ditching senior high-school to do trade-school instead was one of the few big life decisions I don't at-all regret.

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

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

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.

So my boards arrived.

Delivered boards with PCB-Way packaging.

And electronics were assembled.

Soldering components.
IC-socket

I strongly 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 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.

Finally, it is generally best to solder in order of least-sensitive to most-sensitive components, so: sockets, resistors, capacitors, LEDs, and the chip last..


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! Filing the round top off an 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 pushed them right though to 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!

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.

Cable ties securing cable to PCB.

Because this board is intended to be 'bare' since displaying it is part of the whole idea, after soldering and testing, I epoxy-glued some low-density rubber matting to the back. This both protects the rear of the board and also provides a soft 'grippy' surface for it so sit on.

Back of board covered in rubber

My source of low-density rubber was an old mouse-mat (from which I got enough for four backing sheets). Old wet-suit material is the same stuff too. Just make sure that whatever you use is not conductive or static-electricity generating (so definitely not polystyrene foam!) Alternatively, a few coats of (spray) varnish and some adhesive rubber feet should also do the trick.

And the device is finished.

Finished project.

And in operation:

Also, my KiCad files  (Licenced: CC BY-SA 4.0)

Patched circuit board

Note that some of the board-work images above are of my Revision-1 board. The one now published is Revision-2, which has an extra resistor in the oscillator circuit to fix a current leakage issue that wasn't apparent in the breadboarding stage. I patch-wired that resistor in to my Rev1 board in true hacker style! :-P

I'm not inclined to assemble a new board just to neaten up that fix, but I hope to do an assembly-group activity with a few interested friends at some future date, so will upload fresh images then. .... I just need to get the associated game actually-playable, now!