Silicon ChipARDUINO-BASED DIGITAL AUDIO MILLIVOLTMETER - October 2020 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PicoLog Cloud
  5. Back Issues: PICOLOG
  6. Publisher's Letter
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Techno Talk by Mark Nelson
  9. Feature: Net Work by Alan Winstanley
  10. Project: HIGH-POWER 45V/8A VARIABLE LINEAR SUPPLY by Tim Blythman
  11. Back Issues: LFSR Random Number Generator Using Logic ICs by Tim Blythman
  12. Project: PRECISION ‘AUDIO’ SIGNAL AMPLIFIER by Jim Rowe
  13. Project: ARDUINO-BASED DIGITAL AUDIO MILLIVOLTMETER by Jim Rowe
  14. Feature: Circuit Surgery by Ian Bell
  15. Feature: Practically Speaking by Mike Hibbett
  16. Feature: Max’s Cool Beans by Max the Magnificent
  17. Feature: Make it with Micromite by Phil Boyce
  18. Feature: Pedal Power Station! by Julian Edgar
  19. PCB Order Form: Max’s Cool Beans by Max the Magnificent
  20. Feature: AUDIO OUT by Jake Rothman
  21. Advertising Index

This is only a preview of the October 2020 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • Techno Talk (October 2020)
  • Techno Talk (October 2020)
  • (November 2020)
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
  • Techno Talk (June 2025)
ARDUINO-BASED DIGITAL AUDIO MILLIVOLTMETER by Jim Rowe Low cost, easy to build, highly accurate: an essential piece of test equipment! If you’re involved in audio – at any level – you really must have an audio millivoltmeter in your test gear arsenal. Once you’ve used one, you’ll wonder how you ever managed without it. It’s useful for setting up and calibrating audio systems, doing performance measurements and troubleshooting audio equipment, and much more. This one doesn’t just measure low-level signals. It provides high-resolution measurements of balanced or unbalanced audio signals from below –85dBV (56µV RMS) to above +35dBV (60V RMS)! It’s easy to build and has automatic range switching and can log data to a PC. W e decided to design a new Audio Millivoltmeter because we wanted one which worked over a very wide range of signal amplitudes with excellent accuracy and resolution. We also wanted to have the ability to measure balanced or unbalanced audio signals without the need for any additional hardware. But, most of all, we wanted it to be easy to build and would fit in a compact case. 32 So why build this one instead of our previous audio millivoltmeter (March 2011 – Low-Cost Digital Audio Millivoltmeter)? Well, for many reasons this new unit makes that old one obsolete: • It can measure smaller signals and much larger signals • It has much better resolution • Its frequency response (on both ranges) is much better (see Fig.1) • It has a built-in balanced input (no separate converter required) • It does not require manual range selection • It runs off USB power • It is quite a bit smaller. Some of the improvements in this version are due to our use of an Arduino Nano MCU module for control, while most of the performance improvements are due to our use of an LTC2400 24-bit analogue-to-digital converter (ADC). Practical Electronics | October | 2020 Features and specifications • Unbalanced measurement range • Balanced measurement range • Frequency range • Resolution • Measurement linearity • Basic accuracy • Input impedance • Maximum input level • Power supply • Current drain This gives much higher measurement resolution than the 10-bit ADC built into most Arduinos. The result is a unit that’s much more convenient to use, with higher performance and it fits into a diecast box measuring only 119 × 94 × 57mm. That’s less than half the volume of the earlier version. We estimate the total cost for everything you’ll need to build this project to be under £125. That compares more than favourably with what you’d pay for a similar commercial instrument. To give you an idea of why you might want to measure down to –85dBV, if you have a 100W amplifier which can drive 8Ω loads, at full power then it’s delivering 28.28V RMS (√(100W × 8Ω) across the speaker. That equates to +29dBV. For such an amplifier, a noise level of −85dBV would therefore mean a signal-to-noise ratio of 114dB (85dB + 29dB). A good amplifier can do that. So if you had a meter which couldn’t measure down to −85dB, you couldn’t come close to getting an accurate measurement of the signal-to-noise ratio of such an amplifier. Some potential uses ✔ Audio performance measurements ❏ (signal-to-noise ratio, frequency response, sensitivity, power output, channel separation, crosstalk, amplifier gain) ✔ Crossover adjustment ❏ ✔ Equalisation and room response ❏ adjustments (in combination with a microphone and preamp) ✔ Amplifier calibration ❏ ✔ Amplifier and preamplifier ❏ troubleshooting and repair Practical Electronics | October | 2020 A compact high-resolution digital audio millivolt/voltmeter with balanced and unbalanced inputs, backlit LCD readout, automatic range switching and the ability to send its data to a PC. from <56µV RMS (−85dBV) to 60V RMS (+35dBV) from <56µV RMS (−85dBV) to 600mV RMS (−4.5dBV) 5Hz-110kHz (+0/−3dB); 20Hz-70kHz (+0/−0.5dB); 50Hz-45kHz (+0/−0.1dB) 24 bits (1 part in 16,777,215) ±0.3dB approximately ±0.1% after calibration 1MΩ/10kΩ (unbalanced input) or 760kΩ (balanced input) as per measurement ranges 5V DC via USB mini Type-B socket, either from a USB charger or a PC USB port <78mA (390mW at 5V) The best our 2011 design could achieve was −76dBV, limiting you to SNR measurements of no better than about 105dB for a 100W amp, and considerably worse than that for lower-powered amplifiers, or line-level devices. How it works Fig.2 is a simplified block diagram of the new meter. At its heart is IC3, an Analog Devices AD8307 logarithmic amplifier/detector. This is the same device used in our earlier meter. The AD8307 has impressive specifications: it can convert AC signals into a DC voltage equivalent, following a logarithmic ‘law’ of 25mV per dB (typically linear to within ±0.3dB) and with a span of just on 100dB. The device also operates up to around 500MHz, so it’s just ‘idling’ at audio frequencies. In the new meter, we are feeding IC3’s output to IC4, an LTC2400 24bit delta/sigma ADC. This measures the output of IC3 relative to an accurate 2.500V DC provided by an LT1019 bandgap voltage reference. The resulting 24-bit digital samples are passed to the Arduino Nano via SPI (serial peripheral interface). DIGITAL MILLIVOLT/VOLTMETER FREQUENCY RESPONSE • Description The microcontroller then processes the samples to calculate the corresponding measurements, which are displayed on the LCD module shown at upper right in Fig.2. They’re also sent out via the D− and D+ lines of the USB socket at lower right, for logging via a PC if required. The micro indicates when sampling is taking place by lighting LED1. The elements on the left-hand side of Fig.2 have been added to provide input buffering, low-pass filtering (to reject RF or other unwanted signals), range selection and selection between the unbalanced and balanced inputs. IC1 is an AD629B high-commonmode-voltage-rejecting difference amplifier, used to convert the balanced input signals from XLR socket CON1 into an unbalanced signal. Switch S1a then selects between the unbalanced signals from either CON2 or the output of IC1, with the other half of the double-pole switch (S1b) allowing the micro to detect which input is currently selected. The signal then goes into the range switching section, where a reed relay controlled by the micro via transistor +1dB 0.0dB HIGH RANGE –0.5dB LOW RANGE –1.0dB –1.5dB –2.0dB –2.5dB –3.0dB 1Hz 10Hz 100Hz 1kHz FREQUENCY 10kHz 100kHz Fig.1: a frequency response plot for our prototype in the low range (blue) (measured at 600mV RMS) and high range (red). This demonstrates that the reading is within 0.5dB of the actual signal amplitude over the entire audible range and beyond. It’s within 0.1dB from 50Hz to 45kHz. 1MHz SC 20 1 9 33 CON1 BALANCED INPUT SCL DIFFERENCE AMP SDA IC1 S1a 100:1 DIVIDER CON2 UNBALANCED INPUT LOG AMP/ DETECTOR (IC3) SCK 24-BIT ADC (IC4) D9 MISO SS + Q1 REED RELAY D2 + SAMPLING LED ARDUINO NANO MCU 2.500V REFERENCE RLY1 INPUT SELECT SC 20 1 9 BUFFER AMP & LOW-PASS FILTER (IC2) 16x2 I 2 C SERIAL LCD MODULE  LED1 Vbus D– D3 D+ USB SKT TO POWER/PC 1 2 3 X 4 S1b Fig.2: this block diagram shows the operating principle of the Meter. IC1 converts a balanced signal to unbalanced and S1 selects between the two inputs. The signal then either passes through RLY1 or a 100:1 divider, depending on whether Q1 (and therefore RLY1) is energised, giving the unit its two ranges. The signal is then buffered, filtered and fed to the logarithmic detector before passing to the ADC and onto the Arduino. Q1 is used to select between either the input signal divided by 100 (for the high range, up to 60V), or bypassing the divider (for the low range). The signal is then fed to IC2, a dual op amp with the first stage used as a unity-gain buffer and the second stage as a low-pass filter. This removes, or at least significantly reduces, any noise (including digital switching artefacts from the control circuitry) which may be induced into the analogue signal. The full circuit You’ll find more details in the main circuit diagram (Fig.3). The signal from the balanced input at CON1 is filtered using a common-mode choke (T1) and a 47pF capacitor to remove RF signals, before being coupled via two high-voltage capacitors to the inputs of IC1, the balanced-to-unbalanced converter. This allows for balanced common-mode signals up to 400V peak from earth. A 2.5V bias signal is applied to the REF– and REF+ inputs of IC1 (pins 1 and 5), biasing its input signals to half of the 5V supply, to allow for a symmetrical signal swing before it runs into clipping. The signal from the unbalanced input (CON2) is also RF filtered using inductor L1 and a 22Ω series resistor and 22pF capacitor to ground. The output from selector switch S1 is AC-coupled to the precision 100:1 voltage divider, the upper portion of which is shorted out when the contacts of RLY1 are closed for measuring lower Reproduced by arrangement with SILICON CHIP magazine 2020. www.siliconchip.com.au Digital Audio Millivolt/Voltmeter 34 Fig.3: the full circuit follows much the same pattern as Fig.2, but you can see that some details were left out of the earlier diagram, such as the input RF filtering. VR1 allows the 100:1 divider to be accurately trimmed, while VR2 Practical Electronics | October | 2020 level signals. Trimpot VR1 is used to ‘fine-tune’ the divider for calibrating the Meter’s HIGH range. The way the divider works, and the reason for selecting these exact component values, is shown in more detail in Fig.4. The values are selected so that trimpot VR1 can be used to set the divider ratio to precisely 100:1 without restricting its rotation to a narrow portion of its range. VR1 can compensate for within-tolerance variations in the four 0.1% tolerance fixed resistors. Note that as well as forming the lower leg of the divider for the Meter’s HIGH range, the 10kΩ 0.1% resistor also forms the input resistance for the Meter’s LOW range, for the unbalanced input. That’s because when RLY1 is switched on to short out the divider’s upper arm for the LOW range, the lower part of the divider still provides the DC bias for input pin 3 of IC2a. Pin 21 of the Arduino (the D3 digital input) is used to monitor the position of S1, while pin 20 (digital output D2) controls the range selection relay (RLY1) via NPN transistor Q1. Diode D1 protects transistor Q1 from damage due to the back-EMF generated by the coil of RLY1 when it switches off. Schottky diodes D2 and D3 protect IC2a from overload damage, by clamping its pin 3 input voltage within a few hundred millivolts of the supply rails, even if the input signal amplitude is too high for the Meter to measure accurately. The purpose of IC2a is to buffer the signal from the divider to provide a low-impedance source for the following low-pass filter, which is built around the other half of the dual op amp, IC2b. This is a second-order (−12dB/octave) ‘multiple feedback’ low-pass filter with a −3dB point of around 52kHz. This was chosen to give a very flat response up to 20kHz, then a steep rolloff above audio frequencies. This filter is important since, as stated earlier, the log converter (IC3) has a wide bandwidth of up to 500MHz. So any digital noise or RF picked up before this point will add to the signal being detected and give erroneous readings. Therefore, we want to ensure that all ultrasonic frequency signals are severely attenuated. This filter type and its values were chosen carefully for this role, as a multiple-feedback filter has a significant advantage over the more common Sallen-Key type in that it still provides excellent attenuation for signals above the op amp’s bandwidth, and it is far less reliant on said bandwidth to provide the expected filter attenuation. A second-order multiple-feedback resistor needs just one more resistor than a Sallen-Key type, which is well worth it for its superior high-frequency attenuation. The inputs of IC2a and IC2b are biased to the 2.5V rail, both through its connection to the bottom of the switchable voltage divider ladder, as well as it being fed directly to pin 5 of IC2b. Again, this biases the AC signal fed to these rail-to-rail op amps so that it swings symmetrically within the 5V supply. The audio signal is then AC-coupled to input pin 8 of the AD8307 log detector. A 100Ω series resistor provides additional RF filtering, in combination with the 470pF capacitor between its pins 8 and 1. Pin 1 is grounded via a 220µF capacitor, as we are not feeding differential signals to this chip. The INL input sits at the chip’s DC bias level while the INH input swings above and below that voltage. Trimpot VR2 allows us to adjust IC3’s ‘intercept’ point, calibrating the Meter’s LOW measurement range. A 1µF capacitor smoothes the logarithmic output voltage from pin 4, and calibrates the output of the log detector. The components around IC2b form a second-order multiple-feedback low-pass filter, followed by another passive RC low-pass filter, to reject high-frequency signals before IC3 detects them. Practical Electronics | October | 2020 35 Fig.4: the details of the precision 100:1 divider. Starting with the choice of a 10kΩ 0.1% resistor in the bottom leg (which can have a value from 9.99kΩ to 10.01kΩ), that means we need a total resistance in the upper leg of 990kΩ±990Ω. Taking into account the tolerance of the fixed resistors in that upper leg, a 5kΩ potentiometer gives sufficient scope for adjusting for precisely the right attenuation factor. this is then fed to the analogue input of IC4, the 24-bit ADC. JP1, connected to pin 8 of IC4, changes the ADC’s internal sampling frequency to provide a ‘notch’ for rejecting either 50Hz or 60Hz ‘hum’ in the signal from IC3. So for UK use it would be set in the upper (50Hz) position, while in the US and other countries with 60Hz mains power, you’d set it in the lower position. REF1 provides a very stable 2.5V reference to IC4, necessary for it to operate with the high precision possible for a 24-bit ADC. This means its resolution is 149nV (2.5V ÷ 224), so the limiting factor in its performance will be system noise. The reference has an initial tolerance of ±0.05%, which equates to ±1.25mV. REF1’s output also provides the 2.5V biasing for IC1 and IC2 mentioned earlier. The reference output is stabilised by a Zobel network (5.6Ω and 10µF), as recommended in its data sheet. The AD8307 logarithmic amplifier/detector The Arduino Nano communicates with the ADC (IC4) with the standard SPI pins (ie, pins D10, D12 and D13) while communication with the LCD is via an I2C bus at pins A4/SDA and A5/ SCL. Sampling LED1 is driven from the D9 digital output. Construction Most of the circuitry and components of the new Meter (including the Arduino Nano) are mounted on a PCB measuring 109 × 84mm, and which is coded 04106191. The only components not mounted on the PCB are the LCD module, the input connectors and input selector switch S1. These mount on the box front panel and connect to the PCB via short lengths of wire. Some of the components on the PCB are of the through-hole variety and somewhat larger than the SMD components. So it’s best to fit the smaller SMD parts first. +INPUT –INPUT The location and orientation of all parts are shown on the PCB overlay diagram (Fig.5), but you can also refer to the photos. Note though that there may be some slight differences between the prototype and final PCBs. There are no fine-pitch SMD parts; all of them are reasonably generous in terms of size and pin spacings, so they are not difficult to handle. Start by fitting all the SMD passives (resistors and capacitors), except for those which are right next to one of the SMD ICs, as these would otherwise make fitting the latter more tricky. The usual technique is to tack one side of the component onto its pad, make sure it is sitting flat on the board and properly aligned, then solder the opposite pad (after waiting long enough for the first joint to solidify). Then wait a little longer and refresh the first joint with a little extra solder or flux paste. With those passives all in place, you can install the five SMD ICs. In each case, they must be oriented correctly, so find the pin 1 dot or divot on the top face, and make sure it’s facing as shown in Fig.5. If you can’t find the dot, pin 1 is normally also indicated by a chamfered edge on just that side of the IC. Again, locate the IC and tack one pin down before soldering the other seven pins, then refresh that initial joint. The pins are spaced far enough apart to be soldered individually. If you accidentally form a solder bridge between two pins, add a little flux paste and then clean it up using solder wick. SIX 14.3dB GAIN, 900MHz BANDWIDTH AMPLIFIER/LIMITER STAGES AD8307 INT SET INTERCEPT Logarithmic amplifier/detector ICs are a fairly spe3 x PASSIVE CURRENT ATTENUATOR cialised but quite useful device. You can get an MIRROR CELLS idea of how they work from the diagram at right, 2 A/dB which gives a simplified view of what’s inside the NINE FULL-WAVE DETECTOR CELLS WITH OUT DIFFERENTIAL OUTPUT CURRENTS – ALL SUMMED AD8307 device. 25mV/dB The incoming AC signals pass through six casENB BANDGAP REFERENCE INPUT – OFFSET 12.5k caded wideband differential amplifier/limiter stagAND BIASING COMPENSATION LOOP es, each of which has a gain of 14.3dB (about 5.2 times) before it enters limiting. This gives a total OFS COM gain of about 86dB, or around 20,000 times. The outputs of each amplifier/limiter stage are fed to a series of (2.24V). This logarithmic relationship is linear to within ±0.3dB nine full-wave detector cells, along with similar outputs from three over most of the range. The output current (IOUT) increases at a slope of very close cascaded passive 14.3dB attenuator cells connected to the input to 2µA per dB increase in AC input level, and when this current of the first amplifier/limiter. The differential current-mode outputs of all nine detector cells passes through a 12.5kΩ load resistor inside the chip, the result are added together and fed to a ‘current mirror’ output stage, which is a DC output voltage of 25mV/dB. This slope can be fine-tuned using an external adjustable resistor in parallel with the 12.5kΩ effectively converts them into a direct current. Because of the combination of cascaded gain and limiting in internal resistor. The ‘set intercept’ (SI) pin allows you to adjust the DC offset in the amplifiers (plus an internal offset compensation loop), the amplitude of this output current is proportional to the logarithm the output current mirror, which sets the effective zero-level point of the AC input voltage. This holds true over an input range of of the chip’s output current and voltage; ie, the origin from which just on 100dB, from about −93dBV (22.4µV) up to +7.0dBV the output slope rises. 36 Practical Electronics | October | 2020 You can now fit the remaining SMD passives, plus the two SMD diodes, ensuring their cathode stripes face as shown in Fig.5. Next, fit transistor Q1. It has three pins, so its orientation should be obvious. Make sure its leads are sitting flat on the PCB before you solder it in place. The last SMD component is L2, which is quite large. Spread a thin smear of flux paste on both pads before you start. You will need a hot iron to form good solder joints due to the thermal masses of both the PCB and the part. Make sure you add enough solder and heat it long enough to form good fillets. Through-hole parts Before proceeding, we need to wind choke L1 and transformer/commonmode choke T1. These are both wound on 5mm-long ferrite beads, using 0.25mm-diameter enamel-coated copper wire. L1 has three single turns, while T1 has three bifilar turns, wound by first folding a 200mm length of the wire in two, and then using the ‘doubled pair’ to wind their three turns together. Once both chokes are wound, cut off the wire ends about 8mm from the ends of the ferrite beads, scrape off about 4mm of the enamel and then lightly tin the wire ends so they will be easy to solder into the PCB pad holes. Just before you solder in the four wires for T1, use your DMM to make sure that the wire pairs do not ‘cross over’; the leftmost upper and lower wires should be joined together, as should the right-most upper and lower wires. You can now proceed to fit the remaining through-hole parts. Start with diode D1 (as usual, be careful with its orientation). It’s then a good idea to install the six PC pins, if you are going to use them. These make it easier to use clip leads to connect your DMM to the board during testing and calibration. These are for TPGND, TP2.5V, TP5V and TP1-TP3. Next, mount the reed relay, again taking care with its polarity. Follow with the two multi-turn trimpots, which are different values (so don’t get them mixed up), followed by the 4-pin header for CON3, the 3-pin header for JP1 and the 2-pin header used to facilitate the connection of LED1. Now is also a good time to install the 1µF through-hole capacitor, near IC4. Before you mount the Nano board, you will need to fit a short length of wire shorting out its onboard diode D1, on the underside; see the sidebar photo and text for an explanation of why this is necessary and how to do it. Practical Electronics | October | 2020 Fig.5: this PCB overlay diagram (and photo below) shows where the components are mounted on the PCB, including the prebuilt Arduino Nano microcontroller module. Most of the components are larger SMD types which are not difficult to hand-solder. Some components, such as CON1, CON2 and S1 are mounted on the lid (front panel) and wired back to the board using short leads. Now solder the Arduino Nano module to the rows of pads on the board, with its USB connector over the outside edge. Make sure it’s pushed all the way down before soldering; it’s a good idea to solder two diagonal pins first, check that it’s flat and then solder the rest. Finish up by mounting the three large capacitors. The final step at this stage is to solder the leads of LED1 to the pins of the 2-pin header fitted to the PCB, taking care to connect them to the correct pin (the longer anode pin goes to the inner pin marked ‘A’). The leads should be soldered to the pins so that the underside of the LED’s body is 28mm above the top of the PCB. Your Meter’s PCB assembly should now be complete and ready to be fitted into the box, once it has been prepared. Before you do so, though, plug the 4-pin female socket onto CON3 and place the shorting block in the correct position on JP1, to suit your local mains frequency. Preparing the box Most of the holes you’ll need to drill or cut in the box are in the lid, which becomes the Meter’s front panel. There are only three holes to be cut in the base of the box: two circular 37 holes in the right-hand end for access to trimpots VR1 and VR2, and one rectangular hole in the centre of the box rear to allow access for the power/PC USB connector. You’ll find the location and sizes of all of these holes in the two drilling diagrams (Figs.6 and 7). Most of the holes are circular and can be drilled, although the 23mm-diameter hole for Parts list – Digital Audio Millivoltmeter 1 119 × 94 × 57mm diecast aluminium box [Jaycar Cat HB-5064 or similar] 1 double-sided PCB, 109 × 84mm, code 04108191 (RevH) 1 Arduino or Duinotech Nano MCU module 1 USB Type-A to mini Type-B cable 1 16x2 backlit alphanumeric LCD module with I2C serial interface [eg, SILICON CHIP ONLINE SHOP Cat SC4198 or similar] 1 panel-mount miniature DPDT toggle switch (S1) [Jaycar ST035, Altronics S1345] 1 panel-mount 3-pin female XLR connector (CON1) [Jaycar PS1930, Altronics P0804] 1 panel-mount BNC socket (CON2) 1 4-pin header, 2.54mm pitch (CON3) 1 4-pin female header socket, 2.54mm pitch (to connect LCD module) 1 2-pin header, 2.54mm pitch (for LED1) 1 3-pin header with jumper shunt (JP1) 1 SPST DIL reed relay with 5V/10mA coil (RLY1) [Jaycar Cat SY-4030 or similar] 2 5mm-long ferrite beads, 4mm outer diameter (L1,T1) [Jaycar Cat LF-1250 or similar] 1 300mm length of 0.25mm-diameter enamelled copper wire (for L1 and T1) 1 100µH SMD RF inductor (L2) [Jaycar Cat LF-1402 or similar] 4 25mm-long M3 tapped spacers 4 6mm-long untapped spacers 8 12mm or 15mm-long M3 panhead machine screws 2 9mm-long M3 countersunk head machine screws 2 M3 hex nuts and star lockwashers 4 16mm or 20mm-long M2.5 countersunk head machine screws 4 9mm-long untapped spacers, >2.5mm inner diameter 4 M2.5 hex nuts 6 PCB pins (optional; for TPGND, TP2.5V, TP5V and TP1-TP3) Semiconductors 1 AD629BRZ high common-mode-voltage difference amplifier, SOIC-8 (IC1) 1 MCP602-I/SN dual rail-to-rail input/output op amp, SOIC-8 (IC2) 1 AD8307ARZ logarithmic amplifier/detector, SOIC-8 (IC3) 1 LTC2400CS8#PBF 24-bit ADC, SOIC-8 (IC4) 1 LT1019ACS8-2.5#PBF precision 2.500V voltage reference, SOIC-8 (REF1) 1 BC817-40 NPN transistor, SOT-23 (Q1) 1 3mm red LED (LED1) 1 1N4148 silicon small-signal diode (D1) 2 1N5711W-7-F schottky diodes, SOD-123 (D2,D3) Capacitors (all SMD ceramic, 3216/1206 size unless otherwise stated) 2 220µF 6.3V X5R, SMD 3226/1210 size 2 100µF 6.3V X5R 2 22µF 10V X5R 3 10µF 16V X7R 1 10µF 250VDC metallised polypropylene,radial leaded [Panasonic ECQ-E2106KF] 1 1µF 50V through-hole ceramic or MKT 1 1µF 16V X7R 2 220nF 275VAC metallised polypropylene, radial leaded [Panasonic ECQ-U2A224ML] 1 220nF 16V X7R (Code 220, 0.22 or 220n) 7 100nF 16V X7R (Code 100, 0.1 or 100n) 1 2.2nF 16V X7R (Code 2.2, .022 or 2n2) 2 470pF 100V C0G/NP0 (Code 470, .0047 or 470p) 1 47pF 100V C0G/NP0 (Code 47, .00047 or 47p) 1 22pF 250V C0G/NP0 (Code 22, .00022 or 22p) Resistors (all SMD 1% 0.25W, 3216/1206 size unless otherwise stated) 1 910kΩ 0.1% 1 75kΩ 0.1% 1 51kΩ 1 10kΩ 1 10kΩ 0.1% 1 3.0kΩ 0.1% 1 4.7kΩ 1 2.2kΩ 1 1.5kΩ 2 1.2kΩ 1 1kΩ 1 100Ω 3 470Ω 1 22Ω 1 10Ω 1 5.6Ω 1 5kΩ multi-turn horizontal trimpot (VR1) 1 50kΩ multi-turn horizontal trimpot (VR2) 38 XLR connector CON1 is best made using either a hole saw or by drilling a circle of small holes and then cutting between them using either a rat-tailed file or jeweller’s saw. The best plan for cutting the 65 × 15mm rectangular hole for the LCD screen is to drill a 6mm diameter hole inside each corner, to allow you to use a small metal-cutting jigsaw to cut along each side. Then you can tidy up the edges using a small file. For the rectangular hole in the rear of the box, I first drilled a 9mm diameter hole in the centre, then used jeweller’s files to expand it out into the final rectangular shape. Once all of the holes have been made, remove all burrs from the inside and outside of each hole using one or more small files. As a final step in preparing the box for assembly, you should fit a professional-looking panel on the lid. We have produced a front panel artwork for this project, which can be downloaded from the October 2020 page of the PE website as a PDF file. You can then print, laminate and attach it to the lid using thin doublesided adhesive tape or a smear of silicone sealant. The final step is to cut out the holes in the dress front panel to match those in the lid itself, using a sharp knife. Final assembly Glue an 80 × 40mm rectangle of 0.5mm-thick clear plastic sheet to the rear of the lid, just behind the LCD window. This is to keep dust out and protect the LCD screen from accidental scratches. It can be cut from a clean takeaway container lid or similar. Then mount the LCD screen to the underside of the lid using four 16mmlong M2.5 countersunk-head screws with four 9mm-long untapped spacers and four M2.5 nuts, as shown in Fig.8. Next, fit XLR connector CON1 to the lid using two 9mm-long countersunkhead M3 screws with lock washers and nuts on the rear. After this, fit BNC connector CON2 using its matching lock washer, solder lug and nut, then input selector switch S1. To ensure that the switch is fixed in place horizontally, you can drill a small blind hole in the rear of the lid to accept the spigot on the edge of the switch’s flat washer. Now up-end the lid/front panel and solder stiff wire leads to the rear lugs of CON1, CON2 and S1. These don’t have to be very long; just long enough to pass down through their matching holes in the PCB when it’s fitted. Practical Electronics | October | 2020 The only one that needs special treatment is that for CON2, which should ideally be made using a 25mm length of shielded microphone cable. Take care when separating the screen wires at each end, to prevent accidental shorts. Once these extension leads have been fitted, you are ready to mount the PCB to the rear of the lid/front panel. The PCB is mounted using four 25mm-long M3 tapped spacers, together with four 6mm-long untapped spacers, as shown in Fig.8. First attach all four pairs of spacers to the corners of the PCB, using 12mm-long M3 screws passing up through the PCB and the untapped spacers, and then into the 25mm tapped spacers. The complete PCB-and-spacers assembly is then attached to the rear of the lid/front panel, using four 12mmlong M3 screws. While doing this, ensure that the extension wires from CON1, S1 and CON2 pass through their matching holes in the PCB. And before you finally tighten up the screws, make sure that the body of LED1 is protruding through its matching hole in the front panel. Now solder the ends of the extension wires from CON1, S1 and CON2 to their matching pads on the rear of the PCB. If all has gone well so far, you should find that the pin ends of the 4-pin SIL header fitted to the end of the LCD module are now very close to those of the socket plugged into CON3. You should only need to bend the module’s header pins down slightly to meet the pins from CON3’s socket, and then you can solder them together. Your Meter is now complete, apart from the final fitting of the front panel assembly into the box. But before you do this, it’s a good idea to load the Meter’s firmware sketch (program) into the Arduino Nano. This is done using the Arduino IDE, running on a suitable PC, with the Meter connected to a USB port of the PC via a standard USB Type-A to mini Type-B cable. Programming the Meter The firmware program to be loaded into the Meter’s Arduino Nano is called AudiomVmeterMk2_sketch. ino, which you can download from the October 2020 page of the PE website. Save it in a folder where you’ll be able to find it later. Now is also a good time to make sure that you have the latest Arduino IDE (integrated development environment) installed. If not, you can get it from: www.arduino.cc/en/main/software Practical Electronics | October | 2020 showing that the Meter is receiving 5V power. Assuming that you are running Windows, open the Control Panel and select ‘System and Security’ and then This software allows you to compile and upload the code to the Arduino board. Plug the Meter into your PC, and its LCD backlight should light up, 37.5 B 37.5 B A 65 HOLES A: 3. A HOLES B: 2.5 HOLE C: 6.5 A HOLE D: 9.0 15 31 39 33 33 32.5 B 32.5 16 B 8 CL 47 47 A 24 29 9.5 29 24 33 33 12 23 D C 12 A A 9.5 A CL ALL DIMENSIONS IN MILLIMETRES Fig.6: most of the holes that need to be made in the case go in the lid. Holes A are 3mm diameter, B are 2.5mm, C 6.5mm and D 9mm. You’ll probably need a hole saw to cut the 23mm, although you could use a 20mm stepped drill bit and then enlarge to 23mm with a large tapered reamer. Note that holes ‘B’ need to be countersunk after being drilled. See the text for suggestions on how to make the large rectangular cut-out. RIGHT-HAND END OF CASE 25 3mm DIAMETER 2 17 3mm DIAMETER ALL DIMENSIONS IN MILLIMETRES REAR OF CASE CL 19.5 9 11 CL of the case to access the calibration Fig.7: two holes need to be drilled in the side potentiometer screws, while a small rectangular cut-out on one of the long sides provides access to the USB socket, both for power and optionally for logging measurements to a PC. 39 The pre-assembled display PCB mounts so that the LCD lines up with the cutout in the lid (which becomes the front panel). Here we also show the four mounting pillars and the input select switch along with the XLR and BNC sockets, with their connecting wires already soldered in place and ready to connect to the main PCB. ‘Device Manager’. This should allow you to see the Virtual COM Port that the Meter has been allocated. It should also allow you to set the baud rate for communication with the Meter. Set it to 115,200 bps. Now start up the Arduino IDE and load the sketch that you downloaded earlier. In the IDE’s Tools menu, set the Board selection to ‘Arduino Nano’ and the Processor to ‘ATMega328P (Old Bootloader)’, then set the COM Port to whichever one your Meter is connected to, as determined earlier. Open the sketch and in the Sketch menu, click on ‘Verify/Compile’. When you get the ‘Compiling Done’ message, go to the Sketch menu again and click on ‘Upload’. The compiled sketch should then be uploaded into the Nano MCU’s Flash memory. After a few seconds, the Meter should start up, giving you a brief 12mm LONG M3 SCREWS CON1 message on the LCD announcing itself. It will then start sampling from whichever input S1 is set to select. At this stage, the Meter may not be giving sensible readings, since it has yet to be calibrated. But you can check the various DC voltages on the PCB test points. For example, you should find a voltage very close to 5V between TP5V and TPGND, while the voltage at TP2.5V should read 2.500V with respect to TPGND. If those check out, you can now install your Meter in its box, by lowering it in and then screwing the lid with the four M4 countersunk screws supplied with it. Calibration For accurate results, your Meter must be calibrated. You’ll need access to an audio oscillator or a function generator, together with a DMM capable M2.5 x 16mm LONG COUNTERSUNK SCREWS TO ATTACH LCD MODULE CON2 S1 9mm LONG UNTAPPED SPACERS S1 ARDUINO NANO 25mm LONG M3 TAPPED SPACERS 2 LCD WITH I C INTERFACE (BEHIND) 10F 250V 6mm LONG UNTAPPED SPACERS MAIN PCB 12mm LONG M3 SCREWS 40 of making accurate and reasonably high-resolution AC voltage measurements in the range from 500mV to 10V (RMS). Power up the audio oscillator or function generator and set it to provide a 1kHz signal with an amplitude of 600mV RMS (1.697V peak-to-peak). Check this level using your DMM, and adjust the generator if necessary. Then power up the Millivoltmeter and connect the oscillator’s output signal to the Meter’s unbalanced input (CON2), with S1 set appropriately. After a few seconds, the Meter should show a stable reading in both millivolts and dBV, with the legend ‘(L)’ at lower right. This indicates the Meter has switched to its lower range. At this stage, the reading will probably differ a little from the correct value of 600mV and −4.437dBV. So use a small screwdriver or alignment tool to adjust trimpot VR2 (INTERCEPT ADJUST), to bring the reading as close as possible to that correct value. This calibrates the Meter’s low range. The next step is to calibrate the Meter’s high range. Change the output level of the audio oscillator or function generator to 10.000V RMS (28.28V peak-to-peak), checking this using your DMM again. If your oscillator or function generator can’t provide an output that high (which is quite common), you may have to use a small amplifier to boost its output. RLY1 M2.5 NUTS VR1 Fig.8: this ‘cut-away’ side profile view of the assembled unit shows how the various parts attach to each other and the back of the lid, and also gives you an idea of the connections needed from the panel-mounted parts to the PCB below. Practical Electronics | October | 2020 ‘Left and right’ views of the assembled project immediately before it is mounted in the diecast case. The input sockets and selector switch are all connected to the PCB via short lengths of either tinned copper wire or, in the case of the BNC socket (CON2), shielded cable. The photo at right compares with the diagram on the opposite page. An amplifier capable of doing just that, very accurately, is described starting on page 29 of this issue. Now connect the oscillator’s output signal to the Meter’s unbalanced input (CON2) again, and after a couple of seconds, the Meter should display a new reading. This time, the legend at the end of the lower line should read ‘(H)’, to show that it has now switched to the higher range. The new reading is likely to be fairly near the correct value of 10.000V and 20.00dBV, but not spot-on. Correct it by adjusting trimpot VR1 (CALIBRATE HI RANGE). Once this has been done, your new Digital Millivolt/Voltmeter is calibrated and ready for use. Logging measurements All you need to do to log measurements to your PC is open up the Arduino Serial monitor, using the same settings as described above for programming the Nano. With the unit connected to your PC, each time it takes a measurement, it will also be written to the serial monitor. When you have finished, you can save the log for later analysis (for example, using mathematical functions in a spreadsheet). This view of the right end of the PCB shows the two 15-turn trimpots, VR1 (left – 5kΩ) and VR2 (right – 50kΩ) which are used to set the HIGH range calibration and intercept adjust, respectively (see text). These pots line up with access holes drilled in the end of the case. Ensuring that a low-cost Arduino Nano works reliably There are Arduino Nanos... and there are Arduino Nanos! During the development of this project, we discovered on two occasions that the ‘El cheapo’ Arduino Nanos had started to malfunction. In both cases, diode D1 in the Nano’s power supply had ‘blown’ and changed into a high resistance, lowering the supply voltage to less than 2.8V. This diode (an SS1 or an MBR0520) is not really required when the Nano is powered from USB. It’s purely to protect the USB port of the PC when the Nano is powered via a higher voltage supply fed directly into its Vin pin. Since the Nano and its associated circuitry (here, the Millivoltmeter) are always going to be powered from the USB connector, there’s no reason why the diode can’t be simply shorted out, to ensure reliable operation. Practical Electronics | October | 2020 The problem is that the diode is fitted to the underside of the Nano’s tiny PCB. This makes it quite inaccessible if the Nano has already been fitted to your Meter’s main PCB. In fact, I had to virtually destroy the first Nano to remove it from the main PCB to get at the blown diode. So we suggest that if you are going to be using a low-cost Nano in your Millivoltmeter, you should first short out D1 with a short length of wire, before mounting it on the main PCB. This should ensure reliable operation and avoid the need for surgery at a later stage. The photo at right shows where D1 is located, just below the Mini USB connector. The diode is usually marked ‘B2’, although on the one in the photo it looks more like ‘D2’ because there’s a tiny crater in the middle of the B where the smoke came out. It’s quite easy to short out the diode with a short length of tinned copper wire, bent into a tiny inverted ‘U’. If you use the same soldering iron you use to fit SMD components, it can be done quite quickly if you’re careful. Just make sure that the wire link doesn’t protrude upwards very far, or it might touch the top copper of your main PCB when the Nano is mounted on it. 41