Silicon ChipThreshold Voltage Switch - July 2014 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Argo drones gathering deep sea data
  4. Feature: Argo: Drones Of The Deep Oceans by Dr. David Maddison
  5. Review: AmScope Stereo Microscope by Andrew Levido
  6. Project: Threshold Voltage Switch by John Clarke
  7. Feature: Eye-Fi Mobi SD Wireless Camera Cards by Ross Tester
  8. Subscriptions
  9. Product Showcase
  10. Salvage It! Wrecking The Computer Itself by Bruce Pierson
  11. Project: Micromite, Pt.3: Build An ASCII Video Display Terminal by Geoff Graham
  12. Project: Touch-Screen Digital Audio Recorder, Pt.2 by Andrew Levido
  13. Project: L-o-o-o-n-g Gating Times For The 12-Digit Counter by Jim Rowe
  14. Order Form
  15. Vintage Radio: The upmarket 1950 HMV R53A radiogram by Rodney Champness
  16. Market Centre
  17. Notes & Errata
  18. Advertising Index
  19. Outer Back Cover

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

You can view 38 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 "Threshold Voltage Switch":
  • Threshold Voltage Switch PCB [99106141] (AUD $10.00)
  • Threshold Voltage Switch PCB pattern (PDF download) [99106141] (Free)
Items relevant to "Micromite, Pt.3: Build An ASCII Video Display Terminal":
  • PIC32MX170F256B-50I/SP programmed for the Micromite Mk2 plus capacitor (Programmed Microcontroller, AUD $15.00)
  • PIC32MX170F256D-50I/PT programmed for the Micromite Mk2 (44-pin) (Programmed Microcontroller, AUD $15.00)
  • CP2102-based USB/TTL serial converter with 5-pin header and 30cm jumper cable (Component, AUD $5.00)
  • Firmware (HEX) file and user manual for the Micromite (Software, Free)
  • Firmware (HEX) file and user manual for the 44-pin Micromite (Software, Free)
  • 44-pin Micromite PCB pattern (PDF download) [24108141] (Free)
  • 44-pin Micromite PCB [24108141] (AUD $5.00)
  • ASCII Video Terminal PCB [24107141] (AUD $5.00)
  • PIC32MX270F256B-I/SP programmed for the ASCII Video Terminal [2410714A.HEX] (Programmed Microcontroller, AUD $15.00)
  • MCP1700 3.3V LDO (TO-92) (Component, AUD $2.00)
  • Firmware (HEX) file for the ASCII Video Terminal [2410714B] (Software, Free)
  • ASCII Video Terminal PCB pattern (PDF download) [24107141] (Free)
Articles in this series:
  • The Micromite: An Easily Programmed Microcontroller, Pt.1 (May 2014)
  • The Micromite: An Easily Programmed Microcontroller, Pt.1 (May 2014)
  • The Micromite: An Easily Programmed Microcontroller, Pt.2 (June 2014)
  • The Micromite: An Easily Programmed Microcontroller, Pt.2 (June 2014)
  • Micromite, Pt.3: Build An ASCII Video Display Terminal (July 2014)
  • Micromite, Pt.3: Build An ASCII Video Display Terminal (July 2014)
  • The 44-pin Micromite Module (August 2014)
  • The 44-pin Micromite Module (August 2014)
Items relevant to "Touch-Screen Digital Audio Recorder, Pt.2":
  • Touch-screen Audio Recorder PCB [01105141] (AUD $12.50)
  • PIC32MX695F512H-80I/PT programmed for the Touchscreen Digital Audio Recorder (Programmed Microcontroller, AUD $30.00)
  • Firmware for the Touchscreen Audio Recorder [0110514B.HEX] (Software, Free)
  • Touch-screen Audio Recorder PCB pattern (PDF download) [01105141] (Free)
  • Touch-screen Audio Recorder end panel artwork (PDF download) (Free)
Articles in this series:
  • Touch-Screen Digital Audio Recorder, Pt.1 (June 2014)
  • Touch-Screen Digital Audio Recorder, Pt.1 (June 2014)
  • Touch-Screen Digital Audio Recorder, Pt.2 (July 2014)
  • Touch-Screen Digital Audio Recorder, Pt.2 (July 2014)
Items relevant to "L-o-o-o-n-g Gating Times For The 12-Digit Counter":
  • 2.5GHz 12-Digit Frequency Counter Main PCB [04111121] (AUD $20.00)
  • 2.5GHz 12-Digit Frequency Counter Display PCB [04111122] (AUD $12.50)
  • 2.5GHz 12-Digit Frequency Counter Add-on PCB [04106141a/b] (AUD $12.50)
  • PIC16F877A-I/P programmed for the 2.5GHz 12-Digit Frequency Counter [0411112C.HEX] (Programmed Microcontroller, AUD $20.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • 2.5GHz 12-Digit Frequency Counter front panel [04111123] (PCB, AUD $25.00)
  • Firmware for the 2.5GHz 12-Digit Frequency Counter project [0411112C.HEX] (Software, Free)
  • 2.5GHz 12-Digit Frequency Counter Main PCB pattern (PDF download) [04111121] (Free)
  • 2.5GHz 12-Digit Frequency Counter Display PCB pattern (PDF download) [04111122] (Free)
  • Long Gating Time Add-on Module for the 2.5GHz 12-Digit Frequency Counter PCB pattern (PDF download) [04106141a/b] (Free)
  • 2.5GHz 12-Digit Frequency Counter front and rear panel artwork (PDF download) [04111123] (Free)
Articles in this series:
  • A 2.5GHz 12-digit Frequency Counter, Pt.1 (December 2012)
  • A 2.5GHz 12-digit Frequency Counter, Pt.1 (December 2012)
  • A 2.5GHz 12-Digit Frequency Counter, Pt.2 (January 2013)
  • A 2.5GHz 12-Digit Frequency Counter, Pt.2 (January 2013)
  • L-o-o-o-n-g Gating Times For The 12-Digit Counter (July 2014)
  • L-o-o-o-n-g Gating Times For The 12-Digit Counter (July 2014)

Purchase a printed copy of this issue for $10.00.

Threshold Voltage S A simple but versatile device to switch a relay input voltage crosses a preset threshold This versatile Threshold Voltage Switch takes the output of an analog sensor, battery voltage or other varying voltage and switches power to a fan, warning light or similar when a preset threshold voltage is reached. It can be set up for use with a 5V, 12V or 24V supply. It can also be used to prevent a lead-acid battery from being over-charged. T HIS IS a considerably enhanced version of the Voltage Switch project presented in our 2004 publication, “Performance Electronics for Cars”. That has been a very popular project but feedback from readers over the intervening years has suggested a number of improvements which have now been incorporated. When monitoring a sensor or any DC voltage signal, you may wish to switch power to a load on or off when a set voltage is reached. This means that at a particular temperature, pressure, fuel mixture or battery voltage, you can switch power to drive a cooling fan, a warning light, battery charging circuit or whatever you fancy. Switching is done via a relay that 26  Silicon Chip can handle a relatively high current. The relay also provides isolation between the Threshold Voltage Switch sensing circuitry and the load it controls. So there is no requirement to power the Threshold Voltage Switch (TVS) from the same power supply as the load it controls. It also does not matter where you put the relay contacts within the load circuit. So the relay can switch the positive or negative supply to the load, as depicted in Fig.1. Fig.1A shows the load’s ground connection being switched while Fig.1B shows the switch in the positive supply connection. Either way, the effect is the same but it may be more convenient or even a requirement to switch one or the other, depending on your application. The relay can be switched on when the sensed voltage rises above a preset value or when it falls below the preset value. This is selected by links on the PCB. Circuit description Fig.2 shows the complete circuit for the Threshold Voltage Switch (TVS). It comprises two ICs, a 3-terminal regulator, the relay and a few other components. Op amp IC1a is wired as voltage comparator to monitor the input (signal) voltage and compare it against a threshold voltage. The input voltage is fed via a 470kΩ resistor to pin 2, the siliconchip.com.au By JOHN CLARKE Main Features •  Operates from 5-24V DC (nominal, 30V maximum) •  Adjustable trigger threshold •  Trigger on high or low voltage •  Output state indicator LEDs •  Multiple relay options, up to 60A SPDT or 10A DPDT Specifications Power Supply: 5-30V. Current Drain: <1mA with indicator LEDs off (LK4 out), relay off and VR2 set to >100kΩ. With the relay on, the current is dependent on the coil resistance. Signal Input Impedance: 470kΩ minimum. Trigger Threshold: adjustable. Input Divider: divide by 1 (LK1 out) or divide by greater than 5.7 (LK1 in). witch when an inverting input, while the threshold comparison voltage is fed to pin 3. If the required voltage threshold is above 3.3V, you will need to attenuate the input voltage and this is done by inserting link LK1. The amount of attenuation is then adjusted with multi-turn trimpot VR1. A 3.3V reference voltage is provided by REG1, an LM2936 low quiescent current, low-dropout regulator which is fed from the V+ supply rail. It feeds trimpot VR3 and in turn, its wiper voltage is fed to IC1b which acts as a low impedance buffer to provide the reference voltage to pin 3 of IC1a. Trimpot VR2 adjusts the hysteresis of comparator IC1a. Hysteresis can be regarded as positive feedback and it reduces the sensitivity of the comparator to short term variations in the input voltage. To explain further, say the threshold voltage at pin 3 is 3V and the sensed voltage at pin 2 goes slightly above 3V, resulting in the comparator’s output going low. The feedback connection from output pin 1 to pin 3 means that siliconchip.com.au Hysteresis For No Input Attenuation: ~5mV-2.5V for 5V supply; ~12mV-6V for 12V supply. Hysteresis For 10:1 Input Attenuation: ~50mV minimum for 5V supply; ~120mV minimum for 12V supply. Maximum Switching Voltage: 60V DC/40VAC for on-board relay; limited by contact ratings for off-board relay. the voltage at pin 3 is pulled slightly lower than it was before pin 1 flicked low. That means that the sensed voltage at pin 2 will have to drop somewhat below 3V to cause the comparator to change state again. So the output will not switch again immediately if there is only a slight drop in the voltage at pin 2 immediately after the output switches. Conversely, when IC1a’s output goes high (near V+) in response to a dropping voltage at pin 2 of IC1a, pin 3 is instead pulled higher than before and pin 2 will have to rise by an increased amount to switch the comparator’s output low again. So the threshold voltage for IC1a varies depending on the output of IC1a. In practical terms, hysteresis prevents the relay from ‘chattering’ on and off when the sensed voltage is close to the voltage threshold. It also stops the + circuit from switching on and off every few seconds. Say for example, you want a fan to cool a heatsink whenever the temperature reaches 60°C. As the temperature sensor reaches 60°C, the fan will run and almost immediately the temperature will drop by a small amount. This means that, without hysteresis, the fan might run for a less than a second before switching off and then a second or so later, it will be on again as the 60°C threshold is reached. By adding hysteresis, the fan can be set to start running at 60°C but only switch off at say 55°C. That way, the fan will run for longer, preventing rapid on and off cycling. When setting the threshold voltage for IC1a, we monitor test point TP2. This actually allows us to set the two switching thresholds: one when IC1a’s output is high and the second when its + RELAY CONTACTS LOAD B A LOAD RELAY CONTACTS – – Fig.1: the relay can switch either the positive or negative supply lead to the load. Fig.1A shows the load’s ground connection being switched while Fig.1B shows the relay contacts in the positive supply lead. July 2014  27 Parts List 1 double-sided PCB with plated-through holes, code 99106141, 107 x 61mm 1 UB3 plastic utility case, 130 x 68 x 44mm (optional) 1 12V DPDT relay (RELAY1) (Altronics 8A S4190D or lowprofile S4270A, Jaycar 5A SY-4052)* 2 2-way PCB-mount screw term­ inals, 5.08mm spacing (CON1) 2 3-way PCB-mount screw term­ inals, 5.08mm spacing (CON2)# 2 8-pin DIL IC sockets (optional) 5 2-way SIL pin headers with 2.54mm pin spacings (LK1, LK2, LK4, LK5a & LK5b) 1 3-way SIL pin header with 2.54mm pin spacing (LK3) 6 jumper shunts (shorting blocks) 3 PC stakes (TP GND,TP1,TP2) 1 M3 x 6mm machine screw & nut 1 1N4004 1A diode (D3) 1 1N5819 Schottky diode (D4) 1 1N4744 15V zener diode (ZD1) (two required for 24V supply) 2 3mm red LEDs (LED1,LED2) 1 3mm green LEDs (LED3) 2 100kΩ 25-turn trimpots (VR1,VR3) 1 1MΩ 25-turn trimpot (VR2) Semiconductors 1 LMC6482AIN dual CMOS op amp (IC1) 1 7555 CMOS timer (IC2) 1 BC337 NPN transistor (Q1) 1 BC327 PNP transistor (Q2) 1 IRF540 N-channel Mosfet (Q3) 1 LM2936-3.3 3.3V regulator (REG1) (Jaycar ZV1650) 2 1N4148 small signal diodes (D1,D2) Notes * see text and Table 1 for other relay options. # not required if an off-board relay is used; two PCB-mount vertical spade connectors plus matching crimp connectors are required instead. ^ For 5V supply, delete 1 x 100Ω resistor and add 1 x 10Ω; for 24V supply use 220Ω 0.5W. output is low. The threshold measurement is made between test points TP2 and TP GND. IC2, a CMOS 7555 timer, is used as an inverter and its pin 3 output goes to one side of 3-way header LK3. Depending on how link LK3 is set, the gate drive for Mosfet Q3 can come from either pin 1 of IC1a or pin 3 of IC2. This means that the relay can be turned on when the input voltage exceeds the threshold (LK3 set to HIGH) or when the input voltage goes below the threshold (LK3 to LOW). As shown, the HIGH setting selects the output from IC2 while the low setting selects IC1a’s output. The selected output then drives Mosfet Q3 via a 100Ω gate resistor. When Q3’s gate goes high, Q3 turns on and powers the relay coil. LED3 (green) is also lit whenever Q3 is switched on. Note that although Q3 isn’t a logiclevel Mosfet, it’s suitable for use with a 5V supply which results in the Mosfet gate drive being less than 5V. We have specified an IRF540 Mosfet for this reason – it doesn’t need to fully saturate as it’s only switching a small current (the relay coil current). 28  Silicon Chip Capacitors 1 100µF 16V radial electrolytic 1 22µF 16V radial electrolytic 1 1µF 16V radial electrolytic 5 100nF MKT Resistors (0.25W, 1%) 1 470kΩ 3 3.3kΩ (0.5W) 2 1kΩ 2 100Ω^ Plus R1 (5W) if required (see text) Output indication LED1 and LED2 are used to indicate IC2’s output level and are selected by links LK5a & LK5b. They simply indicate whether the input signal is above or below the threshold voltage. LED1 is driven by NPN emitter-follower transistor Q1 while LED2 is driven by PNP emitter-follower Q2. In operation, LED1 lights when the input is greater than the threshold, while LED2 lights when the input is less than the threshold. After setting up the threshold adjustments, the two LK5 jumper shunts can be removed so that these LEDs no longer light. This reduces the current drain of the circuit which can be useful in situations where current drain must be minimised. Supply voltage The circuit can be operated from supply voltages ranging from 5-30V. Most of the circuit is fed via Schottky diode D4 while the relay is directly powered from the input supply. D4 is included for reverse polarity protection. It’s followed by a 100Ω resistor (R2), while zener diode ZD1 is included to clamp the supply to 15V. ZD2 is used to drop the supply by 15V when a 24V supply is connected while LK2 is used to short ZD2 out if the supply voltage is below 15V. A 100µF electrolytic capacitor filters the resultant supply. Note that the 100Ω resistor (R2) in series with D4 should be reduced to 10Ω if a 5V supply is used. If the supply voltage is significantly more than the voltage rating of the relay, it will need a resistor in series with the coil. This is shown on the circuit as R1. As previously stated, the relay is driven by Mosfet Q3. If the voltage rating of the relay coil is close to the supply voltage, resistor R1 is omitted and link LK4 inserted instead. Do not be concerned about the normal voltage variation which can be expected from 12V or 24V lead-acid batteries. A 12V battery may go as high as 14.8V while being charged while a 24V battery can go to 29.6V. Both 12V and 24V relays can cope with this variation and there is no need for a series dropping resistor. Diode D3 and its associated 100nF capacitor suppress the back-EMF transient when the relay switches off. Construction The Threshold Voltage Switch is built on a double-sided PCB coded 99106141 and measuring 107 x 61mm. This is designed to clip into the side channels of a plastic UB3 box (130 x 68 x 44mm), with the external leads exiting via a cable gland. The UB3 box is optional, however. Depending on the application, it may be more convenient to house the PCB inside existing equipment. Fig.3 shows the parts layout on the PCB. Begin by inspecting the PCB for any defects (rare these days) and checking that the hole sizes for the larger parts are correct. If this checks out, the next step is to select the relay siliconchip.com.au siliconchip.com.au July 2014  29 IN 22 µF VR3 100k 100nF THRESHOLD A TP2 A K 6 5 BUFFER 4 IC1b 7 1k E C λ A K 2 6 7 B 1 IC2 7555 8 5 3 K A D1 1N4148 INVERTER 4 100nF THRESHOLD INDICATION LK5a RELAY LED3 3.3k A K ZD1, ZD2 A K 1N5819 K A K A 1N4148 3.3k 1N4004 LED1 Q1 BC337 100 µF 16V INPUT>THRESHOLD 1 100nF V+ COMPARATOR HYSTERESIS IC1a 8 VR2 1M 3 2 1k TP1 ZD1* 15V 1W LK2 OUT FOR 24V IC1: LMC6482AIN 1 µF 16V * SEE TEXT ZD2 15V 1W K LK2 LK5b LOW HIGH K λ A IN E K A K C GND OUT LM 29 36-3.3 B BC 32 7 , BC337 A D2 1N4148 V+ 100Ω B R1 SHUNT LK4 D3 1N4004 LEVEL LK3 100nF # SEE TEXT K A G G C E D S LEDS IRF540 K A Q2 BC327 D NO COM NC NC COM NO CON2# INPUT<THRESHOLD Q3 IRF540 λ LED2 3.3k S D R1 5W# RELAY1, RELAY2 OR RELAY3# Fig.2: the complete circuit of the Threshold Voltage Switch. Op amp IC1 is wired as a voltage comparator and this compares the input (signal) voltage fed in via CON1 with a threshold voltage set by REG1 & VR3 (and buffered by IC1b). IC2 operates as an inverter, while LK3 selects either the output from IC1a or IC2 to drive Mosfet Q3. Q3 is turn switches the relay. LED1 & LED2 provide threshold switching indication, while LED3 indicates when the relay is on. 20 1 4 GND OUT VR1 100k LK1 (10 Ω FOR 5V PWR) DIVIDE K R2 100Ω THRESHOLD VOLTAGE SWITCH 100nF SC  V+ 470k TP GND REG1 LM2936-3.3 CON1 SIGNAL IN – + + POWER IN – A D4 1N5819 IN > SET Q1 A LED1 100nF THRESHOLD NO NC 3.3k LED3 SHUNT R1 LK4 * D3 COIL COIL C NO NC C 3.3k 1k IC2 7555 LMC6482 IC1 470k 3.3k 4004 RELAY1 LOW LEVEL 100nF 22 µF HYSTERESIS COM RELAY2 A C (TRIMPOTS) REG1 NC ON CN IN 0V INPUT TP1 CON2 NO COIL (IN FOR VR1 100k 100nF LM2936-3.3 DIVIDE) DIVIDER RELAY3 IN < SET 100nF 100Ω 1k TP2 HIGH VR2 1M VR3 100k LK3 LK1* LED2 Q2 A 100nF 1 µF R1* C 0V SUPPLY LEVEL TEST BC337 4148 100 µF BC327 4148 ZD1 15V LK5a,b D2 ON CN CON1 + 15V 5819 D4 LK2* 100Ω TP GND 10Ω FOR 5V * SEE TEXT D1 R2* ZD2* NOTE: ONBOARD RELAY MAXIMUM: 60V DC/40VAC Q3 IRF540 C 2014 99106141 1 4 1 6 0 1 9 9 VOLTAGE h ctiSWITCH wS egatloV Fig.3: follow this diagram to build the TVS with an on-board relay. Install LK1 to divide the input signal, remove LK2 and install ZD2 for a 24V supply and install LK4 if the supply voltage doesn’t exceed the relay rating (see text). LK3 selects high or low threshold triggering. to be used from Table 3 (near the end of this article). Choosing the relay Basically, there are several different relays that can be used with the TVS. The overlay shows a standard 12V DPDT relay set up. It’s just a matter of selecting a relay that suits your application. Note that LK4 is fitted for most relays. However, if the supply voltage exceeds the voltage rating of the relay to be used, then LK4 is left out and 5W resistor R1 is fitted instead. R1 is wired in series with the relay coil to drop the voltage. The value required for R1 is easily calculated. For example, if the relay coil is rated at half the supply voltage (eg, a 12V relay with a nominal 24V supply), then the resistor needs to have about the same resistance as the relay coil. In other cases, you can calculate the required value for R1 as follows: (1) subtract the relay coil voltage from the power supply voltage and multiply the result by the coil resistance; (2) divide the result obtained in step 1 by the relay coil voltage to obtain the resistor value required. For example, to run a 12V relay with a coil resistance of 120Ω from an 18V supply, you will need a 60Ω 5W series resistor. This is calculated as ((18 - 12) x 120Ω) ÷ 12. If the calculated value is not a standard 5W resistor value, choose the next highest available value. As stated earlier, for a 5V supply, resistor R2 must be 10Ω. voltage always exceeds the sum of the values of ZD1 and ZD2, but ZD1 must be between 5.1V and 15V. Resistor R2 can remain at 100Ω 0.5W for a 12V supply but should be changed to 220Ω 0.5W for a 24V supply. Installing the parts Once you’ve decided on the relay and supply regulation option, you can begin installing the parts on the PCB. The resistors, diodes and zener diodes can go in first. Table 1 shows the resistor colour codes but a digital multimeter should also be used to check each resistor before soldering it into place. Make sure that the diodes and zener diodes are installed with the correct polarity, ie, with the striped end of each device orientated as shown on Fig.3. Note that ZD2 is not required if you intend using a supply of 12V or less (LK2 is fitted later instead). The three PC stakes can go in next, one at TP GND and the others at TP1 & TP2. Follow these with Mosfet Q1 – it’s mounted horizontally and secured to the PCB using an M3 x 6mm screw and nut. Bend its leads at right angles before mounting it into position and be sure to fasten its tab to the PCB before soldering the leads. Regulating the supply By carefully choosing the values for ZD1 & ZD2, the supply for IC1 can be regulated. However, this is only required if the threshold voltage must have a very high precision, ie, the swing in the input voltage being monitored is below 100mV. The 3.3V reference is quite stable but it will vary by about 1mV for each 1V variation in the V+ rail. Another reason for a regulated supply is that it makes for a more consistent hysteresis voltage. For example, if a 12V lead-acid battery is used to power the TVS, the supply can vary from 11.5-14.8V. In that case, changing ZD1 to 10V will minimise any change in the threshold or hysteresis as the supply varies. Similarly, for a 24V battery, both ZD1 and ZD2 can be 10V types. The point is to ensure that the supply Table 1: Resistor Colour Codes   o o o o o No.   1   3   2   2 30  Silicon Chip Value 470kΩ 3.3kΩ 1kΩ 100Ω 4-Band Code (1%) yellow violet yellow brown orange orange red brown brown black red brown brown black brown brown 5-Band Code (1%) yellow violet black orange brown orange orange black brown brown brown black black brown brown brown black black black brown siliconchip.com.au Maximum Switching Voltages For The TVS Although its contacts may be rated higher, the maximum switching voltage for the on-board relay is 60V DC or 40VAC. Do not try to switch mains voltages using an on-board relay, as the tracks on the PCB are too close together. If you do want to switch mains, you will need to use an off-board relay that has contacts rated for 230VAC. Many will be rated for 230VAC but those designed for automotive applications (eg, horn relays) will not be. REG1, Q1 & Q2 are next on the list. Be sure to use the correct device at each location and note particularly that Q1 is a BC337 while Q2 is a BC327 (don’t get them mixed up). IC1 & IC2 can then go in, again taking care not to get them mixed up and making sure that they are orientated as shown (ie, pin 1 at top left). They can either be soldered directly to the PCB or you can use IC sockets. Now for the capacitors. The electrolytic types must be installed with the polarity shown (the longer lead being positive), while the MKT capacitors can be mounted either way around. Once these parts are in, you can fit the various pin headers for the jumper links. LK1, LK2, LK4, LK5a & LK5b all require 2-way pin headers. Note that the LK4 header must not be installed if resistor R1 is to be fitted. 3-pin header LK3 should also be fitted now. of the PCB. Make sure that each LED is orientated correctly, with its anode lead (the longer of the two) going to the pad marked ‘A’. A cardboard spacer slid between the leads of each LED when soldering can be used to ensure consistent lead lengths. Alternatively, if you want the LEDs to later protrude through the lid of the case, then it will be necessary to extend their leads and sleeve them in heatshrink tubing. You could also glue them to the lid and connect them to the PCB via flying leads; you could even fit pin headers in their place and use flying leads terminated in header plugs. Trimpots VR1-VR3 are straightforward to install. Use the 1MΩ trimpot (code 105) for VR2 and be sure to install them with the adjusting screws to the left. Now for the screw terminal blocks. CON1 consists of two 2-way terminal blocks and these must be dovetailed together before fitting them to the PCB. Push them all the way down onto the board and check that the wire entry holes are facing outwards before soldering the pins. CON2 is required if you intend using a PCB-mounted relay. It consists of three 2-way (or two 3-way) terminal blocks and again check that it sits flush against the PCB and is orientated correctly before soldering the pins. Alternatively, if an external relay with quick connectors it to be used, then the two 6.35mm PCB-mount male spade connectors will need to be installed. These are located just above Q3 and provide the relay coil connections. look for incorrectly orientated parts, parts in the wrong position and missed solder joints. If all is correct, follow this step-by-step procedure to configure the unit: Step 1:  if you are using a 12V or 5V supply, install the jumper shunt for LK2. Alternatively, for a 24V supply, install zener diode ZD2 and leave jumper shunt LK2 out. Step 2:  fit jumpers on LK5a and LK5b so that LED1 & LED2 will work. Step 3:  fit a jumper on LK4 if R1 has not been fitted. Step 4: adjust trimpots VR1, VR2 & VR3 clockwise until the end stop clicks can be heard (note: these are 20-turn or 25-turn trimpots). Step 5: apply power and check that voltage is present between pins 8 & 4 of IC1. The actual voltage will depend on the supply, zener diodes ZD1 and ZD2 and whether ZD2 is bypassed. If you are using a 12V supply and a 15V zener for ZD1 (LK2 in), IC1 should have around 11.7V between pins 8 & 4. For a 5V supply, you should get a reading of about 4.7V. And for a 24V supply (ZD2 in and LK2 out), you should get a reading of about 8.7V. Configuration Threshold adjustment Once the PCB assembly has been completed, go back over your work and check it carefully. In particular, The threshold voltage adjustment is done as follows. Apply a voltage at the level you want the TVS to switch Input signal level adjustment LK1 can be installed to allow the input signal to be reduced if the voltage to be monitored is going to exceed 3.3V. To set VR1, apply a voltage similar to that you require for the threshold (say 10V) to the input, switch on and measure the voltage between TP1 and TPG. Adjust VR1 to obtain less than 3.3V at TP1. The PCB clips neatly into the slots of a standard UB3 utility case. LEDs & trimpots The three LEDs can be pushed all the way down onto the PCB or they can be mounted a few millimetres proud siliconchip.com.au July 2014  31 Table 3: Relay Options For The TVS TVS Supply Voltage: 5V (LK2 in) 12V (LK2 in) 24V (LK2 out, ZD2 installed**) On-Board Relays (Maximum Switched Voltage = 60V DC or 40VAC) 1A DPDT PCB Mount (RELAY2) Contact rating: 24V DC/40VAC Altronics S 4147 Altronics S 4150 Altronics S 4152 5A DPDT PCB Mount (RELAY1) Contact rating: 30V DC/40VAC Jaycar SY-4052 Jaycar SY-4053 8A DPDT PCB Mount (RELAY1) Contact rating: 30V DC/40VAC Altronics S 4190D Altronics S 4270A Altronics S 4195D Altronics S 4272 Off-Board Relays (Maximum Switched Voltage Limited By Relay Contacts) 30A (RELAY3)* Contact rating: 14V DC/240VAC Altronics S 4211 SPDT Jaycar SY-4040 SPST Use 12V relay. R1=180Ω (for S 4211), 120Ω (for SY-4040) 5W, LK6 out 30A SPST Horn Relay* Contact rating: 14V DC Altronics S 4335A Jaycar SY-4068 Altronics S 4332 Jaycar: Use 12V relay. R1=82Ω 5W, LK6 out 30A SPDT Horn Relay* Contact rating: 14V DC Jaycar SY-4070 Use 12V relay. R1=82Ω 5W, LK6 out 60A SPDT Horn Relay* Contact rating: 14V DC Altronics S 4339 Jaycar SY-4074 Use 12V relay. R1=82Ω 5W, LK6 out Notes: LK6 installed (jumper in) unless stated. * Bolt on and quick connector type. Requires 2 x 6.35mm PCB-mount male spade connectors with 5.08mm pin spacing (Altronics H 2094) plus 4 x 6.35mm insulated female spade quick connectors with 4-8mm wire diameter entry (these are not suitable for the 60A relay). ** Install 1N4744 15V zener ZD2. A variety of relays can be used with this unit, such as DPDT (double-pole doublethrow), SPDT (single-pole double-throw) and SPST (single-pole single-throw). Double-pole (DP) simply means that there are two separate sets of contacts that can be used independently to switch power (or even signals). Single-throw (ST) and double-throw (DT) contacts each have a common (COM) contact and both ST and DT types have a contact that is open when the relay is off; ie, the normally open or NO contact. This NO contact closes against the COM terminal when the relay is on (ie, the coil is powered). In relays with DT contacts there is also a normally closed (NC) contact. This connects to the COM terminal when the relay is off and opens when the relay is on. Both SPDT and DPDT relays give the op- the relay, then adjust VR3 until the threshold voltage is reached. LED1 will light when the input is above the threshold, while LED2 will light when the input is below the threshold. With hysteresis trimpot VR2 set at maximum, the threshold for a rising input voltage will be similar to that of a falling input voltage. This hysteresis can be increased by reducing the value of VR2 (ie, turn VR2 anti-clockwise for more hysteresis). 32  Silicon Chip tion of powering something when the relay is either switched on or is switched off. For example, you can set up the TVS so that power is switched on when the relay is off by connecting the load to its supply via the NC and COM contacts. The main reason to do this is to minimise the current drawn by the circuit. The TVS typically draws less than 1mA when the relay is off but when the relay is on, the current drawn by its coil will typically be around 50mA or up to 100mA, depending on the relay used. Table 3 shows the various relays that can be used with the Threshold Voltage Switch. The choice depends on the supply voltage and the current to be switched by the relay’s contacts. PCB-mounting relays are accommodated on the PCB and their contacts brought out Changing the hysteresis will also affect the threshold voltage previously set using VR3, so you will now need to readjust VR3 to correct this. Once that’s done, check that the hysteresis set using VR2 is suitable and repeat the above steps if necessary. Jumper LK3 determines whether the relay turns on or off for rising or falling threshold voltages. Install LK3 in the HIGH position if you want the relay to turn on when the input volt- to screw terminal block CON2. By contrast, relays with quick connect terminals are mounted off the board. You can either use leads fitted with quick connectors or you can solder the leads directly to the terminals. Since relays with 12V coils are more common than 24V relays, the TVS has been designed so that it can use a 12V relay even when operating from 24V. It’s just a matter of removing LK4 and installing a dropping resistor (R1) on the PCB, in series with the relay’s coil. Having said that, if you are operating from a 24V supply and can obtain a suitable relay with a 24V coil and the correct pin-out, this will generally halve power and current consumption when the relay is energised. In that case, leave R1 out and install jumper LK4 instead. age exceeds the threshold. Conversely, install LK3 in the LOW position if you want the relay to turn on when the input voltage goes below the threshold. Finally, to reduce the current drawn by the Threshold Voltage Switch with the relay off, jumpers LK5a & LK5b can be removed (to disable LED1 & LED2) once the set-up procedure has been completed. Alternatively, you may leave them in to monitor the unit’s operation. siliconchip.com.au 17V PEAK 12V RMS θ 230V AC 12V AC D1 + 230V AC TO BATTERY 12V AC D2 0V + θ D1 0V THERMAL CUTOUT 17V PEAK 12V RMS THERMAL CUTOUT TO BATTERY 12V AC D2 D3 D4 – – TRANSFORMER WITH UNTAPPED SECONDARY TRANSFORMER WITH CENTRE-TAPPED SECONDARY Fig.4: typical battery charger circuitry using either a centre-tapped transformer with two rectifier diodes (A) or a single winding transformer with a four-diode bridge rectifier (B). Battery Charging With The Threshold Voltage Switch RT* + 0V INPUT IN 0V CON1 5819 CLIPS 10V 4148 THRESHOLD – higher) transformer. The output after rectification is pulsating DC with a peak voltage of around 17V. If the charger is left on charge for too long, the 17V peak can overcharge the battery easily, reaching well beyond 15V if left unattended. This solution is the Threshold Voltage Switch. It can monitor the battery and switch off the charging current as soon as the voltage reaches 14.4V. Additionally, the hysteresis can be made sufficiently large so that charging does not recommence until battery voltage falls to its 12.6V (typical) resting voltage after charging ceases. Fig.5 shows the required arrangement. The output from the charger 15V HYSTERESIS + CHARGER DIVIDER 4148 87 4004 86 C 2014 99106141 1 4 1 6 0 1 9 9 VOLTAGE h ctiSWITCH wS egatloV siliconchip.com.au transformer with a four-diode bridge rectifier (B). The charger will usually also include a temperature cut-out that switches the charger off when the transformer runs too hot. But there is no facility to sense the battery voltage or stop charging above a certain voltage. You may have a commercial battery charger that uses a circuit like one of these or you may have built the Bits’n’Pieces Battery Charger from April & May 2013 SILICON CHIP. Either way, the charge process can be monitored to ensure that the battery isn’t overcharged. Overcharging can easily occur since these chargers use a nominal 12V (or (TRIMPOTS) ANY READERS have asked for a simple solution to prevent overcharging of lead-acid batteries. Most simple battery chargers do not have any end-of-charge detection and will continue charging at their full current even though the battery may have reached 14.4V. If allowed to continue for too long, such over-charging leads to severe gassing, excessive fluid loss as the battery overheats and even buckling of the plates. Ultimately, the battery will fail much sooner than it should. Over-charging can also lead to a build-up of hydrogen gas in an enclosed space, which is an explosion hazard, especially in the presence of sparks (often caused if the battery is disconnected during charging). An elegant solution to this problem is to use our Threshold Voltage Switch as a battery charge cut-off device and you can then add a trickle charge facility as well. So why do most battery chargers not limit or stop charging when the battery reaches 14.4V (in the case of a 12V lead-acid battery)? The answer is that most chargers simply comprise a transformer and rectifier supplying raw full-wave rectified voltage to the battery. Fig.4 shows two typical battery charger circuits. These use either a centre-tapped transformer with two rectifier diodes (A) or a single winding SUPPLY M NC NO C NC NO VOLTAGE SWITCH * + – BATTERY 85 C 30 RELAY OPTIONAL TRICKLE CHARGE RESISTOR (1W RECOMMENDED) Fig.5: here’s how to add the Threshold Voltage Switch to a battery charger, so that charging automatically ceases when the battery is fully charged. Resistor RT is optional for trickle charging (see text). July 2014  33 (TRIMPOTS) THRESHOLD 3.3k D3 87 87A 85 TO CHARGER POSITIVE 30 86 LED3 SHUNT R1 LED1 3.3k 3.3k 100nF 22 µF REG1 LM2936-3.3 HYSTERESIS 4004 1k IC1 IC2 7555 LMC6482 470k TP1 DIVIDER LOW LEVEL 100nF A 60A RELAY C (IN FOR VR1 100k DIVIDE) 100nF TO BATTERY NEGATIVE ON CN IN 0V INPUT 100Ω 1k TP2 HIGH VR2 1M VR3 100k LK3 LK1 LED2 IN < SET 100nF 100nF 1 µF LK4 BC337 Q2 A BC327 4148 10V ZD1 100 µF LEVEL TEST Q1 C 0V SUPPLY + LK5a,b D2 TO BATTERY POSITIVE IN > SET A ON CN CON1 15V 5819 D4 D1 LK2 100Ω TP GND 10Ω FOR 5V * SEE TEXT R2* ZD2* 4148 10V 1W COIL Q3 IRF540 C 2014 99106141 1 4 1 6 0 1 9 9 VOLTAGE h ctiSWITCH wS egatloV TO CHARGER NEGATIVE Fig.6: follow this diagram to assemble the PCB and wire it to an external relay and battery charging circuit. Mediumduty hook-up wire can be used for all connections to the PCB but be sure to use heavy duty cable for all connections between the charger and the battery and to the relay contacts (30 & 87). is switched using a 60A 12V relay (Altronics S 4339 or Jaycar SY-4074). This heavy-duty relay is mounted externally, since it is too big to fit on the PCB. It works like this: when the Common (COM) and normally open (NO) contacts are closed, the output from the charger is connected directly to the battery and the battery charges. As soon as the battery reaches 14.4V, the relay switches off and the contacts open, thereby disconnecting the battery to prevent overcharging. The supply for the Threshold Voltage Switch is derived from the charger (rather than the battery), so that the battery doesn’t begin to discharge when charging ceases. We do, however, monitor the battery voltage but this process results in a current drain of less than 32µA. That’s much less than the battery self-discharge current. Note that the wiring to the TVS for voltage sensing is run separately from the battery terminals. This ensures that voltage drop across the charging leads does not affect the measurement. Adding trickle charging Switching to trickle charging at the end of a full charge is a good idea, since it ensures that the battery is always fully charged (without the risk of overcharging). The trickle charge must be low enough to allow the battery voltage to drop to below or be held at 13.8V. Typically, the trickle current should 34  Silicon Chip be 0.025% of the battery’s Ah capacity, or about 10mA for a 40Ah battery. This can be achieved by adding a 220Ω resistor across the relay contacts. The resistor value is calculated assuming a charging voltage of 15.8V (ie, 2V more than the 13.8V battery voltage). A 220Ω resistor will dissipate less than 0.25W but we recommend using a 1W resistor as it is more rugged and has thicker leads to make the connection to the relay terminals. Fig.6 shows the PCB layout and external connections necessary to connect the TVS to the battery and the charger. The relay is mounted externally, with its coil terminated to the contacts on the PCB using spade quick connectors. Note that Fig.6 shows the arrangement for charging a 12V battery. Zener diode ZD1 is now a 10V 1W type (1N4740) instead of the original 15V zener and provides a regulated 10V supply for comparator IC1a. This regulated supply is necessary because the hysteresis must be made quite wide and because supply variations would affect the voltage at which the TVS switches off charging. For a 24V charger and battery, use another 10V 1W zener diode for ZD2 and leave LK2 open. In addition, the 100Ω resistor (R1) needs to be changed to 220Ω 0.25W. You will also need a relay with contacts rated for 28V DC. Medium-duty hook-up wire can be used for all connections to the TVS but note that heavy duty cable must be used for all connections between the charger and the battery and for the connections to the relay contacts (30 & 87). We used 25A cable on our prototype but you could use 10A cable if the charger is a low-current type rated at less than 5A. As shown in the photos, we installed the PCB and relay in a UB1 plastic utility case measuring 158 x 95 x 53mm. The PCB mounts on M3 x 9mm tapped stand-offs and is held in place using M3 x 6mm screws. The relay is bolted to the base of the case using an M4 x 12mm screw and an M4 nut. Finally, the connections to the relay contacts are all made via quick connectors and the external leads are fed through a 10-14mm cable gland at one end of the case. Setting up the TVS The TVS must now be set up for battery charging following this stepby-step procedure: Step 1:  feed a voltage (eg, 9V) to the signal input on CON1, then accurately measure this voltage using a DMM (no need to apply power). Step 2: connect the DMM between TP1 and TP GND, make sure LK1 is installed and adjust VR1 for a reading that’s one-tenth the measured voltage in Step 1. This sets VR1 to divide by 10. Step 3:  measure the resistance between TP2 and the LOW position of LK3 (with the LK3 jumper out). Adjust siliconchip.com.au The PCB and relay for the battery charger cut-out version can be installed in a UB1 plastic utility case. VR2 for a reading of 90kΩ to set the hysteresis appropriately. Step 4:  remove the input voltage, short the signal inputs on CON1 using a wire link and apply power to the circuit using the battery charger or a 12V supply. Step 5: monitor the voltage between TP2 and TP GND and adjust trimpot VR3 for 1.44V. This sets the TVS to disconnect the battery from the charger when it reaches 14.4V. The hysteresis setting ensures that the TVS will not switch the relay back on again to reconnect the charger until the input voltage falls below 12.6V. Step 6:  remove the shorting link on the signal input and connect the signal “+” input to the positive supply rail instead. Now, with LK1 out, check the voltage between TP2 and TP GND; it should be close to 1.26V. TP2 should return to 1.44V if the signal input is again shorted to ground (ie, to 0V). Step 7: install LK3 in the LOW position. LK5a & LK5b can either be removed or left in circuit to show the charging status. In practice, leaving LED1 & LED2 operating is a good idea because the The external leads exit through a cable gland at one end of the case and the leads for the battery terminated in large alligator clamps. The two leads with the bared wire ends go to the battery charger. relay indicator LED3 now glows even when the relay is off. This is due to the supply coming from the pulsating DC of the charger plus various capacitive effects which cause the LED to light. By contrast, with a normal constant DC supply, the relay LED is extinguished SC when the relay turns off. Issues Getting Dog-Eared? REAL VALUE AT Keep your copies safe with these handy binders. $14.95 PLUS P & P Order now from www.siliconchip.com.au/Shop/4 or call (02) 9939 3295 and quote your credit card number or mail the handy order form in this issue. *See website for overseas prices. siliconchip.com.au July 2014  35