Silicon ChipAll-new Swimming Pool Lap Counter - March 2017 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Cutting-edge technology – in 1958
  4. Feature: Vale Maurie Findlay: Australian electronics “royalty” by Ross Tester
  5. Feature: Putting a big 43-inch 4K monitor to the test by Leo Simpson
  6. Feature: Australia’s largest vintage radio exhibition by Kevin Poulter
  7. Project: All-new Swimming Pool Lap Counter by John Clarke
  8. Project: The Stationmaster: walk-around PWM train control by Design by Bob Sherwood
  9. Project: Bargain Solar Cells – and what to do with them! by Ross Tester
  10. Product Showcase
  11. Serviceman's Log: Fixing a guitar amp is an enjoyable task by Dave Thompson
  12. Feature: Getting Started with the Micromite, Part Two by Geoff Graham
  13. Project: New SC200 Audio Amplifier - Part 3 by Nicholas Vinen
  14. Project: El Cheapo Modules, Part 5: LCD module with I²C by Jim Rowe
  15. Vintage Radio: Sony's TR-712 Mantel Radio by Ian Batty
  16. Subscriptions
  17. PartShop
  18. Market Centre
  19. Notes & Errata: GPS-Synchronised Analog Clock / Improved PICAXE Wireless Rain Alarm / High Power DC Motor Speed Control
  20. Advertising Index

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

You can view 48 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 "All-new Swimming Pool Lap Counter":
  • All-new Swimming Pool Lap Counter PCB [19102171] (AUD $15.00)
  • PIC16F88-I/P programmed for the All-new Swimming Pool Lap Counter [1910217A.HEX] (Programmed Microcontroller, AUD $15.00)
  • Hard-to-get parts for the LED Pool Lap Counter (Component, AUD $20.00)
  • Translucent blue UB1 lid for the All-new Swimming Pool Lap Counter (PCB, AUD $7.50)
  • Firmware (ASM and HEX) files for the Bright LED Pool Lap Counter [1910217A.HEX] (Software, Free)
  • All-new Swimming Pool Lap Counter PCB pattern (PDF download) [19102171] (Free)
  • All-new Swimming Pool Lap Counter front panel artwork (PDF download) (Free)
Items relevant to "The Stationmaster: walk-around PWM train control":
  • Stationmaster PWM train controller PCBs [09103171/2] (AUD $15.00)
  • Hard-to-get parts for the Stationmaster (Component, AUD $15.00)
  • Stationmaster PCB patterns (PDF download) [09103171/2] (Free)
  • Stationmaster panel artwork (PDF download) (Free)
Articles in this series:
  • Getting Started with the Micromite (February 2017)
  • Getting Started with the Micromite (February 2017)
  • Getting Started with the Micromite, Part Two (March 2017)
  • Getting Started with the Micromite, Part Two (March 2017)
  • Micromite Tutorial, Part 3: strings and arrays (May 2017)
  • Micromite Tutorial, Part 3: strings and arrays (May 2017)
  • Getting Started with the Micromite, Part 4 (June 2017)
  • Getting Started with the Micromite, Part 4 (June 2017)
Items relevant to "New SC200 Audio Amplifier - Part 3":
  • Ultra-LD Mk3/Mk4 Amplifier Power Supply PCB [01109111] (AUD $15.00)
  • New SC200 Audio Amplifier PCB [01108161] (AUD $10.00)
  • Hard-to-get parts for the SC200 Audio Amplifier Module (Component, AUD $50.00)
  • New SC200 Audio Amplifier PCB pattern (PDF download) [01108161] (Free)
Articles in this series:
  • New SC200 Audio Amplifier (January 2017)
  • New SC200 Audio Amplifier (January 2017)
  • New SC200 Audio Amplifier – Part 2 (February 2017)
  • New SC200 Audio Amplifier – Part 2 (February 2017)
  • New SC200 Audio Amplifier - Part 3 (March 2017)
  • New SC200 Audio Amplifier - Part 3 (March 2017)
Items relevant to "El Cheapo Modules, Part 5: LCD module with I²C":
  • 20x4 Alphanumeric serial (I²C) LCD module with blue backlight (Component, AUD $15.00)
  • 16x2 Alphanumeric serial (I²C) LCD module with blue backlight (Component, AUD $12.50)
  • Software for El Cheapo Modules: LCD module with I²C (Free)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)

Purchase a printed copy of this issue for $10.00.

BRIGHT LED POOL LAP COUNTER It has been more than a decade since we produced a swimming pool lap counter – and times (and available parts) have changed significantly. This allnew design should be very easy to build and uses a rather unique lap sensor! T HOSE FORTUNATE ENOUGH to swim in a 50-metre pool don’t have to count very many laps in order to cover a reasonable distance. For example, just 20 laps means that you have swum a kilometre. But even then, as you plough up and down the pool, it is pretty easy to get distracted and lose count. Some people cope with the problem by swimming five laps freestyle, five breaststroke, five backstroke and so on. The problem is worse if you’re swimming in a 25-metre pool (as many, even top-level swimmers, regularly train in) and much worse if you’re swimming in your home pool, which may be only 10 or 15 metres long. For a 10-metre pool, you need to do 100 laps to cover a kilometre. Believe us, trying to keep track of that many laps in a home pool while you swim back and forth is practically impossible. Was it 64 laps or 46? This is where our Pool Lap Counter comes to the rescue. It will display the number of laps you have completed on a 2-digit readout, so you can let your mind wander, solve the world’s problems or even compose your new symphony while you swim up and down. The Pool Lap Counter consists of two parts. First is a small plastic box which contains the counter circuit and 24  Silicon Chip 2-digit readout, along with 6V of “AA” batteries to make it completely portable (and safe – you don’t want a mains adaptor anywhere near the pool!). The other part looks just like a large frozen food “brick” as would be used in a reasonable-size cooler/fridge. That could be because that’s exactly what it is – we’ve pressed one of these into service to act as the lap sensor. But more on this anon. Two ways of counting The way it works is as follows. You place the sensor at the far end of the pool (ie, opposite from where you normally start). You then swim to the other end and touch the sensor, whereupon the display indicates “01”. Congratulations, you have completed one lap! When you swim up and back and touch the sensor again, the display will indicate “03”. In other words, the display increments by two each time the sensor is touched. As an alternative, because this Pool Lap Counter uses the intelligence of a PIC microcontroller, you can start and finish your laps at the same end of the pool. In this case, it displays “0”. You then swim up and back, press the sensiliconchip.com.au A close-up of the business end of the Pool Lap Counter, as seen on the pool deck opposite. Try not to splash pool water on it! sor and it displays “2” and so on, until you are exhausted! A further counting option is where the Lap Counter increases by one each time the pressure plate is tapped, for example, laps around an oval running track. The counting option is set using two jumpers, JP1 and JP2. The circuit has two inputs; either can be used for lap counting. One is for the pressure plate that’s generally used with pools and the second is for a standard momentary pushbutton switch. The display lights up each time one of these inputs is activated and stays lit for a configurable period of typically five seconds. The display is switched off after this period to extend the battery life. The display on-time can be set to be between half a second and 10 seconds or can be configured to be permanently lit if desired. The counting rate is restricted so that the lap count does not increment more than once when the pressure plate or switch is activated. The normal delay period is five seconds but it can be reduced to as little as 40ms (ie, 25 increments per second). This is not so useful when you’re swimming or running but there may be other uses for the Lap Counter where more rapid counting is necessary, for example, if counting the number of people passing through a door by placing a pressure plate on the ground. The current lap count can be displayed at any time by pressing the View switch. The lap count is cleared to zero by pressing the Clear switch. These two switches are located on the front panel of the Lap Counter box. A power switch is also included nearby. The display is designed to be bright enough to be seen in daylight but there may be times when the display is too bright, for example, if you’re swimming in an indoor pool or at night. As a result, we have incorporated a dimming function. The brightness can be reduced in four steps from maximum (100%) down to 25%. Four AA cells (6V) power the counter. To obtain a reasonable battery life, the 7-segment displays are lit for just siliconchip.com.au five seconds each time the button is pressed. Of course, the ICs are powered while the unit is switched on but this amounts to only 40mA. Circuit description The full circuit for the Lap Counter is shown overleaf and is based around a microcontroller (IC1) that drives the display while monitoring the switches and the pressure sensor signal. The pressure sensor is used in conjunction with the pressure plate to detect when the swimmer has completed a lap. The display consists of two large (70mm) seven-segment LED digits, labelled DISP1 and DISP2, with each segment (except for the decimal points) comprising a series string of four blue LEDs. When lit, each segment has a total voltage drop of at least 12V, ie, 3V across each LED. So a supply of more than 12V is required to drive the display, taking into account the voltage lost in the switches and due to current-limiting resistors. Fe at ur es an d Sp ec ifi ca tio ns Maximum count:..... 99 laps Trigger method: ..... waterproo f pressure plate or momentary switch Power supply: ......... 6V battery (four AA cells) Minimum supply:.... 4V Current drain: ......... 280mA ma ximum; 40mA with display off. Battery life: ............ typically at least ten days of use; around 12 hours if display is constantly lit Display size: ........... 100 x 73m m, each digit 33 x 57mm Display type: .......... bright blu e LED Multiplex rate: ........ 488Hz (flic ker free) Display on period:.. 0.5-10s or always on; initial default is 5s Counting delay: ..... 40ms to five seconds; initial default is 5s Dimming: .............. adjustab le in four steps from 25% to full brightness, initial default full brig htness March 2017  25 26  Silicon Chip siliconchip.com.au The 2SMPP-02 pressure sensor detects the slight change in pressure when the sensor pad is touched. It doesn’t take much to trigger it – just a touch when you turn for the next lap. Accordingly, the circuit includes a step-up supply based around regulator REG1, inductor L1 and associated components, to produce a steady 16V to be used for driving the display. Microcontroller IC1 is powered via a 5V regulator (REG2) from this 16V supply, so that the unit can continue to operate even with the battery below 5V, down to 1V/cell (4V total). To control DISP1 and DISP2, the 5V digital outputs of IC1 need to be level shifted. To achieve this, the common anodes of each display are driven by a two-transistor arrangement. When IC1’s RA4 output (pin 3) is high, at 5V, it drives the base of NPN transistor Q3 via a 10kΩ resistor. With Q3 switched on, its collector goes low (near 0V) and this pulls current from the base of PNP transistor Q4 via a 1kΩ resistor, switching it on. Q4 then supplies the common anodes of DISP1’s segments with 16V. Similarly, for DISP2, the RA3 output of IC1 drives Q5 which in turn drives Q6, switching 16V to the common anodes of DISP2. The cathodes of each segment are driven by IC2, a ULN2003 Darlington array, with 100Ω current limiting resistors. IC2 contains seven Darlingtons in the one package along with clamp diodes (which are not required in this case). Base resistors are included in the package so each input is suitable for direct connection to IC1. IC1 drives IC2’s inputs using outputs RA0, RA6 & RA7 and RB4 to RB7. Note that DISP1 and DISP2 are multiplexed, ie, they are lit alternately with only one set of anodes powered at any given time. This is arranged by ensuring that RA3 and RA4 don’t go high simultaneously. This is important since the segment cathodes of DISP1 and DISP2 are connected in parallel and so which segments are lit is determined both by the state of IC2’s inputs as well as which of RA3 or RA4 is high. The displays are multiplexed at 488Hz so there is no visible flicker. There is also a small dead time between when one display switches off and the other is switched on to prevent ghosting. Ghosting is where each display shows a low brightness copy of the other display, due to the cathode drive not switching off before the other display’s anode is energised. The dead time is increased when dimming is required, as this reduces the segment duty cycle and thus apparent brightness. siliconchip.com.au Here’s our “sensor pad” – an Esky Cooler Brick which we bought at Bunnings for $5.99. It’s flexible enough to send a puff of pressure to the circuit when touched. You can clearly see the points which can be drilled through without risk of any of the coolant inside escaping. Inputs IC1 monitors seven inputs. These include the View switch (S1), the Clear switch (S2), the external Lap switch (S4), jumpers JP1 and JP2 along with the wiper position of VR1 and the output of the pressure sensor. All inputs which monitor switches, except S2, have internal pullup current sources which holds these inputs at 5V unless they are pulled low via the switch or jumper connection closing. Clear switch S2 is connected to IC1’s reset input, which has an external 10kΩ pull-up. When pressed, IC1 is reset and the internal software restarts. The pressure sensor is monitored via the output of op amp IC3d at pin 1 (AN2) while the position of VR1’s wiper is monitored at pin 18 (AN1). Both are connected to IC1’s internal analog-to-digital converter (ADC). VR1 is used to set the threshold for the pressure sensor while the output of IC3d is an amplified and level shifted version of the signal from the pressure sensor. As the pressure at PS1 increases, IC3d’s output voltage also increases. When this voltage exceeds the threshold setting at VR1’s wiper, an internal comparator in IC1 is triggered and the software increases the lap count. Pressure sensor PS1 is configured as a Wheatstone resistance bridge the with voltage at pins 1 and 4 about halfway between the voltage applied across pins 6 and 3. This 2V is derived from the regulated 5V rail via a 3kΩ/2kΩ resistive divider and buffered by unity gain amplifier stage IC3a. March 2017  27 – + TO 6V BATTERY +6V 0V L1 47 H CON1 1nF 1 470 F D3 REG1 BAT46 D2 100k 1.5k MC34063 5819 5819 Power D1 + 47 Q2 1 1 10 F MOSFET REG2 BC327 1k 18k 2 .0 k 3 .0 k 10k 10k 10k Q3 100k 100 2 0PP Q4 BC327 10 F 10k 10k 1k 10k JP2 x2 100nF 10k Q5 1 BC547 100nF 1 Pressure Threshold BC327 1k IC2 ULN2003 100 100 100 1720191 VR1 10k 10k Q6 IC1 PIC16F88 100 LAP COUNTER 10k 100 10k 19102171 C 2017 REV.B 1 BC547 IC3 LMC6484 10k 470 F 25V 78L05 SENSOR1 JP1 Odd + Q1 100 View Clear 100 CON2 To S4 The rear view, or bottom side of the PCB, with the component overlay alongside. Increased pressure on the sensor causes the voltage at pin 4 of PS1 to drop and the voltage at pin 1 to rise. IC3c and IC3b buffer the voltages at these two points and form part of an instrumentation amplifier with a gain of 100. The gain is set by the ratio of the 10kΩ resistors in the feedback paths for IC3b and IC3c and the 100Ω resistor between them. The differential output from these amplifiers is converted to a single-ended output by IC3d. IC3d’s output is level shifted so that it will not normally go below 0V, due to the 10kΩ resistor from its pin 12 input to the 2V rail. As a result, the output of IC3d sits at around 2V with the sensor exposed only to ambient pressure. Stepped-up supply REG1 forms part of a boost regulator, to generate 16V from the 4-6V battery supply. It works in conjunction with inductor L1, diode D2, Mosfet Q1 plus a few other parts. REG1 has an internal compound driver transistor that could be used to directly drive the inductor. However, there is some voltage loss across this transistor, particularly at higher currents. So we are using its internal transistor as a low-current switch to drive the gate of Mosfet Q1 via schottky diode D3. The Mosfet is switched off when the internal transistor is switched off due to the 1kΩ pull down resistor. When there 28  Silicon Chip (REAR VIEW ) is no drive from REG1, PNP transistor Q2 is switched on by the base current flow through the 1kΩ resistor, quickly discharging Q1’s gate to around 0.7V. Note that the Mosfet is a low gate threshold type that has a low on-resistance even with a gate voltage of just 3V. This is necessary so the circuit can work down to low supply levels (ie, around 4V). When the output of REG1 goes high, Mosfet Q1’s gate is charged via diode D3 and it switches on, allowing current to flow from the battery supply via reverse polarity protection diode D1, the 0.5Ω current-sense resistor (comprising two parallel 1Ω resistors), inductor L1 and Mosfet Q2 to ground. This charges the magnetic field of inductor L1. REG1 senses when the current through L1 reaches 600mA as this results in a 300mV drop across the 0.5Ω resistor between pins 6 (Vcc) and 7 (Ips). When this current limit is reached, Mosfet Q1 is switched off and the magnetic field in L1’s core collapses, producing a high voltage at the anode of schottky diode D2. This flows through D2 to charge the 470F output filter capacitor. The voltage across the 470F capacitor is divided down by an 18kΩ/1.5kΩ divider and applied to feedback pin 5 of REG1 (Cin-). When the output is at 16V, pin 5 is around 1.25V. REG1 incorporates a 1.25V reference so that when the siliconchip.com.au S3 5819 Power +6V 0V CON1 D2 0 F 5V + DISP 1 SENSOR1 PP02 REV.B C 2017 19102171 19102171 LAP COUNTER 1720191 DISP 2 LAP COUNTER 1910271 1 0 0 0 Clear To S4 View S2 S1 (FRONT VIEW ) CON2 Similarly, here’s the top side, or display side, with the photo not having the LED displays in place for clarity. feedback voltage at pin 5 is above 1.25V, the output duty cycle is reduced to lower the output voltage. When the feedback voltage is below 1.25V, the output duty cycle increases. This maintains the output voltage at the set value of 16V. Construction The Lap Counter is built using a PCB coded 19102171 and measuring 131 x 86mm. This is housed in a UB1 plastic box which measures 158 x 95 x 53mm. The lid is not used and is replaced with a neutral tint or blue-tinted front panel made using 3mm Acrylic or Perspex sheet, measuring 152 x 90mm. This allows the display to be seen through the front panel. Note that the sheet used should be a UV stabilised type or it will not last outdoors. The PCB has components mounted on both sides; see the overlay diagrams above. The two 7-segment displays (DISP1 & DISP2) and switches S1-S3 are mounted on the front, with DISP1 and DISP2 plugged into four 5-way socket strips. Additionally, the pressure sensor is fitted to this side of the PCB, with its input tube poking through a hole to be accessed from the other side. The remaining components mount on the opposite side of the PCB. Note that if you don’t want to use the pressure plate then pressure sensor PS1 and IC3 are not required. Nor are the resistors connecting to IC3. However, it is necessary to fit siliconchip.com.au the 100kΩ resistor at pin 1 of IC1 to hold this input low. Start by installing the components on the back (ie, nondisplay) side first. Start with the resistors – the colour code table shows all the codes, however it’s a good idea to use a digital multimeter to check each resistor value anyway. Diodes D1-D3 can be installed now. Make sure they are oriented correctly and note that D3 is a BAT46 while D1 & D2 are 1N5819 types. Next, fit the IC sockets for REG1 & IC1-IC3. Make sure these are oriented correctly (notched side to top) before soldering. Now fit the two PC stakes for the battery connections at CON1. Transistors Q2-Q6 are installed next, with the top of each transistor 10.5mm above the PCB. You will need to crank their leads out to fit the PCB pads. Make sure that the correct transistors are installed at each position; Q2, Q4 & Q6 are BC327s while Q3 & Q5 are BC547s. REG2 can be fitted now, in a similar manner to the transistors. Next, solder VR1 in place. Mosfet Q1 is mounted horizontally on the PCB with the leads bent at right angles to insert into the PCB. The metal tab is secured with an M3 screw and nut before soldering its leads. Inductor L1 also mounts horizontally, with the leads bent to insert into the PCB holes and is secured with two cable ties before soldering. Fit the capacitors next. The electrolytic types must be March 2017  29 Here’s the PCB from the previous page complete with the two large blue 7-segment displays. We chose blue because they’re very visible, even in broad daylight – but they do require a higher voltage to operate. oriented with the polarity as shown (longer lead to +) and note that the 25V-rated capacitor is located near diode D2. Next, install the 2-way screw terminal for CON2 with the openings toward the edge of the PCB. The two-way pin headers for JP1 and JP2 are next. Insert the shorter pin end into the PCB, leaving the longer pins for fitting the jumper shunts later. Flip the PCB over and snap the 20-way socket strip into four 5-way strips. There are two for each display (DISP1 and DISP2). Having soldered those in place, switches S1, S2 and S3 are next mounted. These can be installed either way around, but note that S3 is the toggle switch. Now fit the pressure sensor, if you’re using it. The air nozzle passes through the hole in the PCB and it must be oriented so its pin 1 is aligned with the pin 1 marking on the PCB. It’s a surface-mounting part and you can solder each pin individually to the PCB. Any solder bridges between pins can be removed with solder wick but note that pins 2 & 3 and pins 5 & 6 are meant to be connected together. Insert one end of a 250mm length of 3mm PVC tubing into the pressure sensor nozzle and tie the pressure sensor to the PCB by looping two cable ties through the allocated holes in the PCB. The locking block section of the cable ties is positioned on the side of the PCB opposite the displays. After tightening the cable ties, the PVC tubing will be held in place. Note that a small hole should be made in the tubing to equalise air pressure. The hole should be about 1mm in diameter and can be made using a 1mm drill or by cutting a V-shaped notch in the tubing. Do not push through a hole with a small jeweller’s screwdriver as the hole will seal up again. The hole will allow air to slowly enter or exit the tube so that it is at atmospheric pressure but will not prevent the sudden air pressure change when the pressure plate is pushed. The two 7-segment displays (DISP1-DISP2) are plugged into the socket strips mounted on the top side of the PCB. Cut the display pins to 4mm in length. When mounting 30  Silicon Chip these, use the overlay diagram as a guide, ie, install them with the decimal points at bottom. The top surface of the displays should be 15mm above the PCB when finished. The battery wires can now be looped through the stress relief holes and soldered to the appropriate PCB pins. Solder the other end to the battery holder, being careful to ensure you use the correct polarity (if it’s reversed, nothing bad will happen, the unit simply won’t work). Front panel Templates for the drilling and cutting front panel, rear and side sections of the box can be downloaded from the SILICON CHIP website (www.siliconchip.com.au) and can be found via the Shop page for the March 2017 issue. As mentioned, the lid is replaced by a UV-stabilised Perspex or Acrylic tinted sheet covering the full size of the box at 152 x 90mm. A pre-cut Acrylic sheet with rounded corners and mounting holes can be purchased from SILICON CHIP, to save you the hassle of doing it yourself and this will give a neat result. This will already have all the required holes. If you’re making the lid yourself, drill pilot holes in the seven locations indicated. These can be further drilled out to size. It’s 3mm for the corner holes and 6.5mm for the switches. These are made larger with successively larger drills or using a reamer to enlarge them out. Take extra care drilling as the plastic can crack if the drill or reamer is forced into the hole. One end of the box will require drilling for the cable gland that should be located near the base of the box. You will need the cable gland for the plastic tubing from the pressure sensor if you intend to use the pressure plate for lap sensing. If you intend to use a pushbutton switch instead our end-of-lap sensor plate, the gland is used for the wiring to that switch from CON2. The AA cell holder is mounted against the base of the box and secured with double-sided foam-core tape. The PCB is held onto the lid of the case by the three switches. siliconchip.com.au Use both nuts for each switch to secure the assembly in place. Testing Plug REG1 into its socket (ensuring it has the correct orientation) and apply power. Check that the voltage between the 0V terminal of CON1 and the cathode of diode D2 is around 16V. Also, check that the voltage between pins 5 and 14 of IC1’s socket is close to 5V (4.75-5.25V). The voltage between pins 11 and 4 of IC3 should also be close to 5V (same as IC1). If this is correct, switch off and plug IC1, IC2 and IC3 into their sockets, again being careful with polarity and to avoid bending any leads under the IC package when doing so. With power reapplied, DISP2 should show 0. DISP1 will be unlit due to leading zero blanking that is incorporated in the Lap Counter software. The display will go off after around five seconds. It will light again if View switch S1 is pressed or Lap switch S4 (if installed) is pressed. Note that the count will not increase if the Lap switch is pressed before the counter delay period has expired. The initial setting for the counter delay is five seconds. If a pressure plate is being used, adjust VR1 fully anticlockwise and the display will continuously increment every five seconds. Slowly rotate VR1 clockwise until the counting ceases. You can then test the pressure plate to check that the display counts up when it is pressed. As before, the count will not increase if the pressure plate is pressed before the counter rate limit period has expired. Dimming Press and hold View switch S1 for six seconds and the display will dim in steps. Release the View switch when the display is at the required brightness. Display on time adjustment The display on-time is adjustable. This is set by pressing and holding View switch S1 and then pressing and releasing Clear switch S2. Keep holding the View switch for five seconds until the letter U is shown on DISP2. The on period is then set using trimpot VR1 (which normally sets the pressure sensor threshold). The on time is adjustable from 0.5s (VR1 fully anticlockwise) up to about 10 seconds siliconchip.com.au Parts list – Pool Lap Counter 1 double-sided PCB coded 19102171, 131 x 86mm 1 UB1 jiffy box, 158 x 95 x 53mm 1 neutral or blue-tinted 3mm Acrylic or Perspex sheet, UV stabilised,     152 x 90mm [available pre-cut from the SILICON CHIP online shop] 1 MEMS Gauge pressure sensor, 0-37kPa (PS1);    [Omron 2SMPP-02 – element14 Cat 2113270] 2 LBT23101BB 2.3-inch blue common anode 7-segment displays       (DISP1,DISP2) [available from the SILICON CHIP online shop] 1 47H 3/5A toroidal inductor (L1) [Jaycar LF-1274, Altronics L6517] 1 four cell AA holder, single layer type    [Jaycar PH9204 or PH9282, Altronics S5028 or S5030] 1 battery snap lead [if required to connect to battery holder] 4 AA alkaline cells 2 SPDT PCB-mount momentary pushbutton switches (S1,S2)   [Altronics S1393] 1 SPDT PCB-mount toggle switch (S3) [Altronics S1315] 1 2-way PCB-mount screw terminal, 5.08mm pin spacing (CON2) 1 DIL18 IC socket (for IC1) 1 DIL16 IC socket (for IC2) 1 DIL14 IC socket (for IC3) 1 DIL8 IC socket (for REG1) 1 20-way IC socket strip (for DISP1 & DISP2) 2 2-way pin headers with jumper shunts (JP1,JP2) 1 M3 x 6-10mm machine screw and nut 4 100mm cable ties 1 cable gland to suit 3-6.5mm cable 2 PC stakes 1 250mm length light duty twin lead or red/black light duty hookup wire 1 100mm length foam-core double-sided tape Semiconductors 1 PIC16F88-I/P microcontroller programmed with 1910217A.hex (IC1) 1 ULN2003N Darlington transistor array (IC2) 1 LMC6484AIN quad rail-to-rail op amps (IC3) 1 MC34063AP switching regulator (REG1) 1 78L05 5V 100mA linear regulator (REG2) 1 CSD18534low gate threshold N-channel Mosfet (Q1) 3 BC327 PNP transistors (Q2,Q4,Q6) 2 BC547 NPN transistors (Q3,Q5) 2 1N5819 1A schottky diodes (D1,D2) 1 BAT46 schottky diode (D3) [Jaycar ZR-1141] Capacitors 1 470F 16V low-ESR PC electrolytic 1 470F 25V low-ESR PC electrolytic 2 10F 16V PC electrolytic 2 100nF MKT polyester 1 1nF MKT polyester Resistors (0.25W, 1%, metal film) 2 100kΩ 1 18kΩ 11 10kΩ 1 3kΩ 3 1kΩ 7 100Ω 1 47Ω 2 1Ω (5%) 1 10kΩ miniature horizontal trimpot (VR1) 1 2kΩ 1 1.5kΩ Additional parts for pressure plate (Parts normally available from hardware stores such as Bunnings) 1 length of 3mm (ID) / 5mm(OD) clear vinyl garden irrigation tubing 1 large flat cooler brick, 320 x 200 x 17mm [eg, Esky Ice Wall 1287091] 2 4mm barbed off-takes (joiners) for tubing    [eg, for “Pope” drip-feed watering system] 1 stainless steel bracket or 2-4 suction cups [see text and diagram] March 2017  31 The only “component” which mounts in the case itself is the 4xAA battery pack (secured with double-sided tape). Everything else “hangs” off the front panel/lid, with the two 7-segment displays obviously toward the front. The clear tube you can clearly see coming from the case goes off to our custom-made pressure sensor plate. with VR1 near fully clockwise. The midpoint setting gives the original five second on time. With VR1 fully clockwise, the display remains on as long as power is applied. Counter delay period The counter delay period (maximum count rate) is also adjustable. This is set by connecting a pushbutton switch to the S4 input at CON2. Press and hold this switch closed and then press and release the Clear switch, S2. Keep holding S4 for five seconds until the letter C shows on DISP2. The counter period is then set using trimpot VR1. The delay period is adjustable from 1/25 second (40ms) at VR1’s fully anticlockwise position, up to about 5 seconds with fully clockwise rotation. Note that after setting either the on time or counter delay, VR1 should be returned to its original position to restore correct pressure sensor operation (assuming you have fitted one). Don’t forget to select the count option using shunts on JP1 and JP2. For normal single number counts (0,1,2,3,...), leave JP1 and JP2 off. For odd number counting (0,1,3,5,…), insert both jumpers JP1 and JP2 while for even number counting (0,2,4,6,…), insert JP2 but leave JP1 out. Pressure plate assembly The pressure plate is made using a large, slim freezer brick. We used an “Esky” brand which we bought at Bunnings Hardware for $5.99 (model No. 1287091). Measuring 320 x 200 x 17mm, this has a gel inside and we leave it there so that the brick won’t float in the pool. The top lid of the brick is drilled to 4mm and a 4mm barbed off-take is inserted. A length of 3mm PVC tubing can then be attached to this barb. A second off-take is used to join to a longer PVC tube to the Lap Counter unit. While the tubing is 3mm and the barb 4mm, the tubing will stretch over the barb connector. If you find it difficult to fit, soak the tube end in hot water for a few seconds to soften the PVC. The pressure (sensor) plate (ie, freez- Resistor Colour Codes           No. 2 1 11 1 1 1 3 7 1 2 32  Silicon Chip Value 100kΩ 18kΩ 10kΩ 3kΩ 2kΩ 1.5kΩ 1kΩ 100Ω 47Ω 1Ω 4-Band Code (1%) brown black yellow brown brown grey orange brown brown black orange brown orange black red brown red black red brown brown green red brown brown black red brown brown black brown brown red purple black brown brown black gold brown 5-Band Code (1%) brown black black orange brown brown grey black red brown brown black black red brown orange black black brown brown red black black brown brown brown greenblack brown brown brown black black brown brown brown black black black brown red purple black gold brown brown black black silver brown siliconchip.com.au FOR STORAGE, DETACH THIS SECTION OF TUBING FROM JOINER, BEND DOUBLE & CRIMP CLOSED WITH CLOTHES PEG (OR USE A ‘TAP’ VERSION OF THE JOINER) TO PRESSURE SENSOR 3mm TUBING SMALL AIR HOLE (SEE TEXT) ‘NALEON ’ SUPER SUCTION HOOKS 3mm VINYL TUBING AIR TUBE TO DISPLAY BOX M3 NYLON SCREWS& NUTS CLAMP TUBING TO HOOKS BARBED ‘OFF TAKE’ (JOINER) LAP COUNTER ‘ESKY’ LARGE SLIM ‘ESKY’ FREEZER BRICK (3 20 x 200 x 1 7 mm) M3 NYLON SCREWS PASSED THROUGH ‘WELDED THROUGH ’ SECTION OF BRICK, WITH M3 NYLON NUTS AT REAR (TOP VIEW ) (FRONT VIEW ) BRACKET TO ATTACH FREEZER BRICK TO SIDE OF POOL ‘ESKY ’ LARGE SLIM FREEZER BRICK (319 15mm) (3 20 x 200 x 1 7 mm) (SIDE VIEW ) NOTE: EXTRA SUCTION HOOKS MAY BE USED TO SUPPORT LOWER SECTION IF REQUIRED Here are two methods of mouting the freezer brick on the end of the pool (you may think of others to suit your pool). The first is to fashion a bracket in marine-grade stainless steel as shown at left. However, it may be difficult for the average person to work with stainless steel. If you use aluminium instead (because it is much easier to work!) remember that the chemicals in your pool will start attacking aluminium quite quickly, so the bracket cannot be left in the pool. The alternative “suction cup” method (as shown at right and in the photo below) will only work if your pool has glazed (ie, shiny!) tiles; the suction cups will not “suck” on a rough surface. er brick) is located at the end of the pool in a vertical position. Note that during transportation, you need to either keep the brick upright or crimp the hose and hold it closed with a cable tie or peg to prevent the gel escaping. The pressure plate can be mounted using various methods. For pools with glazed (ie, shiny!) tiles, a pair of suction cups with thin cord (or even lengths of the 3mm PVC tube we used earlier) will hold it in place (four suction cups could be used for extra stability). Otherwise, a suitable stainless steel bracket can be secured to the pool or hung over the edge on an aboveground pool. Note that PVC tubing and the freezer brick are not suitable for extended exposure to sunlight. It is recommended to store these away in the shade when not in use, especially during the summer. OK, with the remaining warm days of early autumn, it’s time to start swimmin those laps in your pool. At least SC you’ll be able to keep a count! siliconchip.com.au The Naleon Super Suction Hook – $4.60 each at Bunnings. The second method of mounting the sensor using suction cups on shiny tiles – it won’t work on pebblecrete or rough tiles! You can carefully drill through the cooler brick to attach cord or tube where there are dimples in the moulding. Incidentally, the sensor doesn’t need to be wholly under the water – half in and half out works just as well. March 2017  33