Silicon ChipUltrasonic Water Tank Level Gauge - September 2011 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Rising electricity tariffs causing hardship to people on low incomes
  4. Feature: LED Lighting Explained by Ross Spina
  5. Feature: Can You Really Reduce Your Electricity Bill? by John Cameron
  6. Feature: World Record 111-Gigapixel Photograph by Ross Tester
  7. Project: Ultrasonic Water Tank Level Gauge by John Clarke
  8. Project: Improving The GPS-Based Frequency Reference by Jim Rowe
  9. Project: High-Performance Stereo Headphone Amplifier, Pt.1 by Nicholas Vinen
  10. Project: Ultra-LD Mk.3 200W Amplifier Module, Pt.3 by Nicholas Vinen
  11. Feature: The Electronex Show Is Coming To Melbourne by Ross Tester
  12. Project: Upgrading An Ultra-LD Mk.2 Amplifier To Mk.3 Standard by Nicholas Vinen
  13. Vintage Radio: Improving the Hotpoint Bandmaster J35DE console radio by Maurie Findlay
  14. Book Store
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the September 2011 issue of Silicon Chip.

You can view 28 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 "Ultrasonic Water Tank Level Gauge":
  • Ultrasonic Water Tank Level Gauge PCB [04109111] (AUD $15.00)
  • PIC16F88-E/P programmed for the Ultrasonic Tank Level Gauge [0410911A.HEX] (Programmed Microcontroller, AUD $15.00)
  • Firmware (ASM and HEX) files for the Ultrasonic Water Tank Level Gauge [0410911A] (Software, Free)
  • Ultrasonic Water Tank Level Gauge PCB pattern (PDF download) [04109111] (Free)
Items relevant to "Improving The GPS-Based Frequency Reference":
  • PIC16F628A-I/P programmed for the GPS Frequency Reference [GPSFrqRfv3.HEX or GPSFrqRfv4.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F628A firmware for the GPS-Based Frequency Reference (v3 & v4) (Software, Free)
  • Updated PCB pattern for the GPS-Based Frequency Reference (PDF download) [04103073] (Free)
  • Display PCB pattern for the GPS-Based Frequency Reference (PDF download) [04103072] (Free)
  • GPS-based Frequency Reference front and rear panel artwork (PDF download) (Free)
  • GPS Frequency Reference Display PCB [04103072] (AUD $15.00)
  • Revised GPS-Based Frequency Reference PCB [04103073] (AUD $20.00)
  • PIC16F628A-I/P programmed for the GPS Frequency Reference [GPSFrqRfv3.HEX or GPSFrqRfv4.HEX] (Programmed Microcontroller, AUD $10.00)
  • Revised circuit diagram and PCB overlay for the GPS-Based Frequency Reference (Software, Free)
  • PIC16F628A firmware for the GPS-Based Frequency Reference (v3 & v4) (Software, Free)
  • Updated PCB pattern for the GPS-Based Frequency Reference (PDF download) [04103073] (Free)
Articles in this series:
  • GPS-Based Frequency Reference; Pt.1 (March 2007)
  • GPS-Based Frequency Reference; Pt.2 (April 2007)
  • GPS-Based Frequency Reference: Circuit Modifications (May 2007)
  • Improving The GPS-Based Frequency Reference (September 2011)
Items relevant to "High-Performance Stereo Headphone Amplifier, Pt.1":
  • Hifi Stereo Headphone Amplifier PCB [01309111] (AUD $17.50)
  • Red & White PCB-mounting RCA sockets (Component, AUD $4.00)
  • Hifi Stereo Headphone Amplifier PCB pattern (PDF download) [01309111] (Free)
  • Hifi Stereo Headphone Amplifier front & rear panel artwork (PDF download) (Free)
Articles in this series:
  • High-Performance Stereo Headphone Amplifier, Pt.1 (September 2011)
  • High-Performance Stereo Headphone Amplifier, Pt.2 (October 2011)
Items relevant to "Ultra-LD Mk.3 200W Amplifier Module, Pt.3":
  • Ultra-LD Mk3 200W Amplifier Module PCB [01107111] (AUD $15.00)
  • Ultra-LD Mk3/Mk4 Amplifier Power Supply PCB [01109111] (AUD $15.00)
  • Ultra-LD Mk.3 Power Supply PCB pattern (PDF download) [01109111] (Free)
Articles in this series:
  • Ultra-LD Mk.3 200W Amplifier Module (July 2011)
  • Ultra-LD Mk.3 200W Amplifier Module, Pt.2 (August 2011)
  • Ultra-LD Mk.3 200W Amplifier Module, Pt.3 (September 2011)
Items relevant to "Upgrading An Ultra-LD Mk.2 Amplifier To Mk.3 Standard":
  • Upgrade PCB for the Ultra-LD Mk2 Amplifier [01209111] (AUD $5.00)
  • Ultra-LD Mk.2 to Mk.3 Upgrade PCB pattern (PDF download) [01209111] (Free)

Purchase a printed copy of this issue for $10.00.

ULTRASONIC WATER TANK LEVEL GAUGE Do you have a tank to collect rainwater? Do you know how much water is in it? This ultrasonic tank level gauge fires an energy burst which bounces off the surface of the water – and then a microcontroller calculates how far down the tank water level is. Clever, eh! By JOHN CLARKE H aving your own rainwater tank is great – and very, very green! In fact, it’s mandatory in most areas these days. If you just want to water the garden or wash your car in times of water restrictions, it’s not that much of a drama if it runs out. But if you depend on it for your daily water supply, it is crucial to know how much water is in the tank at any time. This Ultrasonic Water Tank Gauge shows the water level using ten LEDs with a display resolution of up to 19 levels. We have published a number of wa30  Silicon Chip ter tank indicators over the years, the most recent being a design based on a pressure sensor, in the November & December 2007 and January 2008 issues. That design is still valid, especially as it also provides a 433MHz link to an LCD panel which could be mounted indoors – much easier to check the levels. This new design is a simple standalone unit which is somewhat easier to install and has the benefit that the sensors are not in contact with or submerged under the water. And the ultrasonic measurement method is also suitable for fluids other than water. The Ultrasonic Tank Level Gauge uses two waterproof ultrasonic sensors mounted in the air space above the water in the tank – one sensor transmits a burst of signal while the other receives it. The idea is that the water in the tank will reflect the signal and the time it takes for signal to be received, divided by two, accurately represents the distance between the water in the tank and the sensor. This is done measured by a microcontroller, which then displays the result on a LED dot or bar graph. It’s very simple in principle but there siliconchip.com.au is a complication in that the speed of sound in air varies with temperature – and you can get a big variation in the air temperature in typical water tanks. It can range from below zero up to 50°C or more. But never fear, the microcontroller compensates for that and computes a corrected reading. LED dot/bar graph display The Ultrasonic Tank Gauge shows the water level on a vertical LED dot/ bar graph display (selectable). In dot mode, 19 separate levels can be displayed, using only 10 LEDs. How’s that again? In fact, the dot display lights either one LED or two adjacent LEDs at a time, to show levels between each individual LED dot level. For the bar graph display, ten separate levels can be displayed. The Gauge is designed to suit many types of tanks, up to a height of 2.4m. It is powered from a 9V battery which should last a long time since current only flows for a brief time after the pushbutton switch is pressed to show the water level. It is housed in a waterproof box with a clear lid so that the display LEDs can be seen. Circuit As already noted, the circuit is based on a microcontroller, a PIC16F88-I/P (IC1). It generates the 40kHz signal to drive the ultrasonic transducer, computes the water level and drives the LED bar graph. As well, it monitors the air temperature inside the tank to provide compensation for the variations of the speed of sound at different temperatures. Transistors Q1 to Q6 are used to provide push-pull drive to step-up transformer T1, which drives the ul- Features • Non-contact sensing • Dot or Bar di splay • Easy calibra tion • Powered by 9V battery or D C plugpack • Suitable for water or other flu ids • Temperature compensation • Error indicatio ns trasonic transducer. Outputs RB0 and RB2 of IC1 are configured to provide complementary 40kHz signals to drive the transistors. When no signal is being delivered, RB0 and RB2 are low at 0V and transistors Q1, Q3, Q5 & Q6 will be off. Transistors Q2 and Q4 will each be held off via the 10k resistors between their base and emitter. When RB0 goes high to about +5V, Q3 & Q5 are switched on. Q5 turns on Q2 and this pulls one side of T’s primary winding to +8.7V. Meanwhile, the other side of the primary is pulled to 0V via Q3. After about 12.5s, RB0 goes low, switching off the transistors Q2, Q3 and Q5. RB2 now goes high to drive Q1 and Q6. Q6 switches on Q4. This reverses the current in the transformer primary and is maintained for about 12.5s, when RB2 goes low and the transistors switch off. The cycle repeats with outputs RB0 and RB3 producing bursts of 40kHz which last for 15 cycles or 375s. The transformer steps up the output primary to about 85V peakto-peak. Diodes D1-D4 clamp spike voltages induced by the transformer each time the primary current is switched off. They clamp the voltage to about 0.6V above the 8.7V supply and below the 0V supply rail to protect the driver transistors Q1-Q4 from over voltage. Ultrasonic signal is reflected from the water surface and is received by sensor 1, an identical ultrasonic transducer. Its signal is amplified by op amps IC2a and IC2b which are configured to provide a gain of about 67.7 each. Overall gain is therefore about 4,580 at 40kHz. Low frequency roll off is below 10.6kHz and high frequency roll off is above 159kHz. The amplifier itself also rolls off response above 100kHz. IC2b’s output is fed to a window comparator comprising IC3a & IC3b. Its sensitivity can be varied by trimpot VR1. It only produces an output when the signal from IC2b has sufficient amplitude to exceed its positive and negative thresholds. That only happens when there is ultrasonic signal being bounced off the surface of the water in the tank. When that happens, the output at pins 1 & 7 (common collector outputs joined to- The Water Level Gauge consists of the ultrasonic sensor assembly (above) which goes inside the tank and the processor/display (right) which is mounted outside the tank. siliconchip.com.au September 2011  31 S2 A +8.7V K REG1 7805 D5 1N5819 +9V 10 F 16V 0V +5V OUT IN GND 100 F 10k 10k <at> 25°C NTC THERMISTOR  TH1 100 4 100nF 3 +8.7V ULTRASONIC TRANSDUCER (RECEIVER) CON2 2 10 SENSOR1 + IC2: LM833 2 IC2a 5 1 8 IC2b 6 1 470 IC3: LM393 10pF 3 1.5k 10nF 10nF 1 IC3a 10k VR1 SENSITIVITY 10k 10pF 1.5k 8 2 100 7 100k 100k 150pF 10 F 3 4 1 10k 10 F 100nF 10k 10 F 6 5 100 7 IC3b 4 3.9k 470k 32  Silicon Chip 9 LED10 470 3.9k 10k 10k VR1 100 9V – 1 F IC1 PIC16F88-I/P MMC + 100 10 F 1k 10k 100nF 1k S2 Q5 REG1 7805 Q6 100 F 1k 1 1 1 9 0 1 4 0 1 10 F 10k D1 470k 10nF 100 1k 10k 4148 4148 100k 10pF IC2 LM833 IC3 LM393 3.9nF S1 10pF 10 F 1 10nF CON2 1.5k 6 D2 Q2 Q1 100 F 10 F 150pF SENSOR 1 8 TH1 7 SENSOR2 6 1.5k 5 10 4 100k 3 simply requires the S2 terminals to be shorted permanently. The battery supply is regulated down to 5V with REG1. It is protected 470 470 470 10k 10k LED1 2 470 470 470 470 A negative temperature coefficient (NTC) thermistor (TH1) is used to measure temperature. This has a resistance of 10k at 25°C and it falls with rising temperature. It is connected in series with a 10k resistor to the 5V supply. The resulting voltage across the thermistor is fed to the AN5 input of IC1. IC1 converts the thermistor voltage to a digital value, calculates the temperature and uses this to compensate for the variation in the speed of sound. The ten LEDs are driven from separate outputs of IC1 via 470 resistors. Switch S1 is used allow setting the minimum and maximum water levels, when calibrating the unit. Switch S2 is pressed when you want to read the water level. At other times the circuit is not powered and so the 9V battery should last for several years. 470 470 470 Temperature compensation Some users may wish to have a permanently-on display and power the circuit from a 9V DC plugpack instead of a battery. This is quite practical and 5819 gether) goes low, close to 0V. This low signal is filtered by a 3.9nF capacitor and fed to the RB3 input of IC1. Fig.1: the circuit mainly consists of an ultrasonic receiver and amplifier (left) plus a microprocessor, display and ultrasonic transmitter (right). 100nF ULTRASONIC WATER LEVEL GAUGE D5 SC 2011 T1 Q4 D3 Q3 4148 1k 4148 10k D4 CABLE RETE M K NAT RETAW CITIE N OSARTLU Fig.2: all components (with the obvious exception of the ultrasonic transducers and thermistor, which are in the tank) mount on one PCB. siliconchip.com.au +8.7V +5V 10k Q2 1 F 1k B MMC 14 Vdd 4 12 CAL 7 RB4 MCLR/RA5 AN5/RB6 RB5 RB1 RB7 S1 RA6 RA7 10 11 13 15 16 17 RA0 IC1 PIC16F88 18 -I/P RA1 RA2 RA3 RA4 1 2 3 K 470 K 470 470 K 470 470 K 470 470 K 470 470 K   9 RB3 3.9nF RB2 LED9 K   A LED8 LED7 K   A LED6 LED5 K   A LED4 LED3 K   A LED2 A 1k Q1 A B A C 10k Q4 B 1k K C Q3 B D3 A E A A A Q5 A T1 1k B 6 5 C 1k CON2 SENSOR2 + E 10k 1 ULTRASONIC TRANSDUCER (TRANSMITTER) BC547 Q6 10k 8 TRANSDUCERS 1 2 from reverse supply connection using series Schottky diode D5. This has a low forward voltage and is used in preference to a standard diode to A LEDS K D1–D4: 1N4148 K B BC547 1N5819 A K A maximise battery life and allows the battery to drop to around 7V before it requires replacement. The PCB, photographed here same size as the overlay at left. Between the two illustrations, assembly should be a breeze! siliconchip.com.au Q2, Q4: BC327 Q1, Q3: BC337 D1 E E D4 K C K 6 Vss 5 A A LED10 LED1 EMPTY RB0 D2 C FULL 470 100 F K E BC327, BC337, BC548 B E E 7805 GND IN C C GND OUT Construction The Ultrasonic Water Level Gauge is constructed on a PCB coded 04109111 and measuring 104 x 78.5mm. It is mounted in an IP65 ABS box with a clear lid, measuring 115 x 90 x 55mm. The PCB component overlay is shown in Fig.2. The PCB is shaped to the correct outline so it fits into the box. Check that the hole sizes are correct for each component to fit neatly. The mounting holes for the regulator and the corner mounting holes are 3mm in diameter. Install all the resistors first, checking their values with a digital multimeter. Then install the diodes, making sure they all go in with the correct polarity, followed by the PC stakes. These are located at the 9V supply, the switch (S2) terminals and for the transformer connections. IC1 is mounted on a DIP18 socket while IC2 and IC3 can be soldered into place or you can use sockets if you wish. September 2011  33 SHIELDED CABLE CONNECTS TO SENSOR1 PRIMARY 7 TURNS 9V BATTERY SNAP BATTERY SNAP LEAD RUNS THROUGH HOLES IN PCB T1 CABLE GLAND SECONDARY 34 TURNS + TO S2 6 4148 5819 Fig.3 (above): here’s how to wind the transformer. It’s quite simple – and you don’t need to worry about starts or finishes. CON2 1 – LEADS TO SENSORS & THERMISTOR Q2 Q1 4148 Fig.4 (right): and here’s how it goes into the waterproof ABS box. The corners of the PCB need to be shaped to fit. Take care to install all the transistor in their correct spots. Q1 & Q3 are BC337s; Q2 & Q4 are BC327s while Q5 & Q6 are BC547s. REG1 mounts horizontally and its regulator leads should be bent at right angles to insert into the holes in the PCB. The regulator tab is secured using an M3 x 10mm screw and nut. The capacitors can go in next, making sure that the electrolytics have the correct polarity. Note that the stripe down one side of the electrolytics indicates their negative connection. Install trimpot VR1 with its adjustment screw to the left. Then install S1 and the 6-way header. The LEDs should be mounted so that their tops are close to the underside of the lid, ie, with the top of each LED 25mm above the PCB. A strip of cardboard can be used to set the height of each LED using a strip 18.5mm high that slides between the LED leads. The cardboard is then removed after soldering each LED in place. Take care with the LED orientation. The anode has the longer lead. 1 1 2 0 WU CJ the photos. Before soldering the wire to the PC stakes, scrape the insulation from the wire ends using a hobby knife or emery paper. The transformer is held in place with a cable tie through the PCB and across the entire core. The waterproof case You will need to drill holes in the case for the switch (S2; if used) in the lid, for the IP65 cable gland at one end 4148 4148 RETE M K NAT RETAW CI N OSARTLU and for an M3 screw to hold the 9V battery holder. The cable gland is located so the securing nut is just below the lip of the box. We used a Nylon countersunk screw for the 9V battery holder and placed the hole so the clip was located in between the side flanges in the box and positioned over Q2 and Q4. The hole was countersunk and provides a watertight fit to the box when using a Winding the transformer Transformer T1 is wound using 0.5mm diameter enamelled copper wire on a ferrite toroid. Fig.3 shows the details: 7 turns on the primary and 34 turns on the secondary. Direction of the windings is not important. Install the transformer as shown in 34  Silicon Chip Compare this to the diagram above when completing the Tank Level Gauge. The label can be glued to the inside of the lid. If printed on paper, a window needs to be cut (as seen above) to allow the LEDs to shine through. siliconchip.com.au Nylon screw. If using a metal screw, silicone sealant should be used over the screw head to prevent rusting. Wiring Fig.4 shows the wiring details. Shielded cable is used for the wires to sensor 1 while figure-8 wire is used for the thermistor and transmitter, sensor 2. When wiring the shielded cable to sensor 1, it is important that the shield wire connects to the negative terminal (the shorter terminal) of this sensor. The reason for this is that the negative terminal connects to the body of the sensor, to shield the transducer. The longer terminal on the sensor connects to the central wire of the shielded cable. Wires from CON2 pass through the cable gland located on the opposite end of the case, while wires from the 9V battery clip are looped through 3mm holes in the PCB so that the wires are retained without causing stress on the connections to the 9V supply pins. Wires to the switch are made using short lengths of hookup wire. We used heatshrink tubing over all soldered wire joints to help prevent stress (and possible breakage) of the wire connection. As mentioned earlier, if you want a permanently-on display, simply short the S2 connections on the PCB with a length of wire soldered between the two PC stakes. Transducer assembly Fig.5 shows how the ultrasonic transmitter and receiver and the thermistor are mounted. The 158 x 95mm lid from a UB1 plastic box is used as a baseplate. We used an ABS lid in preference to metal or timber because it is does not ring at 40kHz with the transmitter burst signal. Any ringing at 40kHz causes the receiver to ring for a considerable period after the 40kHz burst and will prevent measuring at close range. Also essential to prevent signal coupling, both transmitter and receiver ultrasonic transducers are mounted within soft PVC housings and held in place with neutral cure silicone sealant. For the transducer housings, we used the shroud (ie, outer cover) from Arlec 10A mains plugs with the top 20mm cut off. Each housing is held within a 38mm (1½”) hole in the UB1 lid. siliconchip.com.au Parts List – Ultrasonic Tank Level Gauge 1 PCB coded 04109111, 104 x 78.5mm 1 IP65 box 115 x 90 x 55mm with a clear lid (Jaycar HB-6246 or equivalent) 2 Ultrasonic waterproof sensors (Jaycar AU-5550 or equivalent) (Sensor 1, Sensor 2) 1 U shaped 9V battery holder (Jaycar PH-9237, Altronics S 5050) 1 9V battery connector 1 9V 522 type Alkaline battery 1 SPST momentary 2-pin PCB switch (Jaycar SP-0611 or equivalent) (S1) 1 momentary pushbutton switch IP56 rated (Jaycar SP-0756 or equivalent) or IP67 rated (Jaycar SP-0656 or equivalent) (S2) 1 ferrite toroid 18 x 10 x 6mm AL=700, permeability 1500 1 IP65 cable gland PG7 sized for 3-6.5mm cable 1 6-way pin header socket with 6-way pin header 1 DIP18 IC socket 1 10k NTC thermistor 5 M3 x 10mm screws 1 M3 x 6mm Nylon countersunk (CSK) screw, with nut 2m single-core shielded cable 4m light duty figure-8 wire 1m 0.5mm enamelled copper (ENCU) winding wire 1 100mm length of light duty hookup wire 1 100mm cable tie 1 100mm length of 3mm heatshrink tubing 8 PC stakes Semiconductors 1 PIC16F88-I/P microcontroller programmed with 0410911A.hex (IC1) 1 LM833 dual op amp (IC2) 1 LM393 dual comparator (IC3) 1 7805T three terminal regulator (REG1) 4 1N4148 diodes (D1-D4) 1 1N5819 Schottky diode (D5) 2 BC337 NPN transistors (Q1,Q3) 2 BC327 PNP transistors (Q2,Q4) 2 BC547 NPN transistors (Q5,Q6) 10 3mm high intensity red LEDs (LED1-LED10) Capacitors 2 100F 16V PC electrolytic 4 10F 16V PC electrolytic 1 1F monolithic ceramic 2 100nF MKT polyester 2 10nF MKT polyester 1 3.9nF MKT polyester 1 150pF ceramic 2 10pF ceramic Resistors (0.25W, 1%) 1 470k 2 100k 8 10k 1 3.9k 5 1k 11 470 3 100 1 10 1 10k top adjust multiturn trimpot (VR1) 2 1.5k Ultrasonic transducer mounting hardware 1 UB1 ABS box lid 158 x 95mm 2 140 x 15 x 1mm aluminium as mounting brackets 4 M3 x 10 Nylon screws with M3 nylon nuts or tapped Nylon spacers 1 IP65 cable gland PG7 sized for 3-6.5mm cable 2 10A mains plugs with clear covers (eg Arlec Type 9331B) 2 rubber grommets suitable for a mounting hole of 9.5mm and cable 6mm 1 P-type Nylon cable clamp for 5mm cable 1 M4 x 10mm Nylon screw 1 M4 Nylon nut “Food grade” silicone sealant (eg neutral cure roof and guttering) September 2011  35 UB1 BOX LID (158 x 95mm) M4 SCREW AND NUT P CLAMP PG7 CABLE GLAND WITH NTC THERMISTOR INSIDE 38mm DIAMETER HOLES 110mm 20mm OF THE NARROW END OF EACH MAINS PLUG SLEEVE CUT OFF GROMMET GROMMET SILICONE SEALANT “PLUG” OUTER SLEEVE FROM ARLEC 10A MAINS PLUG SENSOR 1 (RECEIVER) SENSOR 2 (TRANSMITTER) NTC THERMISTOR INSIDE PG7 CABLE GLAND SILICONE SEALANT “PLUG” OUTER SLEEVE FROM ARLEC 10A MAINS PLUG Fig.5: detail of the ultrasonic transducer and thermistor mounting in the lid from a UB1 zippy box (the rest of the box is not used). It is important that both transducers are held parallel to the face of the “shroud” while the silicone sealant cures. We did this by placing a stack of seven 10c coins over each sensor, as shown in the photograph. These allowed us to align the top of the stack with the face. Make sure you don’t glue any of the coins to the sensors! For the sensor assembly mounting, drill out the two 38mm holes in the zippy box lid 110mm apart. A 1½” hole saw can be used for this. A 12mm (1/2”) hole is also drilled out for the PG7 gland in the centre of the lid while a 4mm (5/32”) hole is drilled for the P-clamp screw (as shown in Fig.5). Pass the thermistor wires through the top of the gland and strip back the insulation from both leads ready for soldering to the thermistor. The thermistor leads should be cut to 10mm before soldering to the wires. Slide a short length of 3mm heatshrink tubing over the wire ends and shrink down with a hot air gun. This tubing will prevent the thermistor leads shorting together. 36  Silicon Chip The thermistor is positioned within the cable gland and secured by tightening it. The thermistor can be sealed within the gland with neutral cure silicone sealant. Testing With IC1 out of its socket, apply power and check that there is 5V (4.85 to 5.15V) between the pins 5 and 14 of IC1’s socket. Check that IC2 and IC3 have about 8.7V between pins 4 and 8 when there is a 9V supply connected to the input. Check that the bias voltage between pin 7 and pin 4 of IC2 is between 3.3 and 3.8V. If all checks out OK, disconnect power and insert IC1 taking care to orient it correctly. Check that at least one LED lights when power is applied (ie, S2 is pushed). Adjust VR1 fully anticlockwise. This sets the sensitivity to detection of received ultrasonic signal at maximum and any noise or direct coupled signal will be detected. This will be indicated with the full LED lit. The default calibration is set for 331mm for the minimum measurement and 1m for the maximum measurement. Aim the transducer assembly square-on to a hard surface such as a timber floor, wall or window at a distance of about 1m. Adjust VR1 slowly clockwise until either the empty LED, or any lower LED lights. Moving the transducer assembly should now allow a measurement over 340mm to 1m with the LED display showing the range. Note that the measurement update is every 0.5s so movement of the sensors needs to be done slowly if all the 19 levels are to be indicated. You may need to wind VR1 further clockwise if the full LED sometimes lights with distances above 340mm. If VR1 is wound too far clockwise, the sensitivity is reduced so that reflected signal may never be detected. The display will cycle through lighting LED1 through to LED10 in sequence to indicate that no measurement of The transducer (sensor) mounting assembly, ready for installation inside the tank. The aluminium brackets suited our tank, yours may well be different! siliconchip.com.au While the silicone sealant was drying we used a stack of 10c coins on top of the sensors to check they were both absolutely level with the “lid” surface. You can just see the (blue) nose of the thermistor poking through the cable gland (centre of pic). distance is made. With a constant distance measurement the measurement update rate goes from once every 0.5s to once every 25s after running for 2 minutes. This is something to be aware of as you may initially think there is a fault if the display does not change with a changed distance. To have the display update return to the faster 0.5s update, switch off power for a few seconds. At power up, the display update returns to the faster rate. The faster rate is also restored if S1 is pressed for calibration. Dot or Bar? The initial default display is for the dot mode. This has 19 levels shown with the intermediate levels indicated with two adjacent LEDs lit. If you want a bar display (with only 10 levels) this can be selected by switching off power and pressing and holding switch S1. Power up again and the row of LEDs from LED1 to LED5 will light (indicating bar mode) while the switch is held pressed. When the switch is released, the measurements will show as a bar. This setting will remain unless you reset to the dot mode, using the same method with S1 pressed at power up. When returning to the dot mode, just LED6 on its own will light (indicating dot mode) while S1 is pressed and upon release of the switch, the dot mode will be displayed. Setting the bar mode is not recommended for battery operation since this draws extra power due to more LEDs being normally lit. The bar mode is recommended if night-time level measurements are required and when the power for the Water Tank Level Gauge is from a 9VDC plugpack. The bar mode readily shows the level at night whereas a dot display showing just one or two LEDs does siliconchip.com.au Temperature Compensation While the water in the tank tends to remain at a relatively constant temperature over a period, this is not the case for the air space within a water tank. With full sun on the tank, this temperature can rise to over 50 degrees C during the day only to plummet during the night. The variation in air temperature means that we need to correct for the change in the variation in the speed of sound, to maintain accurate water level readings. not show the actual position within the 10-LED bargraph as clearly as the bar mode. The speed of sound at 0°C is 331.3m/s while at 50°C it is 363.13m/s. These values are calculated from the formula: Calibration Speed of sound = 331.3 x Calibrating is done once the location of the ultrasonic transducer assembly has been decided (more details on the location for the sensors are in the installation section). Two calibrations need to be made, one for the distance between the transducer assembly and the water level of a full tank and the second the distance between the transducer assembly and the level of an empty tank. You do not need to empty or fill the tank to do these calibrations. You should be able to determine both the full and empty level of your tank knowing where the heights of the overflow (full) and outlet (empty) pipes are located. Measure the vertical distance between where the ultrasonic transducer assembly will be located to the bottom of the overflow pipe to obtain the full level. Then measure the vertical distance from the ultrasonic transducer assembly to the bottom of the outlet pipe to obtain the empty level. Calibration can be done using these distances and aiming the ultrasonic transducer assembly at a hard surface, such as a wall. It might be easier when doing this to short out the S2 switch so that the Water Tank Level Gauge runs without holding the switch closed. To calibrate the full level, aim the ultrasonic transducer assembly square on (perpendicular) to the wall at the full distance between the transducer assembly and the wall. Now press switch S1. Either the empty or full LED will flash. If the empty LED is flashing skip this paragraph and go to the next paragraph. If the full LED is flashing, keep the 1 + °C  273.15 Using that formula we calculate that over the range of 0 degrees C to 55 degrees C, the speed of sound will vary by 9.61%. That can cause a reading inaccuracy of two levels in the 19-level display. Note that we do not need to compensate for the change in the speed of sound due to variations in humidity or air pressure. Even with a change in humidity from zero to 100%, the speed of sound only changes by 1.2%, not enough to affect the reading of this tank level gauge. More information about the speed of sound is available in the Audio Engineering Society paper. Vol. 36, No. 4, April 1988 entitled “Environmental Effects on the Speed of Sound” by Dennis A Bohn, (Rane Corporation, Mukilteo, WA 98275 USA). This is available at w w w. r a n e . c o m / p d f / r a n e n o t e s / Enviromental%20Effects%20on%20 the%20Speed%20of%20Sound.pdf Information is also at http://en.wikipedia. org/wiki/Speed of sound switch closed and maintain the distance steady between the sensors and the wall. After eight flashes the LED will stay lit for about two seconds and then go out. The full calibration is now set. If the empty LED is flashing, release S1 and then repress it and wait till the full LED begins to flash. After eight flashes the LED will stay lit for about two seconds and then go out. The full calibration is now set. To calibrate the empty level, aim the ultrasonic transducer assembly square on (perpendicular) to the wall at the empty distance. Now press switch S1. Either the empty or full LED will flash on and off. September 2011  37 How we minimised the minimum distance measurement The ultrasonic transducers in this project can be used for transmitting, receiving or for both. So the same transducer could be used to transmit a 40kHz burst and then it could be used to receive the reflected signal. This would be ideal because it would save having a separate receive transducer. But there is a problem with using the transmit transducer to also receive the reflected signal. That is, the transducer continues to “ring” at 40kHz signal for about two milliseconds after any drive signal has ceased. (Even if you have a separate receiver it also “rings” if an ultrasonic transmitter is placed too close to it). With sound travelling at a speed of 340m/s the ultrasonic burst will have travelled 680mm in that 2ms period. This means that the If the full LED is flashing skip this and go to the next paragraph. If the empty LED is flashing, keep the switch closed and maintain the distance steady between the sensors and the wall. After eight flashes the LED will stay lit for about two seconds and then go out. The empty calibration is now set. If the full LED is flashing, release S1 and then repress it and wait till the empty LED begins to flash. After eight flashes the LED will stay lit for about two seconds and then go out. The empty calibration is now set. Note that an error will occur if the full and empty calibration distances are reversed. LED1 and LED10 will flash alternately to indicate this. The calibration can be redone using the correct full and empty distances. If the calibration appears to be stuck and continues showing an error after recalibration, you can return to the default calibration settings. Shorting the thermistor terminals at CON2 and pressing switch S1 returns the default settings. Both LED1 and LED10 will light for 1s as an acknowledgment of the default settings. The display will then operate between 331mm minimum and 1m maximum and have a dot display as minimum distance that can be measured is around 340mm. That’s hardly ideal since it means that you could not measure the water level in a tank that is full. We got around that problem by having good isolation between the transmitter and receiver transducers. Such isolation prevents the receiver from resonating after the transmitter is driven by a 40kHz burst. In that way the receive transducer is ready to receive reflected ultrasonic signal almost immediately the transmit burst is completed. This was achieved by mounting the transducers in separate soft PVC cups and spacing them 110mm apart to minimise direct signal reaching the receiver through the mounting surface. the default. Calibration can then be redone to set the minimum and maximum levels. Installation The ultrasonic transducer assembly preferably needs to be mounted inside the water tank within the top most airspace. There should be sufficient space for this in the dome shape of the tank roof. Steel tanks generally have a flat roof and will need a different mounting scheme. The transducer assembly should not be placed too close to the side of the tank or the receiver may detect signal reflected off the side. Our gauge, for example, needed the transducer assembly to be 110mm away from the side of the tank. Check that the Water Tank Level Gauge works without false sensing before making a permanent installation. The transducer assembly is mounted within the tank using suitable brackets attached to the roof of the tank. For a plastic tank you can attach the brackets to the tank roof with screws and nuts and holes drilled through the tank roof. For a concrete tank, glue the assembly to the roof with builders’ adhesive or neutral cure silicone sealant. “Food grade” sealant should be used where the tank is used for drinking water. Food grade silicone is usually neutral-cure plumbers roof and gutter sealant (eg, Zbond roof and gutter sealant, Kason food service Silicone Adhesive Sealant, Selleys Silicone 401 etc). Check the label to see if it is suitable for this purpose. Ensure that the transducer faces are positioned parallel to the water surface otherwise the reception of reflected ultrasonic signal may be too weak for reliable detection. The advantage of using aluminium brackets is that these can be carefully bent to align the sensors correctly with the water surface. Note that a water tank may not be located on a perfectly horizontal ground base, so do not use the tank as a guide to positioning the sensors parallel to the water surface. A spirit level can be used to check sensor placement to ensure they are horizontal and parallel to the water surface. If wires from the transducer assembly are to exit from the tank, use a cable gland or via a silicone covered hole. It is important to ensure the tank is kept mosquito proof. The Water Tank Level Gauge can be installed directly onto the outside of the tank or onto a nearby wall. Specifications Power....................................7.5 to 9VDC at 18 to 24mA max for dot mode, 80mA max for bar mode Display..................................Dot or Bar with 19 levels in dot mode, 10 levels for bar mode Reading update....................Initially every 500ms increasing to every 25s after 2 minutes. Returns to 500ms update with a display value change, no signal received and during calibration Temp compensation............Speed of sound compensated between 0-70°C Measurement distance........Minimum 40mm; Maximum 2.4m Ultrasonic burst...................15 cycles at 40kHz (375s) Transmitter drive.................85Vpk-pk with a 9V supply 38  Silicon Chip siliconchip.com.au Note that the box has four mounting points that are outside the box’s sealed section but can only be accessed by removing the lid of the box. Mounting can be on brackets or directly onto a wall or the tank. It is not recommended to drill holes anywhere in a concrete tank or it may crack. Plastic and steel tanks can have mounting holes drilled in the top cover but not on the sides where the water sits. Plastic tanks generally have lifting attachment points and you can drill into these sections or use the existing lifting hole for mounting. To mount the Water Tank Level Gauge to the side of the tank, secure two lengths of 25mm x 25mm hardwood spaced apart to match the box’s mounting holes. The timber can be secured to the tank sides with builders adhesive or silicone sealant. The box is then attached to the timber batons with suitable wood screws. Make sure the Neoprene seal is inserted around the lid before the lid is attached to the box base. Steel tanks Steel tanks are not so easily accommodated because they usually have a flat roof and allow the water to fill up to this roof leaving no room to mount the sensors within the tank. Additionally, the metal tank is liable to resonate at the 40kHz ultrasonic frequency causing the receiving sensor to ring and prevent the 40mm minimum distance measurement from working. You could have the transducer assembly mounted within the inlet strainer. Alternatively, the PVC shrouds, which encapsulate the ultrasonic sensors, could be inserted into holes in the tank roof. The transducer assembly should not be directly mounted onto a steel tank; use rubber grommets or dobs of silicone sealant at each corner. This provides a compliant mounting which prevents the steel roof from resonating at 40kHz. If the transducer assembly is mounted above the tank it could be covered using the box that came with the UBI box lid. The wires could exit through a cable gland located in the side of the box. Some silicone sealant around the seal will prevent any water entering the box although rainwater onto the assembly will not cause a problem so long as it can escape out the bottom of the box. Another method for using the Water Tank Level Gauge with steel tanks is to use a different mounting method for the ultrasonic sensors where they are located onto a smaller diameter “plate” that is installed within a length of 90mm PVC pipe that protrudes by 331mm above the tank. The default minimum calibration (full tank level) of 331mm is used and the maximum distance (empty tank level) calibration can be changed from the 1m setting to be up to 2.4m to suit the tank depth. This depth includes the 331mm extension above the tank. Note that the default full tank level must be used rather than setting a new 331mm full tank level because the default setting ignores all received signal for the first 331mm. A recalibrated 331mm distance will have the metering looking for reflected sounds after a 40mm distance and will cause false readings when reflected signal comes directly back from the pipe. So if the full tank level has been recalibrated, then the default values must first be restored. Shorting the thermistor connections and pressing S1 for a few seconds does that. Using the default full tank level means reflected sounds from the sides of the PVC tubing will be ignored. Only the empty tank level should be recalibrated to suit the tank depth. SC Quality ISO 9001 siliconchip.com.au September 2011  39