Silicon ChipSwiss Army Knife - April 2024 SILICON CHIP
  1. Contents: FLOWCODE
  2. Subscriptions
  3. Back Issues
  4. Publisher's Letter: Welcome to the future
  5. Feature: Techno Talk - Wait! What? Really? by Max the Magnificent
  6. Feature: Net Work by Alan Winstanley
  7. Project: Basic RF Signal Generator by Charles Kosina
  8. Project: Swiss Army Knife by Richard Palmer
  9. Project: Silicon Chirp - the pet cricket by John Clarke
  10. Project: Teach-In 2024 by Mike Tooley
  11. Feature: Circuit Surgery by Ian Bell
  12. Feature: Max’s Cool Beans by Max the Magnificent
  13. Project: AUDIO OUT by Jake Rothman
  14. PartShop
  15. Advertising Index: Peak Test Instruments
  16. Back Issues

This is only a preview of the April 2024 issue of Practical Electronics.

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

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Articles in this series:
  • Win a Microchip Explorer 8 Development Kit (April 2024)
  • Net Work (May 2024)
  • Net Work (June 2024)
  • Net Work (July 2024)
  • Net Work (August 2024)
  • Net Work (September 2024)
  • Net Work (October 2024)
  • Net Work (November 2024)
  • Net Work (December 2024)
  • Net Work (January 2025)
  • Net Work (February 2025)
  • Net Work (March 2025)
  • Net Work (April 2025)
Articles in this series:
  • Teach-In 2024 (April 2024)
  • Teach-In 2024 (May 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (June 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (July 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (August 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (September 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (October 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (November 2024)
Articles in this series:
  • Circuit Surgery (April 2024)
  • STEWART OF READING (April 2024)
  • Circuit Surgery (May 2024)
  • Circuit Surgery (June 2024)
  • Circuit Surgery (July 2024)
  • Circuit Surgery (August 2024)
  • Circuit Surgery (September 2024)
  • Circuit Surgery (October 2024)
  • Circuit Surgery (November 2024)
  • Circuit Surgery (December 2024)
  • Circuit Surgery (January 2025)
  • Circuit Surgery (February 2025)
  • Circuit Surgery (March 2025)
  • Circuit Surgery (April 2025)
  • Circuit Surgery (May 2025)
  • Circuit Surgery (June 2025)
Articles in this series:
  • Max’s Cool Beans (April 2024)
  • Max’s Cool Beans (May 2024)
  • Max’s Cool Beans (June 2024)
  • Max’s Cool Beans (July 2024)
  • Max’s Cool Beans (August 2024)
  • Max’s Cool Beans (September 2024)
  • Max’s Cool Beans (October 2024)
  • Max’s Cool Beans (November 2024)
  • Max’s Cool Beans (December 2024)
Articles in this series:
  • Audio Out (January 2024)
  • Audio Out (February 2024)
  • AUDIO OUT (April 2024)
  • Audio Out (May 2024)
  • Audio Out (June 2024)
  • Audio Out (July 2024)
  • Audio Out (August 2024)
  • Audio Out (September 2024)
  • Audio Out (October 2024)
  • Audio Out (March 2025)
  • Audio Out (April 2025)
  • Audio Out (May 2025)
  • Audio Out (June 2025)
Articles in this series:
  • Circuit Surgery (April 2024)
  • STEWART OF READING (April 2024)
  • Circuit Surgery (May 2024)
  • Circuit Surgery (June 2024)
  • Circuit Surgery (July 2024)
  • Circuit Surgery (August 2024)
  • Circuit Surgery (September 2024)
  • Circuit Surgery (October 2024)
  • Circuit Surgery (November 2024)
  • Circuit Surgery (December 2024)
  • Circuit Surgery (January 2025)
  • Circuit Surgery (February 2025)
  • Circuit Surgery (March 2025)
  • Circuit Surgery (April 2025)
  • Circuit Surgery (May 2025)
  • Circuit Surgery (June 2025)
This handy device can provide test voltages, test signals, vary a resistance, switch a component in or out of circuit and even measure some voltages. It ties into automation software so it performs tests automatically and records input and output values for analysis. Swiss Army Knife An Automated Test Bench by Richard Palmer W hen testing something on the bench, I often need to fish around in the parts drawer for some control component, like a switch or a pot. That’s so I can test some circuitry across a range of voltages, with different component values or with some element in and out of circuit. I’m usually also measuring the impact of changes at one or two places in the circuit. It’s remarkable how often I reach for the same components: a switch, a 100kW pot, a sinewave generator and a 0-10V control voltage source being among the most frequent. A collection of these most-used elements would be like a ‘Swiss Army Knife’ for the test bench. Most pocket knives don’t pretend to have all the tools you’ll ever need, or even the absolute best of each kind of tool. Still, they offer a set of robust, basic tools that will get the job done when the perfect tool isn’t at hand or isn’t needed. The cost and complexity of the project have been kept down by controlling it via Wi-Fi using a web interface rather than an LCD screen. That also means it can be teamed up with test automation software, such as TestController, to automate many test bench tasks. Features and performance Pocket knives range from a single blade to monsters with more than thirty functions. We’ve settled on nine functions for this project, and focused on making them simple to use while designing them to tolerate moderate abuse. The input and output connections are made with spring-loaded or cam-operated terminals and multiple ground connections are provided. 24 Two 16-bit analogue inputs with over-voltage protection can measure ±10V DC to within a few millivolts with excellent linearity. As long as both input terminals are kept within that range, it can measure differentials up to 20V. The input range can be extended by adding series resistance to the inputs. The 0-10V DC analogue output has 256 steps of approximately 40mV (see Screen 1). While the accuracy isn’t at the same level as the analogue inputs, 256 individual test values should be enough for most purposes. The sinewave generator operates from 133Hz to 55kHz. The generator has two output voltages: 6V peak-topeak (2.1V RMS) and 775mV peak-topeak (0.27V RMS). The available frequencies are multiples of 133.33 Hz, and the software rounds settings down to the nearest available value. Despite being driven by an 8-bit digital-to-analogue converter (DAC), the noise and distortion total less than 1.5% across the range (see Scope 1 and 2) after low-pass filtering. Major contributors to this are the sine generator DAC’s voltage steps and a jump of several steps at the zero-crossing point. These artefacts are much less visible on the high output range, making that the range of choice. When finer voltage control is desired, the sinewave generator can be teamed up with the digital pot to provide 256 voltage attenuation steps for either of the basic output voltages. A general-purpose op amp based inverter is included to provide additional flexibility in handling negative input or output voltages. We’ve included two different relays: RLY1 is a 350mA SPST reed relay, useful for switching signals, while RLY2 Features and Specifications ∎ 256-step, 0-10V output (from a DAC) ∎ 133Hz-55kHz sinewave generator ∎ Two ±10V fully-differential analogue inputs (16-bit ADC) ∎ Analogue inverter with ±10V input and output ranges ∎ Two 3.3V digital outputs ∎ Two 5V-tolerant digital inputs ∎ 100kΩ digital pot with ±15V terminal ranges ∎ One 10A SPDT relay ∎ One 350mA SPST reed relay ∎ ±15V and +5V power supply rails ∎ Remote control via serial terminal and Wi-Fi telnet SCPI commands ∎ Web interface ∎ TestController integration ∎ Powered by a 5V plugpack ∎ Open-source code (excluding web interface) Practical Electronics | April | 2024 Screen 1: here, the DAC output has been fed to both ADC inputs, and we are plotting the desired voltage (mauve) against the actual voltage read by a multimeter (red) and ADC channels one (blue) and two (dark grey) over the range of 0-250mV. The ADC2 plot tracks the external multimeter almost exactly; ADC1 has a slight offset error due to using 5% resistors in the prototype. is a 10A SPDT type that can switch power supplies and similar. Both have LED indicators. The maximum recommended voltage across both relays is limited to 50V by safety considerations for breadboard-style operation, rather than the relays themselves. Both can switch in less than 10ms. The digital inputs and outputs connect to ESP32 3.3V GPIO pins with series resistances to limit current if they are misconnected. The inputs have zener diode protection, will correctly read 5V logic and are tolerant of up to 20V. The inputs and outputs all have LED indicators. A 256-step 100kΩ digital potentiometer completes the feature set. We have specified a high-voltage type, which allows the pot terminals to be at any voltage within the ±15V analogue supply rails. If you prefer a different resistance (or can’t get the 100kΩ type), you can substitute any other MCP45HV value (5kΩ, 10kΩ and 50kΩ). The project is housed in a UB1 Jiffy box and powered by a 5V plugpack. A readily available switching boost converter module is used to provide ±15V supplies for the op amps and digital pot. The ±15V and +5V supply rails are available to power external circuitry. The specified boost converter can supply 500mA at +15V and 200mA at −15V. At idle, the unit draws less than 100mA from the 5V supply and around 200mA with both relays energised and all the LEDs lit. While a 1A plug pack is more than adequate to power the unit itself, we recommend a 1.5A model if you will be powering much in the way of external circuitry. Even with relatively high conversion efficiency, the 5V supply current draw will be around three times that drawn from either the +15V or −15V rails, and more than six times that drawn by a device across those rails. While the project can be USB-­ powered for commissioning, the USB Scope 1: the direct sine output from the DAC at 400Hz (blue trace) on the low-level output range shows some noise and a zero-crossing discontinuity. The filtered output (yellow trace) shows a significant reduction in noise at the cost of a slight overshoot at each step change. Practical Electronics | April | 2024 cable voltage drop during operation might cause the brownout detector on the ESP32 to trigger, resulting in a potentially endless reboot cycle. The unit features a flexible suite of remote control functions, which is fortunate as there are no controls on the unit itself! It has been specifically designed to be compatible with TestController, or via its web interface. You can also control it via SCPI text commands from the USB serial monitor in Arduino or via Telnet from a terminal program like PuTTY. The manual included in the project downloads has full details of the SCPI command set and communication parameters. Keeping with our pocket knife theme, we’ve specified critical resistors as readily available 1% values to provide a fullscale accuracy of a few percent ‘out of the box’. With a simple calibration process that only requires a multimeter, you can make the analogue accuracy better than 1%. Scope 2: the distortion artefacts from the sinewave output are much less prominent on the filtered output at 5kHz as it spends much less time on each step. 25 ‘Swiss Army Knife’ Test Bench Multitool Fig.1: the Swiss Army Knife is based around an ESP32 Wi-Fi microcontroller module. Besides its digital inputs and outputs, its internal DAC at pin 9 (IO25) is used. Because the ESP32 ADC is poor, an external two-channel differential I2C ADC chip (IC1) is used, along with a digital pot IC for that function (IC2) and a quad op amp to buffer and filter the DAC signal plus provide an externally accessible voltage inverter (IC3b). While this isn’t a highly calibrated instrument, it has sufficient flexibility, accuracy and connectivity to make life on the test bench far more productive. Circuit details As shown in Fig.1, the heart of the project is an ESP32 Wi-Fi microcontroller module. The ESP32 handles the digital 26 inputs and outputs directly via its GPIO pins, plus it has a DAC and sinewave generator. It also manages Wi-Fi and serial communications. The nominally 3.3V digital inputs have 4.7kΩ series resistors and 3.3V zener clamping diodes ZD1 and ZD2 to make them reasonably fault tolerant. They draw minimal current from 3.3V logic and around 0.3mA from a 5V source. The inputs will register ‘high’ for any voltage above 2.5V at pins 5 and 6 (IO34 and IO35) and are weakly pulled down by 50kΩ resistors within the ESP32. The input LED indicators are driven by pins 29 and 30 (IO5 and IO18) to avoid loading the digital inputs. Practical Electronics | April | 2024 Pins 24 and 26 (IO2 and IO4) drive the digital outputs. When low, they will be below 0.3V, and when high, above 2.7V. 220Ω series resistors limit the output current and, with zener clamping diodes ZD3 and ZD4, provide a measure of protection against misconnection. Op amp IC3a amplifies the output from the DAC line (pin 9) that’s Practical Electronics | April | 2024 nominally 0-3.3V to 0-10V full scale. The feedback resistor has been chosen to provide a little more than the required three-times gain so that component variations can be readily corrected via calibration. The 10kΩ resistor and 100pF capacitor form a low-pass filter to reduce the noise from the DAC. IC3d is an amplifying Sallen-Key low-pass filter for the sinewave output, with a -3dB frequency of around 70kHz. The op amp gain is set to two, as Sallen-Key filters with gains of more than three are unstable. The MC33079 op amps can drive their outputs within 1.5V of the supply rails and have a 175kΩ input impedance. They can source and sink up to 30mA and feature short-circuit current limiting. 100Ω resistors in series with the outputs provide an extra margin of safety if they are misconnected. As the op amps use an industry-­ standard footprint, substitution should be possible if the specified devices aren’t available. While the MC33079 is a more modern op amp with better specifications, for most jobs the Swiss Army Knife will be used for, the venerable LM324 will work fine. While the ESP32 has in-built analogue-­ to-digital converter (ADC) channels, they are not linear enough for even basic measurements. Analogue voltages fed in via CON4 and CON5 are measured by a two-channel, 16-bit differential ADS1115 ADC (IC1) which is set to have a 2.048V input range. 91kΩ/10kΩ resistive dividers on the inputs reduce 10V signals to just under 1V, allowing for excess input voltages to be sensed and some component variation to be corrected by calibration. As it is desired to measure both positive and negative voltages, both divider chains are referenced to the 1.1V bias supply (VREF) rather than ground. The ADS1115 has inbuilt over-voltage and negative voltage protection for input currents of less than 10mA, which are limited by the upper resistors in the dividers. If the ADS1115 isn’t available, an ADS1015 can be substituted with a slight drop in accuracy. The bias voltage for the ADC is provided by IC3c, which amplifies D1’s 0.65V forward voltage to the required 1.1V. This diode is biased with 1mA from the 3.3V rail via a 2.7kW current-­ limiting resistor. Inverting amplifier IC3b completes the analogue functions. Its gain is set to −1 and input impedance to 10kW by the pair of 10kW resistors. The 100pF capacitor combines with those resistors to filter noise from the input, with a corner frequency of 160kHz (1 / [2π × 10kW × 100pF]). Digital potentiometer The terminal voltages of digital pots are generally limited to the device’s digital supply rails. The MCP45HV51 (IC2) is a somewhat unusual high-­voltage component with an extended analogue-­side voltage range. Its ±15V analogue power rails allow the pot terminal voltages to 27 be anywhere within that range. While we chose the 100kW model for our prototype, the MCP45HV series also has 5kW, 10kW and 50kW variants, any of which may be substituted without any circuit changes. Both the ADS1115 ADC and MCP45HV digital pot are controlled over an I2C serial bus by the ESP32. Both devices have their additional address pins tied low. Two relays are provided, driven by NPN transistors Q1 and Q2, with diodes D2 and D3 to quench back-EMF of the coils at switch-off. RLY1 is a 350mA SPST reed relay with a 15mA coil, while RLY2 is a heavy-duty, 10A model with SPDT contacts and a 5V 85mA coil. The indicator LEDs light when a coil is energised. Power comes from a 5V plugpack and a boost converter module (MOD2) that supplies ±15V. All three supply rails are brought out to a terminal block for breadboard use. Case preparation Start by marking out and cutting the holes in the lid as shown in Fig.2. There are just the four corner mounting holes to drill to 3mm, plus the rectangular cutout to make. You can do that by drilling a series of holes just inside the rectangular outline, cutting between the holes to remove the plastic inside and then filing the edges smooth and to full size. We’re doing this before assembling the PCB because, to assist you 9mm D I A M E T E R C O A X P O W E R J A C K H O L E I N S I D E O F C A S E, 10mm D O W N F R O M TO P L I P The pins on this dual-supply boost converter (5V to ±15V) match those on the PCB (MOD2). Other 5V to ±15V modules could be used but would need to be wired to the PCB appropriately. in locating the holes, you can place the blank PCB on the underside of the Jiffy box lid with the component side showing. It should sit neatly inside the locating ridges. Mark and drill the four mounting holes, then make the cut-out, which should be 3mm outside the terminal block outlines. While not necessary, it would be nice to countersink those four mounting holes and use countersunk screws, so they are flush with the lid. PCB assembly Given the ongoing global supply shortage of electronic components, some substitution of the active components may be required. Alternatives are noted in the circuit details above and in the parts list. The 142 × 83.5mm double-sided PCB is coded 04110221, available from the PE PCB Service, and the component locations are shown in Figs.3 and 4. Most of the components and the ESP32 are on one side, with just the connectors and LEDs on the other side. It’s best to fit the three SMD ICs first. Locate their pin 1 indicators and line them up with the pin 1 indicators on the PCB or Fig.3. Spread flux paste on the IC pads, then tack one pin of the IC to a corner pad. Check that the part is flat on the PCB and all the leads line up with the pads, re-check the orientation of pin 1, then tack a diagonally opposite pin. Solder the remaining pins with minimal solder on the iron and clean up any bridges between pins with more flux paste and some solder wick. Once you’ve finished, clean off all the flux residue and scrutinise the pins under magnification to ensure all solder joints have formed properly. Move on to the four SOT-23 devices and solder them using a similar technique. Note that there are two devices using this package, so don’t get them mixed up. Then solder the four zener diodes, ensuring their cathode stripes face as shown. Follow with the SMD capacitors and resistors; the resistors will be marked with codes indicating their values, but you’ll have to refer to the ceramic capacitor packages to see their values (or measure them if unsure). Now flip the board over and solder the six SMD LEDs using a similar technique. Their cathodes are usually Fig.2: the Swiss Army Knife board can be used bare, or housed in a plastic UB1 Jiffy box. Just with four holes and one large rectangular cut-out need to be made on the lid, plus one hole on the side for access to the DC power input socket. 14 L I D O F U B1 B O X (V I E W E D F R O M TO P/O U T S I D E) 60 A 60 20 90 x 77mm C U TO U T F O R A C C E S S TO T E R M I N A L S A 10 37.5 C L 37.5 A A 2 H O L E S A A R E A L L 3.0mm I N D I A M E T E R 28 C L ALL DIMENSIONS IN MILLIMETRES Practical Electronics | April | 2024 marked, and they go opposite the + markings in Fig.4 and on the PCB (+ indicates the anodes, not cathodes). You can check their polarity using a DMM set on diode test mode; they should light up with the red lead touching the anode and the black lead touching the cathode. With all the SMDs on the board, clean off any remaining flux residue before fitting the through-hole parts. We have specified header sockets for the ESP32 and the boost module so you can make those items pluggable. While it might be possible to solder them directly, we don’t advise that as it will interfere with the testing and programming sequence. On the side with most of the components, fit the DC socket (CON1), ESP32 (MOD1), boost module (MOD2) and relays. When fitting the boost module, refer to Fig.3 and the photo above. There is an extra row of pins for the ESP32 on the PCB, as some variants of the ESP32 DevkitC come with narrower spacing. You only need to populate the row that matches your module. Mount the terminals (CON2-CON12) on the other side of the board. You’ll probably want to orient them so that the wire entries face the outside of the board, as that will be the most convenient way to use it. Final assembly The PCB mounts under the lid of a UB1 jiffy box with a hole cut in its top, exposing the rectangular area shown in Fig.4. It is a tight fit; some trimming of the PCB locating slots on the case’s side walls may be required. There is no need for a decal or cover plate as the critical information is silk-screened directly onto the PCB. Clip or file off any pins protruding more than 1.5mm from the silkscreened side of the board, and mount it on the lid using 2mm spacers (eg, two 1mm-thick washers stacked) to provide clearance for the component pins. Mark and drill the hole in the case for the coaxial power socket, as shown in Fig.2, if you haven’t already. Loading the software You should now program the ESP32 separated from the PCB. As well as programs being compiled and loaded via an integrated development environment (IDE) such as the Arduino IDE, the ESP32 can load binary files using an over-the-air (OTA) update program. That has the convenience of being able to update its firmware away from your computer. The first step is to load the OTA program, which also conducts validation of the PCB. Install the Arduino ESP32 board files, following the instructions at https://bit.ly/pe-apr24-esp1 Figs.3 and 4: fit the components to the board as shown here, paying particular attention to the orientations of the ICs, LEDs, zener diodes, relay RLY1 and the boost module. Also, don’t get the transistors (Q1 and Q2) and small signal diodes (D1 and D2) mixed up. The resistors and capacitors are not polarised; while the resistors will be marked with coded values, the capacitors won’t. While the boost module is shown mounted vertically here, using a straight header, you can mount it horizontally as shown in the photo overleaf. Practical Electronics | April | 2024 29 Next, install the ESP32 exception decoder and file uploader plug-in releases: https://bit.ly/pe-apr24-esp2 Select ‘ESP32 Dev Module’ as the board in the Tools menu of the Arduino IDE and edit the OTA-Test.ino file from the project download package to include your Wi-Fi credentials – file available from the April 2024 page of the PE website: https://bit.ly/pe-downloads The underside of the PCB is where most of the components are mounted. This prototype differs from the final version, hence the added wires and components. Parts List – Test Bench ‘Swiss Army Knife’ 1 double-sided PCB coded 04110221, 142mm × 83.5mm available from the PE PCB Service 1 UB1 Jiffy box [Altronics H0201 or H0151, Jaycar HB6011] 1 laser-cut UB1 Jiffy box lid (optional; 3mm acrylic) [Silicon Chip SC6337] 1 5V 1A or 1.5A plugpack with 2.1mm inner diameter coaxial plug [Altronics M8903A, Jaycar MP3144] 1 Espressif ESP32-DEVKITC-32D (MOD1) [Silicon Chip SC4447, Altronics Z6385A, Jaycar XC3800] 1 +5V to ±15V boost regulator module (MOD2) [Silicon Chip SC6587] 1 micro-USB cable (to program MOD1) 1 5V SIP reed relay (RLY1) [Pan Chang SIP-1A05, Littelfuse HE3621A0510, Teledyne SIP-1A05-D] 1 5V DC coil 10A SPDT relay (RLY2) [Altronics Z6325, Jaycar XC4419] 2 19-pin female 2.54mm headers (for MOD1) 1 5-pin female 2.54mm header (for MOD2) (can be cut from longer header) 1 2.1mm inner diameter PCB-mount DC barrel socket (CON1) [Altronics P0620, Jaycar PS0519] 7 2-pole, 5mm pitch ‘Euro’ type spring terminal blocks (CON2, CON4, CON5, CON10-CON12) [Altronics P2068, Jaycar HM3140, DECA MX722-500M or Eaton EM278502] 5 3-pole, 5mm pitch ‘Euro’ type spring- or cam-operated terminal blocks (CON3, CON6-CON9) [Altronics P2070, Jaycar HM3142, DECA MX732-500M or Eaton EM278503] 4 M3 × 12mm countersunk machine screws and hex nuts 8 M3 x 1mm Nylon washers Semiconductors 1 ADS1115IDGST or ADS1115IDGSR ADC, MSOP-10 (IC1) 1 MCP45HV51-x0xE/ST 8-bit I2C digital potentiometer, TSSOP-14 (IC2) (x0x = 502 [5kΩ], 103 [10kΩ], 503 [50kΩ] or 104 [100kΩ]) 1 LM324D or MC33079 quad op amp, SOIC-14 (IC3) [Altronics Y2523, Jaycar ZL3342] 2 BC817 or BC846-BC850 SMD NPN transistors, SOT-23 (Q1, Q2) [Altronics Y1312, Jaycar ZT2118] 6 SMD LEDs, M2012/0805 or gull-wing [Altronics Y1107, Jaycar ZD2000] 4 3.3V 1/2W+ zener diodes, DO-214AC or DO-213AA/SOD-80/MiniMELF (ZD1-ZD4) [eg, BZG05C3V3 or MLL5226B] 3 BAS16, BAV99 or similar signal diode, SOT-23 (D1-D3) [Altronics Y0089] Capacitors (all 50V SMD ceramic M2012/0805 size) 4 1μF X7R 8 100nF X7R 2 270pF NP0 2 100pF NP0 Resistors (all 1% SMD metal film, M2012/0805 size) 1 100kΩ 5 91kΩ 1 22kΩ 1 15kΩ 1 12kΩ 15 10kΩ 2 4.7kΩ 1 2.7kΩ 2 1.8kΩ 2 1.5kΩ 4 1kΩ 2 220Ω 3 100Ω 30 Compile and run the program; the Serial Monitor will display the IP Address of the ESP32. You should get an output similar to Screen 2 with the Arduino Serial Monitor baud rate set to 115,200. As expected, the program has failed to find the ADC and digital pot. If you miss the messages on the Serial Monitor, simply push the boot (EN) button on the ESP32 module, and it will restart. Power down the ESP32 and plug it into the PCB sockets with the USB socket near the power input barrel socket, leaving off the boost module for now. Re-connect its USB cable to the computer. The two I2C devices should now show as available. All six LEDs and the two relays should turn on and off at two-second intervals. Now connect the boost converter (with power briefly removed) and check the ±15V rails while still operating on USB power. The DAC output should vary slowly between 0 and 10V at the terminal block. The sinewave output should be a series of pulses at the terminal block, as its buffer is AC-coupled, and we’re feeding it a staircase signal. Connect the DAC signal to the inverter input and check that the inverter’s output varies inversely with its input voltage. You can fully test the digital pot and ADC once the main program is loaded. For now, we have confirmed that they are responding to I2C messages. In the Data folder that is associated with the OTA-Test program, edit the profile.json file, find the section that looks like the following and replace the placeholder ‘ssid’ and ‘pass’ values with those for your Wi-Fi network: { } “ssid” : “your SSID”, “pass” : “WiFi password”, “hostname” : “SwissArmy” Next, close the Serial Monitor window. In the Arduino Tools menu, click ‘ESP32 Sketch Data Upload’ to copy the files in the Data folder to the ESP32’s local file system. The rest of the files in this folder are needed for the web interface. This uploaded file system will remain intact when new programs are uploaded. Practical Electronics | April | 2024 OTA loader and Swiss Army Knife basic tests. Starting with WiFi with SSID = [MYSSID], password = [MYPASSWD] ....... Connected to MYSSID IP address: 192.168.1.XX OTA loader at http://SwissArmy.local or the IP address above. ADC NOT found at I2C address 0x48 Digital pot NOT found at I2C address 0x3C Setup done. Now toggling relays and digital outputs, DAC staircases. Screen 2: the expected output of the OTA-Test program on the serial monitor, before the ESP32 is plugged into the main PCB. Screen 3: the Over The Air (OTA) login page displays when first accessing the ESP32 via a browser. Open up a web page using the IP address or URL indicated by the Serial Monitor. On the OTA-Test program’s web interface, log in using ‘admin’ and ‘admin’ as the credentials (see Screen 3). After you have logged in, select the downloaded project BIN file with the ‘Choose file’ button, and then press the Update button. The web page will track the upload progress, and after a short delay, the ESP32 will reboot. Re-open the Arduino Serial Monitor, and start-up commands should be displayed, ending with an ‘SCPI Changing the Wi-Fi credentials If you have difficulty connecting to your local Wi-Fi or need to change the settings, you can issue the following commands from a terminal program or the Arduino Serial Monitor: Command?’ prompt. If you type ‘*IDN?’ (without quotes) into the command field on the Serial Monitor and click Send, the software should respond with something like ‘Platy,SwissArmy,00,v0.1’. The unit can now be sealed up in the Jiffy box, powered via the plugpack and remotely controlled via the web interface. If you intend to use a USB connection from this point on, then we strongly recommend that a USB isolator be used. This will help to avoid damage to the ESP32 in the event of a misconnection. :SYST:SSID your-WiFi-SSIDwithout-quote-marks :SYST:PASS your-WiFi-Passwordwithout-quote-marks You can also change the Wi-Fi credentials by editing the profile.json file on your computer and uploading it again, using the instructions above. You only need to open the OTA-Test Screen 4: the Swiss Army Knife web interface main page. ADC1 and ADC2 are reading 5.10V and 5.11V respectively, while digital inputs D1 and D2 are both low. On the Settings panel, relay RLY2 is on, and digital output D1 is high. The digital pot is set at 128 steps (50%). The sinewave is currently being adjusted (setting highlighted) to 5.09V; turning the dial will result in 0.1V steps (radio buttons under the dial). Screen 5: the calibration page. If the external multimeter reads 9.61V, DAC1’s output voltage reading would need to be boosted by 0.1V. Changes are not stored until the Save button is clicked but calibration values are saved between sessions. The source code and other software files are available from GitHub at: https://bit. ly/pe-apr24-sak Practical Electronics | April | 2024 31 Screen 6: adding the Swiss Army Knife via TestController’s ‘Load devices’ screen. The option won’t be available until you’ve installed the device definition file and restarted TestController. program and re-upload the sketch data. The OTA-Test program does not need to be compiled or uploaded, but the unit will need to be re-calibrated after the profile upload. Remote control and calibration The unit has been primarily designed to work with the open source software TestController: https://bit.ly/pe-apr24-test or via its web interface. SCPI commands can also be issued via an isolated USB serial connection or over Wi-Fi, using a terminal program (PuTTy or TeraTerm). TestController uses SCPI commands to control all functions besides calibration and communication settings. Further details of the remote control modes and SCPI commands are available in the manual included in the download for this project available from the April 2024 page of the PE website: https://bit.ly/pe-downloads The web interface can control all the outputs and display all the input readings on its Main tab (Screen 4). It also offers calibration functions on its Cal tab (Screen 5). It’s best if only one of the remote control options is active at any time, as settings made on one interface may not seamlessly update on all the others. Web interface The Main tab of the web interface is accessible via http://swissarmy.local and has the input readings on the left and settings on the right. To set a numeric value, click on the setting to be changed and wind the knob. The radio buttons under the knob determine the size of the increment, from 0.1 to 100 units. Under the sinewave generator frequency setting there are buttons to select the low and high output ranges. The digital pot has two linked scales, one in counts (0 to 255) and the other in percent of rotation. Either may be used, and the other will change synchroScreen 7: the TestController Setup pop-up window shows nously. The relay and digital output buttons the readings and allows most functions to be controlled. Input values are updated every second. are on the far right. 32 Calibration The analogue inputs and outputs can be calibrated using a multimeter on the Cal tab. Connect the analogue output to both analogue inputs, set the DAC value to around 9.5V on the Main tab then move to the Cal tab. Measure the analogue input voltage with your multimeter and set the difference between the external multimeter’s reading and the analogue input in the ‘difference’ column for each input (positive if the multimeter reading is higher than shown). Once that is done, set the difference value for the DAC, then click the Save button. DAC calibration is somewhat less accurate than for the ADCs, given that it only has 256 steps to cover the entire 10V range. You don’t need to calibrate all the inputs and outputs at once as the calibration for any input or output, where the difference value is zero, will remain unchanged when Save is clicked. TestController integration The TestController interface can control all functions other than calibration and communication parameters. The device definition file included in the downloads (SwissArmyKnife.txt) needs to be loaded into the Devices folder wherever you have installed TestController; the default location is C:\TestController\Devices Restart TestController and add the device on the Load devices tab in TestController (Screen 6), using the address ‘swissarmy.local’ rather than its IP number, which could change if the unit hasn’t been used for some time. Then click the Reconnect button. On the TestController command screen, click the Setup button, and the pop-up window in Screen 7 should Practical Electronics | April | 2024 appear. The input values displayed at the top of the window will update once a second, and you can set all output values in the lower sections. Conclusion This is a relatively simple project, but it can improve both the productivity and flexibility of your test bench. Reproduced by arrangement with SILICON CHIP magazine 2024. www.siliconchip.com.au Using the Swiss Army Knife to test itself The performance graphs in Screen 1 and Screen 8 were created by connecting the analogue output to an analogue input on the unit, then using TestController to control the analogue output. The values were logged by TestController, along with voltage measurements from a Bluetooth-connected multimeter. TestController was used to create the charts. The results could also have been exported to Excel for analysis. While I wrote a script (shown adjacent) to do this, TestController has a built-in step generator function that would have worked equally well. I ran the script several times with different parameters. The first iteration tested the basic linearity of the device before calibration, using 0.25V steps to ramp the control value (Math.sVal) from 0 to 10V. The analogue input (blue) line in Screen 8 is almost hidden behind the multimeter results (red), indicating excellent linearity. The analogue output (grey) had not been calibrated before the test run and shows a full-scale error of around 300mV. The second test (Screen 1), using increments of 10mV, tested behaviour close to 0V and how the floating-point control value mapped to the 256-step DAC output voltage. As the analogue output has a step size of 40mV, the output voltage stays the same for four 10mV control variable increments, allowing time for each output level to be sampled four times pre-step. The ADC1 input has a negative offset of -10mV. This was traced to a mismatch between the divider resistors R2 and R4, as 5% 10kW resistors were used in the prototype. The second analogue input (dark grey trace) shows almost no offset voltage and tracks the multimeter reading accurately across the entire range. The code averages 16 samples per reading to reduce the variation between readings. The ADS1115 is capable of 860 samples per second. Over the two ADC channels, averaging sixteen samples gives 25 readings per second, more than fast enough for our purposes. To demonstrate how much this helps, compare Screen 1 to Screen 9, which is the same measurement without the averaging. The analogue input measurement (blue trace) also has some unevenness, representing a variation of a few counts between ADC readings. These scripts were run many times during the project’s development, saving time and avoiding transcription errors. Even at a modest hourly rate, the time saved more than equalled the entire cost of the Swiss Army Knife’s components. Practical Electronics | April | 2024 ; ADC & DAC voltage tracking test ; create a control variable that can be logged =globalvar sVal=0 ; set initial value, let it settle and wait until value is logged =sVal=0.0 PlatyKnife::SOUR:A1 0.00 #delay 3 ; don’t log commands and log values every 3 seconds #logcmds 0 #log 3 #hasLogged ; each iteration: update analogue output and wait for logging #while (sVal<10.2) PlatyKnife::SOUR:A1 (sVal) #hasLogged =sVal=(sVal+0.25) #endwhile #hasLogged #log 0 A TestController script I used to test the Swiss Army Knife. After setting up the initial values, the analogue output value is incremented by 0.25V until the limit is reached. Each cycle waits for the log entry to be written before updating to the next value. Screen 8: the tracking of the analogue input and output against the value measured on a B41T multimeter over the complete output range of 0-10V. Note that while the analogue input and multimeter readings track well, the analogue output had not yet been calibrated and is low (Math.sVal is the analogue output setting). Screen 9: the performance at the low end of the analogue scale without input sample averaging. You can see the DAC steps of just over 40mV. The ADC’s offset is around -1mV and tracks the multimeter well at low voltages. The 1 LSB jitter seen here is all but eliminated by the averaging done by the firmware. 33