Silicon ChipFlexiDice - November 2024 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The hydraulic analogy is valuable for beginners
  4. Feature: Nikola Tesla, Part 2 by Dr David Maddison
  5. Project: Variable Speed Drive Mk2, Part 1 by Andrew Levido
  6. Subscriptions
  7. Feature: Precision Electronics, Part 1 by Andrew Levido
  8. Project: Surf Sound Simulator by John Clarke
  9. Project: JMP014 - Analog pace clock & stopwatch by Tim Blythman
  10. Project: JMP013 - Digital spirit level by Tim Blythman
  11. Project: FlexiDice by Tim Blythman
  12. Feature: 0.91-inch OLED Screen by Jim Rowe
  13. Project: 3D Printer Filament Dryer, Part 2 by Phil Prosser
  14. Feature: Maxwell’s Equations by Brandon Speedie
  15. PartShop
  16. Serviceman's Log: The Show Must Go On by Dave Thompson
  17. Vintage Radio: Revisting the Zenith Royal 500 by Ian Batty
  18. Market Centre
  19. Advertising Index
  20. Notes & Errata: PicoMSA, September 2024
  21. Outer Back Cover

This is only a preview of the November 2024 issue of Silicon Chip.

You can view 46 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • The life of Nikola Tesla, Part 1 (October 2024)
  • The life of Nikola Tesla, Part 1 (October 2024)
  • Nikola Tesla, Part 2 (November 2024)
  • Nikola Tesla, Part 2 (November 2024)
Items relevant to "Variable Speed Drive Mk2, Part 1":
  • Mk2 VSD PCB [11111241 or 9048-02] (AUD $15.00)
  • STM32G030K6T6 programmed for the VSD Mk2 [1111124A] (Programmed Microcontroller, AUD $10.00)
  • Firmware for the VSD Mk2 (Software, Free)
  • VSD Mk2 PCB pattern (PDF download) [11111241] (Free)
  • Mk2 VSD drilling & cutting diagrams (Panel Artwork, Free)
Articles in this series:
  • Variable Speed Drive Mk2, Part 1 (November 2024)
  • Variable Speed Drive Mk2, Part 1 (November 2024)
  • Variable Speed Drive Mk2, Part 2 (December 2024)
  • Variable Speed Drive Mk2, Part 2 (December 2024)
Articles in this series:
  • Precision Electronics, Part 1 (November 2024)
  • Precision Electronics, Part 1 (November 2024)
  • Precision Electronics, Part 2 (December 2024)
  • Precision Electronics, Part 2 (December 2024)
  • Precision Electronics, Part 3 (January 2025)
  • Precision Electronics, part one (January 2025)
  • Precision Electronics, part one (January 2025)
  • Precision Electronics, Part 3 (January 2025)
  • Precision Electronics, part two (February 2025)
  • Precision Electronics, Part 4 (February 2025)
  • Precision Electronics, Part 4 (February 2025)
  • Precision Electronics, part two (February 2025)
  • Precision Electronics, part three (March 2025)
  • Precision Electronics, part three (March 2025)
  • Precision Electronics, Part 5 (March 2025)
  • Precision Electronics, Part 5 (March 2025)
  • Precision Electronics, Part 6 (April 2025)
  • Precision Electronics, Part 6 (April 2025)
  • Precision Electronics, part four (April 2025)
  • Precision Electronics, part four (April 2025)
  • Precision Electronics, part five (May 2025)
  • Precision Electronics, Part 7: ADCs (May 2025)
  • Precision Electronics, part five (May 2025)
  • Precision Electronics, Part 7: ADCs (May 2025)
  • Precision Electronics, part six (June 2025)
  • Precision Electronics, part six (June 2025)
Items relevant to "Surf Sound Simulator":
  • Surf Sound Simulator PCB [01111241] (AUD $10.00)
  • Surf Sound Simulator PCB pattern (PDF download) [01111241] (Free)
Items relevant to "JMP014 - Analog pace clock & stopwatch":
  • Firmware for JMP014 - Pace Clock (Software, Free)
Articles in this series:
  • Wired Infrared Remote Extender (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Wired Infrared Remote Extender (May 2024)
  • Thermal Fan Controller (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Thermal Fan Controller (May 2024)
  • Self Toggling Relay (June 2024)
  • Self Toggling Relay (June 2024)
  • Arduino Clap Light (June 2024)
  • Arduino Clap Light (June 2024)
  • Lava Lamp Display (July 2024)
  • Digital Compass (July 2024)
  • Digital Compass (July 2024)
  • Lava Lamp Display (July 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • IR Helper (September 2024)
  • IR Helper (September 2024)
  • No-IC Colour Shifter (September 2024)
  • No-IC Colour Shifter (September 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • BIG LED clock (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • BIG LED clock (January 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
Items relevant to "JMP013 - Digital spirit level":
  • Firmware for JMP013 - Digital Spirit Level (Software, Free)
Articles in this series:
  • Wired Infrared Remote Extender (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Wired Infrared Remote Extender (May 2024)
  • Thermal Fan Controller (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Thermal Fan Controller (May 2024)
  • Self Toggling Relay (June 2024)
  • Self Toggling Relay (June 2024)
  • Arduino Clap Light (June 2024)
  • Arduino Clap Light (June 2024)
  • Lava Lamp Display (July 2024)
  • Digital Compass (July 2024)
  • Digital Compass (July 2024)
  • Lava Lamp Display (July 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • IR Helper (September 2024)
  • IR Helper (September 2024)
  • No-IC Colour Shifter (September 2024)
  • No-IC Colour Shifter (September 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • BIG LED clock (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • BIG LED clock (January 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
Items relevant to "FlexiDice":
  • FlexiDice PCB set [08107241-2] (AUD $5.00)
  • PIC16F18146-I/SO programmed for the Flexidice [0810724A.HEX] (Programmed Microcontroller, AUD $10.00)
  • 1.3-inch blue OLED with 4-pin I²C interface (Component, AUD $15.00)
  • 1.3-inch white OLED with 4-pin I²C interface (Component, AUD $15.00)
  • FlexiDice kit (Component, AUD $30.00)
  • Firmware (C and HEX) files for the FlexiDice (Software, Free)
  • FlexiDice PCB patterns (PDF download) [08107241-2] (Free)
Items relevant to "0.91-inch OLED Screen":
  • Software for driving a 0.91in OLED module (Free)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "3D Printer Filament Dryer, Part 2":
  • Filament Dryer Control PCB [28110241] (AUD $7.50)
  • PIC16F15214-I/P programmed for the 3D Printer Filament Dryer [2811024A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Firmware and 3D printing (STL) files for the 3D Printer Filament Dryer (Software, Free)
  • Filament Dryer Control PCB pattern (PDF download) [28110241] (Free)
  • 3D Printer Filament Dryer drilling templates (Panel Artwork, Free)
Articles in this series:
  • 3D Printer Filament Dryer, Part 1 (October 2024)
  • 3D Printer Filament Dryer, Part 1 (October 2024)
  • 3D Printer Filament Dryer, Part 2 (November 2024)
  • 3D Printer Filament Dryer, Part 2 (November 2024)

Purchase a printed copy of this issue for $13.00.

FlexIIDIce Flex Project by Tim Blythman We’ve published several dice projects over the years but all have been traditional six-sided affairs. Other types of dice are used for various games and activities. This dice project can emulate dice with up to 100 faces, coin tossing and other random events. N ot long after publishing our Dual Mini LED Dice project (August 2024 issue, siliconchip.au/Article/16418), we thought it'd be nice to have a more configurable ‘digital dice’ design. While some Circuit Notebook dice-rolling entries have used a microcontroller, most of our electronic dice designs, including the latest iteration from August, have used straightforward digital logic to implement the throw and display of the dice. One thing these designs all have in common is that they only emulate dice with six faces. The FlexiDice uses a microcontroller and an OLED display, so it can emulate just about any number of faces. We have chosen to allow up to 100, as that is the highest number of faces we have found on a real-life die. The FlexiDice is compact and handheld, running from a coin cell. The board uses surface-mounting components, but they are M3216 (3.2 × 1.6mm) passives, SOIC ICs and several larger parts, so it is not too difficult to build. Some games need only one or two six-sided dice, but many games use other types of dice or larger numbers. For example, the Dungeons and Dragons role-playing game (like many other role-playing games) uses dice with four, eight, 10, 12 and 20 sides. That includes 10-sided dice marked in tens so that its result can be combined with a regular 10-sided die to produce one of 100 different values. Dice with 100 sides exist, although their near-spherical shape makes them impractical to use because they do not stop rolling as quickly as smaller dice. One such example is shown below. Most of the other dice mentioned (with four, six, eight, 12 and 20 sides) are regular polyhedrons, so they are symmetrical with regard to their faces, while the 100-sided dice are not. Asymmetrical dice like the D100 may not show each face with equal probability. Those familiar with Dungeons and Dragons will also know the abbreviations used for various combinations of dice rolls. A roll of a single six-sided die would be abbreviated as “D6”, while the roll of two six-sided dice (as in games like Monopoly) is “2D6”. Dice with 100 sides exist but can be impractical. Our FlexiDice can give rolls up to 100 but won’t roll off the table. Source: https://w.wiki/AjL4 66 Silicon Chip Australia's electronics magazine We also use this terminology with the FlexiDice. Other games of chance use playing cards or coins to give a random result. The FlexiDice can emulate flipping two coins and shows images that resemble those found on an Australian penny, as is traditional in the historic Australian game Two-Up. The FlexiDice can also display playing cards and imitate decks with between zero and six Jokers. While most people will be familiar with decks with two Jokers (and thus 54 cards), the German game Zwickern has six Jokers in a 58-card deck. The Jokers are removed for many games (hence the zero option). The odds A microcontroller is designed to provide a deterministic outcome; the same input should result in the same output, so we need a way to inject some randomness into its behaviour. Of course, having a truly random outcome is the essence of dice, so we must ensure our means of generating random numbers is fair and not predictable. That the result is fair means that each outcome has a reasonably equal chance. For a result to be not predictable, results must be independent of each other. The most common method of generating randomness in our earlier siliconchip.com.au Features & Specifications ● Compact, handheld device ● Runs from one 3V lithium coin cell ● Operates down to 2.4V ● Auto power-down with <1μA sleep current ● Fun mini-game console form factor ● Graphic display for easy viewing ● Shake-to-roll vibration sensor ● Hardware-based random number generator ● Ten configurable roll presets plus numerous user presets Roll Types Dice with two to nine pips Numeric dice from two to 100 Random card pick with 0-6 Jokers Coin toss (heads or tails) dice projects is to use the variability in user input to randomise the result. That usually involves the user pressing a button or switch to activate the roll. The exact time the button is held down is used as the random element. As long as the hardware can cycle through the states fast enough, the user cannot influence the outcome, and the result is random. As we found during the development of the Dual Mini LED Dice, that is not always sufficient. In that case, we found that if the values of two critical timing capacitors were similar, the two halves of the circuit would interact and synchronise, resulting in the two dice often having the same result. The result could still be fair, but it was also predictable, which is undesirable. Fortunately, using two different values of timing capacitor was enough to overcome this with the Dual Mini LED Dice. The FlexiDice measures user input, but that is not the only source of randomness. We investigated several different noise (true random data) sources to see what would be suitable for this project. implemented such a circuit in the Personal Noise Source from September 2001 (siliconchip.au/Article/4151). A high enough voltage applied to the junction reaches a critical point that causes a rapid and unpredictable increase in current; an avalanche. In situations where the current is sustained, this can cause heating and damage. When avalanche breakdown is used for noise generation, a series resistor limits the current to avoid damage to the junction and allows it to recover and experience further random events. Many such noise sources (including the 2001 project) use the emitter-base junction of a transistor, with the collector being left unconnected. The necessary breakdown behaviour requires at least 6V, and the noise level is quite low, so substantial amplification is needed. These factors conspire to make such a noise source difficult to operate from a coin cell; hence, we looked at other options. Pseudo-random (LFSR) A later noise source project, the White Noise Generator (September 2018; siliconchip.au/Article/11225), uses a different noise generation method. In this case, the output is known as ‘pseudo-random’ since it is not truly random but generated by a deterministic process. Since they are deterministic, many pseudo-random processes can be proven to be fair and uncorrelated, but as the name suggests, they are not truly random. There are many types of pseudo-­ random noise sources, but one of the simplest to implement is the linear feedback shift register (LFSR). This is a shift register with its input being a linear combination of some of its outputs, usually by XORing some carefully chosen register bits. The FlexiDice implements a 31-bit LFSR that works in much the same fashion as that in the Digital White Noise Generator from 2018, although we do not use it as the primary source of randomness. This 31-bit LFSR cycles through nearly all 31-bit states (and thus over two billion 31-bit numbers) and so takes very many cycles to repeat. The all-zero state is the only state that is avoided since it results in the LFSR being stuck in that state. Since the LFSR's future state can be known from its current state, it can be very predictable. For example, we tested the FlexiDice using the LFSR as its only input and, unsurprisingly, the dice rolls were identical every time it was powered on. Noise multiplier The circuit we have implemented is known by various names, but “noise multiplier” seems the most appropriate. As the name suggests, the circuit amplifies noise from all sources, so even power supply noise enhances its operation. Unlike an avalanche diode, only modest amplification is needed, and one of the outputs is digital in nature, allowing it to be easily fed to a microcontroller. Consider the sub-circuit shown in Fig.1. The left-hand op amp is wired as a comparator, with its inverting input connected to a half-rail reference generated by a divider. A signal is applied at Vin; if it is more than half of the supply voltage, BIT_OUT is high; otherwise, it is low. The right-hand op amp is configured to have a gain of two, with the inverting input referenced to BIT_OUT. In other words, Vout will be double Vin minus BIT_OUT. Scope 1 shows these values as Vin is simulated being swept from 0V to Vcc. Avalanche diodes One of the better-known random noise sources is the breakdown behaviour of a reverse-biased PN junction (avalanche breakdown). We Fig.1: this circuit snippet has various uses, including as an analog-to-digital converter, but we are using it as a noise source. By sampling and holding the output and feeding it back to the input, repeated cycles amplify the noise to a measurable level. siliconchip.com.au Australia's electronics magazine November 2024  67 Scope 1: these traces are from a simulation of the Fig.1 circuit, with Vin being the input and Vout and BIT_OUT being the outputs. If you add the green trace to the cyan trace, the result is double the pink trace. Scope 2: the voltages around IC2 and IC3. The blue trace is one of the phase outputs from IC1, while the yellow trace is the mid-rail reference. The red trace is Vin and the green trace is Vout downstream of the 1kW resistor. Note the settling time and that for each phase, the red trace follows the previous phase’s green trace as the capacitors alternate. Scope 3: this is much the same as Scope 1, except it is measured on the actual hardware. Vin (red) ramps up as current is applied to one of the 100nF capacitors. The transition on BIT_OUT (blue trace) is clear. The grey trace shows the sum of BIT_OUT and Vout (green trace), which is double Vin apart from the brief glitch at the transition. 68 Silicon Chip Australia's electronics magazine What the circuit is doing is doubling the voltage (including any noise present); hence the term noise multiplier. By maintaining its output between the supply rails, the circuit avoids saturating, which would cause noise information to be ‘lost’. The extra information is available at BIT_OUT. Another name we have seen for this circuit is “modular entropy multiplier”. Consider a division operation, with the dividend being Vin × 2 and the divisor being Vcc. The outputs (BIT_OUT and Vout, respectively) are the quotient and modulus (or remainder) of the operation. Another way of viewing the circuit is as a one-bit analog-to-digital converter. The circuit can iterate over multiple bits by taking the output voltage and feeding it back to the input. To do that, we need a sample-and-hold circuit to allow the intermediate states to stabilise and not immediately feed back. At each stage, the value of the BIT_ OUT line state would be noted, then the voltage on Vout would be fed back to Vin. In this case, it turns out that the BIT_OUT values will form a binary value representing the initial voltage. Table 1 shows the progression with a starting voltage of 0.333 (for Vcc = 1V). The binary value formed from the BIT_OUT column is 01010101, or 85 in decimal, which is one-third of 256, as expected. Note that the Vin values do not return exactly to the 0.333 starting value but quickly diverge from it. That is what makes this circuit useful as a random source. For example, take a 100nF capacitor at 3V, for which the formula Q = CV gives a charge of 3 × 10-7 coulombs or around 1.8 × 1012 electrons. That many electrons can be represented by a binary number with 41 bits. If we run the noise multiplier for more than 41 cycles, we are apparently counting fractions of electrons. Those familiar with electrons will know that they do not divide easily! What we are measuring at this stage (and probably for many stages before) is just the noise present in the system. That is the essence of the noise multiplier’s operation. Firmware The program on the microcontroller is responsible for driving the display in siliconchip.com.au The top (right) and bottom (left) side of the main PCB. The OLED module mounts to the top side and sits with a small gap between it and the components below. Note the hole for a screw to help secure the coin cell in place. response to user input. The main task is to emulate a random event, such as rolling dice or picking a playing card at random. The firmware requests multiple bits from the noise multiplier by toggling PH1 and PH2 and reading BIT_OUT a few times (more on this later). It performs an XOR operation on those bits. We substantially reduce the correlation between successive bits by combining multiple bits to output one bit. We need to request multiple bits to represent an event with more than two outcomes. In practice, every roll uses 24 bits from the noise generator. A 24-bit number is large enough that any rounding that might cause one number to appear more often than another is minimal. The result is converted to a coin flip, dice pips, card selection or numerical display and then shown on the OLED screen. Each ‘roll’ can be configured to show one or two results, and they can be any of the alternatives; you could request a coin and a playing card, for example. Two dice would be a common option. Note that the choice is done ‘with replacement’. For playing cards, it is equivalent to picking a card from a deck and then returning that card before choosing the second card. Thus, the same card can be selected twice in the same draw. Another way to consider this is drawing a single card from each of two decks. When starting up, the analog voltage on pin 19 (which is not connected to anything) is converted to a value from 0 to 1023. The noise multiplier is run siliconchip.com.au for that many cycles plus another 40, which ensures it is not in a state that can not be predicted by the initial conditions. When a roll is requested, bits are taken from the noise amplifier while the button is held down, further randomising the outcome. An animation is played with random results from the LFSR before the final roll is displayed using results from the noise multiplier. We use the LFSR for the animation since the noise multiplier takes some time to generate a result. It’s also possible to use the LFSR as the main random data source for rolls. When the results are displayed, the microcontroller starts a timer. When the timer expires, all peripherals are shut down, and the microcontroller enters a low-power sleep mode that it can be left in for extended periods without flattening the cell. We tested this with our Coin Cell Emulator from the December 2023 issue (siliconchip.au/Article/16046). Table 1 – analog-to-digital conversion one bit at a time It registered 0.0μA during sleep, so we are confident that the current consumption when not in use is well below 1μA. When it is not sleeping, like many such projects, the OLED is the main current draw; how much it draws depends on the brightness setting. We saw up to 10mA total current with the default brightness settings, so it pays to keep the OLED brightness as low as possible. The rest of the circuitry uses about 1.5mA when it is not sleeping, jumping to 2.5mA while a roll is occurring or SETTINGS is active, since the processor has more to do. The remainder of the firmware is responsible for configuring the Flexi­ Dice, including choosing what combinations of rolls are available. We’ll delve into these once construction is complete. Much of the microcontroller’s flash memory (which also holds the program instructions) is used to store the graphics and fonts used to create the various displays. Circuit details VIN BIT_OUT VOUT 0.333 0 0.666 0.666 1 0.332 0.332 0 0.664 0.664 1 0.328 0.328 0 0.656 0.656 1 0.312 0.312 0 0.624 0.624 1 0.248 Fig.2 shows the final FlexiDice circuit. IC2 and IC3 form the noise multiplier, each with a 100nF capacitor bypassing their supplies. IC3 is a dual low-power rail-to-rail op amp configured nearly the same circuit as in Fig.1. The main exceptions are that the feedback resistor is only 82kW and that there is a 1kW resistor on Vout to limit peak currents from the op amp. The Vin and Vout voltages connect Australia's electronics magazine November 2024  69 to quad analog switch IC2, which is arranged to allow either of two 100nF capacitors to be connected to Vin and Vout. This is the sample-and-hold buffer mentioned before in practice. The PH1 and PH2 lines from microcontroller IC1 control it. If both PH1 & PH2 are low, the capacitors are disconnected. When PH1 is high and PH2 low, one capacitor is connected to Vin and the other to Vout. The connections are reversed if PH1 is low and PH2 is high. The situation with both PH1 and PH2 high is avoided. Alternating PH1 and PH2 allows us to step bits out of the noise multiplier circuit, which you can see in Scope 2. Note the settling time (about 1ms) needed to ensure the capacitor fully charges to the Vout value. Even with a rail-to-rail op amp, component tolerances and op amp input offsets could conspire to saturate Vout to one of the power rails, which would result in the same data being continually delivered. The feedback resistor value has been reduced from 100kW to 82kW in order to exclude the possibility of the multiplier getting stuck in this state. This value means that Vout is limited to between about 10% and 90% of Vcc, which makes it more likely for BIT_OUT to change states on each cycle. Thus, the output is not entirely random. Using the terms we mentioned earlier, the outcome is fair but slightly predictable. We handle this by requesting extra random bits in the microcontroller firmware. Microcontroller IC1 is a PIC16F18146 8-bit microcontroller; it also has a 100nF supply bypass capacitor. A 22μF bulk bypass capacitor helps reduce the peak current loads on 3V coin cell BAT1. IC1’s pin 4 MCLR input is pulled up to 3V by a 10kW resistor; this, the power pins (1 and 20) and programming pins (18 and 19) are taken to Coin Cell Precautions The FlexiDice requires a coin cell; even though we have added protections such as the locking screw, care should be taken so that children are not left unattended with it. ICSP connector CON1. This can be used to program the microcontroller; we also used it for debugging during development. The microcontroller drives the PH1 and PH2 lines from pins 6 and 7, ensuring that both are never high simultaneously. When it switches them, they are both briefly set low to ensure that the circuitry around IC2 is not closed in a loop. Seven of the micro’s I/O pins (9, 10, 14, 13, 12, 11 and 15) are configured as inputs with pullups, and these connect to switches S1-S7. S1-S6 are tactile switches, while S7 is a vibration switch that can be triggered by shaking or bumping the FlexiDice. The other ends of all the switches connect to ground so that their closure changes the state of the connected I/O pin to low. MOD1 is an I2C OLED display module powered by IC1’s pin 3 (RA4). This allows the display to be completely powered down for minimum power consumption when not needed. Pins 2 and 16 of IC1 provide the I2C data interface for updating the display. Fig.2: apart from the noise amplifier section, which is similar to Fig.1, the FlexiDice circuit is a fairly simple microcontroller application. IC3 is the op amp in Fig.1, while quad analog switch IC2 and the two 100nF capacitors provide the sample-and-hold feature. The microcontroller can power down everything except itself, allowing the lowest possible sleep current. 70 Silicon Chip Australia's electronics magazine siliconchip.com.au Similarly, the noise multiplier is powered from IC1’s pin 5 and can be shut down as needed. We have connected one of the noise multiplier capacitors to pin 17, allowing us to monitor the noise multiplier state or inject a voltage if required. Using a weak pullup current from pin 17, we created the plot shown in Scope 3. This is similar to Scope 1 but measured on real hardware instead of a simulation. All ICs are rated for operation down to 2V or lower, but from experience, we have found that the OLED display modules will falter around 2.4V; this is what sets our lower operating limit. A lithium cell reaching that voltage under a light load has exhausted almost all its stored energy. Construction The FlexiDice is built on a double-­ sided PCB coded 08107241 that measures 34 × 62mm. It includes surface-­ mounting components, so you will need the standard SMT gear. A finetipped soldering iron, flux paste and tweezers are recommended. A magnifier, some solder-wicking braid and fume extraction will also help. Start with the three ICs. They are all different sizes, so it should be easy to tell them apart, although you will have to take care with their orientations. Note the location of the pin 1 dot in each case and check it against the PCB silkscreen and Fig.3 overlay diagram. Start by applying flux to the PCB pads for the ICs and sit each in place. Tack one lead and check that the others are aligned. If not, remelt the solder and nudge them into place. Also make sure that the parts are flat against the PCB. Solder the remaining leads, cleaning the iron’s tip as needed. If you get a bridge between pins, you can remove that by adding more flux and pressing the braid against the bridge with the iron. Carefully drag both away Parts List – FlexiDice 1 double-sided main PCB coded 08107241, 34 × 62mm 1 double-sided panel PCB coded 08107242, 34 × 62mm 1 SMD 2025/2032 coin cell holder (BAT1) 1 5-way right-angled header strip (CON1, optional, for ICSP) 1 1.3in 128×64 I2C OLED module (MOD1) [Silicon Chip SC6511 or SC5026] 1 4-way pin header (for MOD1, may be included) 6 SMD 2-pin tactile switches (S1-S6) 1 SW18010 vibration-triggered switch or similar (S7) 1 M2 × 6mm Nylon panhead machine screw 2 M2 Nylon hex nuts 1 2 × 2cm piece of double-sided foam-core tape 2 1cm piece of wire (eg axial lead offcut or pin header) to secure MOD1 Semiconductors 1 PIC16F18146-I/SO microcontroller programmed with 0810724A.HEX, SOIC-20 (IC1) 1 74HC4066 quad analog mux IC, SOIC-14 (IC2) 1 MCP6L2 dual low power rail-to-rail op amp, SOIC-8 (IC3) Capacitors (all SMD M3216/1206 X5R/X7R) 1 22μF 16V 1 1μF 35V 5 100nF 50V Resistors (all SMD M3216/1206, 1%, ⅛W) 3 100kW [104/1003] 1 10kW [103/1002] 1 82kW [823/8202] 1 1kW [102/1001] FlexiDice Kit (SC7361, $30 + P&P): contains all parts in the parts list except the ICSP header, which is not required because IC1 comes pre-programmed. together once the excess solder has been taken up. Five 100nF capacitors and one 1μF capacitor mount on the top of the PCB. Do not mix them up, as they will not be marked. Solder them using a similar strategy to the ICs: add flux, tack one lead, check and then solder the other lead. The six resistors will have codes marked on their tops, making them less likely to be mixed up. Solder them to the PCB similarly, according to the silkscreen markings. Flip the PCB over and solder the 22μF capacitor, followed by cell holder BAT1, as shown in Fig.3. Ensure that the cell holder opening faces towards the edge of the PCB. Add a good amount of solder to help secure it firmly. Now is a good time to clean flux residue from the PCB. Use a solvent such as isopropyl alcohol, a general flux cleaner or whatever is recommended for your flux. Allow the PCB to dry and inspect it closely for dry joints, bridges and other issues. These will be hard to fix once the OLED screen is fitted to the PCB. One of the more insidious problems occurs when the solder does not adhere to the pad on the PCB. The lead may appear to have a glossy, well-formed solder bead, but it is not connected to the pad below. That can be caused by the part not being flat against the board. If you find this has happened, add more flux and press down gently on the pin with your soldering iron. Solder the six tactile switches next, being sure to align them with their Fig.3: assembly of the FlexiDice is easy with even modest SMD skills. Ensure the ICs are orientated correctly and do not mix up the capacitors. The OLED module sits over the top of the PCB (see the black outline). Once you have tested everything, we recommend carefully glueing the body of the vibration switch to the PCB. siliconchip.com.au Australia's electronics magazine November 2024  71 Screen 1: when first powered on, the FlexiDice shows this screen, indicating it is ready to roll a D4 (four-sided die). The coin cell voltage is at upper left, while the sleep countdown timer is at top right. Screen 2: pressing the UP button will run a brief random animation and then show the result of the roll. Pressing DOWN will return to Screen 1. Any button press will also reset the countdown timer. Screen 3: pressing LEFT and RIGHT will cycle between numerous roll options. Shown here is a draw of two playing cards, each from a standard 52-card deck (without Jokers). Screen 7: in case you find the vibration sensor too sensitive, you can turn off S7's ability to wake the FlexiDice from low-power sleep. By default, ‘shake to wake’ is on. Screen 8: if you wish to test the MEM (modular entropy multiplier), press UP from this screen. Screen 11 shows the testing screen that can be used to check its fairness and correlation. Screen 9: if you prefer to use the LFSR (linear feedback shift register) as the random noise source, this screen can be used to turn the hardware noise source off, saving a small amount of power. silkscreen markings. Any excess flux can be cleaned up with a cotton tip dipped in solvent, which avoids getting solvent into the switch mechanisms (that can cause them to fail). Solder vibration switch S7 next. Bend the leads 90°, being mindful of the orientation of the leads. Make sure its body is flat against the PCB. If the 4-way header is not already attached to MOD1, the OLED module, fit it now. Then use a piece of card or thin plastic to temporarily space the module away from the components below it on the PCB. Solder its leads, adjusting if needed to make the display align neatly with the PCB. Trim the excess lead lengths and remove the card or plastic. Next, solder some short pieces of wire (such as lead offcuts or single header pins) from the PCB to the two pads in the bottom corners of the display, adding some mounting rigidity. part of the MPLAB X IDE from: siliconchip.au/link/abzy The Snap cannot supply power, so you will need to provide some; fitting a coin cell is the easiest way. Choose the PIC16F18146 as the Part, open the 0810724A.HEX file (available to download from our website) and connect the programmer to CON1, aligning the pins marked with the arrow. If you only plan to use this connection once, you can insert a five-way pin header into the first five pins of the programmer’s header and hold the FlexiDice PCB against the pins to ensure good contact. Press the Program button and check that the programming completes and is verified successfully. The OLED should also light up (see Screen 1), indicating that the program is working. Using it Fit a coin cell if you have not already done so. Check that the polarity is correct; there should be a small + sign on the top part of the cell holder. The default program allows the FlexiDice Programming IC1 If you have bought the PIC or a kit from the Silicon Chip Shop, IC1 will be programmed already and you can skip to the next section. Otherwise, use a PICkit 4, PICkit 5 or Snap programmer and the MPLAB IPE (integrated programming environment). The IPE can be downloaded as The main board should look like this before you fit the OLED. Make sure all the solder joints are good before doing that! 72 Australia's electronics magazine Silicon Chip siliconchip.com.au Screen 4: Pressing BACK and OK together will enter SETTINGS. This screen sets the display timeout, which can be changed in five-second steps with the UP and DOWN buttons. Screen 5: pressing RIGHT cycles to the next setting screen, which changes the display OLED module’s brightness. The display will dim slightly during the last two seconds before sleep. Screen 6: some OLED modules have a horizontal offset, which can be trimmed on this screen with UP and DOWN. Both arrows are showing fully, meaning the display is correctly aligned. Screen 10: this and nine other screens like it configure your custom rolls. Pressing UP will take you to Screen 12, where you can change the graphics, colour and number of outcomes. Screen 11: here, UP starts the test, taking 100 single-bit samples from the noise generator. The results are shown at the bottom. If you consistently see low % results, the noise generator may not be working. Screen 12: from each page here, use LEFT and RIGHT to view each option and UP and DOWN to edit it. If the right die is set to NONE, only a single outcome (the left die) will be displayed. to work immediately, and the OLED should show a sensible display as soon as it is powered on (see Screen 1). You can initiate a roll by pressing S3 (the UP button) or activating the S7 vibration switch. Screen 2 shows the result of a roll. S4 and S5 (LEFT and RIGHT) cycle between the different roll options. Screen 3 shows one of the other options before a roll is performed. Pressing S6, the DOWN button, will reset the screen; the other two buttons are associated with SETTINGS. If the display times out and the FlexiDice enters sleep mode, pressing any button will wake it up again. Perform a few rolls and confirm that the results appear random. If you get the same result on every roll (especially if it is 1), the noise multiplier may not be working. There is a utility within SETTINGS to check the noise multiplier’s output (see Screen 11). mode. In this mode, the LEFT and RIGHT buttons cycle between the available parameters, while UP and DOWN will change them. Pressing BACK will exit SETTINGS. There are a handful of display and operation preferences, plus configuration for ten roll combinations that can be set up as you choose. They (and the other settings) are kept in EEPROM, so they take effect immediately and will be retained even if the battery is removed. Screens 4-12 and their accompanying captions explain Configuration Pressing S1 and S2 (BACK and OK) together will enter the SETTINGS The PCB shown at left is only used as a ‘panel’ to protect the back of the main PCB, it has no components to solder to it. siliconchip.com.au Australia's electronics magazine November 2024  73 Screen 13: dice with pips can show rolls up to nine. You’ll note some nice touches, like the orientation of the two and three roll is not fixed but can vary, just like actual dice. Screen 14: rolls (draws?) using the card options show the standard playing card symbols as seen here. Up to six Jokers can be added to the deck by selecting the 58-card option. Screen 15: the coin toss shows its outcomes as images of an Australian penny, so it’s well-suited for a traditional game of Two-Up. each of the settings screens available on the FlexiDice. notable bias towards one result. Our tests would put the fairness and correlation of those real-life coin toss results at around 97%. and card picks and those that are configurable from SETTINGS. Whenever the FlexiDice enters sleep mode, all settings are retained. Pressing any button apart from UP (or the vibration switch) will reinstate the previous display so that you can, for example, see what the last roll was. Pressing UP (or shaking) will always start a new roll, so there is no delay in getting a result after exiting sleep mode. This means it is less distracting when you are playing a game. Because settings are saved in EEPROM, all the settings and presets will be retained even if you change the cell. The LFSR state is also saved every time the Dice goes to sleep, so there is less chance of the same result occurring repeatedly if you are using the LFSR. Diagnostics Screen 11 shows the noise multiplier diagnostic screen. It performs several rolls and reports on their fairness and correlation. Scores of 100% mean that the rolls are fair (equal number of 0s and 1s) and uncorrelated (any roll has an equal chance of following any other roll). The result of all rolls is also delivered as serial (UART) data at 115,200 baud through pin 18 (RA1) of IC1, which is also pin 5 of the CON1 ICSP header (furthest from the > pin 1 marker). Pin 3 of CON1 is circuit ground. You could connect a USB-­ serial converter to these pins to dump this data into a computer for analysis. All rolls from the main screens are also dumped via the serial port in this fashion. You can run repeated rolls on the main screen (for example, to accumulate numerous results on the serial port) by holding the DOWN button after pressing the UP button for a roll. On Screen 11, values above 90% are typical and expected, although any one test might show a lower result. This is because any truly random phenomenon will occasionally show long runs of one particular value. Running multiple tests will accumulate the results, and you should see the long-term results, which will be more representative. If you see values near 0%, the noise multiplier is not working and is probably stuck at a specific value. In that case, check the circuitry around IC2 and IC3, plus their connections to IC1. During our research for this project, we came across an experiment (see siliconchip.au/link/abzz) where coins were tossed 40,000 times. It found that even a real coin shows a 74 Silicon Chip Completion Once you are confident the Flexi­ Dice is working as expected, you can secure the coin cell by using the M2 screw and nuts. Attach them to the hole near the cell to prevent it from being accidentally removed. Add a dab of glue between the PCB and the vibration switch. This will reduce the strain on the leads. Stick the double-sided foam tape to the back of the battery holder and use it to attach the panel PCB, aligning it with the main PCB. Some pads on the back of the panel PCB align to CON1, so you can solder some wires between the two for some extra stability if you want. Play Screens 13-15 show some of the different graphics the FlexiDice can display. They include dice ‘pip’ faces, playing cards and coin faces. For numbers higher than nine, numeric displays like those seen in Screen 2 must be used; they are also available for lower rolls. Use the LEFT and RIGHT buttons to cycle between the various options, which include several single dice rolls Conclusion The FlexiDice is a compact and handy substitute for all sorts of dice and can also be used to simulate coin tosses and card draws. You could even set it up to pick your numbers for Lotto draws. It runs from a single coin cell and the cell voltage display should give you plenty of warning before it goes flat. It also looks like a tiny games console, so we hope some of our readers think of other playful applications for SC this hardware. Double-sided foam tape is used to attach the protective panel PCB to the battery holder, although it isn’t strictly required. Australia's electronics magazine siliconchip.com.au