Silicon ChipOne hour project: Kelvin – the very clever cricket - October 2017 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Let’s be realistic about an Australian space industry
  4. Mailbag
  5. Feature: WRESAT: Australia’s first satellite – 50 years ago! by Dr David Maddison
  6. Feature: Three of our miniature satellites have gone missing... by Ross Tester
  7. Project: 0.01Hz - 6+GHz touchscreen frequency meter, Part 1 by Nicholas Vinen
  8. Feature: El Cheapo Modules Part 10: GPS receivers by Jim Rowe
  9. Project: One hour project: Kelvin – the very clever cricket by John Clarke
  10. Serviceman's Log: Old-fashioned appliance repairs are still worthwhile by Dave Thompson
  11. Project: 3-way Active Crossover for speakers, Part 2 by John Clarke
  12. Project: Deluxe eFuse, Part 3: using it! by Nicholas Vinen
  13. Feature: Adjust your hot-water thermostat and save $$$$ by Leo Simpson
  14. Subscriptions
  15. Vintage Radio: HMV 1955 Portable Model 12-11 by Associate Professor Graham Parslow
  16. PartShop
  17. Market Centre
  18. Notes & Errata: Automatic NBN/ADSL Router Rebooter / Power Supply for Battery-Operated Valve Radios / Vintage Radio (DKE38)
  19. Advertising Index
  20. Outer Back Cover: Microchip Low-power LCD

This is only a preview of the October 2017 issue of Silicon Chip.

You can view 34 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.

Items relevant to "0.01Hz - 6+GHz touchscreen frequency meter, Part 1":
  • 6GHz+ Touchscreen Frequency Counter PCB [04110171] (AUD $10.00)
  • Short Form Kit for the Micromite Plus Explore 100 (Component, AUD $75.00)
  • Case pieces for the 6GHz+ Frequency Counter (PCB, AUD $15.00)
  • Software for the 6GHz+ Touchscreen Frequency Counter (v1.01) (Free)
Articles in this series:
  • 0.01Hz - 6+GHz touchscreen frequency meter, Part 1 (October 2017)
  • 0.01Hz - 6+GHz touchscreen frequency meter, Part 1 (October 2017)
  • Touch-screen 6GHz+ Frequency Counter, part II (November 2017)
  • Touch-screen 6GHz+ Frequency Counter, part II (November 2017)
  • Part 3: Finishing our new 6GHz+ Digital Frequency Meter (December 2017)
  • Part 3: Finishing our new 6GHz+ Digital Frequency Meter (December 2017)
Items relevant to "El Cheapo Modules Part 10: GPS receivers":
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
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 "One hour project: Kelvin – the very clever cricket":
  • Kelvin the Cricket PCB [08109171] (AUD $7.50)
  • PIC12F675-I/P programmed for Kelvin the Cricket [0810917B.HEX] (Programmed Microcontroller, AUD $10.00)
  • Firmware (HEX and ASM) file for Kelvin, the Very Clever Cricket [0810917B.HEX] (Software, Free)
  • Kelvin the Clever Cricket PCB pattern (PDF download) [08109171] (Free)
Items relevant to "3-way Active Crossover for speakers, Part 2":
  • 3-Way Adjustable Stereo Active Crossover PCB [01108171 RevD] (AUD $12.50)
  • 3-Way Adjustable Stereo Active Crossover prototype PCB [01108171 RevC] (AUD $5.00)
  • 3-Way Adjustable Stereo Active Crossover PCB [01108171 RevE] (AUD $20.00)
  • Set of four 8-gang potentiometers with knobs for the 2/3-Way Active Crossover (Component, AUD $55.00)
  • SMD parts for the 3-way Adjustable Active Stereo Crossover (Component, AUD $30.00)
  • 3-Way Adjustable Stereo Active Crossover simulation file (Software, Free)
  • 3-Way Adjustable Stereo Active Crossover PCB pattern (PDF download) [01108171] (Free)
  • 3-Way Adjustable Stereo Active Crossover front & rear panel artwork (PDF download) (Free)
Articles in this series:
  • Fully adjustable, 3-way active loudspeaker crossover Pt.1 (September 2017)
  • Fully adjustable, 3-way active loudspeaker crossover Pt.1 (September 2017)
  • 3-way Active Crossover for speakers, Part 2 (October 2017)
  • 3-way Active Crossover for speakers, Part 2 (October 2017)
Items relevant to "Deluxe eFuse, Part 3: using it!":
  • Deluxe Touchscreen eFuse PCB [18106171] (AUD $12.50)
  • PIC32MX170F256B-50I/SP programmed for the Deluxe Touchscreen eFuse [1810617A.HEX] (Programmed Microcontroller, AUD $15.00)
  • 2.8-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $25.00)
  • IPP80P03P4L-07 high-current P-channel Mosfet (Component, AUD $2.50)
  • LT1490ACN8 dual "Over-the-Top" rail-to-rail op amp (Component, AUD $10.00)
  • IPP80N06S4L-07 high-current N-channel Mosfet (TO-220) (Component, AUD $2.00)
  • Matte Black UB1 Lid for the Deluxe Touchscreen eFuse (PCB, AUD $7.50)
  • Software for the Deluxe Touchscreen eFuse (Free)
  • Deluxe Touchscreen eFuse PCB pattern (PDF download) [18106171] (Free)
Articles in this series:
  • Deluxe Touchscreen eFuse, Part 1 (July 2017)
  • Deluxe Touchscreen eFuse, Part 1 (July 2017)
  • Deluxe Touchscreen eFuse, Part 2 (August 2017)
  • Deluxe Touchscreen eFuse, Part 2 (August 2017)
  • Deluxe eFuse, Part 3: using it! (October 2017)
  • Deluxe eFuse, Part 3: using it! (October 2017)

Purchase a printed copy of this issue for $10.00.

KELVIN,, the clever cricket KELVIN Kelvin, the electronic cricket, is a bit of a smart alec. Just like a real cricket, he only starts chirping in the dark. And also like a real cricket, the warmer it is, the more rapidly he chirps. So you can actually tell the temperature, based on the sounds he makes! By All-rounder John Clarke A s well as being quite useful, Kelvin is easy to build, consisting of around 20 through-hole components. It runs from a Lithium button cell and because it’s power efficient, you won’t have to change the cell too often. It’s a great project for beginners but experienced constructors will enjoy this one too. Talking about the temperature or cricket is always a good conversation starter [Editor’s note: this may be a different kind of cricket. . .]. With Kelvin, the clever cricket, you can talk about both at once. Sure, you could check the temperature on your smartphone but that’s so. . . boring. Using an electronic cricket is a much more entertaining method and a bit of a conversation starter, too. Mind you, Kelvin is just like a real cricket in that he won’t make a single chirp in daylight. It needs to be dark before he finds his voice. Then you simply need to count the number of chirps Kelvin makes to obtain the temperature reading. We have included various chirping options to speed up Scope1: this shows the typical cadence of chirps emitted by Kelvin, the clever cricket. Each chirp consists of three 20 millisecond bursts at 4kHz from its piezoelectric transducer. Note that the gap between each chirp is uneven, similar to that from a real cricket. Scope2: a burst of 4kHz, measured between pins 2 & 3 of the PIC12F675 microcontroller. Since the piezoelectric transducer is driven in bridge mode from the microcontroller, the waveform amplitude is almost double that of the battery voltage (3V). 42 Silicon Chip Celebrating 30 Years siliconchip.com.au Features • • • • • • Multiple temperature reporting options, acknowledged at power-up Realistic cricket sound with varying chirp length/period Flashing eyes Random and on-demand temperature declaration Night, day or day/night operation Low current drain Specifications • • • • • • this process. But more on that later. Operating temperature: 0-60°C, 1°C resolution Chirps: three 4kHz bursts, ~20ms wide with ~20ms gaps Power: 3V CR2032 Lithium button cell Current drain: 2µA measured (typically 3µA) when dormant and 1mA while chirping Cell life: about one year, with several uses per day. Random temperature reporting interval: 8 seconds to 29 minutes It has been known for more than a century that crickets chirp at a rate that is related to temperature. Back in 1881, Margarette W. Brooks established a relationship between air temperature and a cricket’s chirp rate. Her work was followed by that of Amos Dolbear in 1897 and as a result, the formula for estimating the chirping rate is known as Dolbear’s Law. It goes like this: To find the temperature in degrees Celsius, count the number of cricket chirps over a one minute period. Then subtract 40, divide the result by seven and then add 10. If the mental arithmetic this formula requires stumps you (sorry!) it is unlikely that a cricket ever intended its chirping rate to be used in this manner. Evidently, crickets just use a different and non-linear temperature scale compared to us humans. The cricket chirp rate represents their own °C scale, where the C stands for Cricket. (Crickets are cleverer than humans – they knew Scope3: the output signals at pins 2 & 3 (yellow & green traces) while the purple trace shows the summed amplitude which drives the piezoelectric transducer. Note that there are lots of overshoots in the two output signals which do not appear in the summed output. Scope4: the 4kHz square wave signal which is emitted in bursts from pins 2 and 3 of the PIC12F675 microcontroller and fed to the piezoelectric transducer. Considering that this a flea-power circuit is really quite loud – just like a real cricket! Real crickets do tell the temperature siliconchip.com.au Celebrating 30 Years October 2017  43 Fig.1: complete circuit for Kelvin the cricket. This is based around microcontroller IC1 which monitors the resistance of LDR1 to sense the ambient light level and NTC1 to sense the temperature. The GP4 and GP5 outputs from IC1 drive the piezo transducer and also the two LEDs for the cricket’s eyes. all along that we couldn’t make our minds up whether our “C” stood for Centigrade or Celsius). Since Kelvin is a clever electronic cricket, you don’t have to do this mental arithmetic. It produces the temperature directly in °C – Celsius, that is. Not only does that make it easier but it also reduces the amount of chirping required. Dolbear’s Law reveals that temperature in degrees Cricket is a gruelling scale that requires a lot of chirping. For example, at 25°C, to chirp out the temperature in degrees Cricket, the cricket would need to chirp some 145 times each minute. Another thing to note from Dolbear’s Law is that a cricket does not report temperatures below about 4°C. That’s when the number of chirps required to report this temperature is equal to zero. However, if you don’t hear any crickets chirping, that may not mean that the temperature is too cold. Instead, there may be an absence of crickets. You can solve that by building Kelvin. Cricket sounds Crickets produce chirping sounds by rubbing a coarse section of one wing against a scraper located on the other wing. This process is called stridulation and it’s a bit like flicking a fingernail along the teeth of a comb. For a cricket, the reporting of the temperature is a secondary consideration. Crickets are more concerned about making these sounds to establish their territory or to attract a mate. With regard to the latter, it means that the male cricket is attempting to “bowl a maiden over” [Editor’s note: we again apologise for this terrible pun]. That stands to reason though. Since crickets are coldblooded, the stridulation rate would vary with temperature. A cricket’s wing muscles would tend to be rather slow-acting at low temperatures compared to when they warm up as temperature rises. Typically, the sound a cricket produces comprises three closely spaced chirps, followed by a longer gap, then another three and so on (ie, they have a particular cadence). A typical cricket chirp comprises three bursts of a 4kHz tone with each burst lasting for around 50ms. The spac44 Silicon Chip ing between each chirp is also around 50ms. The separation between each triplet is around 250ms. These periods are not precise and do vary a little. The tone of the chirp, however, does not appear to vary by any noticeable degree. Kelvin’s chirps follow the same pattern, with three 4kHz bursts, each separated by a longer gap. However, we found that driving a piezo transducer with three 50ms burst and 50ms gaps for each chirp tended to sound more like an umpire’s whistle than a cricket. In order to sound more realistic, Kelvin’s chirps are 20ms bursts of 4kHz with 20ms gaps between them. Scope1 is a screen grab which shows the chirp cadence on an oscilloscope. But a real cricket does not chirp at precise intervals – they’re quite irregular. To simulate this, Kelvin’s chirping periods vary randomly over a limited range. In other words, they aren’t always exactly 20ms long or spaced apart by exactly 20ms. The variations in the periods lend Kelvin a more natural cadence and prevent the simulated cricket chirp from sounding artificial. Delivery Kelvin can produce one chirp per degree Celsius. In this mode, the chirp rate will vary with temperature, to keep the chirping period to a reasonable length. This is similar to the behaviour of a real cricket. But that still means you could need to count many chirps in hot weather and it’s quite easy to lose track. So Kelvin can optionally produce chirp triplets in sets of five, six or ten. The gaps between the chirp triplets are deliberately made short so they are easily recognised. The remainder of the temperature value is delivered as single chirp bursts with a wider gap. So if you have set the temperature to be reported in sets of five (see “modes” in Table 1) and the temperature is 27°C, there will be five sets of five delivered (for 25), followed by two separate chirps to add up to 27. Why did we include an option for six chirps? Well, obviously that’s because, in cricket, there are six balls to an Celebrating 30 Years siliconchip.com.au over. So if you’re a cricket fan and you are used to counting balls and overs, this should be natural for you. [Editor’s note: John appears to be deliberately conflating crickets with cricket. We suspect he may be a cricket tragic – in more ways than one!] Physical appearance Kelvin has a cricket-shaped PCB (funny, that). Crickets can be black, brown or green; Kelvin happens to be green. Most components are mounted on Kelvin’s back, with its eyes being 3mm red LEDs. The piezo transducer that produces the cricket sound is slung under Kelvin’s abdomen. Kelvin’s six legs are fashioned from thick 1.25mm cop-   siliconchip.com.au per wire. As well as the LBW (legs being wire), the two antennae and ovipositor (tail) are also made from wire; a thinner gauge, at 0.5mm diameter. We make no comment about Kelvin being an apparently male cricket (do you know any females named Kelvin?) and equipped with an ovipositor. Circuit description The complete circuit is shown in Fig.1. It’s based around microcontroller IC1, a PIC12F675, which is powered by a 3V lithium cell. Power is applied when jumper JP1 is inserted. It does not draw much current, typically only about 3µA while Kelvin is dormant. This rises to around     Celebrating 30 Years Fig.2: most of the parts are fitted on the top side of the PCB, with just the piezo transducer being mounted underneath, held in place by M2 machine screws. Take care that the button cell holder, IC1, D1 and the LEDs are oriented correctly (ie, as shown here). October 2017  45 Parts list – Kelvin the Cricket 1 double-sided shaped PCB, coded 08109171, overall 155 x 51mm 1 20mm button cell holder [Jaycar PH-9238, Altronics S 5056] 1 CR2032 lithium cell (3V) 1 30mm diameter piezo transducer (PIEZO1) [Jaycar AB-3440, Altronics S 6140] 1 LDR, 10kΩ light resistance (LDR1) [Jaycar RD-3480, Altronics Z 1621] 1 NTC thermistor, 10kΩ at 25°C (NTC1) [Jaycar RN-3440] 1 momentary 2-pin pushbutton switch (S1) [Jaycar SP-0611, Altronics S1127] 1 8-pin DIL IC socket (IC1) 2 TO-220 insulating bushes (for mounting PIEZO1) 2 M2 x 8mm screws and nuts (for mounting PIEZO1) 1 2-way, 2.54mm pin header with jumper shunt (JP1) 1 400mm length of 1.25mm diameter enamelled copper wire 1 200mm length of 0.5mm diameter enamelled copper wire 2 PC stakes 1 25mm length of 1.5mm heatshrink tubing Semiconductors 1 PIC12F675-I/P microcontroller programmed with 0810917A.HEX (IC1) 1 1N4004 1A diode (D1) 2 3mm high brightness, clear lens red LEDs (LED1,LED2) Capacitors 1 100nF 63V or 100V MKT polyester (code 104 or 100n) 1 10nF 63V or 100V MKT polyester   (code 103 or 10n) Resistors (all 0.25W, 1% – 4-band codes shown) 1 470kΩ (Code yellow purple yellow brown) 2 10kΩ (Code brown black orange brown) 2 330Ω (Code orange orange brown brown) 1 100Ω (Code brown black brown brown) Accuracy of temperature measurement 1mA while chirping. Diode D1 is included as a safety measure to prevent damage to IC1 should the cell be connected incorrectly somehow. This could happen if Kelvin is powered from an external 3V source which is connected back to front. In this case, D1 will prevent more than -1V being applied to IC1. However, with a correctly installed cell holder, of the same type we used, there is no way that the button cell can be inserted to produce the wrong polarity supply voltage. IC1’s power supply is bypassed with a 100nF capacitor and IC1 runs using its internal 4MHz oscillator. When Kelvin is dormant, this oscillator is shut down (ie, sleep mode) to save power. A “watchdog” timer remains running to wake IC1 periodically (at approximately 2.3 second intervals). During the waking period, IC1 checks the ambient light level from the light dependent resistor, LDR1. Normally, the GP1 output of IC1 is set high (3V) so there is no current flow through the 470kΩ resistor and the LDR. Again, this is done to minimise current drain. When IC1 is awake, it sets the GP1 output low (0V) and the LDR forms a voltage divider in conjunction with the 470kΩ resistor across the 3V supply. The voltage across LDR1 is monitored at the GP2 digital input. In darkness, the LDR resistance is high (above 1MΩ) and so the voltage at the GP2 input is more than 2V, due 46 Silicon Chip to the voltage divider action of the LDR and the 470kΩ resistor. This voltage is detected as a high level by IC1. With more light, the LDR resistance drops to around 10kΩ so the voltage divider produces a low level at the GP2 input. When the GP2 input is low (the light level is high), chirping may be disabled, depending on the mode (explained later). Kelvin can also be woken up by pressing S1. When closed, GP2 is pulled low (to 0V) and IC1 wakes up and reads the temperature using a Negative Temperature Coefficient (NTC) thermistor, NTC1. Like the LDR, this thermistor is only powered when the GP1 output is low and that’s only briefly, to reduce power consumption. The NTC Thermistor has a resistance of 10kΩ at 25°C. This forms a voltage divider with the 10kΩ resistor connected to the 3V supply. Since the two resistances are equal at 25°C, the voltage at the AN0 input will be at half-supply, ie, around 1.5V. This is converted to a digital value by IC1’s internal analog-to-digital (A/D) converter. The 10nF capacitor between pins 6 and 7 stabilises this voltage. As temperature falls, the thermistor resistance rises and voltage at the AN0 input also rises. Conversely, with temperatures above 25°C, thermistor resistance falls and voltage at the AN0 input falls. The change in resistance with temperature is non-linear and we use a software lookup table within IC1 to convert the measurement from AN0 to a temperature value. The table contains values from 60°C down to 0°C. Kelvin hibernates at temperatures below 1°C anyway. While the voltage at AN0 will vary depending on the supply (cell) voltage, so does the A/D converter’s reference voltage, which is derived from pin 1 (VDD) of IC1. So these changes cancel out and the temperature readings are stable even if the supply voltage varies. Although the general purpose NTC thermistor specified for this project will be accurate to within a few degrees, you may prefer greater accuracy. In this case, you could use a thermistor such as the AVX NJ28NA0103FCC which also has a 10kΩ nominal resistance and a ±1% tolerance at 25°C. It has a beta value of 4100 ±1%. The beta value defines the shape of the resistance/temperature curve. The NJ28NA0103FCC is available from RS at siliconchip. com.au/link/aaf7 Driving the piezo transducer IC1’s GP4 and GP5 output pins drive the LEDs which form Kelvin’s eyes, as well as the piezo transducer which produces the chirps. The piezo is driven in bridge mode, connected across these two outputs, which increases the AC voltage to produce a louder sound. When GP4 is high, the GP5 output is low and when the GP4 output is taken low, GP5 is taken high. In one condition there is +3V across the piezo transducer and in the other, -3V, producing a 6V peak-to-peak square wave. This is shown in Scope3 and Scope4. The yellow trace in Scope3 shows the waveform at GP4 and the green trace is the output of GP5. The pink trace shows the difference between them and as you can see, it has a higher amplitude. A 100Ω resistor limits the peak current into the transducer’s capacitive load immediately after the outputs switch. LED1 and LED2 are independently driven via the same Celebrating 30 Years siliconchip.com.au two outputs with separate 330Ω current-limiting resistors. These LEDs are driven alternately on and off while the piezo transducer is driven. They can also be lit independently by holding one output high and the other low; this will only produce a click from the piezo transducer. The circuit could have been arranged with a single limiting resistor for both LEDs but two resistors have been used so that the PCB layout is symmetrical. A symmetrical cricket is a happy cricket. In other words, the second resistor is required cosmetically but not electrically. Construction Kelvin is built on a PCB coded 08109171, measuring 155 x 51mm (but certainly not rectangular!). Fig.2 shows the PCB overlay diagram. Begin construction by installing the six resistors; use a multimeter to check the value of each before inserting into the PCB. The resistor colour codes for four-band resistors are shown in the parts list but with only four different values, it should be hard to mix them up! Diode D1 can be installed next, taking care to orient it correctly. The 10nF and 100nF capacitors go in next. These can be oriented either way round but must be in the right spots! Then solder the IC socket for IC1 – note that its notched end faces the 100nF capacitor. Switch S1 and the 2-way pin header can be installed next, followed by the two PC stakes at the wiring points for the piezo transducer (these stakes mount on the underside of the PCB). Push the cell holder down firmly in place then solder its pins, with its positive terminal oriented towards D1. LED1 and LED2 are mounted with their lenses pointing diagonally outward toward their respective corners of the PCB and about 3mm off the PCB surface. The exact angle is not important; we bent the leads down by around 45°. The longer lead of each LED must go into the pad marked “A”. The LDR should be mounted about 5mm above the PCB surface and sits horizontally while the thermistor is pushed down fully onto the PCB. Neither of these com- ponents are polarised. The piezo transducer is fitted to the underside of the PCB, supported on TO-220 insulating bushes (used as spacers) and secured with M2 x 8mm machine screws and M2 nuts. Once it’s in place, solder its wires to the PC stakes on the underside of the PCB. The polarity of these wires is not important. Before soldering, slide some short lengths of heatshrink tubing over the wire, then slide them down onto the PC stake connections and shrink them (a heat gun is preferred but we’ve found a high-power hair dryer on its highest setting should work) to prevent the connections from being stressed and breaking later. Kelvin’s legs and antennae Kelvin’s legs are fashioned from 1.25mm diameter copper wire. Each front leg is 75mm long and the mid and rear legs are each 60mm. These can be as simple or as fancy as you like – the cricket shape printed on the rear of the PCB shows the general shape we used. Bend the legs so that Kelvin will be able to stand raised up from the platform it sits on. The feet are formed as small loops so that sharp ends are not left exposed. Where the legs are soldered to the PCB, you will need to scrape off the enamel insulation (eg, using a sharp hobby knife or fine sandpaper) before they can be soldered. Make up the two antennae using 80mm lengths of 0.5mm diameter wire and the ovipositor (tail) with a 40mm length. Once soldered in place, curl the two antenna wires into shape by running a thumbnail along the inside of the radius, with your index finger on the outside. Check your construction before installing the programmed microcontroller (IC1) in its socket. If you intend to program the PIC yourself, the firmware (08109171A.HEX) can be downloaded from the SILICON CHIP website. See the programming section below for more details. Test cricket Make sure IC1 is oriented correctly (notch in the IC to the notch in the socket) before inserting into its socket. Now Mode Temperature indication – Chirp & LED 1-2 pattern Random chirping Notes    On power up 1 2 3 4 1 chirp for each °C measured 1 “chirrrrp” for each 5° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 6° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 10° + 1 “chrp” for each 1° balance None No of chirps = °C None None None LED2 flashes once LED2 flashes twice LED2 flashes three times LED2 flashes four times 5 6 7 8 1 chirp for each °C measured 1 “chirrrrp” for each 5° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 6° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 10° + 1 “chrp” for each 1° balance During the night No of chirps = °C During the night During the night During the night LED2 flashes five times LED2 flashes six times LED2 flashes seven times LED2 flashes eight times 9 10 11 12 1 chirp for each °C measured 1 “chirrrrp” for each 5° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 6° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 10° + 1 “chrp” for each 1° balance During the day No of chirps = °C During the day During the day During the day LED2 flashes nine times LED1 flashes once LED1 flashes once; LED2 once LED1 flashes once; LED2 twice 13 14 15 16 1 chirp for each °C measured 1 “chirrrrp” for each 5° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 6° + 1 “chrp” for each 1° balance 1 “chirrrrp” for each 10° + 1 “chrp” for each 1° balance Day and night No of chirps = °C Day and night Day and night Day and night LED1 flashes once; LED2 three times LED1 flashes once; LED2 four times LED1 flashes once; LED2 five times LED1 flashes once; LED2 six times Table 1: Kelvin’s sixteen modes which enable various measurement parameters and also how his random chirping is controlled. Modes 1, 5, 9 and 13 give 1 chirp for each degree; other modes count the degrees in groups and chirp accordingly. His red eyes flash as he chirps, too. siliconchip.com.au Celebrating 30 Years October 2017  47 fit the CR2032 cell in its holder and place the jumper link across the two pins on the 2-way header (JP1). The initial mode for temperature reporting is mode 1 (see Table 1). When powered, Kelvin first flashes the mode. So, in this case, it will flash LED2 (the ones LED) once to indicate mode 1. To have Kelvin deliver the temperature reading, press the switch that is labelled “Test Cricket”. [Editor: John, one more cricket reference and “you’re out”!] The default mode (1) does not include randomly delivered chirps so you will need to change the mode if you want this. Traditionally, since a cricket normally chirps at night, you would want to enable night-only mode. But you can also have day-only random chirps or random chirps at any time. We could even refer to this mode as “day/ night test” mode; how’s that? [Editor: safe! But only just...] All the modes Kelvin has 16 possible modes, as shown in Table 1. There are four sets of four, with each set being identical as far as the chirps and LED flashes go. The difference between the mode sets is the time of day (or more accurately the ambient light level) – Kelvin assumes, arguably correctly, that higher light levels are probably daytime and lower light levels could be night-time; the time when crickets come out to play. Depending on which mode set is chosen, Kelvin will not randomly chirp at all (modes 1-4); he’ll chirp only during the night (modes 5-8); he’ll chirp only during the day (modes 9-12) or, the most annoying setting of all, with modes 13-16 chosen he’ll randomly chirp at any time, day or night! The groups of modes also determines what you hear and see as Kelvin measures the temperature. In modes 1/5/9/13 he chirps and flashes once for each degree C he senses. So if it is 15°C it will chirp 15 times and then stop. The trouble is, it’s easy to lose count, especially when the temperature goes higher! So there are three more modes – and in these cases, Kelvin chirps out the temperature in groups of 5, 6 or 10 respectively. For example, if it’s in mode 2, 6, 10 or 14, 17°C will be chirped as two groups – the first of three long chirps, for 15° (5 x 3), the second is two more short chirps for the remainder over 15° (degrees 16 and 17). Got that? Here’s another example: in modes 4, 8, 12 or 16, 23° (counting to ten) Kelvin would give two long chirps (for 20°) and three short chirps (for the remainder). Modes 5-8 are identical to modes 1-4 except that these modes also enable random temperature chirping at night (ie, when darkness is detected), at intervals of between eight seconds and 29 minutes. And modes 9-12 are again identical except that in these modes, Kelvin will chirp randomly during the day but not at night. Modes 13-16 are also similar to modes 1-4 but enable random chirping regardless of the light level. Modes 4, 8, 12 and 16 have an additional feature, where LED1 lights briefly at the start of each group of 10 chirps, while LED2 lights briefly at the start of each single chirp. Setting modes Modes 1-4 require the Test Cricket switch (S1) to be pressed in order to initiate any chirping. You can also use this switch in the other modes if you don’t want to wait 48 Silicon Chip for the random chirping to start. To change the mode, first switch off power by removing JP1. Then press and hold the Test Cricket switch (S1) and re-insert JP1. Wait until there is a chirp acknowledgement from the piezo transducer and release S1. You can then select the mode by pressing S1 the same number of times as the desired mode. Kelvin will chirp to acknowledge each press of S1. If S1 is not pressed, Kelvin will eventually time out and the mode will not be changed. You will hear three chirps to indicate this. If you do select a new mode using S1, wait and then you should hear two chirps. That indicates that the new mode has been accepted and stored, and will be used from now on. The new delivery format will now be used by Kelvin. The new mode will then be indicated by flashes from one of the LEDs. For numbers less than 10, LED2 (the ones LED) will flash a number of times. For modes 10 and above, LED1 (the tens LED) will flash once. Modes above 10 are then indicated by extra flashes from LED2. For example, LED2 will flash once for mode 11 and twice for mode 12. Modifications Kelvin has a loud chirp, which can be pretty annoying! If you want to reduce the volume, increase the 100Ω resistor in series with the piezo transducer. Increasing it to, say, 10kΩ will reduce the apparent volume by about 50%. Higher values will provide an even lower volume, to the point where he won’t chirp at all. You shouldn’t reduce the resistor to below 100Ω – Kelvin is quite annoying enough, thank you (especially at night!). The light sensitivity (ie, the point at which Kelvin senses light levels) can also be altered, by changing the 470kΩ resistor between the positive supply and the PIC’s GP2 input. Increasing the resistance value (say to 1MΩ) will mean Kelvin reacts to lower daylight levels. By contrast, reducing the resistance value will mean that more light will be required to detect daytime. If you go too low Kelvin probably won’t detect light level changes at all. (No appealing against the light . . .) Programming IC1 If you are programming the microcontroller yourself, note that the PIC12F675 needs special programming due to the fact that it has an oscillator calibration value (OSCAL) that is held at the last location of the PIC’s memory. This calibration value is individually programmed into each PIC by the manufacturer and provides a value that allows setting of the PIC to run at reasonably accurate 4MHz rate when using the internal oscillator. (See Circuit Notebook page 83 of this issue for a detailed explanation on how to set this calibration value). This value must be read before the chip is erased (in preparation for being re-programmed) so that it can be written back with the rest of the code during programming. If this procedure is not done correctly, either the PIC won’t be programmed or the oscillator frequency could be off. That will have an adverse effect on the realism of Kelvin’s chirps. Most PIC programmers will automatically cater for this OSCAL value (eg, the PICkit 3 does), but it is worthwhile checking if your programmer correctly handles this. SC Celebrating 30 Years siliconchip.com.au