Silicon ChipLab-Standard 16-Bit Digital Potentiometer - July 2010 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Today's TV - brilliant pictures, mediocre sound
  4. Feature: Electronics Goes Boating by Kevin Poulter
  5. Feature: 3DTV: From Stadium To Living Room by Nicholas Vinen
  6. Feature: Programming PIC Microcontrollers: How It’s Done by Mauro Grassi
  7. Project: An Intelligent 12V Fan Controller by Geoff Graham
  8. PICAXE Project Development System by Jeff Monegal
  9. Project: Lab-Standard 16-Bit Digital Potentiometer by Jim Rowe
  10. Project: Dual-Tracking ±19V Power Supply, Pt.2 by Nicholas Vinen
  11. Vintage Radio: Reflex receivers: why they were necessary by Rodney Champness
  12. Advertising Index
  13. Outer Back Cover

This is only a preview of the July 2010 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 "An Intelligent 12V Fan Controller":
  • Intelligent 12V Fan Controller PCB [18107101] (AUD $5.00)
  • PIC18F2550-I/SP programmed for Intelligent 12V Fan Controller [1810710A.HEX] (Programmed Microcontroller, AUD $20.00)
  • Firmware and PC software plus source code for the Intelligent 12V Fan Controller [1810710A.HEX] (Free)
  • Intelligent 12V Fan Controller PCB pattern (PDF download) [18107101] (Free)
Items relevant to "PICAXE Project Development System":
  • BASIC source code for the PICAXE Project Development System (Software, Free)
Items relevant to "Lab-Standard 16-Bit Digital Potentiometer":
  • Lab-Standard 16-Bit Digital Potentiometer PCB [04107101] (AUD $20.00)
  • PIC16F877A-I/P programmed for the 16-Bit Digital Potentiometer [0410710A.HEX] (Programmed Microcontroller, AUD $20.00)
  • PIC16F877A firmware and source code for the Lab-standard 16-bit Digital Potentiometer [0410710A.HEX] (Software, Free)
  • Lab-Standard 16-bit Digital Potentiometer PCB pattern (PDF download) [04107101] (Free)
  • Lab-Standard 16-bit Digital Potentiometer front panel artwork/drilling template (PDF download) (Free)
Items relevant to "Dual-Tracking ±19V Power Supply, Pt.2":
  • Dual Tracking ±0-19V Power Supply PCB [04206101] (AUD $15.00)
  • Dual Tracking ±0-19V Power Supply front panel PCB [04206102] (AUD $5.00)
  • Dual Tracking ±0-19V Bench Supply PCB patterns (PDF download) [04206101/2/3] (Free)
  • Dual Tracking ±0-19V Supply panel artwork/drilling templates (mains-powered) (PDF download) (Free)
  • Dual Tracking ±0-19V Supply panel artwork/drilling templates (plugpack-powered) (PDF download) (Free)
Articles in this series:
  • Dual-Tracking ±19V Power Supply, Pt.1 (June 2010)
  • Dual-Tracking ±19V Power Supply, Pt.1 (June 2010)
  • Dual-Tracking ±19V Power Supply, Pt.2 (July 2010)
  • Dual-Tracking ±19V Power Supply, Pt.2 (July 2010)

Purchase a printed copy of this issue for $10.00.

By JIM ROWE Lab-standard 16-Bit Digital Potentiometer No, this is not some kind of fancy digital volume control for hifi systems. Instead, it’s a low-cost digital programmable voltage divider. It’s used to provide an accurate adjustable output from a precision voltage reference for meter calibration and other tasks. L et’s say you’ve built the Precision DC Voltage Reference described in the May 2009 issue of SILICON CHIP. This provides an accurate 10.000V DC voltage source which is fine for calibrating the higher voltage ranges of a DMM or other meter. But how can you use it for calibrating the lower ranges? That’s where you need to use a voltage divider, to break down the 10.000V to a suitable lower level – like 4.999V, 1.999V or even 199.9mV. In principle, a voltage divider is very straightforward but in this situsiliconchip.com.au ation there’s a special requirement: the divider’s division ratio should be programmable with a high degree of accuracy, if the accuracy of its output is not to be degraded significantly from that of the 10.000V reference. So that’s the idea behind this new Digital Potentiometer; it’s designed to provide a voltage divider with an accurately programmable division ratio over a 10,000:1 range. It will allow you to take the 10.000V reference and derive any lower voltage you wish – from 0.001V (1mV) up to 9.999V – with a resolution of 1mV and an absolute accuracy of ±0.2mV up to 200mV, ±0.5mV up to 1.000V and ±1mV up to 9.999V. These figures translate to a relative accuracy of ±0.4% at 10mV, ±0.02% at 100mV, ±0.05% at 1V and ±0.01% at 9.9V. This order of accuracy should be quite suitable for calibrating the majority of handheld DMMs and similar instruments. By the way, because the potentiometer itself uses purely resistive elements, it can be used as an accurate July 2010  65 Parts List 1 PC board, code 04107101, 184 x 99.5mm 1 UB2 jiffy box, 197 x 113 x 63mm 1 16 x 2 LCD module, Altronics Z-7013 or similar (with LED backlighting) 1 16-key (4 x 4) keypad 16 SPDT mini DIL relay, 6V coil 1 SPDT mini toggle switch (S1) 1 4MHz crystal (X1) 1 2.5mm concentric power connector, PC board mtg (CON1) 1 40-pin 0.6-inch DIL IC socket 1 16-way SIL socket strip 1 16-way SIL pin strip 1 8-way SIL socket strip 1 8-way SIL pin strip (long) 4 M3 x 25mm tapped spacers 2 M3 x 15mm tapped Nylon spacers 13 M3 x 6mm screws, pan head 1 M3 nut 4 No.5 x 8mm self-tapping screws 3 binding post/banana jacks, red 3 binding post/banana jacks, black 1 400mm length of tinned copper wire, 0.7mm diameter 1 10kΩ mini horizontal trimpot (VR1) Semiconductors 1 PIC16F877A-I/P microcontroller programmed with 0410710A.hex 1 LM7805 +5V regulator (REG1) 16 PN100 NPN transistors (Q1-Q16) 17 1N4004 1A diodes (D1-D17) Capacitors 1 470µF 16V RB electrolytic 1 220µF 16V RB electrolytic 2 100nF monolithic 1 100nF MKT metallised polyester 2 27pF disc ceramic Resistors (0.25W, 1%) 4 10kΩ 1 2.2kΩ 1 8.2kΩ 16 47Ω 16 4.7kΩ 1 22Ω Precision Resistors 17 3.000kΩ 0.1% metal film (Farnell 1634061) 15 1.500kΩ 0.1% metal film (Farnell 9500901 or 1751462; RS 165-933) 66  Silicon Chip divider for low-frequency AC (eg, below 20kHz) as well as DC. input) can be programmed very simply in binary fashion. S1 has a binary weighting of 1, S2 a weighting of 2, S3 a weighting of 4 and so on all the way up to S16, which has a weighting of 32,768. If we connect this 16-step divider to an input voltage of 10.000V, it is therefore capable of providing an output voltage adjustable in steps of 0.15259mV (10,000/65,535) from 0V to 10.000V, simply by setting switches S1-S16 to the correct binary combination. So the simple switched resistive ladder arrangement of Fig.1 is quite capable of being used as a precision voltage divider as it stands. But in this simple binary form it would be difficult to program; you’d have to work out the binary number corresponding to the particular output voltage you wanted, in order to set the 16 switches. Instead, we have used a microcontroller to drive a set of 16 SPDT relays in place of the switches, as shown in the block diagram of Fig.2. This allows you to simply key in the output voltage you want (in decimal) via a keypad, with an LCD readout to show you what you’re doing. The micro calculates the correct binary number to program the divider’s 16 relays to achieve this output voltage – or as close as it can get. How it works Resolution & accuracy In order to achieve this level of accuracy and to make the Digital Potentiometer easily programmable, we have adopted the same “binary switched resistive ladder” configuration used in many linear DACs (digital-to-analog converters). We have used a 16-step ladder because this allows the division ratio to be adjusted in 65,536 discrete steps. That’s because 216 = 65,536, meaning that 16 binary switches have the potential for 65,536 different combinations (0-65,535 inclusive). The basic form of the 16-step ladder is shown in Fig.1, although only five of the 16 switches are shown, ie, the two lowest switches S1 & S2 and the three uppermost switches S14-S16. The intermediate switches S3-S13 have been omitted for clarity. This configuration may not look like a conventional voltage divider but it does the same job and has the advantage that the binary “weighting” of each switch increases by a factor of two, as you move up from S1 to S2, S2 to S3 and so on up to S16. So the divider’s output (as a proportion of the Before we look at the full circuit of the Digital Potentiometer, we should clarify a few points regarding its accuracy. There are two main factors which determine the unit’s accuracy: (1) the resolution of the binary ladder as a whole by virtue of its having 16 steps and (2) the accuracy of the binary weighting of each of those individual steps as a function of the tolerance of the “R” and “2R” resistors in the ladder. As mentioned, the basic resolution of a 16-bit binary divider is 1/65,535, so in this situation where it is dividing down from an input voltage of 10.000V, the resolution becomes 0.15259mV per binary step. This means that even if all the resistors in the ladder network have values of exactly R and 2R as required, we will only be able to program any particular output voltage to an accuracy of ±0.076295mV (ie, 0.15259/2). Let’s say that we want to program the divider for an output voltage of 0.001V or 1mV. If we do the maths, 1.000/0.15259 = 6.5535. Since we can INPUT HIGH 1 S16 2R S15 2R S14 2R OUTPUT HIGH 0 R 1 0 R 1 0 (S3 – S13 AND ASSOCIATED RESISTORS NOT SHOWN) 1 S2 2R 0 R 1 S1 2R 0 INPUT LOW 2R OUTPUT LOW Fig.1: the basic form of the 16-step R/2R ladder network (switches S3-S13 omitted for clarity). siliconchip.com.au INPUT HIGH +12V 1 (RLY16) 2R (RLY15) 2R (RLY14) 2R OUTPUT HIGH 0 RLY16 R 1 RELAY DRIVERS 0 RLY15 16x2 LCD READOUT R 1 0 RLY14 MICRO CONTROLLER (IC1) (RLY3 – 13 AND THEIR DRIVERS NOT SHOWN) 1 PROGRAMMING BUTTONS (RLY2) 2R (RLY1) 2R 0 RLY2 R 1 0 RLY1 INPUT LOW 2R OUTPUT LOW Fig.2: block diagram of the 16-Bit Digital Potentiometer. The desired output voltage is entered via a keypad and the microcontroller calculates the correct binary number to drive the 16 relays in the R/2R ladder network. only program the divider in binary integers, this means that we can only program it for the binary equivalent of either 6 or 7. So our actual output voltage will be either 0.91554mV (6 x 0.15259) or 1.068mV (7 x 0.152159). This “resolution error” varies depending on the output voltage setting. For example, if you want to program the divider for a voltage of 3.052V, the binary equivalent of 20,001 will give an actual output voltage of 3.05195V – only 0.05mV low. On the other hand, if you want an output voltage of 1.000V, the binary equivalent of 6553 will give an output voltage of 999.92mV (0.08mV low) while the equivalent of 6554 will give an output voltage of 1000.075mV (0.075mV high). So the actual size and polarity of the divider’s resolution error does vary but should always be within the range of ±0.0763mV. We could only get a lower figure for this error factor by using additional binary divider steps (it will halve for each additional step). As you can see though, the errors caused by the divider’s 16-bit resolution are really not all that great. In terms of relative error, even a 1mV output voltage will only be either high or low by about 7% – and this relative error drops rapidly as the output siliconchip.com.au voltage rises. The relative error for a 50mV output voltage is only +0.099%, while that for a 100mV output voltage is -0.053%. In practical terms, the second error factor is more serious, because the operation of this type of binary switched voltage divider does depend on the resistors in each divider step having an exact 2:1 ratio (except for the very bottom step, which must have an exact 2:2 ratio, as shown). This means that this source of error will be zero only with “perfect” exact-value resistors in all steps. However, with “real world” resistors, the errors tend to rise significantly, because they accumulate as you move up the ladder. What does this mean in practice? Well, in our first prototype, we used Main Features & Specifications Features • A lab-type voltage divider, suitable for dividing down the output of a voltage reference to an accurately known lower voltage. It can be used for either DC or AC. • Desired output voltage is programmed directly in decimal via a keypad, with an LCD readout. The divider output can be disabled or re-enabled at any time, simply by pressing an “Output Toggle” key. Specifications Output resolution: input voltage/65,535 or 0.15259mV steps when Vin = 10.000V. Typical absolute accuracy: see plot in Fig.3. Better than ±1mV over full range, better than ±0.2mV up to 250mV output (Vin = 10.000V). Input resistance: 813Ω minimum Output resistance: 1.5kΩ (note: do not connect to a load of less than 1.5MΩ in order to obtain the specified accuracy) Power drain: approximately 4.5W maximum (50-360mA from an external 12V DC supply) July 2010  67 +3 ABSOLUTE ERROR in MILLIVOLTS +2 +1 0 –1 –2 –3 1mV Note: in some conditions of the ladder network switching, the load presented to the Precision DC Voltage Reference will be less than the specified 1kΩ (thus exceeding the specified 10mA maximum output current). In practice, this regulation curve shows that this condition is not critical. 2mV 5mV 10mV 20mV 50mV 100mV 200mV 500mV 1.000V 2.000V 5.000V 10.000V OUTPUT SETTING (Vin = 10.000V) Fig.3: this graph plots the absolute error as a function of the output voltage. The absolute error is better than ±0.2mV up to 250mV output, ±0.5mV up to 1V output and ±1mV from 1V up to 10V output. standard close-tolerance 1% metal film resistors (3.0kΩ and 1.5kΩ) in the ladder, to see what sort of accuracy this would result in (1% resistor values meant that the 2:1 ratio in each of the upper steps, together with the 1:1 ratio for the lowest step, would be only accurate to within ±2%). However, when we measured the performance of this version, the accuracy was quite poor – particularly for output voltages above 200mV. In fact, the absolute error rose to +1mV at 300mV output, then to +2mV at 1V output, +5mV at 2.500V output, -2.5mV at 2.600V output and 5.1V output, +2.4mV at 7.6V output and -5.5mV at 7.8V output. Not good! Clearly the cumulative effect of the resistor tolerance error was wreaking havoc at the higher outputs. In view of this poor result, we realised that in order to get acceptable performance, it would be necessary to use ladder resistors with significantly closer tolerance than 1%. The resistors we finally settled on were of 0.1% tolerance, which resulted in the absolute error curve shown in Fig.3. This shows that the absolute error is better than ±0.2mV up to 250mV output, ±0.5mV up to 1V output and ±1mV from 1V up to 10V output. To get any better accuracy than this, you would need to use ladder resistors with closer tolerance again or else go through the laborious work of selecting a set of 0.1% resistors with closer toler68  Silicon Chip ance from a large stock. That assumes that you have a least one resistor of much higher tolerance to use as your standard. By the way, even 0.1% tolerance resistors can pose a problem because although the value of 1.500kΩ is available in this tolerance, 3.000kΩ resistors are harder to find. As a result, you may have to use 3.010kΩ resistors, padding each one down to 3.000kΩ (±0.1%) by connecting a 910kΩ 1% resistor in parallel with it. We should also warn you that 0.1% tolerance metal film resistors are much more expensive than the standard 1% tolerance types: just over $1.00 each, compared to about 6 cents each. So you’ll end up paying about $37.00 for the 32 resistors used in the Digital Potentiometer’s ladder network. Circuit description Now let’s look at the full circuit of the Digital Potentiometer – see Fig.4. It’s not very different from the block diagram of Fig.2 – we’ve just added the fine details. The ladder divider is at upper right, with the binary switching done by relays RLY1-RLY16 as before. The relays are mini DIL types and they’re all operated from a +11.4V supply rail, with a 47Ω resistor in series with each one to limit the coil current. Transistors Q1-Q16 are the relay drivers, while diodes D1-D16 are there to protect the transistors from back-EMF damage when each relay is turned off. Each relay driver transistor is controlled by one of the RB0-7 or RD0-7 port outputs of microcontroller IC1 (PIC16F877A-I/P). The 4.7kΩ base series resistors minimise the loading on the IC’s port output lines, while still ensuring that driver transistors Q1Q16 are switched on and off reliably. The rest of the circuit is straightforward and is involved mainly with IC1 scanning the 4 x 4 input keypad (at lower left) to detect user input, as well as providing feedback to the user via the 16 x 2 LCD module at lower right. We have used a 4 x 4 keypad to provide an economical array of 16 input keys – including the 10 keys used to input the numerals 0-9. The additional six keys are used to perform the following functions: A key: tells the micro that you want to key in a new output voltage. B key: a destructive backspace, for correcting input errors. C key: toggles the Digital Potentiometer’s output on/off. D key: tells the micro that you want to key in a new input reference voltage in place of the default 10.000V. * key: acts as the decimal point input key. # key: acts as the Enter key, to conclude an input entry. The display on the LCD module shows the unit’s status in each operating mode. When you are keying siliconchip.com.au POT OUTPUTS POT INPUT + + – RLY16 3.000k 0.1% ON/OFF + +11.4V S1 K D16 OUT IN D17 470 µF 16V 1.500k 0.1% A GND A 12V DC INPUT K REG1 7805 220 µF 47Ω CON1 C Q16 PN100 B E +5V 100nF 100nF 2.2k 11 1 Vdd Vdd MCLR RB7 RB6 100nF RB5 RB4 RB3 RB2 10 8.2k 24 23 14 X1 4.0MHz RB1 RE2 RB0 RC5 RD7 RD6 RD5 RC4 RD4 OSC2 RD3 RD2 13 27pF RD1 OSC1 27pF RLY2 RD0 8x 4.7k 40 +11.4V K 39 D2 38 A 37 36 47Ω 35 34 33 C Q2 PN100 B 29 28 RLY1 27 22 4 5 16-KEY PAD 1 2 4 5 3 A 6 6 B 7 7 8 9 C 8 * 0 # D 9 3.000k 0.1% K 20 D1 19 – A 10k 10k 10k – 47Ω C Q1 PN100 E RA0 RA1 +5V RA2 RC6 RA4 RA5 RC7 RE0 RC3 RC2 RE1 RC1 12 Vss RC0 25 26 18 4 6 15 2 Vdd ABL 16x2 LCD MODULE CONTRAST RS EN D4 D5 D6 D7 D3 D2 D1 D0 14 13 12 11 10 9 8 7 GND 1 R/W LCD CONTRAST VR1 10k 3 KBL 16 5 17 16 15 31 7805 PN100 SC 2010 NOTE: 3.000k 0.1% RESISTORS MAY BE REPLACED WITH 3.010k 0.1% AND 910k 1% IN PARALLEL 22Ω RA3 Vss 10k 3.000k 0.1% +11.4V 21 B 3 1.500k 0.1% E 8x 4.7k 30 IC1 PIC16F877A 2 3.000k 0.1% 32 16-BIT DIGITAL POTENTIOMETER D1-D17: 1N4004 A K B C E GND IN GND OUT Fig.4: the circuit uses 3.000kΩ & 1.500kΩ 0.1% precision resistors in the R/2R ladder network. The PIC micro calculates the binary value from the entered data and drives relays RLY1-RLY16 via NPN transistors Q1-Q16. siliconchip.com.au July 2010  69 OUTPUT 2– 910k* 3.000k OUTPUT 1.500k 2+ 1.500k 910k* 3.000k 910k* 3.000k 1.500k 910k* 3.000k 1.500k 910k* 3.000k 1.500k 910k* 3.000k 1.500k 910k* 3.000k 1– 910k* 3.000k 1.500k 910k* 3.000k 1.500k OUTPUT 1+ 1.500k 910k* 3.000k 1.500k 910k* 3.000k 1.500k 910k* 3.000k 1.500k 910k* 3.000k 1.500k OUTPUT – 1.500k 910k* 3.000k 1.500k 910k* 3.000k INPUT + 910k* 3.000k INPUT 910k* 3.000k COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON COMMON RLY16 RLY15 RLY14 RLY13 RLY12 RLY11 RLY10 RLY9 RLY8 RLY7 RLY6 RLY5 RLY4 RLY3 RLY2 RLY1 COIL COIL COIL COIL COIL COIL COIL COIL COIL COIL COIL COIL COIL COIL COIL NO NC NO NC NO NC NO NC NO NC NO 4004 4004 4004 4004 4004 4004 D8 D7 D6 D5 D4 D3 D2 PN100 PN100 PN100 PN100 Q4 47Ω PN100 Q3 4.7k Q5 PN100 4.7k 47Ω Q6 PN100 4.7k Q7 PN100 4.7k Q8 PN100 4.7k Q9 4.7k Q10 4.7k BQ11 Q12 PN100 47Ω 4004 D9 47Ω 4004 47Ω 4004 D10 47Ω 4004 D11 PN100 COIL NC NO NC 4004 D1 Q2 PN100 47Ω NC 47Ω NO 4.7k NC D12 6 Q13 NO 47Ω 5 Q14 NC 47Ω 4Q15 NO 4.7k PN100 A 4004 NC 47Ω PN100 NO 4.7k PN100 3 NC 47Ω 4004 D13 47Ω 4004 NO 4.7k NC D14 4.7k 47Ω 2 NO 4004 4.7k 4.7k Q16 NC D15 D16 PN100 NO 47Ω 1 4004 NC 4.7k NO 4.7k NC 47Ω NO Q1 4x4 KEYPAD (ATTACHED TO FRONT PANEL) 8 9 C ALTRONICS 16X2 LCD MODULE RETE M OIT NET OP LATI GID TI B- 6 1 Z-7013 (B/L) 220 µF 0 1 10k 10k D # 100nF 1 8 KEYPAD CONNECTIONS REG1 7805 14 13 12 11 10 9 8 7 6 5 4 3 2 1 16 15 X1 4MHz 10k 10k 470 µF POWER 4004 8.2k IC1 PIC16F877A C1 C2 C3 C4 Ra Rb Rc Rd 100nF * 100nF + 2.2k 7 27pF 27pF VR1 10k D17 0102 © 10170140 CON1 S1 12V IN 22Ω LCD CONTRAST * NOTE: 910k 1% RESISTORS ARE ONLY REQUIRED IF 3.010k 0.1% RESISTORS ARE USED INSTEAD OF 3.000k 0.1% RESISTORS Fig.5: install the parts on the PC board as shown on this overlay diagram and the photo at right. Be sure to use 0.1% tolerance resistors as specified in the R/2R ladder network (ie, for the 1.500kΩ and 3.000kΩ types) – see parts list. in a new output (or input) voltage, it displays the digits as you enter them. In the normal mode, where the divider is set to provide a specific output voltage, it displays that voltage along with the assumed input voltage. Or if you have toggled the divider’s output off, it displays “OFF” to remind you that there is currently zero output. All the control circuitry operates from an external 12V DC supply, which can be a 12V battery or plugpack. The maximum current drawn is about 360mA when all 16 relays are switched on (ie, when the output voltage is 10.000V). This drops to around 50mA when the relays are all switched off (output OFF). The relays are operated directly from the incoming 12V via series diode D17 which is used for polarity protection. The rest of the circuit (IC1 and the LCD module) operates from a regulated +5V rail, derived from the 11.4V line via a 7805 3-terminal regulator (REG1). The only other items to mention are 4MHz crystal X1 (used for IC1’s clock oscillator), trimpot VR1 which sets the contrast of the LCD module and the 22Ω resistor connecting to pin 15 of the LCD module. The latter sets the current for the LCD module’s LED backlighting. easy to build, with almost all components mounted directly on a single PC board coded 04107101 and measuring 184 x 99.5mm. The board assembly fits snugly inside a standard UB2-size jiffy box measuring 197 x 113 x 63mm. It mounts on the rear of the box lid on four M3 x 25mm tapped spacers. The only parts not mounted directly on the PC board are power switch S1, Table 2: Capacitor Codes Value µF Value IEC Code EIA Code 100nF 0.1µF 100n 104 27pF NA 27p 27 Construction The Digital Potentiometer is fairly Table 1: Resistor Colour Codes o o o o o o o o o   No.    4    1 16 17    1 15 16    1 70  Silicon Chip Value 10kΩ 8.2kΩ 4.7kΩ 3.000kΩ 2.2kΩ 1.500kΩ 47Ω 22Ω 4-Band Code (1%) brown black orange brown grey red red brown yellow violet red brown not applicable red red red brown not applicable yellow violet black brown red red black brown 5-Band Code (1%) brown black black red brown grey red black brown brown yellow violet black brown brown not applicable red red black brown brown not applicable yellow violet black gold brown red red black gold brown siliconchip.com.au The LCD module is mounted on two M3 x 15mm tapped Nylon spacers and plugs directly into a 16way SIL socket (see text for mounting details). the 4 x 4 keypad and the six binding posts. These all mount on the box lid which forms the front panel. As you can see from the photos, the panel layout is a little unusual. The keypad, LCD readout and power switch are all in the lower part of the front panel, while the input and output terminals are along the top. This has been done for two reasons, one being to make the completed unit easier to “drive” when placed on a workbench or table. The other reason is that this PC board layout turned out to be the easiest and most logical. It allows the 16 mini relays and their drivers to fit in a row across the board between the ladder resistors at the top and the microcontroller circuitry at the bottom. So while it may seem unusual, you’ll find it’s easy to build and quite intuitive to use. Fig.5 shows the parts layout on the PC board. Begin by fitting the 20 wire links, 16 of which are arranged in a horizontal row just below the 16 relays. Note that the link under relay RLY16 at far left is “U” shaped as it must loop around the relay to complete the earth return line for the relay contacts. The remaining four links are in the lower half of the board, in the controller section. Two of these are under the LCD module while a third horizontal link is located just below siliconchip.com.au the microcontroller. The final link runs vertically at centre right, just above the 470µF electrolytic capacitor. Once the links are in place, fit all the “ordinary” (ie, 1%) resistors to the board. These include the 910kΩ resistors at the top if you need them plus all the resistors below the relays. The 17 1N4004 diodes can now be installed, 16 of which run in a horizontal row just below the relays. These diodes must all have their leads bent down quite close to their bodies, so take care when bending them. Take care also with their orientation – they go in with the cathode bands to the left. The last diode (D17) goes in just behind DC input socket CON1 at lower right. Note that its leads are bent down somewhat further away from the body and it’s fitted with its cathode towards the top of the board. VR1 (the LCD contrast adjust trimpot) is next, followed by the capacitors. The keypad is fitted to the back of the case lid as shown here. In addition, you have to fit extension wires to the binding post terminals and to switch S1 before mounting the PC board. July 2010  71 The PC board is secured to the back of the lid on four M3 x 25mm tapped spacers, with the keypad’s SIL pin header plugging into a matching socket. Ignore the resistors shown on the copper side of the PC board – this is a prototype and all resistors go on the top of the board in the final version. You can purchase 3.010kΩ resistors from either Farnell (Cat. 1083305, 9501886 or 1751494) or RS Components (Cat. 166-223). Most of these are relatively low-value unpolarised ceramic or metallised polyester types. The only two polarised capacitors are the 470µF and 220µF electrolytics, both of which go in at lower right. Make sure you fit these the correct way around. Now you can fit DC input socket (CON1), the 40-pin socket for IC1 and the 16-way SIL socket for making the connections to the LCD module. Also fit an 8-way length of SIL socket strip for the keypad connections, at lower left on the board. Driver transistors Q1-Q16 are next. They must be orientated as shown in Fig.5, after which you can install crystal X1. Solder the crystal’s leads quickly, so that it doesn’t get too hot. Regulator REG1 can now go in. It mounts flat on the board, with its leads bent down by 90° about 6mm from its body. Secure it to the PC board using an M3 x 6mm screw and nut before soldering its leads (warning: don’t solder the leads first, otherwise you could crack the PC board tracks as the mounting screw is tightened down). Once the regulator is in place, install the 16 mini relays (RLY1-RLY16). LCD module 72  Silicon Chip These have a polarised pin layout, so they can only be fitted one way around. Precision resistors The “precision” resistors in the ladder network all fit along the top edge of the board, above the relays. There are 32 of these in all, consisting of two different values: 3.000kΩ (0.1%) and 1.500kΩ (0.1%). Fit the 15 x 1.500kΩ resistors first, followed by the 17 x 3.000kΩ resistors. It’s also a good idea to fit the 3.000kΩ and 1.500kΩ resistors with their bodies a couple of millimetres above the board. This will help ensure that the resistors are not overheated when their leads are being soldered to the pads underneath. You should also make the solder joints quickly, to minimise the risk of damage. As mentioned previously, if you are unable to obtain 3.000kΩ 0.1% resistors, you can use 3.010kΩ 0.1% resistors instead. These must then each have a 910kΩ 1% resistor connected in parallel, to trim the values back to 3.000kΩ. Install these 910kΩ resistors only if necessary (they are shown dotted on Fig.5). The only remaining component to install (apart from the PIC micro) is the LCD module. To do this, first attach two M3 x 15mm tapped Nylon spacers to the main PC board at the indicated mounting positions. These spacers can be secured using M3 x 6mm machine screws, passing up from underneath. Next, plug the long ends of a 16-way SIL pin header strip into the SIL socket just above trimpot VR1, pushing the pins in as far as they’ll go. The LCD module is then be fitted in position, with the top ends of the SIL header pins passing through the holes in the lower edge of the module. Push the LCD module all the way down so that it sits against the spacers, then secure it using another two M3 x 6mm machine screws. A fine-tipped soldering iron must then be used to solder all 16 pins of the SIL header to the tiny pads along the top edge of the LCD module. Having secured the LCD module, the next step is to carefully plug the PIC16F877A-I/P microcontroller (programmed with the 0410710A.hex firm­ ware) into its 40-pin socket. Be careful siliconchip.com.au 20mm 80.5 80.5 Front panel assembly The 4 x 4 keypad mounts on the siliconchip.com.au 12.5 C 17.5 9.5 E E 21 58.5 23 22.25 21.5 59.5 MAIN CUTOUT FOR KEYPAD 80.5 57 59.5 19 A 4.0mm RADIUS 11 B E E ALL DIMENSIONS IN MILLIMETRES 23 39.5 B HOLES A: 3.5mm DIA. HOLES B: 9mm DIA. CL 9.5 9.5 B 15 80.5 10.5 A At this stage, the PC board assembly is virtually complete. It can now be placed aside while you prepare the front panel and case. Most of this preparation involves the lid – the case itself only needs to have a single hole drilled in the righthand end to provide access to the 12V DC input socket (CON1). Fig.6 shows the drilling details. Fig.7 shows the drilling details for the lid. This diagram is actual size, so a photocopy of it can be used as a template. Note that the 6.5mm and 9mm holes are best made by first drilling small pilot holes and then carefully enlarging them to size using a tapered reamer. That way, you can position them more accurately. The two large rectangular cutouts are for the the LCD viewing window and the keypad. These are made by drilling a series of small holes around the inside perimeter of the marked area, then knocking out the centre piece and filing the job to a clean finish. You are now ready to fit the front panel. Fig.8 shows the full-size frontpanel artwork. This can either be photocopied or you can download it in PDF format from the SILICON CHIP website and print it out. The artwork can then be laminated, attached to the lid using double-sided adhesive tape and the holes cut out using a sharp hobby knife. B Preparing the case 53 x 17mm 43.5 with its orientation – its notched end goes to the left. LCD CUTOUT 39.5 67 Fig.6: this is the drilling template for the DC input socket access hole. 60 (RIGHT-HAND END OF UB2 BOX) B 17 21.5 19 29 HOLE 10mm DIAMETER FOR DC INPUT PLUG HOLE C: 4.0mm DIA. HOLE D: 6.5mm DIA. HOLES E: 2.5mm DIA. 11 D B 10.5 A A 18mm Fig.7: the drilling template for the lid. The rectangular cutouts are made by first drilling a series of small holes, then knocking out the centre pieces and filing the cutouts to a smooth finish. front panel in the larger cutout. However, before mounting it, you need to fit an 8-way length of “long-pin” SIL strip to the pads on the lower edge of the keypad board (to mate with the 8-way SIL socket on the main board). This is done by pushing the pin strip pins up through the holes near the lower edge of the keypad board so that they protrude by about 1mm – just enough to allow you to solder each pin to its mating copper pad. Once the pin strip is fitted, the keypad can be passed up through the front-panel cutout and secured using four No.5 self-tapping screws. You can July 2010  73 CONTRAST LCD ENTER NEW INPUT DEC .PT Fig.8: this full-size front panel artwork can be copied, laminated and attached to the case lid using double-sided adhesive tape. 12V DC INPUT POWER LCD CUTOUT OUTPUT ON/OFF KEYPAD FOR BACK SPACE NEW OUTPUT INPUT 74  Silicon Chip MAIN CUTOUT OUTPUT 1 16-BIT DIGITAL POTENTIOMETER OUTPUT 2 – + – + – + then fit the mini toggle switch (S1) at lower right and the six binding post terminals along the top edge. That done, solder 25mm-lengths of 0.7mm tinned copper wire to the three connection lugs at the rear of S1 and to the rear spigots of the six binding posts. These “extension wires” are to make it easier to complete the connections between these parts and the main PC board when the board is sub- sequently mounted behind the panel. Next, attach a 65 x 25mm rectangle of thin, clear plastic (1mm Perspex or similar) behind the cut-out for the LCD panel (ie, to the rear of the front panel). This can be secured using either a few spots of contact cement or strips of adhesive tape around the edges. Once it’s in place, attach the four M3 x 25mm spacers to the rear of the lid using M3 x 6mm machine screws. Don’t tighten these screws completely just yet though, because the spacers may need to be moved slightly when mounting the PC board assembly. This next step is slightly tricky. That’s because you need to make sure that the “extension wires” attached to S1 and the six binding posts pass through their matching holes in the board. At the same time, the pins of the 8-way SIL strip attached to the keypad must go into the matching header socket. This isn’t all that difficult to do but you do need to be both careful and patient to get it right. Push the board down until it rests on the spacers, then secure it using four more M3 x 6mm machine screws. The screws attaching the spacers to the front panel can then be tightened, after which the complete assembly can be upended and the various extension wires soldered to their pads on the board. Your new 16-Bit Digital Potentiometer is now complete. Checkout time All you need for the initial checkout is a source of 12V DC capable of supplying 400mA or more. This can be either a 12V battery or a suitable mains plugpack. Fit a 2.5mm (ID) concentric plug to its output lead (positive to the centre pin) and plug it into CON1. When you switch the power on via S1, you should be greeted by a warm yellow-green glow from the LCD module’s backlighting. You should also see the initial greeting message, ie, “SC 16-Bit Digital Potentiometer”. If this isn’t displayed clearly, adjust trimpot VR1 with a small screwdriver to set the LCD module for optimum contrast. By the time you do this, you should find that the message displayed has changed to “Output = OFF” on the top line and “(Input = 10.000V)” on the bottom line. This shows the default start-up settings, ie, with the divider relays all turned off so there is zero output and the firmware set for an assumed divider input voltage of 10.000V. If everything checks out so far, try pressing the keypad’s “C” (output toggle) key for about 300ms. This should result in the top line of the LCD display changing to “Output = 5.000V”. At the same time, you should hear a faint “click” as some of the relays are energised to set the divider to the appropriate division ratio. siliconchip.com.au The Digital Potentiometer is ideal for use with the SILICON CHIP Precision DC Voltage Reference described in May 2009. Assuming everything has happened as described, the unit has passed its initial checkout and can be fitted into its box to complete the assembly. Using it Using the Digital Potentiometer is very straightforward. The first step is to connect its input terminals to the output of your Voltage Reference (eg, the 10.000V Precision Voltage Reference described in SILICON CHIP, May 2009). It’s best to use external sensing and a 4-lead connection. That way, the Voltage Reference will maintain an accurate output voltage right at the Digital Potentiometer’s input terminals. One pair of the Digital Potentiometer’s output terminals is then connected to the DMM (or to any other instrument you want to check). The other output terminal pair can be connected to another DMM (eg, if you want to use this as a reference). It’s now just a matter of applying power and using the keypad to enter the desired output voltage. This is siliconchip.com.au done by first pressing the “A” key and then keying the voltage in as a five or six-digit number, including the decimal point (which is keyed in using the “*” key). If you make any errors, they can be corrected using the “B” key, which acts as a destructive backspace. The LCD readout shows the keypad entries. If you are keying in a voltage of 9.999V or less, you only need to key in the significant digits, including the decimal point. You then press the “#” key, which is used here as an Enter key. The micro will then automatically fill in the remaining digit positions with zeros. For example, if you key in “2.3#”, this will give an output voltage of 2.300V. The only variation from this sequence is if you key in an output voltage like 10.000V, which does require you to key in the full six values (including the decimal point). In that case, there’s no need to press the “#” (Enter) key at the end in order to get the micro to accept this voltage setting. It will do so automatically after the sixth digit is keyed in. If you need to disable the Digital Potentiometer’s output voltage at any time, this is done by pressing the “C” key. The output can then be re-enabled by pressing the “C” key again (ie, “C” toggles the output on and off). All of the above assumes that you are using the Digital Potentiometer with our May 2009 Voltage Reference, with its output of 10.000V DC. However, as mentioned earlier, the Digital Potentiometer is also suitable for use with other references, including those with output voltages such as 8.192V or 5.000V. All that is necessary to use it with other reference voltages is to key in the new input voltage. This is done in a very similar way to keying in a new output voltage. The only difference is that before keying in a new input voltage you press the “D” key instead of the “A” key. That’s it – we hope you find the 16-bit Digital Potentiometer a useful SC addition to your workbench. July 2010  75