Silicon ChipSuper Clock now shows your electricity tariff - July 2018 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Don’t be ripped off by your smart meter
  4. Feature: The farm of the future . . . Part II by Ross Tester
  5. Feature: Revolutionary: the Philips Compact Cassette by Ian Batty
  6. Project: Super Clock now shows your electricity tariff by Tim Blythman
  7. Serviceman's Log: Valve repairs are not for the inexperienced by Dave Thompson
  8. Review: The latest Raspberry Pi – the Model 3 B+ by Tim Blythman
  9. Project: Raspberry Pi Tide Chart by Tim Blythman
  10. Project: How’s your memory? Build the Event Reminder by John Clarke
  11. Project: 800W (+) Uninterruptible Power Supply (UPS) Part III by Duraid Madina and Tim Blythman
  12. Feature: El Cheapo: 500MHz frequency counter and preamp by Jim Rowe
  13. Vintage Radio: The 6-transistor Motorola 66T1 by Ian Batty
  14. Product Showcase
  15. PartShop
  16. Market Centre
  17. Advertising Index
  18. Notes & Errata: AM Radio Transmitter
  19. Outer Back Cover: Hare & Forbes Machineryhouse

This is only a preview of the July 2018 issue of Silicon Chip.

You can view 40 of the 104 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:
  • AgBots – robots working on the farm of tomorrow! (June 2018)
  • AgBots – robots working on the farm of tomorrow! (June 2018)
  • The farm of the future . . . Part II (July 2018)
  • The farm of the future . . . Part II (July 2018)
Items relevant to "Super Clock now shows your electricity tariff":
  • PIC32MX170F256B-50I/SP programmed for the Tariff Super Clock [SuperTariffClock.hex] (Programmed Microcontroller, AUD $15.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • Micromite LCD BackPack V2 complete kit (Component, AUD $70.00)
  • Firmware (HEX) files and BASIC source code for the Micromite-based Tariff Super Clock [v2] (Software, Free)
Items relevant to "Raspberry Pi Tide Chart":
  • Raspberry Pi 2.8-inch Touchscreen Display Adaptor PCB [24108181] (AUD $5.00)
  • 2.8-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $25.00)
  • Software for the Raspberry Pi Tide Chart (Free)
  • Raspberry Pi 2.8-inch Touchscreen Display Adaptor PCB pattern (PDF download) [24108181] (Free)
Items relevant to "How’s your memory? Build the Event Reminder":
  • Recurring Event Reminder PCB [19107181] (AUD $5.00)
  • PIC12F617-I/P programmed for the Recurring Event Reminder [1910718A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Firmware (ASM and HEX) files for the Recurring Event Reminder [1910718A.HEX] (Software, Free)
  • Recurring Event Reminder PCB pattern (PDF download) [19107181] (Free)
Items relevant to "800W (+) Uninterruptible Power Supply (UPS) Part III":
  • 800W+ Uninterruptible Power Supply control shield PCB [11106181] (AUD $5.00)
  • Arduino Sketches (.ino) and library for the 800W+ Uninterruptable Power Supply (Software, Free)
  • 800W+ Uninterruptible Power Supply control shield PCB pattern (PDF download) [11106181] (Free)
  • 800W+ Uninterruptible Power Supply front panel artwork (PDF download) (Free)
Articles in this series:
  • 800W (+) Uninterruptible Power Supply (UPS) (May 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) (May 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part II (June 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part II (June 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part III (July 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part III (July 2018)
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)

Purchase a printed copy of this issue for $10.00.

Are you paying way too much for your electricity? VERY SMART TARIFF SUPER CLOCK The media abounds with sob stories involving electricity smart meters, where promised savings have not only failed to materialise but hapless consumers are even paying $$$ more for their power than they did before their smart meter was installed. The main problem is that most consumers are blissfully unaware when shoulder tariffs (read expensive!) or peak tariffs (read very expensive!) have kicked in. This “clock” project will warn you – and help you to avoid “bill shock” from electricity suppliers! By Tim Blythman T he principle is simple enough: all you need to know is which tariff is active at any particular time. The execution is a little more complex – the way we’ve gone about it is to modify our very popular Touchscreen Super Clock (July 2016 – siliconchip. com.au/Article/10004) so it can display which power tariff is currently active (peak, shoulder or off-peak) so that you know how much you’re paying for electricity. Don’t know? The clock will also display that for you. You can build it from scratch or update an existing Super Clock. It’s superaccurate, using a real-time clock module, GPS or NTP (internet) time. This project is a two-for-one deal – you get a very useful world clock with accurate timekeeping and automatic daylight saving adjustments, plus you get that very simple way of checking how much you are currently paying for electricity. Since electricity is very expensive and potentially much more expensive if you have a so-called “smart meter”, you want to run your high-power appliances during off-peak times, if at all possible. But how do you know when that is? All you have to do is look at the face of this clock and you will immediately know by its colour whether the present tariff is peak, off-peak or shoulder. The display is red during peak periods, black for shoulder periods and green for off-peak. Looking for controls? There are none: everything is controlled via the Micromite BackPack touchscreen. Here the black screen denotes that it is on “shoulder” tariff time (32c per kWh) – not quite as expensive as “peak” but expensive enough to make a serious dent in your budget! Incidentally, you have the choice of digital or analog clock “face” (as seen here). 34 Silicon Chip Australia’s electronics magazine siliconchip.com.au You can also have a small display in the corner of the screen showing the current cost in cents per kWh, so you know exactly how much you are paying for power at any instant. While you can’t always decide when to use power, some energy-hungry tasks can be timed to coincide with the cheaper tariffs. For example, you could avoid doing laundry when the peak tariff is in effect, and similarly, you could delay running the dishwasher when power is expensive. Most dishwashers heat the water electrically, as do many washing machines, making them very power-hungry. If you have a swimming pool, your pool pump is probably on an automatic timer but you need to periodically check that it mostly runs during off-peak periods to save money. And some people prefer switching on their pool pump manually at certain times, especially when using it to run a Kreepy Krauly or similar cleaning appliance. You can set up the tariff periods and costs displayed by the clock to match those from your electricity retailer (you should find the rates on your last bill). Don’t die of shock when you’re reminded what you’re paying! Features • • • • • • • Display changes colour to indicate peak, shoulder or off-peak tariff Cost of electricity is shown (in c/kWh) Up to six tariff transitions per day; can vary between weekdays and weekends Digital (12hr/24hr) and Analog clocks Up to 20 separate clock screens with different time zones Accurate timekeeping with low-cost real-time clock module Alternatively, can be synchronised to GPS or NTC (internet) time NOTE: this clock does not control power in any way (it is not connected to the mains supply). It is only designed to give you an accurate, visual indication of the current tariff. But the real key to that project was the MMBasic software which turned it into an accurate and easy-to-use world clock. to keep time accurately but don’t have good GPS reception – perhaps because the unit is too far indoors. For this you only need an ESP8266 WiFi module, as described in our April 2018 article on the “Clayton’s” GPS Time Source (siliconchip.com.au/Article/11039). If you’ve already built the Micromite Super Clock, it’s easy to update the software to add the Time-of-Day Tariff display; no extra hardware is needed. If you haven’t, building it is quite straightforward. Circuit description This project is an evolution of Geoff Graham’s “Touchscreen Super Clock”, which was published in the July 2016 issue (siliconchip.com.au/Article/10004). It used a Micromite LCD BackPack module with 32-bit PIC and 2.8-inch LCD touchscreen, plus either a realtime clock module or GPS module for timekeeping. Since then, we published an updated Micromite LCD BackPack V2 module (May 2017; siliconchip.com.au/Article/10652), which incorporates an onboard USB/serial interface and PIC32 programmer, making it easier to set up. It also has the option for the software to control the LCD backlight brightness. And we are providing another refinement for this version of the clock: if you have a WiFi network, you can use the Network Time Protocol (NTP) to get accurate time over the internet. This is especially useful if you want the clock The circuit is shown in Fig.1 and virtually all the parts are part of the LCD BackPack V2 module. The only additional parts are the timekeeping modules, as shown near the bottom of the diagram. Only one of the three modules needs to be fitted. The BackPack is designed around IC1, a 32-bit microcontroller with 64KB of RAM, 256KB of flash memory, an internal analog-to-digital converter, timers, PWM generators and so on. IC2 is an 8-bit microcontroller which provides the USB serial interface via CON4 and interfaces with the main serial port at pins 11 and 12 of IC1 (which is also broken out to header CON1). Twenty to five in the morning and the clock is glowing green to show you that you’re in the off-peak tariff (they’re still charging you 19c/kWh!) 11.13AM and you’re in the black: shoulder, that is! But look at that tariff – 32c/kWh – it’s almost (but not quite!) as bad as the peak tariff! Danger, Will Robinson, danger! It’s glowing red to warn you that you’re being charged a whopping 38c/kWh in peak period (3pm–9pm in this case). Hardware and software siliconchip.com.au Australia’s electronics magazine July 2018  35 Fig.1: the circuit of the Tariff Clock is essentially just the Micromite LCD BackPack V2 (which incorporates the Microbridge [IC2]) with one of three possible time sources wired to CON2, allowing it to get the time from either the internet (NTP), GPS satellites or an on-board real-time clock. Power comes from a USB charger or 5V plugpack wired to CON1. IC2 also allows operation in a different mode, where it resets microcontroller IC1 and re-programs its flash memory via pins 4 and 5 (programming data and clock respectively). This means you don’t need a separate PIC programmer to upgrade to a newer version of the Micromite firmware (and MMBasic). REG1 provides the 3.3V supply for IC1, derived from the 5V either from the USB socket (CON4) via jumper JP1 or from header CON1. Mosfets Q1 and Q2 allow a PWM signal from pin 26 of IC1 to control the touchscreen backlighting LED brightness. VR1 can be fitted instead to provide manual control, however, the kit is supplied with 36 Silicon Chip these Mosfets and we recommend that you fit them. Communications between IC1 and the LCD touchscreen are over an SPI (serial peripheral interface) bus on pins 25 (clock), 3 (data from IC1) and 14 (data to IC1). Pins 6, 23 and 2 of IC1 drive the LCD chip select, reset and data/command control lines respectively. The touch sensor shares the same SPI bus, however pin 7 and 15 are used for its chip select and interrupt request lines. The circuit diagram shows a WeMos D1 ESP8266 WiFi module being used as the time source. This needs to be programmed with the software from our Australia’s electronics magazine April 2018 project to allow it to connect to NTP servers over the internet (via WiFi), fetch the time and supply it to microcontroller IC1. Only three wires are required; two for power (3.3V and GND) and one to feed the serial NMEA data to pin 22 of IC1. The two alternative time source connections are also shown in Fig.1, with connections for the GPS module being almost identical to those for the WeMos module. The 1kΩ resistor is simply a safety feature in case your GPS module is running from 5V and its output pin goes higher than +3.3V. Our recommended GPS module can run from 3.3V, in siliconchip.com.au We used the Clayton’s GPS (WeMos D1 Mini) option for our clock. It’s cheaper than a fullblown GPS module. which case this resistor is not necessary. The third option is the DS3231-based real-time clock module and this simply involves four connections, two for power (5V/GND) and two for the I2C bus (SDA [data] and SCL [clock]). The 5V supply is used so that the module can charge its on-board Lithium-ion button cell. If you’re using a primary (Lithium) cell then you could run it off 3.3V instead and indeed that would be safer, since it would not have enough voltage to try to charge that cell. Having said that, if using a primary cell, it’s still a good idea to pull the charging diode off the board just in case (see page 60 of the June 2016 issue for details on doing so). So that covers the operation of the Micromite BackPack circuit and its alternative time sources; what sets this project apart from the original Super Clock is the new software. How the software works We started with the existing Super Clock code, which already handles tasks such as getting the time from the GPS module or real-time clock, calculating the time in a variety of locations (ie, applying time zone offsets and daylight saving rules) and displaying the time in analog or digital format, along with the date, on the screen. The software did not need any changes to support the new NTP (internet) time source since that was purposefully designed to appear as if it is a GPS module and thus the existing Super Clock GPS code already worked with it. But we needed to add some new configuration screens to allow you to set the times when the tariff (ie, the cost per kWh) changes. This new code stores this data in flash memory, to determine the current tariff based on the time and date and to change the clock colour and display the cost on the screen. Changing the background colour of the display, based on the current tariff siliconchip.com.au Determining the current tariff The tariff periods are defined simply by providing a list of times (to the nearest hour) and the new tariff which becomes active on that hour. You should be able to find the tariff switching times (and indeed the amount charged under each tariff) by referring to your energy provider’s website. (Actual amounts charged under each tariff should also be shown on your electricity bill). So, for example, if the Peak tariff is active from 3pm to 9pm and the Shoulder from 7am to 3pm and 9pm to 10pm, you have four tariff changes per day. These are: 7am (Off-peak to Shoulder), 3pm (Shoulder to Peak), 9pm (Peak to Shoulder) and 10pm (Shoulder to Off-peak). Since the previous state is already known, we need only specify the time and new state (Peak, Shoulder or Off-peak) for the Clock to be able to determine the current tariff. By setting the prices (in cents per kWh) of the Peak, Shoulder and Off-peak tariffs, the Clock can then look up and display the current tariff. If there were two Peak periods during the day (morning and evening) then the same scheme could be used but you would have six transitions. We have made provision for this, even though no Australian electricity retailer currently has such a scheme. We also allow you to choose whether a given transition is active on weekdays, weekends or all days. This is necessary because in some cases, the Peak period is not active on weekends. Therefore, by making the transitions to the Peak tariff dependent on it being a weekday, they are ignored on weekends and the previous (usually Shoulder) tariff applies during those periods instead. So the six “tariffs” which are listed on the Edit Tariffs page are actually the start times of the listed tariff period. The default tariff periods are as follows: Weekdays: Weekends: Shoulder from 7am to 3pm, Peak from 3pm to 9pm, Shoulder from 9pm to 10pm, Off Peak other times Shoulder from 7am-10pm, Off Peak other times To change these, access the Edit Tariffs page via the main menu and click on the Edit button next to the entry that you want to change. You can then set the transition period type (Peak, Shoulder, Off-peak or not in use), transition time (on the hour) and whether it applies on weekdays, weekends or any day. For example, one tariff plan we saw specified Peak hours of 7am-11pm weekdays with all other times being Off-peak. This can be reduced to two entries 1: Peak, 7am Weekdays 2: Off-peak, 11pm, Weekdays All other tariff entries should be set to “not in use”. The choice of allowing the time to be set to the nearest hour was based on the fact that all the tariff offers we saw are timed on the hour. This greatly simplified programming and reduced the amount of data to be stored. If at some point a retailer specifies a transition time that is not on the hour, we suggest that you round the transition time to the start of that hour if it is from a cheaper to a more expensive tariff (eg, shoulder to peak) or to the next hour if it is from a more expensive to cheaper tariff (eg, peak to shoulder). This way, the tariff displayed will always be either correct or high for a short period. You won’t be lulled into thinking electricity is a lot cheaper than it actually is. Australia’s electronics magazine July 2018  37 period, makes it immediately apparent and does not occupy any extra space on the screen, so that the time and date can still be shown at the same size as before. When the background is red (when the peak tariff is active) or green (when the off-peak tariff is active), the colours used are a dull red and dull green respectively. This provides good contrast for the brighter foreground colours used. If we had used bright colours, the existing display would have become hard to read. If you aren’t happy with our colour choices, you could easily change them by modifying and re-uploading the BASIC source code. We have named the three tariff periods “peak”, “shoulder” and “off-peak”. The shoulder period may not be used by some electricity providers or in some regions, in which case you can simply ignore it and use peak and off-peak only. These names could also be changed in the BASIC code, if necessary. Every hour, on the hour, the clock checks which tariff is active and sets the screen background colour. The clock display on the screen is re-drawn with this colour and the background remains this colour until it needs to change again. The more complicated changes to the program are in the menu code which is used to set the tariff times. An extra button has been added to the configuration screen to access these options (see screen grabs). Building it from scratch If you’re building this Clock project from scratch (ie, you haven’t already built the Super Clock), we recommend that you use the Micromite BackPack V2, which is available as a short form kit from the SILICON CHIP Online Shop (see parts list). The following instructions are based on this. The clock configuration menu: here’s where you choose between analog and digital formats and as shown, set the date, time, tariff and so on. 38 Silicon Chip Parts list – Tariff Super Clock Micromite LCD Backpack V2 short form kit [SILICON CHIP Cat SC4237; includes laser-cut UB3 lid] 1 USB Type-A to mini Type-B cable 1 WeMos D1 Mini programmed as Clayton’s GPS module (for NTP time; see April 2018 issue) [Jaycar cat XC3802] Or 1 VK2828U7G5LF GPS module [SILICON CHIP Cat SC3362] Or 1 DS3231-based RTCC module with rechargeable cell [SILICON CHIP Cat SC3519] 1 UB3 Jiffy box [Jaycar HB6013, Altronics H0203] 2.1mm inner diameter DC bulkhead socket [eg, Jaycar PS0522, Altronics P0622] 2.1mm inner diameter DC line plug [eg, Jaycar PP0510, Altronics P0634A] 1 USB lead with Type-A plug at one end 1 red DuPont-style jumper lead with female socket 1 black DuPont-style jumper lead with female socket However, it can also be built using the original Micromite LCD BackPack kit; if you’re upgrading an existing Super Clock, you will almost certainly be using this board. While you can use the Micromite Plus LCD BackPack from the November 2016 issue (siliconchip.com.au/ Article/10415), which has a faster processor and more memory, it is more tricky to assemble as it uses mostly surface-mounting components. If you decide to do this, refer to the November 2016 issue for construction details. No software changes are required. If ordering one of the BackPack kits from our Online Shop, you have the option for the microcontroller to be preprogrammed with the BASIC code for the Tariff Clock, so that it’s ready to go as soon as it’s powered up, or the original Super Clock code. Besides the BackPack kit, the next most critical part is the time source: either a real-time clock module, GPS module or ESP8266 WiFi module. All three are available from the SILICON CHIP Online Shop (see parts list for catalog codes) or from Jaycar. The few remaining parts needed are also shown in the Parts List above. When choosing a time source, keep in mind that the GPS module will give the most accurate time if you have a good signal while the ESP-01 module (Clayton’s Time Source) will get the correct time most quickly when power is first applied. The real-time clock is quite accurate and only drifts a few seconds per year but you will need to set the time initially, from an accurate clock. You could also use the very accurate “pips” marking the hour on many radio stations – the sixth “pip” actually marks the start of the hour (if you want to be pedantic, the start of the sixth pip marks the start of the hour!). The standard analog clock display features location title, tariff currently being charged (which you set) along with today’s day and date – plus, of course, the current time. Here’s the 12-hour digital clock, in this case set up for New York (you can set it for just about anywhere you want). Again, you get the time, day/ date and electricity tariff. Australia’s electronics magazine Construction First, you need to build the BackPack module. Full instructions are available in the articles mentioned above. It’s basically just a matter of soldering the components in place where shown on the PCB overlay diagram and PCB silkscreen printing. If you’re building the recommended V2 BackPack, you can use the overlay diagram shown in Fig.2 as a guide. There are just 22 components to fit to the PCB before plugging in and attaching the Touchscreen module. Three of these are SMDs (CON4, Q1 and Q2) so we recommend that you solder these first. siliconchip.com.au Fig.2: use this PCB overlay diagram and photo when assembling the BackPack board. Take care with the orientation of IC1, IC2, REG1 and LED1. The 2.8-inch LCD touchscreen module plugs into CON3 and sits on top of this board once it is complete. It is attached using tapped spacers in each corner. VR1 (highlighted in red above) should not be fitted if Q1 and Q2 are used, as recommended. Start with CON4. Place a thin smear of solder paste on each of its pads, then solder one of its large mounting tabs first. Check that the small pins are lined up and then solder these. Clean up any solder bridges using solder wick with some additional flux paste. Check carefully that these solder joints have been formed properly since it’s easy to miss one or two. After mounting Q1 and Q2, fit the resistors, then S1 and IC1/IC2. It’s a good idea to use a socket for IC1 at least, and possibly IC2. Regardless of whether you’re soldering in the socket or the IC, ensure that the pin 1 dot/notch is orientated correctly as shown in Fig.2. Then solder the remaining components from shortest to tallest, ensuring that LED1 and REG1 are orientated correctly. If using SMD ceramic capacitors, they are not polarised. You don’t need to fit VR1 if you have fitted Q1 and Q2 as recommended, and note that CON1 and CON2 are soldered to the opposite side of the PCB compared to the other components. You can then plug in the LCD touchscreen to CON3 and mount it to the main PCB using 12mm tapped spacers and short machine screws. Ths screen allows you to change any of the tariffs according to your area and electricity supplier. If you don’t have a “shoulder”, for example, simply leave blank. Getting down to the nitty gritty, here’s where you set the start time for each tariff. The software automatically assumes the next tariff start time will be the current tariff stop time. siliconchip.com.au Fault finding Your BackPack should work first time but if it does not, the first thing to do is check that the correct supply voltages are on the IC1 and IC2 sockets and CON3 (the LCD connector). Then check the 5V current drain for the full module, including the LCD; it should range from 100mA to 200mA, depending on the setting of the backlight (which is normally off at powerup if using software backlight control). If it is substantially lower than 100mA, check that the PIC32 and the LCD are correctly seated in their sockets. With the LCD removed, the current drain should be about 30mA. If it is a lot less than this, it indicates that the PIC32 processor has not started up and in that case, the 47μF capacitor is the most likely culprit. It must be a tantalum or multilayer ceramic type; not an aluminium electrolytic. If the current drain is correct, check that the Microbridge is working correctly. Does your PC recognise it as a valid USB device? Do you have the correct driver installed? Do you have your ter- Australia’s electronics magazine minal emulator configured correctly? You can check the Microbridge’s operation by typing characters into your terminal emulator and watching for the LED to flash as they are received by the Microbridge. Finishing it up The next step is to wire up the time source. You have two basic options here. The first is to keep the two modules separate (and later mount them separately in the box) and join them using a few short jumper wires with female DuPont connectors at either end. The second is to solder a header onto the time source module so that it plugs into the BackPack header so that you only need to panel-mount the BackPack module. Regardless of the method you choose, see the circuit diagram (Fig.1) to see which pins need to be connected where. We used the Clayton’s GPS (WeMos D1 Mini) option for our final prototype and chose the second option of plugging this into the headers on the BackPack as this made it much easier to fit it in a UB3 Jiffy box. We used an eight-way stackable Much the same as the previous screen but this allows you to set the next tariff type. You can also change the colour code if you don’t like our green, black and red (see text)! July 2018  39 Fig.3 (left): a cut-away diagram showing how the BackPack module is mounted to the lid of the case. If using a real-time clock module, it can be mounted on the base of the case as shown here. If using an NTP or GPS module instead, you will need a different mounting arrangement (see text). The photo above shows how the components “hang” from the display board and case lid, which is a laser-cut acrylic piece specifically made to suit the BackPack. header (the type often used for Arduino shields) to attach a socket to the D1 Mini board that plugs onto the Micromite’s I/O header. See the photos for details. To do this, we plugged the header onto the Micromite and cut off the pins except the ones that connected to the GND and 3V3 pins, and pin 22. Then we bent the pins over 90°. The GND pin and pin 22 should line up with G and TX on the D1 Mini. Solder these in place, then run a short length of light-duty hookup wire between the 3V3 connections on the Micromite and D1 Mini. You can then plug this into the BackPack and power it up. Check that the blue LED on the D1 Mini starts flashing about once per second. The Micromite LCD should then show: RTC not found. Checking for GPS And after a second, it will show: Searching for Satellites The first ‘lock’ by the Clayton’s GPS may take a while. Once that has been achieved, one of the default clocks will be displayed. Now is a good time to set up the clock with the various time zones and clock formats that you need, noting that most Here’s where you can set the huge amount the electricity suppliers are charging you for each tariff, up to 999c/kWh. When they get to $10.00/ kWh – sorry, you’re on your own. 40 Silicon Chip of the settings are identical to the original Super Clock, with the addition of the tariff settings as described earlier. See the screen shots for examples. Fitting it in a case The Super Clock with Tariff Display lends itself to fitting a UB3 Jiffy box just like the original Super Clock and assembly is quite straightforward. As before, we added a DC socket to the case so that the clock can be powered by a power source with a DC plug. To attach the BackPack assembly to the lid, remove the four machine screws from the top of the display panel, and place the laser-cut lid on top of the display panel, ensuring the nylon washers are in place to keep the lid clear of the headers from the Micromite board. Reattach the machine screws to hold the lid in place. For details, see Fig.3. Cut an end off each of the red and black DuPont style cables, and solder to the DC socket, as shown in Fig.4. Solder the DC plug to the end of the USB lead, running the red wire to the centre conductor and the black wire to the outside conductor. It’s a good idea to check that the polarity is correct through the plug and socket assembly. Plug the USB cable into a powered USB socket and check that +5V is present between the red and black connectors. If all is well, disconnect the USB plug, then drill a hole in the side of the case and mount the socket in the hole. Attach the wires to the Micromite Backpack, with 5V to red and GND to black. If you’re mounting the time source separately, now is the time to do it. You can mount the Real-time Clock module as shown in Fig.3. For the Clayton’s GPS or actual GPS module, the easiest method is to attach them to the inside of the case using double-sided tape. In both cases, it would be a good idea to attach them to the part of the case which will be at the top when using the clock. Wire up the time source to the Micromite Backpack (or plug it in, if you’re fitted it with a socket) before attaching the lid to the case, using using the screws included with the Jiffy box. Depending on the case supplier, these screws may be long enough to go through the thicker laser-cut lid. You will need to acquire slightly longer self-tapping screws if they are not. The Micromite Super Clock with Tariff Display can now be powered up by plugging the USB lead into a USB power source. Fig.4 (above): mount and wire up a DC socket to power the BackPack board, as shown here. You can either use a 5V DC regulated plugpack or fabricate a USB power cable as shown, which can be plugged into a USB charger, computer USB port or other source capable of delivering 500mA at 5V. Australia’s electronics magazine siliconchip.com.au Configuring the Micromite If you used a PIC32 that was pre-programmed for this project then it should be ready to go, as the LCD setting will be pre-loaded along with the BASIC code. However, if you have loaded the Micromite firmware yourself or started with a plain Micromite BackPack kit then you will need to do this configuration yourself. Note that since the Microbridge allows you to flash the PIC32 with the all-in-one Tariff Clock HEX file, if you are comfortable doing this, it’s the quickest way to get up and running. Otherwise, you will need the BASIC source code, which is supplied in the same package as the HEX file. If you do want to load the Tariff Clock HEX file directly, this can be done using the pic32prog program, available from the SILICON CHIP website. Simply copy the “SuperTariffClock.hex” file into the same folder as pic32prog, then use the command: pic32prog -d ascii:comxx SuperTariffClock.hex As before, replace “comxx” with the COM port assigned to your BackPack. The clock should burst into life once the flashing is complete and you will then need to skip below to the “Finishing it up” cross-heading for instructions on connecting the time source. If instead you will be loading the BASIC program into a preprogrammed Micromite chip, you need a terminal program which supports the XMODEM protocol for transferring files. TeraTerm Pro for Windows is recommended in the Micromite manual for this reason. Connect the Micromite to your computer using a USB cable and open its terminal at 38,400 baud, then type the following command and press enter: OPTION BAUDRATE 230400 This will change the baud rate on the Micromite immediately, so you will need to reopen the terminal at 230,400 baud to continue. Configure the LCD using the following command: OPTION LCDPANEL ILI9341,L,2,23,6 This should cause the panel to flicker and clear. You can test that the LCD is working by typing: GUI TEST LCDPANEL This will draw random circles on the LCD screen. Press Ctrl-C to exit the test. Then type: OPTION TOUCH 7,15 And then this command, to calibrate the touch panel: GUI CALIBRATE The Micromite will ask for four touches to be made on the panel, in the middle of the targets drawn on the LCD, and should respond with ‘Done, no errors’ if the calibration completes. You can then test the touch panel: GUI TEST TOUCH This program will allow you to draw on the screen using the touch panel. Press Ctrl-C in the terminal window to end the test. Now that the LCD panel has been set up, the BASIC program can be uploaded. Run this command on the Micromite first: XMODEM R Then commence the transfer of the “SuperClockFonts.bas” file. This can be done in TeraTerm by using the File → Transfer... siliconchip.com.au → XMODEM → Send... option. When the transfer has completed, save the font file as a library using this command: LIBRARY SAVE Then set the Micromite to receive the main program using the same command as before: XMODEM R This time, transfer the file “SuperTariffClockCrunched.bas” to the Micromite. We are using the ‘crunched’ version (ie, without comments) as the original version is too large to fit in the Micromite’s flash memory (but the uncrunched file is included in the .zip file if you wish to examine it). Now set the program to start automatically using the following command: OPTION AUTORUN ON You can then power the unit off to finish construction. Programming the chip If you have purchased a BackPack kit, both chips should be supplied pre-programmed. If your PIC16F1455 is blank, you will need a PIC programmer to load the Microbridge HEX file (a free download from the SILICON CHIP website) onto it. If, however, you have a pre-programmed PIC16F1455 and a blank PIC32, or you wish to update the PIC32 to the latest version of the Micromite firmware, this can be done via the Microbridge and you do not need a separate PIC programmer. Even if you have both chips already programmed, you may still need to load the Microbridge drivers, so keep reading. This procedure was covered in detail in the Microbridge article (May 2017; siliconchip.com.au/Article/10648) so we will only provide an abbreviated description here. The first step is to get the Microbridge working as a USB/serial bridge. This involves installing the correct drivers (available from www.microchip.com/wwwproducts/en/MCP2200) and launching a terminal emulator and connecting to the COM port created by the Microbridge. You can verify that everything is working correctly by typing characters into the terminal emulator and checking that LED1 on the BackPack flashes with each keystroke. Now close the terminal emulator. This is important as the programming operation will fail if it is still open. You need a Windows computer for the next step. Run the program pic32prog (also downloadable from the SILICON CHIP website) in a command prompt box with the command line: pic32prog -d ascii:comxx yyyy.hex Where xx is the COM port number created by Windows for the Microbridge and yyyy.hex is the file containing the latest Micromite firmware. For example, if your Microbridge was allocated the virtual serial port of COM6 and the file that you wanted to program was “Micromite_V5.04.08.hex”, the command line that you should use would be: pic32prog -d ascii:com6 Micromite_V5.04.08.hex When you press Enter, pic32prog will automatically run through the programming sequence and then return to USB/ serial mode. You can then launch your terminal emulator and when you press return you should see the Micromite command prompt (a greater than symbol “>”). Australia’s electronics magazine SC July 2018  41