Silicon ChipOl’ Timer II - August 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PicoLog Cloud
  5. Back Issues: PICOLOG
  6. Publisher's Letter
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Techno Talk by Mark Nelson
  9. Feature: Net Work by Alan Winstanley
  10. Project: Ol’ Timer II by Tim Blythman
  11. Project: Low-cost, Wideband Digital RF Power Meter by Jim Rowe
  12. Project: Switchmode Replacement for 78xx regulators by Tim Blythman
  13. Feature: KickStart by Mike Tooley
  14. Feature: Microphone Preamplifier (for Vocoder) – Part 4 by Jake Rothman
  15. Feature: Make it with Micromite by Phil Boyce
  16. Feature: Circuit Surgery by Jake Rothman
  17. Feature: Max’s Cool Beans by Max the Magnificent
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the August 2021 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
O l’ T i m e r I I Once upon a time, clocks were not very accurate. Nowadays, the time shown on your mobile phone or computer is probably accurate to a miniscule fraction of a second. If you’re yearning for a more relaxed attitude to time, this project is for you! by Tim Blythman T he digital clock in your mobile phone or computer is highly accurate and regularly updated, kept within a fraction of a second of an atomic clock standard via the Internet. But it hasn’t always been like that. When I visited my grandparents as a child, I remember the tall grandfather clock they had in their house. Aside from the minor ceremony of its weekly winding, it was practically hidden away and not easy to see, but frequently heard, as it had the type of chimes that would sound off the quarter hours. On the hour, it would sound off the number of hours; in between, distinct chimes for each quarter-hour. It was easy to tell what the time was to the nearest fifteen minutes. 16 The Ol’ Timer II recalls this more relaxed attitude to time while evoking a modern and stylish appearance. Inspiration This project was inspired by and named for the (old) Ol’ Timer project from November 1994. It displayed the time as a combination of words and numbers and used a PIC16C57 microcontroller to control bitmaps on a 40×7 LED matrix. Back in the day, we didn’t need to know the time to the nearest second, and the manner of speaking the time reflected that. People would say, ‘quarter to ten’ or ‘five o’clock’ instead of ‘nine-forty-five’ or just ‘five’. The proliferation of digital clocks means some young people can’t even read older analogue clocks, let alone understand this way of speaking the time. But the Ol’ Timer II displays the time in written words, expressed in this style. The display is only updated every fifteen minutes; this was partly a conscious design decision, and partly because we’re limited by what fits on the chosen display. So, if you prefer a relaxed and oldfashioned attitude to time, this clock is for you. Design Rather than using a graphical or character LCD, we have combined an 8×8 RGB LED matrix with a cleverlydesigned PCB mask. This approach allows various combinations of letters to be displayed. Practical Electronics | August | 2021 It’s the sort of thing that could have been rigged up with a matrix of incandescent lamps controlled by clockwork. That is, if we were designing this in the 1920s rather than the 2020s! So this is how words are displayed on the Ol’ Timer II, although the choice of an RGB LED matrix means we aren’t limited to illuminating the letters in an ‘incandescent yellow’ colour. The RGB matrix is based on 64 WS2812B ICs which each contain red, green and blue LEDs plus a seriallycontrolled driver chip. We had a good look at this type of display in PE’s January 2021 issue. Circuit description Refer to Fig.1, the circuit diagram. The Ol’ Timer II is controlled by IC1, a PIC16F1455 8-bit microcontroller. IC1’s RC5 GPIO pin (pin 5) is configured as a digital output, and this drives the serial data input of the LED matrix via a 390Ω resistor and pin header CON3. The other two pins on the three-pin display header supply 5V power to the 8×8 RGB LED matrix module, MOD1. Details on how this serial data is used to control the colour and brightness of the 64 LEDs are in the article mentioned above. Suffice to say, these three lines are sufficient to power and control all the LEDs with individually settable 24-bit RGB colour values, giving 16,777,216 possible colours for each. IC1’s RC4 and RC3 general-purpose I/Os at pins 6 and 7 connect to the I2C serial bus interface of IC2, a DS3231 RTC (real-time clock) IC. Although IC1 has a dedicated I 2C interface, its pins are shared with the programming header. Since I2C is easy to ‘bitbang’ with direct port operations, we preferred to do it this way. Thus, IC2 cannot interfere with programming signals and vice versa. We had enough free pins on IC1 to allow us to do this; and it also simplifies the PCB layout slightly. The two I2C lines are pulled up to 5V by a pair of 4.7kΩ resistors, as required by the I2C specification. IC1’s pins 8, 9 and 10 (analogue pins AN6, AN5 and AN4 respectively) are connected to circular touchpads on the PCB. We use the analogue-to-digital converter (ADC) peripheral to sense these pads being touched. A finger on any of the pads alters its capacitance slightly, Practical Electronics | August | 2021 changing the rate at which it charges or discharges via weak DC currents, enough to be detected by IC1. These touchpads provide a way to set the unit up even if you don’t have a computer with a USB interface handy. LDR1 has a resistance which changes depending on the light level falling on it. It is connected in series with a 1MΩ resistor across the 5V supply, and a 100nF capacitor smooths the resulting voltage, which is then fed to the AN3 analogue input (pin 3) on IC1. When the LDR is illuminated, its resistance is of the order of 100kΩ, and the voltage at AN3 is around 4.5V. In the dark, the LDR has a resistance of about 10MΩ, so the voltage on pin 3 is closer to 0.5V. The 100nF capacitor provides a low-impedance source for the AN3 analogue pin (pin 3), which reads this voltage and calculates a display-brightness level based on the ambient light level and the user settings. IC1, IC2 and the LED matrix receive 5V DC power from CON1, a mini-USB socket. IC1 and IC2 each have 100nF local supply bypass capacitors. The USB data lines on CON1 are also connected to the dedicated USB D+/D− pins (13 and 12) on IC1, allowing the device to be configured via a computer’s USB port. The Ol’ Timer II sports a modern look but recalls an older way of reading the time. It’s powered by 5V from a miniUSB socket, and the display colours are fully customisable. Features • Displays the time as words • Uses a DS3231 real-time clock IC for accurate long-term timekeeping • Compact and stylish • LED colours are customisable • USB-powered • Setup via USB or integrated capacitive touch buttons • Adjustable brightness with ambient light sensing A 10kΩ resistor provides a pullup for IC1’s MCLR pin (pin 4), allowing it to run whenever it is powered. IC2 has support for battery backup power at its pin 14, which is connected to a button cell battery holder. It is intended to be fitted with a CR2032type battery, so that the time is retained even when 5V power is removed. Finally, IC1’s in-circuit serial programming (ICSP) pins are wired to CON2 so that IC1 can be programmed after it has been soldered to the board. The required connections are 5V, GND, MCLR, ICSPCLK and ICSPDAT (pins 9 and 10). Pins 9 and 10 have 100Ω series resistors to avoid damage to a programmer if it is connected while pins 9 and 10 are being driven. CON4 is not electrically connected to any part of the circuit, but is used to mechanically secure a corresponding set of pads on MOD1, the LED matrix PCB. Operation The general operation of the circuit is typical for microcontroller-based digital circuits and naturally depends heavily on the firmware we have written. IC1 checks the time by querying IC2 over the I2C bus and then updates the display at CON3 as necessary. As you might have seen from the article about these modules (and the individual LED chips used in them), the control signal is quite time-sensitive. Thus, we have written this part of the code in assembly language to guarantee the timing. This includes turning off microcontroller interrupts while the data is being sent to the matrix. We were initially concerned that this might interfere with USB communications (it takes around 2ms to update all the LEDs), but we have not noticed any problems. 17 Screen1: the menu system offered over the USB-serial port is easy to use. Press Esc then 1 to set the time, followed by six digits in 24-hour HHMMSS format. Screen2: display colours can be set with menu options 2, 3 and 4, in the standard ‘web’ format of a sixdigit hexadecimal colour code in RRGGBB order. The colour shown here (ØØFFØØ) is pure green. Screen3: pressing Q at any time starts a debugging output display which can be stopped by pressing Esc. The RTC status, digital time and intended LED display are shown and updated every second. IC1’s USB peripheral does all the time-critical work independently in hardware; so as long as the software doesn’t delay too long, it works fine. As briefly described above, the three touchpads are probed using the shared capacitance technique. The detail behind this method is explained in a panel in our ATtiny816 Breakout Board article that we published in last month (July 2021). Essentially, the change in capacitance from finger proximity can be measured by clever use of the ADC (analogue-to-digital converter) peripheral. So we have been able to add three ‘pushbuttons’ without any extra hardware, apart from some PCB tracks. At the back of the PCB, on the reverse of the touchpads is a copper ground pour. This, combined with the shape chosen for the touchpads, maximises the capacitance change that occurs when it is touched. These three pads can be used to set the time and alter the clock configuration, with the SET button cycling between several parameters and the UP and DOWN buttons allowing the parameters to be changed. The USB peripheral on IC1 is also programmed in firmware to behave as a USB-serial bridge. When connected to a serial terminal program, an intuitive configuration menu can be accessed to change the time and other clock settings. shape of the letters. Where we want light to shine through, the solder mask and copper layer have been removed, meaning that light from the LED underneath is only diffused by the FR4 fibreglass material in between. The top copper layer forms a solidly opaque mask, and the solder mask gives a uniform appearance (the alternative here would be a bright silver layer of solder). To reduce spillover from adjacent LEDs, an acrylic mask sits around each LED, further limiting the spread of light. Since each LED can be lit up to practically any colour in the RGB spectrum, we can illuminate each letter a different colour to differentiate the words, or set the brightness to account for different viewing conditions. This basic concept is not new, but most of the similar designs we have seen use a much larger matrix. We felt that 8×8 should be enough. Laying out the letters to display the necessary words was the tricky part. We managed to fit everything in with the help of a spreadsheet, although we did have to fit some words in vertically, which is not something we’d seen done before. We had a few LEDs left over which were not needed to form any of the words, so we have allocated them to other useful features. The last two ‘pixels’ at bottom right were free and are well suited to an AM/PM display, so the masks have been designed to show these pairs of letters in a slightly smaller font. With some clever use of the existing letter layout, some other words can be displayed, if necessary, although the software does not make use of this. The matrix can also be used as individual pixels, so we can also display some small bit-mapped numbers if necessary. We use this to display information when the colour or brightness is being updated by the touchpad controls. Display That we have used a microcontroller to control the LED matrix is straightforward enough, but we think the clever part is how the matrix is used to create a readable output capable of displaying words. Most of the PCB is actually a carefully crafted mask intended to transmit the 18 Construction Like many projects, this one depends on surface-mounted components; not so much due to size, but because it allows the front of the PCB to be unmarred by soldered pads. As such, we suggest that you have some solder flux paste, braid (wick), tweezers and a magnifier on hand, along with a soldering iron, preferably one which can have its temperature adjusted. The flux generates a moderate amount of smoke, so use a fume extractor or work outside if possible to avoid breathing in the fumes. A fine-tipped iron is helpful, but even a chisel tip held with its edge vertically should be OK to do the job. We used a 2.4mm chisel tip to build our prototype. Refer to the PCB overlay diagrams (Fig.2) during construction. The clock is built on a 77 × 99mm PCB, coded 19104201 and available from the PE PCB Service. Start with the components that mount on the back. Specifically, solder CON1 first because its pins are somewhat difficult to access. We’ve extended its PCB pads to make soldering it slightly easier. Apply some flux paste to the pads for the USB socket, turn your iron up slightly (if it’s adjustable) and line up the socket; the locating pins go into holes on the PCB to aid alignment. Solder one of the larger mechanical pads on the body, ensuring that the electrical pads are flat against the PCB. Load up the tip of the iron with a small amount of fresh solder and place it on each PCB pad in turn, adding some solder to the tip between pins. The flux Practical Electronics | August | 2021 +5V +5V 100nF  10k D+ 12 13 4 GND 10k 2 +V D– 10k 1 +5V CON1 1 2 3 X 4 100nF LDR1 Jaycar RD3480 8 9 10 D–/RA1 AN3/RA4 IC1 RC5/RX PIC16F PIC 1 6F1 14 4 55 D+/RA0 MCLR/RA3 RC4/TX AN7/RC3 RC2/SDO/AN6 RC1/SDA PWM2/RA5 RC0/SCL/AN4 VUSB3V3 1M 3 100nF 16 15 5 5 6 6 7 7 2 8 +5V 390 9 11 0V 3 100nF 14 2 SCL Vcc NC NC 32kHz SQW/INT SDA RESET NC NC NC 1 3 BAT1 2032 4 IC2 14 DS3231 VBAT NC NC 1 GND NC 2 12 1 11 10 13 CON3 CON2 1 3 4 100 SET DOWN 5 ICSP CON4 WS2812B 8x8 RGB LED MODULE (BEHIND) 2 100 UP CAPACITIVE ‘BUTTONS’ ATtiny816 Breakout Board for PICkit 4 SC OL’ TIMER II WORD CLOCK 2020 Fig.1: like many microcontroller-based projects, the circuit for this one is quite simple. It uses two ICs and a handful of passives; the largest part is 8×8 RGB LED matrix MOD1, which connects to the rest of the circuitry via pin header CON3. will induce the solder to run off the iron and onto the pins. Inspect your work with a magnifying glass; it will be much easier to correct this now without other components in place. Use the braid and iron to remove any excess if there is a bridge. There isn’t much room to do this, so take your time. Once you are happy with the socket’s pins, solder the remaining mechanical tabs. The iron can be turned back to its regular setting after this. Fit the ICs next. IC1 is the smaller, 14-lead part. Apply some flux to the IC’s PCB pads and rest the IC on its pads. Check that the pin 1 dot is adjacent to the dot marked on the PCB. Solder one corner pin in place and check that the remaining pins are flat and within their pads. If not, soften the solder with the iron and adjust until they are. Solder the remaining pins, adding solder to the iron as you go. If you make a solder bridge, leave it for now and ensure that the pins are all soldered before correcting. This will ensure that the IC stays in the correct place. Use the braid and iron (and extra flux if necessary) to remove any excess Practical Electronics | August | 2021 H A L F P A S T Q U A R T E R O T M E I G H I H S I R T E N I E L S E V E N L E X F T T W O E O C L solder which is bridging between pins. The technique we use is to apply the flux to the top of the bridge, then press the braid against it using the iron. Gently draw the braid away from the pins after the solder melts and is drawn into the braid. IC2, the wider 16-pin part, has a similar treatment. Check its orientation then solder one pin. Once it is in the correct location, solder the remaining pins and remove bridges as necessary. There are four identical 100nF capacitors. They will have no markings and are not polarised. Refer to our photos, the overlay and PCB silkscreen to see where they fit. As with the ICs, apply flux, solder one pin in place, check that it is square, flat and flush against the PCB before soldering the remaining pin. There are a few different resistor values, so check these against the PCB markings, the photos and Fig.2 before fitting them. The LDR is a through-hole part, but we have to mount it in an unorthodox fashion to fit in with the other parts. Have a look at the overlay and photos as you read through the explanation. O U R N E O L O C K V E AM PM Sit the PCB face-down on a flat surface, bend the LDR’s leads by 90° and place it in the centre of the hole marked LDR1 with the leads aligned vertically. It’s not polarised, so it doesn’t matter which way it is rotated. Mark on the leads where they cross the pads on each side of the hole, then trim one, using the other to position the part. Place the LDR back in the hole and solder the shortened lead in place to the adjacent pad. Flip the PCB over and check that the appearance is acceptable and that the LDR is centred and parallel to the PCB before trimming and soldering the remaining lead. It’s easier to bend and adjust the leads while only one is soldered. The battery holder is a larger part, so you might like to turn the iron temperature up. Apply some flux paste to the pads and sit the battery-holder (BAT1) over the top. Ensure that the opening is at the edge of the PCB to allow the battery to be fitted or removed. As for the other parts, solder one pad, then check the alignment and then solder the other pad. If you need to program IC1 in-circuit, then you can solder a header for CON2 19 CON4 T S A P F L A H O R E T R AU Q T H G I EM I T R UO F X I S H O E N I N E T R L N E V E S L E E V L E OWT E MP MA K C O L C O H A L F P A S T Q UA R T E R O T I ME I G H T H S I X F OU R R T E N I N E O E L S E V E N L E TWO E L V E O C L O C K AM PM UP 100nF 100nF + SILICON CHIP OL’ TIMER II BAT1 FRONT VIEW 4.7k IC2 DS3231 CR–3032 4.7k 1M 100nF 10k IC1 DOWN CON3 PIC16F1455 SET CON3 LDR1 390 100nF CON1 2x 100 CON2 REAR VIEW (WITHOUT RGB LED MODULE) Fig.2: follow these top and bottom side PCB overlay diagrams during construction. Most of the PCB does not have components installed; it is used as a mask for the LEDs. Since virtually all components are on the back, the letter mask appears backwards in that view. Fit the USB socket, then the ICs, followed by the passives. The battery holder and LED module come last. as we have done. But this is not strictly necessary as it is possible to simply hold the header in place during programming. There are small vias on the pads which help keep the header aligned. We should point out that while they are through-hole parts, none of the headers (CON2-CON4) are soldered in the regular manner. Instead, they are vertically surface-mounted onto a set of pads. In each case, first insert it into a header socket to keep the pins together and aligned (and also provide something to hold onto, as the header will get hot!). Put some solder flux on the pads and rest the header approximately where it needs to go. Solder one pin in place and check the alignment. If it is only slightly off, you might be able to gently flex it before soldering a pin at the other end of the row, but don’t flex it too hard, or it might tear the pads from the PCB. For CON2, once it is in position, solder the remaining pins of the header and then remove the header strip. For CON3 and CON4, you should check that MOD1 is correctly aligned before soldering the remaining pins. So once you’ve tacked CON3 and CON4 in place, check for squareness by trying to fit the LED matrix module over the top. It’s also a good idea to test-fit the acrylic mask piece to ensure that everything is aligned before soldering all the header pins. Once they’ve been fitted, slide the acrylic mask piece over 20 the pins, then fit MOD1. This is then soldered to CON3 and CON4. It will be tricky to undo this, so take extra care in ensuring that the two boards are parallel and as close together as possible. We tacked one pin, then firmly squeezed the boards together while remelting the solder, allowing the gap to close. Note that the PCB and module won’t quite be flush because the LED module also has small capacitors on its surface. Programming You don’t need to program IC1 if you purchased it pre-programmed. But if you have a blank micro, you need to program its Flash memory with the firmware HEX file to get the clock to work correctly. Download this from August 2021 page of the PE website before proceeding and extract the HEX file from the ZIP package. You can use a PICkit 3, PICkit 4 or Snap programmer to do this. We used a Snap, but since this does not provide power, you will need to supply power via a USB cable plugged into the USB socket. Note that the Snap cannot perform high-voltage programming, so if IC1 has had its LVP (low-voltage programming) fuse bit set, the Snap can’t clear it. But it will work with a new, blank chip. Plug your programmer into the ICSP header (CON2). Its pin 1 is closest to the USB socket and marked with a small arrow. If you have not soldered the header for CON2, merely plug a male header To remove the plastic holder from the pin headers (after soldering to the main PCB), carefully place a pair of pliers as shown and squeeze. You should repeat this procedure for CON4 too, before soldering MOD1 in place. Practical Electronics | August | 2021 At left is the populated PCB with the LED Matrix (MOD1) fitted above. Not seen is the acrylic mask that sits between the two. The photo at right shows the gaps in the solder mask which allow the light to shine through. strip into your programmer and hold it against the pads of CON2. We recommend that you use the free Microchip MPLAB X IPE (integrated programming environment) software. Windows, Linux and Mac versions are available from www. microchip.com/mplab/mplab-x-ide The PIC16F1455 is an 8-bit part, so install support for 8-bit parts if queried. Open the IPE, select ‘PIC16F1455’ as the device and choose your tool from the dropdown below this. Select ‘power target circuit from tool’ if you aren’t providing 5V via the USB cable. But do not do both. Click ‘Apply’, then ‘Connect’; the IPE should indicate that it has found a PIC16F1455 device. You can then use the browse button opposite the Hex File option to choose the .HEX file that you downloaded earlier. Click ‘Program’ to write the .HEX file into the chip’s Flash memory. If you run into problems, check that the programmer settings are correct and ensure that power is supplied from either the programmer or a USB cable, but not both. Also, check that your programmer is making good contact with CON2. If holding the header to the board, it might work if you try again. Setup If you haven’t already done so, connect the clock to a computer using a mini-USB cable. The first time it’s powered up (ie, with IC2’s time unset), it should light up showing the words, ‘TWELVE OCLOCK AM’. The clock uses the same IC and USB-serial profile as the Build the Microbridge project from May 2018. If you need drivers (which should not The LED matrix module is connected to the main PCB by two pin headers, with a laser-cut acrylic spacer in-between. It can be fiddly to put this all together and even tougher to disassemble if it is wrong, so proceed carefully. Practical Electronics | August | 2021 be necessary under Windows 10, Mac or Linux), then suitable drivers can be downloaded from www.microchip. com/wwwproducts/en/MCP2200 You will need a serial terminal program to complete the setup. We used TeraTerm, although most serial terminal programs, including PuTTY (but not the very limited Arduino Serial Monitor) should work. Find the device’s port and open it. You do not need to worry about the baud rate as the clock uses a virtual serial connection that ignores that setting. Once connected, pressing the Esc key should bring up the menu. If at any time you don’t know what the setup program is doing, press Esc to return to this point and abort any entry. Refer to screengrabs Screen 1-3 during the setup process. The prompts and responses are quite intuitive. The first option, ‘1’, sets the time. Press Esc, 1 and then the time in HHMMSS 24-hour form, then press Enter. The time is immediately saved to IC2 and the time display is updated. For example, to set the time to 3:30pm, type the digits ‘153000’ when prompted. There are also three colours that can be set, for the hours, minutes and AM/PM. These are entered as six-digit hexadecimal codes in the form RRGGBB. These sorts of codes are commonly used on webpages, so are easy to find, even if you don’t speak hexadecimal! 21 Parts list – Ol’ Timer II 1 double-sided PCB coded 19104201, 77 x 99mm [From PE PCB Shop] 1 8x8 RGB LED module using WS2812B or similar (MOD1) [19104201-88 From PE PCB Shop] 1 set of acrylic case pieces and spacer [19104201-ACR From PE PCB Shop] 1 ORP12 or similar LDR (LDR1) [Jaycar RD3480, Altronics Z1617] 1 SMD button cell holder to suit CR2032 (BAT1) 1 CR2032 lithium cell (BAT1) 4 100nF 50V X7R SMD capacitors, 3216/1206 size Code 104 1 SMD mini type-B USB socket (CON1) 1 5-way male pin header (CON2, optional) 2 3-way male pin headers (CON3,CON4) 8 M3 x 6mm machine screws 4 M3 tapped 15mm nylon spacers Semiconductors 1 PIC16F1455-I/SL 8-bit microcontroller programmed with 1910420A.hex SOIC-14 (IC1) 1 DS3231 real-time clock IC, wide SOIC-16 (IC2) [19104201-RTC From PE PCB Shop] Resistors (all 1% SMD, 3216/1206 size) 1 1M Code 105 1 10k Code 103 2 4.7k Code 472 1 390 Code 391 2 100 Code 101 We’ve listed a few common colour codes in Table 1; these are taken from the officially named HTML colours. If these are not suitable you may find the website https://htmlcolorcodes. com/ quite helpful for generating and listing codes. Thus, to set the colour of the minutes display to red, you would press ESCAPE, 2, FF0000 and press Enter. The colour change takes effect immediately, but does not get saved to non-volatile memory. This is only done when needed to reduce wear and tear on the Flash memory. If you make an error while typing, you can use Delete or Backspace to remove the last character, or press Esc to abort and jump back to the main menu. There are two different brightness settings. One of these corresponds to the brightness under low light conditions and is controlled by using the ‘+’ and ‘−’ keys. These can be pressed at any time to alter the brightness, no matter what the menu is doing. The ‘<’ and ‘>’ keys control brightness under higher ambient light conditions, and they operate similarly. We found that in indoor conditions, quite low levels were comfortable, so we set the defaults quite low. The software prevents the level being set so low that the display is invisible. The software does not manage the current drawn by the clock, nor make requests for power above the 100mA default set by the USB standards. We found that the normal clock display at default brightness levels sat just under 100mA, and rose to near 500mA with the brightness set high during setup (when more than the usual number of segments are lit). With the brightness set this high, the display is almost too bright to look at, so lower levels are quite adequate. Still, this shouldn’t be a problem, especially if the clock is to be powered by a ‘dumb’ USB charger. Even if left connected to a computer, most USB ports will supply 500mA without complaining, enough to run the clock. To set the clock brightness to work with a full range of lighting conditions, put the clock in a dark room (what it Table 1 Common hexadecimal colour codes Aqua 00FFFF Blue 0000FF Brown A52A2A Crimson DC143C Cyan 00FFFF Gold FFD700 Grey 808080 Green 008000 Indigo 4B0082 Lime 00FF00 Maroon 800000 Navy 000080 Orange FFA500 Pink FFC0CB Purple 800080 Red FF0000 Salmon FA8072 Sky blue 87CEEB Tan D2B48C Teal 008080 Violet EE82EE White FFFFFF Yellow FFFF00 The colour codes here are drawn from the standard HTML colours used on web pages (we don’t ‘agree’ with some of the name choices, but they give you some idea). Note that they may look different on the clock due to the PCB fibreglass colour and surrounding solder mask. would be typically exposed to, say, at night) and set the ‘low’ brightness to a comfortable level using + and −. Then expose the Clock to daytime illumination and set the ‘high’ brightness with the < and > keys. Check that the clock now responds correctly under all light conditions and tweak these further if necessary; the ‘low’ and ‘high’ levels will interact to a small degree so you may need to iterate this process a few times. To save the colour and brightness settings, press Esc and then 5 as per the menu prompt. The current settings are saved to Flash memory and will now be loaded every time the clock powers up. The serial interface has one more trick. If the ‘q’ key is pressed, the debugging mode is turned on. It can be turned off by pressing ‘q’ again or pressing Esc. The result is shown in Screen3; the current time, RTC status and intended The case pieces are assembled from back to front; the spacers are fitted to the back panel before the side pieces are slotted in place, with the main PCB being screwed in from above. 22 Practical Electronics | August | 2021 In setting the hours, minutes and seconds, either an H, M or S is seen along with the value as a decimal number (17 here). The real-time clock is updated after you leave the seconds setting. LED display is scrolled and updated every second. If the unit’s display does not look right, this will give you an indication as to what the problem might be. Or, if the time does not appear to be saved or loaded correctly, you will know whether RTC chip IC2 is functioning correctly. Touchpads If you don’t have access to a computer or USB terminal program, all these parameters can be set using the touchpads. There are fourteen parameters set in turn; these are cycled by pressing the SET touchpad. The current parameter is changed by using the UP and DOWN touchpads. The two brightness settings HI and LO are also set in hexadecimal, although you should simply adjust the level to be comfortable. A palette at the bottom indicates how some colours will look. Practical Electronics | August | 2021 The pads have to be pressed quite firmly; we deliberately avoided making it too sensitive as it would be quite annoying to have the settings change unintentionally. If you have trouble, then try slightly moistening your finger. The values are shown in decimal for time and hexadecimal for other numeric values (colour and brightness). Apart from the numeric display, some other LEDs are lit to let you know what is being set. The first three parameters (in order) are the time in hours, minutes and seconds, with the letters H, M or S being shown to indicate this. After the seconds are entered, the time is saved. If you make a mistake, the best option is to remove power for a second; there is no other way to avoid saving the time. This is followed by the hours colour (red, followed by green, then blue) components. The minutes colour and then AM/PM colour follow. The component is shown by, for example, a red H or blue O (for other; ie AM/PM). The top-right LED (a T) shows how the mixed red, green and blue components look. This is followed by the low brightness ‘LO’ and the high brightness ‘HI’. A palette along the bottom line shows how different colours would look at these brightnesses. The photos on this page show these different displays. A fifteenth screen shows a red (floppy disk!) save icon. If the UP or DOWN buttons are pressed when this is showing, the colour and brightness settings are saved to Flash. Thus, all the parameters can be set, even if you don’t have access to a computer or terminal program. Completing assembly Once you are happy that the clock is working correctly, fit a CR2032 battery to the holder. Check that the time is retained when the power is off. The battery should last close to its shelf life if the clock is powered most of the time. Fit the threaded spacers to the large back panel, with screws on the matte side. Slot the side and top pieces in place. The spacers are a tight fit, so you may need to rotate them to clear the side pieces. Note that the lefthand and righthand pieces are similar, but slightly different to fit around the USB socket or battery holder. Rest the PCB on top and use the remaining screws to secure it to the spacers and the remainder of the case. The clock is now able to sit upright on its bottom edge. There are nine colour pages, one each for the red, green and blue components of the hour, minute, and AM/PM colour. The displayed colour is in hexadecimal (FF here) and jumps by 15 steps at each press. For a simpler way to set the colours, use the USB terminal. Final notes Coin cells can be dangerous if they are ingested. Thus the clock should be kept away from small children and babies. We suspect it would be very difficult to remove the battery from the Ol’ Timer II without removing the back of the case, but we recommend not taking any chances with this. If you wish to be even more cautious, you could secure the battery in place with some glue or silicone sealant. Reproduced by arrangement with SILICON CHIP magazine 2021. www.siliconchip.com.au The settings are not saved by default. You should press the UP or DOWN button when this icon is visible to save the settings to Flash memory, meaning they are loaded at power-on. 23