Silicon ChipAn Automotive Thermometer - October 2001 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Australia is still the lucky country
  4. Feature: Run Rabbit, Run by Silicon Chip
  5. Project: A Video Microscope From Scrounged Parts by Peter Rosenthal & Ross Tester
  6. Subscriptions
  7. Project: Build Your Own MP3 Jukebox; Pt.2 by Peter Smith
  8. Project: Super-Sensitive Body Detector by Thomas Scarborough
  9. Order Form
  10. Project: An Automotive Thermometer by John Clarke
  11. Project: Programming Adapter For Atmel Microcontrollers by Peter Smith
  12. Feature: Building Your Own PC - One Man's Approach by Stephen Davies
  13. Product Showcase
  14. Weblink
  15. Vintage Radio: Beginner's radios: as they were by Rodney Champness
  16. Book Store
  17. Back Issues
  18. Market Centre
  19. Advertising Index
  20. Outer Back Cover

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

You can view 30 of the 96 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 "Build Your Own MP3 Jukebox; Pt.2":
  • Software for the "Build Your Own MP3 Jukebox" articles (Free)
  • AT90S2313 firmware and source code for the PC IR Interface & LCD Display (Software, Free)
  • IR Remote Receiver & LCD Display PCB pattern (PDF download) [07109011] (Free)
Articles in this series:
  • Build Your Own MP3 Jukebox; Pt.1 (September 2001)
  • Build Your Own MP3 Jukebox; Pt.1 (September 2001)
  • Build Your Own MP3 Jukebox; Pt.2 (October 2001)
  • Build Your Own MP3 Jukebox; Pt.2 (October 2001)
  • Computer Tips (January 2002)
  • Computer Tips (January 2002)
  • Computer Tips (April 2002)
  • Computer Tips (April 2002)
Items relevant to "Super-Sensitive Body Detector":
  • Super-Sensitive Body Detector PCB pattern (PDF download) [03110011] (Free)
  • Panel artwork for the Super-Sensitive Body Detector (PDF download) (Free)
Items relevant to "An Automotive Thermometer":
  • PIC16F84(A)-04/P programmed for the Automotive Thermometer [TEMP.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F84 firmware and source code for the Automotive Thermometer [TEMP.HEX] (Software, Free)
  • Automotive Thermometer PCB patterns (PDF download) [05110011/2] (Free)
  • Panel artwork for the Automotive Thermometer (PDF download) (Free)
Items relevant to "Programming Adapter For Atmel Microcontrollers":
  • Programming Adaptor for Atmel Microcontrollers PCB pattern (PDF download) [07110011] (Free)
This easy-to-build thermometer can monitor temperatures both inside and outside your car. It’s particularly useful for checking just how well your car’s air conditioner is coping under the hot Australian sun. By JOHN CLARKE Automotive Thermometer Keep tabs on in-car temperatures A S WE ALL KNOW, the temperature inside a car can rise dramatically during the summer months, particularly if the car is left out in the midday sun. In fact, inside temperatures can quickly reach 60°C or more. This is because a car makes a good glasshouse that collects and traps solar radiation. Because it can monitor both inside and outside temper­atures, this thermometer will quickly show you how 58  Silicon Chip much hotter it is inside the cabin than outside. And by temporarily position­­ ing the inside sensor near the air-conditioner vents, you can quickly check on the effectiveness of the air-conditioning. Conversely, during the winter months, our new thermometer will reveal how cold it is outside and just how effective the heater is in warming the interior. Outside temperatures of 0°C and below can indicate possible icy conditions on the road. But perhaps the main use of an in-car thermometer is to provide valuable feedback when it comes to setting air-condition­ing or heater controls. Generally, you will want to maintain a constant temperature of about 23°C with plenty of fresh air. Obviously, a comfortable environment contributes greatly to road safety. A hot and stuffy cabin greatly increases driver irrita­tion and can also lead to www.siliconchip.com.au drowsiness. Accidents due to drivers falling asleep at the wheel occur all too frequently. Main features Many aftermarket thermometers use liquid crystal displays (LCDs) but most of these are not suitable for automotive use. While the sensors may be rated to read temperatures up to say 100°C, the LCD itself may not be rated for the high cabin temper­atures reached in a car during summer. After a hot day, you can be left with a thermometer which just shows a black display and this effect isn’t reversible. So don’t be tempted to use these thermometers in a car unless they are specifically rated for high ambient temperatures. Our design gets around this problem by using LED displays. These are unaffected by high temperatures and give a better display at night. And by using LED displays, we’ve been able to design an instrument that matches the appearance of our previous car projects – ie, the Speed Alarm (Nov. 99); the Digital Volt­meter (Feb. 2000); the Digital Tacho (April 2000); and the Fuel Mixture Display (Sept. 2000). Naturally, we’ve included an automatic dimming feature, so that the display brightness varies according to the ambient light. That way, the displays are nice and bright for daytime viewing but are dimmed at night so that they don’t become too distracting. Our previous instruments were all based on a PIC16F84 microcontroller which kept the parts count (and the cost) down. That’s right, you’ve guess­ ed it! – our new Automotive Thermometer is also based on a PIC16F84 microcontroller. It’s the bits that “hang off” the microcontroller and the software embedded into it that makes each design perform its intended role. Our new Automotive Thermometer is also quite small and is very accurate because it uses precision sensors (LM335) to moni­ tor the inside and outside temperatures. These sensors are typi­cally accurate to within 1°C over the entire -40°C to 125°C temp­ era­ture range. It’s also a easy to use, which is the way it should be for a car project. On power up, the display initially shows three dashes while the unit is making the temperature measure­ments. The www.siliconchip.com.au The assembly fits neatly into the smallest available plastic utility box and matches several previous car projects based on PIC microcontrollers. display then shows either the inside or outside tem­perature, depending on the last selection made. The single pushbutton switch on the front panel lets you toggle between the internal and external temperature readings. How do you know which is which? Simple – the righthand decimal point lights when the external temperature is being displayed. Calibration – it’s a snack A feature of the design is that the unit is self-calibrating. First, both sensors are cooled to 0°C in a solution, as described later. The unit is then switched on with the Display switch held down. When the switch is released, the display will show “CAL” and the thermometer then automatically determines the calibration required for each temperature sensor. That’s it – you don’t have to do Main Features • Measures inside and outside air temperatures • • -40°C to +125°C range • • • Measurement accuracy better than 1°C Resolution of 1°C Easy calibration Display dimming anything else! Once calibration is complete, the display shows the current temperature – ie, 0°C for both sensors. If the sensors are then removed from the 0°C solution, the display then shows the individ­ual temperatures measured by each sensor. Circuit details OK, let’s now take a look at the circuit – see Fig.1. It’s dominated by IC1 which is the PIC16F84 microcontroller. It ac­cepts inputs from the two temperature sensors (SENS1 & SENS2) via a signal conditioning circuit (IC2) and drives the 7-segment LED displays (DISP1-DISP3). Most of the complexity of this circuit is hidden inside the PIC microcontroller and its internal program. That’s the beauty of using a microcontroller – we can easily do complicated things with a very low parts count. Temperature sensors SENS1 and SENS2 respectively monitor the internal and external temperatures. These devices are each supplied with current from the nominal 12V supply via a 15kΩ resistor. Assuming a supply of 13.8V (normal in most cars), this gives about 700µA of current through each device at 25°C. As the temperature rises, the voltage across the sensor rises in a linear fashion at 10mV/°C. However, the current through the sensors remains reasonaOctober 2001  59 60  Silicon Chip www.siliconchip.com.au Fig.1 (left): the PIC microcontroller (IC1) processes the input signals from the temperature sensors and drives the 7-segment LED displays. Q6, IC2 and REF1 work with IC1 to provide the A/D conversion, while LDR1 and Q5 automatically vary the display brightness, so that they don’t appear too bright at night. bly constant. For example, at 125°C, the nominal 3.98V across the sensor reduces the sensor current to 650µA, while at -40°C, the 2.33V across the sensor increases the current to 760µA. So the current through the sensors varies by just 110µA over a 165°C temperature range. This effectively prevents any change in sensor voltage (and thus false readings) due to current changes. Also, the self-heating of the sensors due to power dissipa­tion is as low as practicable but this effect does contribute to inaccuracies in the temperature reading. However, to a large extent, the self-heating effect is cancelled out when the thermom­ eter unit is calibrated. IC1’s RA1 output is used to select between the two sensors. It works like this: when RA1 is high, pin 5 of CMOS switch IC3a is pulled high and so IC3a is closed. As a result, the voltage across SENS1 is fed through to pin 3 of IC3a and applied to pin 2 (inverting) of op amp IC2 via a 10kΩ resistor. At the same time, CMOS switch IC3c also closes and this pulls pin 13 of IC3b to ground. This means that IC3b is open and so SENS2 is effectively out of circuit. Conversely, SENS2 is selected by taking RA1 low. When that happens, IC3a & IC3c both open and pin 13 of IC3b is pulled high via a 10kΩ resistor connected to the +5V rail. This closes IC3b and so the voltage across SENS2 is now applied to pin 2 of IC2 via the 10kΩ resistor. So when RA1 is high, SENS1 is selected and when RA1 is low, SENS2 is selected. The 10kΩ resistor and .01µF capacitor on pin 2 of IC2 filter out any glitches due to the operation of the CMOS switches. A/D converter Op amp IC2 works in conjunction with the RA0 output of IC1 to form an A/D (analog-to-digital) converter. This converts the analog voltage applied to www.siliconchip.com.au Parts List 1 display PC board, code 05110011, 79 x 50mm 1 processor PC board, code 05110012, 79 x 50mm 1 front panel label, 80 x 53mm 1 plastic case utility case, 83 x 54 x 30mm 1 red Perspex or acrylic sheet, 18 x 46mm 1 4MHz parallel resonant crystal (X1) 1 LDR (light resistance <1kΩ, dark resistance >1MΩ) (LDR1) 4 PC stakes 1 100kΩ horizontal trimpot (VR1) 1 10kΩ horizontal trimpot (VR2) 1 5mm x 20mm piece of 0.5mm brass or 1mm aluminium for heatsink 2 7-way pin head launchers 1 2-way pin head launcher 1 3-way pin head launcher 2 DIP-14 low-cost IC sockets with wiper contacts (cut for 2 x 7-way single in line socket, 1 x 2-way single in line socket and 1 x 3-way SIL socket) 1 PC-mount click action push-on switch (S1) 1 9mm tapped brass spacer 1 6mm untapped spacer 2 6mm tapped spacers 2 M3 x 6mm countersunk screws or Nylon cheesehead 2 M3 plastic washers 1mm thick or 1 M3 plastic washer 2mm thick 2 M3 x 15mm brass screws 1 2m length of red automotive wire 1 2m length of green automotive wire 1 4m length of shielded cable 1 500mm length of 0.8mm tinned copper wire pin 2 of IC2 into an 11-bit digital value which is then used to drive the LED displays. Let’s see how this works. IC2 is an LM627 precision op amp and is wired here as a comparator. This device has the very low input offset and input current specifications necessary to obtain the 2.44mV resolution required for an 11-bit A/D converter. By contrast, standard op amps with 10mV offset voltages cannot be used here because they would introduce Semiconductors 1 PIC16F84P microprocessor programmed with TEMP.HEX pro­gram (IC1) 1 LM627N op amp (IC2) 1 4066 quad CMOS switch (IC3) 1 7805 1A 3-terminal regulator (REG1) 2 LM335Z temperature sensors (SENS1,SENS2) 1 LM336Z-5 5V reference (REF1) (Altronics Z 0558) 3 BC328 PNP transistors (Q1Q3) 1 BC548 NPN transistor (Q4) 1 BC338 NPN transistors (Q6) 1 BD139 NPN transistor (Q5) 3 HDSP5301, BS-A536RW common anode 7-segment LED displays (DISP1-DISP3) 1 16V 1W zener diode (ZD1) 1 3.3V 1W zener diode (ZD2) 6 1N914, 1N4148 diodes (D1-D6) Capacitors 1 47µF16VW PC electrolytic 1 22µF 35VW PC electrolytic 2 10µF 16VW PC electrolytic 1 0.1µF MKT polyester 1 .01µF MKT polyester 2 18pF ceramic Resistors (0.25W 1%) 1 270kΩ 1 1kΩ 2 15kΩ 3 680Ω 4 10kΩ 1 470Ω 3 4.7kΩ 8 150Ω 1 3.3kΩ 1 10Ω 1W Miscellaneous Automotive connectors, heatshrink tubing or 5mm ID metal tubing, cable ties, etc. significant errors during conversion. In operation, the A/D converter relies on IC1 to ensure that the voltage applied to pin 3 of IC2 matches the sensor voltage applied to pin 2. It does this by producing a pulse width modulated signal (PWM) at its RA0 output which is then stabilised and filtered to produce a steady voltage. For example, if the RA0 output has a 50% duty cycle, the filtered voltage October 2001  61 Fig.2: here are the assembly details for the two PC boards. Take care to ensure that you don’t get the transistors mixed up. a “successive approxima­ tion” technique. This all takes place inside the PIC micro­controller, with the duty cycle for each successive approximation controlled by the software. Following the conversion, the binary number is stored in an 11-bit register in IC1 and this must be converted to a decimal value before it can be shown on the 3-digit LED display. Once again, this takes place inside the PIC microcontroller. Note that the A/D conversion of the temperature sensor outputs is done on a continuous basis – ie, SENS1 is measured, then SENS2 is measured and then the process is repeated. The actual conversion time is a fairly slow, taking around seven seconds, but since the sensors are also slow responding, a fast conversion isn’t important. The only time it does become noticeable is at power up, since the display will show dashes until the first conversion is completed. That’s hardly a problem. To digress briefly, note that IC2 is powered from a 12V supply which means that its output can switch higher than the 5V supply to IC1. For this reason, pin 6 of IC2 drives RB0 of IC1 via a 3.3kΩ current limiting resistor to prevent damage to the internal protection diodes on pin 6 of IC1. These internal protection diodes clamp the signal input to RB0 to a maximum of 5.6V. Driving the displays will be 50% of the peak square-wave voltage. The accuracy depends on the precision of the PWM signal (set by a timer based on a crystal oscillator) and on the peak voltage remaining constant with temperature. An LM336Z-5 3-terminal reference (REF1) is used to set the peak voltage to this required precision. This device is supplied with current from the +12V rail via a 4.7kΩ resistor and is adjusted using trimpot VR2 to produce a fixed 5V output. Diodes D3-D6 are wired in series with VR1 (two on either side) and provide temperature compensation for this adjustment. As shown on Fig.1, RA0 drives the base of transistor Q6. Each time RA0 goes high, Q6 turns and so the voltage across REF1 drops to a few millivolts. Conversely, when RA0 goes low, Q6 is off and so the REF1 voltage (+5V) is present on Q6’s collector. As a result, a PWM signal appears 62  Silicon Chip at Q6’s collector which has a precise +5V amplitude. This PWM signal is filtered using a 10kΩ resistor and a 22µF capacitor to produce a steady DC voltage which is applied to pin 3 of IC2. In greater detail, the PWM signal from RA0 has a fixed frequency of 1960Hz but operates with a duty cycle ranging from about 40% (ie, high for 40% of the time) to 80%. If the duty cycle is 50%, then the filtered voltage on pin 3 of IC2 is 50% of 5V, or 2.5V. Other voltages are obtained by using different duty cycles. The A/D conversion process uses Table 1: Capacitor Codes     Value IEC Code EIA Code 0.1µF   100n   104 .01µF   10n  103 18pF   18p   18 The 7-segment display data from IC1 appears at outputs RB1-RB7. These directly drive the display segments via 150Ω current-limiting resistors, while the RA2 & RA3 outputs drive the indi­vidual displays in multiplex fashion via switching transistors Q1Q4. As shown, the corresponding display segments are all tied together, while the common anode terminals are driven by the switching transistors. In this case, the RA2 & RA3 outputs drive transistors Q1 & Q2 directly via 680Ω base resistors to control displays DISP1 & DISP2. What happens is that IC1 switches its RA2 & RA3 lines low in sequence to control the switching transistors. For example, when RA2 goes low, transistor Q1 turns on and applies power to the common anode connection of DISP1. Any low outputs on RB1-RB7 will thus light the corresponding segwww.siliconchip.com.au ments of that display. After this display has been lit for a short time, RA2 is switched high and DISP1 turns off. The 7-segment display data on RB1-RB7 is then updated, after which RA3 is switched low to drive Q2 and display DISP2. RA3 is then switched high a short time later to turn DISP2 off and give DISP3 its turn. Display DISP3 is driven whenever RA2 and RA3 are both high at the same time. It works like this: if RA2 and RA3 are both high, diode D1 is reverse biased and so Q4 turns on due to base current flowing through the associated 1kΩ resistor and zener diode ZD2. Q4 in turn drives Q3 via a 680Ω base resistor and so Q3 applies power to DISP3. DISP3 is subsequently switched off when either RA2 or RA3 goes low. For example, if RA2 goes low, there is no base drive to Q4 and so both Q4 and Q3 are off (note: when Q4 turns off, the 470Ω resistor pulls the base of Q3 high). On the other hand, if RA3 goes low, D1 becomes forward biased and pulls ZD2’s cathode low. This turns Q4 off and so Q3 also turns off, as before. The 3.3kΩ resistor on Q4’s base is there to ensure it turns fully off. If this were not done, DISP3 would show a faint repli­ca of the lit segments on DISP2. Display dimming Light dependent resistor LDR1, transistor Q5 and trimpot VR1 control the display dimming. In bright light, LDR1’s resist­ ance is low and thus Q5’s base voltage is pulled high and is clamped via D2 to about 5.6V. Q5 is wired as an emitter follower. The display board (top) carries the three 7-segment LED displays and the LDR. It plugs directly into the header sockets on the microcontroller board (above), thus eliminating messy external wiring connections between the two. This means that its emitter will be at +5V and so the LED displays will operate at full brightness. In low light conditions, the LDR resistance increases so that it now forms a voltage divider with VR1. Table 2: Resistor Colour Codes            No. 1 2 4 3 1 1 3 1 8 1 www.siliconchip.com.au Value 270kΩ 15kΩ 10kΩ 4.7kΩ 3.3kΩ 1kΩ 680Ω 470Ω 150Ω 10Ω 4-Band Code (1%) red violet yellow brown brown green orange brown brown black orange brown yellow violet red brown orange orange red brown brown black red brown blue grey brown brown yellow violet brown brown brown green brown brown brown black black brown 5-Band Code (1%) red violet black orange brown brown green black red brown brown black black red brown yellow violet black brown brown orange orange black brown brown brown black black brown brown blue grey black black brown yellow violet black black brown brown green black black brown brown black black gold brown October 2001  63 Fig.3: this diagram shows how the two boards are stacked together and secured using screws, nuts and brass spacers. Notice that the righthand spacer is 9mm long, while the lefthand one is just 6mm long. two capacitors are there to provide the correct loading for the crystal, to ensure that the oscillator starts reliably. The crystal frequency is divided down internally to produce separate clock signals for the microcontroller operation and for display multiplexing. Power Power for the circuit is derived from the vehicle’s battery via the ignition switch. A 10Ω 1W resistor and 22µF capacitor decouple this 12V supply, while zener diode ZD1 provides tran­ sient protection – ie, it limits any spike voltage to 16V – and also provides reverse polarity protection. The decoupled supply rail is then fed to REG1 which provides a regulated +5V output and this in turn is decoupled using 47µF and 0.1µF capacitors. The +5V rail is used to power IC1 & IC3, while the decou­pled 12V rail supplies the rest of the circuitry, including IC2 the sensors and the displays. Construction Fig.4: here’s how to wire up the two temperature sensors. Note that the internal sensor plugs into a matching 3-way header socket on the microcontroller board. This lowers the base voltage applied to Q5, which reduces the voltage on it emitter (and hence the supply to the displays) accordingly. As a result, the displays operate with reduced brightness. VR1 is used to set the minimum display brightness. Display switch The display switch S1 performs two functions: (1) it tog­gles the readings between the internal and external sensors; and (2) it’s used to initiate the calibration procedure (by holding it down during power-up). This switch is connected directly to the RA4 pin of IC1. This input is normally held high by a 10kΩ resistor but is pulled low each time S1 is pressed. This is detected by IC1 and pro­cessed by the software accordingly. The RA4 pin also acts as an output which drives the right­hand decimal point for DISP1 when the external 64  Silicon Chip temperature is being displayed. In practice, if this decimal point is to be lit, it is only necessary for the RA4 line to be low when DISP1 is selected. If either the DISP2 and DISP3 displays are lit, RA4 is free to monitor S1. This is all done under software control, with the decimal point in DISP1 only turning on when SENS2 (the external sensor) is selected. The display is also blanked while the display switch is pressed, so that the decimal point does not light due to the low on RA4. This blanking is achieved by setting all the RB1-RB7 outputs high on the display and by ensuring that RA1 remains high so that Q1 remains off. Clock signals Clock signals for IC1 are provided by an internal oscilla­tor which operates in conjunction with 4MHz crystal X1 and two 18pF capacitors. The You don’t have to understand how the software works or do any programming to build this project. Instead, it’s all pro­grammed into the PIC chip. You just buy the preprogrammed chip and “plug” it in and it all works. All the parts for the Automotive Thermometer are mounted on two PC boards: a display board coded 05110011 and a processor board coded 05110012. Both boards measure 79 x 50mm and are stacked together using pin headers and cut-down IC sockets. These pin headers and modified IC sockets make all the necessary connections between the two PC boards. The only wiring you have to run involves the external power supply connections and the sensor leads. Fig.2 shows the assembly details for the two PC boards. As usual, check your PC boards for defects and undrilled holes before installing any of the parts. In addition, the corners of each board must be shaped as shown in Fig.2, so that they clear the mounting pillars in the case. You can start the assembly by building the processor board. Install the wire links first, then install the resistors using Table 2 as a guide to the colour codes. It’s also a good idea to measure each resistor using a digital www.siliconchip.com.au multimeter, as some of the colours can be difficult to read. Note that the seven 150Ω resistors at top right are mounted end-on, as are the two 4.7kΩ resistors and the 3.3kΩ resistor. The horizontal trimpot (VR2) can be installed next, fol­lowed by a socket to accept IC1 (don’t install the IC yet). This done, install IC2 & IC3, taking care to ensure that both are correctly oriented. Next, install zener diodes ZD1 & ZD2, diodes D1-D6, tran­sistor Q6 and the voltage reference (REF1). Regulator REG1 can then go in. This is installed with its metal tab flat against the PC board and its leads bent at rightangles to pass through their respective mounting holes. Make sure that the hole in the metal tab lines up correctly with its matching hole on the PC board. The capacitors can now all be installed as shown, making sure that the electrolytics are mounted with the correct polari­ ty. Note that the electrolytics must all be mounted with their leads bent at right angles, so that they lie parallel with the PC board (see photo). In particular, note that two of these capaci­tors lie over the regulator’s leads. Crystal X1 also mounts horizontally on the PC board. It is secured by soldering a short length of tinned copper wire between its metal case and a PC pad immediately to the right of D6. Finally, you can complete the processor board assembly by fitting PC stakes to the external wiring points and installing the in-line sockets. These in-line sockets are cut down from 14-pin IC sockets using either a sharp knife or a fine-toothed hack­saw. You will need to cut down two 7-way sockets, a 3-way socket and a 2-way socket. Clean up the rough edges with a file before installing them on the PC board. Note that the 3-way strip mounts sideways in the SENS1 position, which means that you have to bend its leads at right angles before installing it on the board. A dob of superglue can be used to hold it in place. Display board assembly Now for the display board assembly. Install the six wire links and the resistors first, then install the three 7-segment LED displays. This done, install the PC stakes, transistors, diodes www.siliconchip.com.au Fig.5: here are the full-size etching patterns for the two PC boards (top) and the front panel artwork. and trimpot VR1. Take care with the transistors: Q1-Q3 are all BC328s, Q4 is a BC548 and Q6 is a BC338. Transistor Q5 mounts with its leads bent over so that its metal side faces upwards – see photo. It must be fitted with a small heatsink to assist in its cooling. We used a piece of 5 x 20mm brass bent over in the middle to form a spring-loaded clip. This was then slid over the body of the transistor. Switch S1 can now be installed, making sure that the flat side is oriented as shown. This done, install the electrolytic capacitor and the LDR. The LDR should be mounted so that its top face is about 3mm above the displays. Make sure that its leads do not short against Q5’s clip-on heatsink. Finally, complete the display board assembly by fitting the pin headers. These are installed from the copper side of the board with their leads just protruding above the top surface. You will need a fine-tipped soldering iron to solder them to the copper pads on the PC board. It will also be necessary to slide the plastic spacers along the leads to allow room for soldering, after October 2001  65 inside edges can be used to make sure the window stays in place. Testing Mount the pin headers on the back of the display board as shown here. This photo show how the two boards are married together, with the pin headers on the display board plugging directly into the sockets on the microcontroller board – see Fig.3. which the spacers can be pushed back down again. Final assembly Work can now begin on the plastic case. First, remove the integral side pillars with a sharp chisel and slide the processor PC board in place. Check that it doesn’t foul the corner pillars. Next, drill the two mounting holes in the base of the case for the PC board – one aligned with the metal tab hole of the regulator and the other to the above left of IC3. These holes should be countersunk on the outside of the case to suit the screws. A hole is also required in one side of the case directly opposite the SENS1 socket. This hole is drilled 9mm up from the base of the case. You will also have to drill holes in the base of the case for the two power leads and the SENS2 lead (these should be drilled opposite their respective mounting points). 66  Silicon Chip The display board can now be plugged into the processor board and the assembly secured as shown in Fig.3. Be sure to use a plastic washer in the location shown. Once it’s all together, check that none of the leads on the display PC board interfere with any of the parts on the processor PC board. Some of the pigtails on the display PC board may have to be trimmed to avoid this. The front panel artwork can now be used as a template for marking out and drilling the front panel. You will need to drill holes to make the display cutout, plus holes for the pushbutton switch and the LDR. The main display cutout is made by first drilling a series of small holes around the inside perimeter, then knocking out the centre piece and filing the job to a smooth finish. Make the cutout so that the red Perspex (or acrylic) window is a tight fit. A few spots of superglue along the It is best to check the power supply before installing the microcontroller (IC1) in its socket. To do this, unplug the display board and connect automotive cable to the +12V and GND inputs. Apply power and use a multimet­er to check that there is +5V on pins 4 & 14 of IC1’s socket, using the metal tab of REG1 for the negative (ground) connection. If this is OK, connect the positive lead of the multimeter to the collector of Q6 (or the anode of D3) and adjust VR2 for a reading of 5V. This sets REF1 correctly so that it will deliver 5V when Q6 is off and have minimal drift with tempera­ture. Once this has been done, disconnect the power and install IC1, making sure it is oriented correctly. Now plug the display board back in and reapply power – the display should light and should show three dashes (---) for about six seconds. It should then show the current (uncalibrated) temperature. You can test the dimming feature by holding your finger over the LDR. Adjust VR1 until the display dims to the correct level. The final adjustment will have to be done when it’s dark, so that you can correctly set the minimum brightness level. Sensors SENS1 is used to measure the in-cabin temperature but this sensor is actually mounted outside the case. This is necessary because the temperature inside the case will be higher than the ambient air temperature. Fig.4 shows the wiring arrangements for both the internal and external sensors. As shown, SENS1 is attached to the thermom­eter box using a 3-way pin header and a length of shielded cable. This plug must be inserted with the correct polarity so it’s a good idea to mark the polarity with a marking pen or dab of paint. The external sensor is connected to a length of single-core shielded cable and the wires directly soldered to the PC board. Both sensors should be coated with a smear of silicone sealant (neutral cure; eg, Selley’s Roof & Gutter Sealant) and either covered with heatshrink tubing or a short length of 5mm-diameter metal tubing. We cut www.siliconchip.com.au up a discarded car radio telescopic antenna to obtain the requisite diameter metal tubing. Note that the circuit is designed to operate with both sensors connected. If one is disconnected or connected with reverse polarity, the display will show strange values. If the thermometer is to be operated with only one sensor, it will be necessary to connect the two positive (+) input termi­ nals for each sensor together on the PC board using a short length of hookup wire. In addition, one of the 15kΩ resistors supplying the sensor current should be removed from the circuit. Alternatively, you can simply short out the terminal inputs for that particular sensor. Calibration All that remains now is the calibration. The first step is to cool the two sensors to 0°C. This is done using a mixture of fresh water and ice (made from fresh water). Add the ice to a bowl of fresh water and stir this continuously until the ice appears to have stopped melting. If you run out of ice in the solution, place some more into the water and continue stirring. When you have a mixture of both ice and water and the ice has stopped melting, the water temperature is at 0°C. The internal and external thermo­ meter sensors can now be immersed in the mixture and allowed to sit there for at least a minute while the water is stirred. Now switch the thermometer off for a few seconds and switch it on again while holding the Dis­play switch down. Release the switch and the display will show “CAL” to indicate that it is measuring the output voltage from each sensor. When the calibration is complete, the display will show 0°C. Press the Display switch to check that the second sensor has been calibrated. It should show either “CAL”, indicating that it is still being calibrated, or 0°C if the calibration has been com­pleted. Note that depending on the particular calibration number, the reading could jump to show -1°C on occasions. This is because the internal calculation to convert to °C does not consid­ er results after the decimal point. This does not mean that the calibration has not been successful and nor does it alter the accuracy of www.siliconchip.com.au The LM335 Temperature Sensor: How It Works The output from the LM335 temperature sensor is linear from -273.15°C to 125°C, with a slope that is typically 10mV/°C. At 0°C, the output voltage is typically 10mV x 273.15 or 2.73V. However, the slope variation can range from 9.8mV/°C to 10.2mV/°C so we need some way of correcting for this variation. Normally, these sensors are used with a trimpot connected to their adjust terminal, to allow the sensor slope to be adjust­ ed to exactly 10mV/°C. In this case, however, we don’t adjust the slope of the sensor but instead carry out a calculation to derive the temperature reading. We can calculate the temperature from a given sensor if we know its slope characteristic. Looking at the output curve, shows that the output is 0V at the -273.15°C point. This temperature is often termed “absolute zero” since it is the coldest temperature possible. This temperature is also called 0K, where “K” denotes the Kelvin temperature scale (note that this is not called de­grees K but simply K or Kelvin). At 0°C, the output can range from 2.67V to 2.79V, depending on the sensor output slope characteristic. A simple formula allows us to derive the measured temperature from the voltage output of the sensor if we know the output voltage at a particu­ lar known temperature. temperature readings. However, if the readings appear to remain fixed at -1°C while the sensors are in the ice water, it means that the sensors were not given sufficient time to cool to 0°C before calibration took place and so it will be necessary to repeat the procedure. Note too that the calibration procedure must be done again if one of the sensors is replaced. Installation Be sure to use automotive cable and connectors to connect the unit to the ignition switch wiring and to the chassis. The +12V supply is derived via the ignition switch and a suitable In our case, we use 0°C as the known temperature and the formula becomes: Temperature = (273.15 x Vout/Vout <at> 0°C) -273.15. Once we determine the output voltage for the sensor at 0°C, we can then calculate the temperature for any other output voltage. For our calculations, we ignore the value after the decimal point since it has negligible effect on the result. The analog output from the temperature sensor is converted into a digital word using an 11-bit A/D converter. This provides a value ranging from 0-2048 for a 0-5V analog input. The sensor output typically ranges from 2.33V - 3.98V for temperature readings from -40°C to +125°C. During the calibration procedure, the A/D converter meas­ ures the sensor output and stores this value as the value to use for Vout <at> 0°C. It does this for both sensors, with separate storage for each. The default setting before calibration is 2.73V at 0°C. This corresponds to an A/D value of 2048 x 2.73/5V or 1118. Once the calibration number has been measured for each sensor, the values are stored and then the thermometer runs in its normal mode. In operation, the temperature sensor output voltages are converted to digital values and the calculation made to derive the temperature. This value is then shown on the LED display. connection can usually be made at the fusebox. The ground connection can be made by connecting a lead to the chassis via a solder eyelet and a self-tapping screw. The external sensor can be installed in any convenient location outside the vehicle and behind the front bump­er bar is a good place. This affords a reasonable degree of protection and keeps it away from engine heat. The internal sensor should be fitted in a location which is unaffected by direct sunlight and also away from any air vents. It’s up to you where you fit it – under the glovebox or somewhere else under the dashboard is as good a SC location as any. October 2001  67