Silicon ChipPico Audio Analyser - November 2023 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Computer keyboards need an update / Australia Post wants to put prices up again!
  4. Feature: The History of Electronics, Pt2 by Dr David Maddison
  5. Product Showcase
  6. Project: Pico Audio Analyser by Tim Blythman
  7. Feature: 16-bit precision 4-input ADC by Jim Rowe
  8. Project: K-Type Thermostat by John Clarke
  9. Review: Microchip's new PICkit 5 by Tim Blythman
  10. Project: Modem/Router Watchdog by Nicholas Vinen
  11. Project: 1kW+ Class-D Amplifier, Pt2 by Allan Linton-Smith
  12. Serviceman's Log: Charge of the light yardwork by Dave Thompson
  13. PartShop
  14. Subscriptions
  15. Vintage Radio: Recreating Sputnik-1, Part 1 by Dr Hugo Holden
  16. Market Centre
  17. Advertising Index
  18. Notes & Errata: Watering System Controller
  19. Outer Back Cover

This is only a preview of the November 2023 issue of Silicon Chip.

You can view 47 of the 112 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.

Articles in this series:
  • The History of Electronics, Pt1 (October 2023)
  • The History of Electronics, Pt1 (October 2023)
  • The History of Electronics, Pt2 (November 2023)
  • The History of Electronics, Pt2 (November 2023)
  • The History of Electronics, Pt3 (December 2023)
  • The History of Electronics, Pt3 (December 2023)
  • The History of Electronics, part one (January 2025)
  • The History of Electronics, part one (January 2025)
  • The History of Electronics, part two (February 2025)
  • The History of Electronics, part two (February 2025)
  • The History of Electronics, part three (March 2025)
  • The History of Electronics, part three (March 2025)
  • The History of Electronics, part four (April 2025)
  • The History of Electronics, part four (April 2025)
  • The History of Electronics, part five (May 2025)
  • The History of Electronics, part five (May 2025)
  • The History of Electronics, part six (June 2025)
  • The History of Electronics, part six (June 2025)
Items relevant to "Pico Audio Analyser":
  • Pico (2) Audio Analyser PCB [04107231] (AUD $5.00)
  • 1.3-inch blue OLED with 4-pin I²C interface (Component, AUD $15.00)
  • 1.3-inch white OLED with 4-pin I²C interface (Component, AUD $15.00)
  • Short-form kit for the Pico 2 Audio Analyser (Component, AUD $50.00)
  • Pico Audio Analyser PCB pattern (PDF download) [04107231] (Free)
  • Pico Audio Analyser firmware (0410723A) (Software, Free)
  • Pico Audio Analyser box cutting details (Panel Artwork, Free)
Articles in this series:
  • Pico Audio Analyser (November 2023)
  • Pico Audio Analyser (November 2023)
  • Pico 2 Audio Analyser (March 2025)
  • Pico 2 Audio Analyser (March 2025)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "K-Type Thermostat":
  • Thermocouple Thermometer/Thermostat main PCB [04108231] (AUD $7.50)
  • Thermocouple Thermometer/Thermostat front panel PCB [04108232] (AUD $2.50)
  • PIC16F1459-I/P programmed for the Thermocouple Thermometer/Thermostat (0410823A.HEX) (Programmed Microcontroller, AUD $10.00)
  • MCP1700 3.3V LDO (TO-92) (Component, AUD $2.00)
  • K-Type Thermocouple Thermometer/Thermostat short-form kit (Component, AUD $75.00)
  • K-Type Thermocouple Thermometer/Thermostat firmware (0410823A.HEX) (Software, Free)
  • K-Type Thermocouple Thermometer/Thermostat PCB pattern (PDF download) [04108231] (Free)
  • K-Type Thermostat panel artwork (PDF download) (Free)
Items relevant to "Modem/Router Watchdog":
  • Modem Watchdog PCB [10111231] (AUD $2.50)
  • Modem/Router Watchdog kit (Component, AUD $35.00)
  • Modem/Router Watchdog Software (Free)
  • Modem Watchdog PCB pattern (PDF download) [10111231] (Free)
Items relevant to "1kW+ Class-D Amplifier, Pt2":
  • 1kW+ Mono Class-D Amplifier cutting and drilling details (Panel Artwork, Free)
Articles in this series:
  • 1kW+ Class-D Amplifier, Pt1 (October 2023)
  • 1kW+ Class-D Amplifier, Pt1 (October 2023)
  • 1kW+ Class-D Amplifier, Pt2 (November 2023)
  • 1kW+ Class-D Amplifier, Pt2 (November 2023)
Items relevant to "Recreating Sputnik-1, Part 1":
  • Sputnik design documents and Manipulator sound recording (Software, Free)
Articles in this series:
  • Recreating Sputnik-1, Part 1 (November 2023)
  • Recreating Sputnik-1, Part 1 (November 2023)
  • Recreating Sputnik-1, Part 2 (December 2023)
  • Recreating Sputnik-1, Part 2 (December 2023)

Purchase a printed copy of this issue for $12.50.

Project by Tim Blythman This handy little tool uses an inexpensive Raspberry Pi Pico microcontroller board and not much else to generate and analyse audio signals. It has oscilloscope and spectrum modes and can run a sweep to plot a frequency response or perform harmonic analysis to check signal quality. It fits in the palm of your hand, is portable and battery powered. PICO Audio Analyser T he Pico Audio Analyser is a compact handheld device that’s powered by an internal rechargeable battery. It can generate and analyse basic audio signals and is suitable for various tasks such as checking amplifiers, wiring, filters etc. It’s a handy tool for working in the field, and for troubleshooting and tinkering with audio circuits. You can even hook it up to a breadboard to test simple circuits like RC filters. This project was inspired by a Circuit Notebook submission, which used a dsPIC microcontroller with an LCD to create a spectrum analyser (August 2023; siliconchip.au/Article/15908). The concept is also similar to our Low Frequency Distortion Analyser (April 2015; siliconchip.au/Article/8441). We took those ideas and expanded them to include more features. One potentially interesting use is to monitor the distortion of the mains waveform, which theoretically is a sinewave, but often looks little like one! To do that, you’d connect the output of just about any AC plugpack to its input and put it in distortion analysis mode. Like the earlier designs mentioned Features & Specifications > Audio signal generator (up to 3V peak-to-peak/1.06V RMS) with selectable frequency > Sine, square, triangle, sawtooth and white noise waveforms > Audio signal input with switchable 3.6V and 34V peak-to-peak ranges (1.27/12V > > > > > > > > > > > 36 RMS) Oscilloscope and spectrum displays Harmonic analysis with THD measured down to 0.3% (1.2V RMS, 1.2kHz) Can measure and monitor mains distortion with a suitable plugpack Sweep analysis with frequency response display RCA sockets for input and output Runs from USB power or an internal rechargeable battery Uses 128×64 OLED display and pushbutton controls Compact and portable Controllable from a virtual USB serial port Typical current draw around 50mA Operates for around 12 hours with a fully charged 600mAh battery Silicon Chip Australia's electronics magazine above, the Pico Analyser uses a Fourier transform to examine the frequency components of a signal. That allows us to create a spectrum display and perform a sweep analysis. The April 2015 article explains in detail the use of Fourier transforms and how they are used to measure distortion. Design When planning this design, we had in mind that it should be inexpensive and compact. The circuitry fits in the smallest Jiffy box (UB5), measuring just 83 × 54mm. The front panel is also the back of the main PCB, recessed into the top of the box, meaning that the height is just 28mm and even less than it would be with the box’s included lid. The display is a 1.3-inch (33mm) diagonal OLED, about the smallest type of display capable of showing graphics. It can also display multiple lines of text. We used this sort of screen in the Advanced SMD Test Tweezers (February & March 2023; siliconchip. au/Series/396). No expensive ADC (analog-to-­ digital converter) or DAC (digital-to-­ analog converter) chips are used in this design. Instead, a Pico microcontroller board uses its onboard 12-bit ADC (see panel later) to sample the input and a filtered PWM (pulse width modulation) peripheral to drive the output. The Pico also has an onboard 3.3V switchmode regulator that can operate in PFM (pulse frequency modulation) siliconchip.com.au Fig.1: the Analyser is implemented mainly in software running on the Pico. By only making connections along one side of MOD1, we can mount the Pico on its edge, saving PCB space. and PWM modes. We use the PWM mode, as the PFM mode can introduce low-frequency artefacts under the light load levels that this circuit draws. A clean 3.3V rail is important for this application, as it is used to set the output level and as the reference for the ADC. While a switchmode regulator is not the best choice for high-­ quality audio, using the Pico’s onboard regulator also removes the need to provide separate circuitry and saves us further on hardware costs. Circuit details Fig.1 shows the circuit diagram of the Pico Analyser. MOD1 is the Raspberry Pi Pico microcontroller module. The input stage of the Pico Analyser receives a signal via the RCA socket at CON1. A 4.7kW resistor combined with a 1nF capacitor gives a low-pass filter with a -3dB point of around 34kHz. This reduces any high-frequency components that the ADC might alias. The 100kW resistor keeps this signal biased to ground whenever nothing siliconchip.com.au is connected. A 10μF capacitor AC-­ couples the signal so that the Pico’s analog input pin (AIN, pin 31) can be DC-biased to 1.65V (half of the 3.3V supply) by another 100kW resistor. The incoming network attenuates the audio slightly, to around 91% of its original level. That means that voltages up to 3.6V (peak-to-peak) can be measured before clipping occurs, corresponding to around 1.2V RMS. Switch S6 can connect a 510W resistor in parallel to the first 100kW resistor, changing the divider formed with the 4.7kW resistor. This allows levels up to 34V peak-to-peak (or 12V RMS) to be measured without clipping. This resistor does change the filter characteristics and may let in more higher-­ frequency components than the ×1 range. The output signal from the Pico (DOUT, pin 21) is a PWM signal at around 250kHz, so it first passes through two RC filter stages, each consisting of a 2.2kW resistor and 1nF capacitor. A 100kW resistor also biases Australia's electronics magazine this to the 1.65V rail so that a known level is present if the pin is not being driven. The two RC stages give a similar -3dB point to the input stage, attenuating the 250kHz PWM artefacts by 24dB in total, compared to the 12dB for a single stage. The result is not hifi, but good enough for our purposes. This signal is buffered by IC1b, then AC coupled and biased to ground by another 10μF/100kW pair before being made available at CON2. The filtering and biasing mean that around 3.1V peak-to-peak is available from a 3.3V rail, or about 1.1V RMS, although this is limited by the op amp’s drive near its rails and will depend on the output load. Buttons S1-S4 are connected to other available digital input pins. These are used to provide controls for the user interface. Internal pullup currents supplied by the Pico hold the corresponding pins high unless the switches are closed, pulling the attached pins to ground. November 2023  37 Power supply Important to the circuit’s operation is a schottky diode internal to MOD1, from its VBUS pin (40) to its VSYS pin (39). The Pico’s switchmode regulator is fed from VSYS and its output is available at the 3V3 pin. You’ll note that only one side of the Pico has connections. By mounting it on its edge against the PCB, we save much PCB space and it fits more easily in the box. The circuit can be powered from a USB supply via the Pico’s onboard USB connector, leaving around 4.7V available at the VSYS pin. Alternatively, power from a rechargeable lithium battery is provided via D1 when switch S5 is closed, giving around 3.4-3.9V at VSYS. The regulator on the Pico can handle between 1.8V and 5.5V, so these are all comfortably within its operating range. When USB power is available, the battery is charged by IC2. The two 10μF capacitors provide the input and output bypassing it requires, while a 10kW resistor between its pin 5 (PROG) and ground sets the charge current to 100mA. The STAT pin (pin 1) is low during charging and goes high when charging is complete, so the bi-colour LED will show the charging state: red during charging or green when charged; separate 1kW resistors limit the LED currents. MOD2 is a 1.3-inch (33mm) OLED display module. Its VCC pin is fed with whatever voltage is available at the Pico’s VSYS pin, and its onboard regulator provides 3.3V for its operation, as well as internal pullups for the I2C control lines, SDA and SCL. The I2C lines are taken back to the appropriate pins on the Pico so the Pico can update the display. IC1 is a low-voltage dual op amp, and it too is fed from the VSYS rail with a 10μF supply bypass capacitor. Since VSYS is slightly higher than 3.3V, this provides a bit more headroom than the 3V3 rail would allow. The 3V3 rail is divided by a pair of 10kW resistors and bypassed by the 10μF capacitor to give the 1.65V mid-rail reference. This is buffered by unity-­gain op amp IC1a. The Pico has four ADC channels, with one internally connected to VSYS via a divider, so two are left after we’ve fed in our audio signal. We’ve connected one of these to the 1.65V rail 38 Silicon Chip so the Pico can check that it is correct. The remaining ADC channel is connected to a divider comprising two 22kW resistors across the battery downstream of the switch. This allows it to read the battery voltage when S5 is closed, ensuring the battery is not drained when the unit is switched off. Software We used the Arduino IDE to create the software, mainly because so many libraries are available. We use OLED libraries from Adafruit that make generating the graphics needed for the spectrum, oscilloscope and frequency response modes easy. The audio generation software is a fairly straightforward PWM implementation, where the PWM duty cycle is updated between samples to provide a varying waveform. It is based on the software we wrote for the Pico BackPack, which has a stereo audio output (siliconchip.au/Article/15236). While we’re using 8-bit PWM, the data is calculated and stored as 16-bit samples, with the PWM data derived from the upper eight bits. Then the remainder due to the lower eight bits is dithered over several PWM cycles per sample period, slightly improving the effective resolution. A block of samples equivalent to about 200ms is generated to provide this data. For all but the lowest frequencies, this means that the frequency does not need to divide evenly into the sampling rate since the sample block contains multiple cycles. We use the second processor core to calculate and update the dithered samples. That is about all the second processor does, so not much can interrupt audio generation once it is running. A similar technique is applied to the analog input sampling. The 12-bit The right-hand end of the case has two holes for the RCA sockets and a notch for S6. ADC runs at 490kHz, very close to its maximum speed of 500kHz. The DMA peripheral captures a block of samples over about 1/10th of a second without interrupting either processor. This means we can detect frequencies down to around 10Hz. The performance of the ADC is a little disappointing; it turns out that the RP2040 chip on the Pico has some problems with the ADC peripheral (see the panel for details). Our software applies adjustments to the ADC readings to compensate for this somewhat. It helps, but the ADC still only has about nine effective bits. The oscilloscope mode uses the raw samples for its display, which provides adequate resolution for the 50-pixel vertical axis. The other modes apply downsampling before running a Fourier transform to extract the frequency elements of the sampled waveform. Much of the software is involved in drawing the various displays and user interfaces. Construction First, use the blank PCB to mark the box, then perform the cuts shown in Fig.2. One end of the box has a notch Fig.2: many of these cuts can be made without measuring. The notches for the switches at the top of the box can be marked using the PCB as a template, while the holes for the RCA sockets do not need to be precisely located, as the sockets are wired with flying leads. Australia's electronics magazine siliconchip.com.au Fig.3: the rear of the PCB also forms the device’s front panel, so all components are surface-mounting. It’s a bit cramped with the OLED and Pico adjacent. We recommend fitting the Pico first and ensuring it is aligned with the hole for its USB socket, then fit the OLED and check its operation before continuing. Note that the OLED is mounted face-down on the rear side. for S5 and the Pico’s USB socket, while the other has a notch for S6, plus two holes for the RCA sockets. The notches can be marked using the edge of the PCB, which might be easier than using a ruler to find the midpoint. Make a pair of vertical cuts on each side, not quite to the desired depth, with a sharp hobby knife or hacksaw. Score along the bottom of the notches with a sharp knife, then carefully flex the tab, which should break off along the scored line. Tidy the corners and edges to the correct depth with a small file or sharp knife if necessary. Mark out the slot for the USB socket and start by drilling two or three holes inside the lines. Then use a small file or sharp-pointed hobby knife to square up the edges of the slot. We can use this slot later to align the Pico correctly, or alternatively, we can make the Pico fit it more easily than we can adjust the hole! The RCA sockets mount in drilled holes that can be made with a twist or step drill. Their exact positions are not critical, as the sockets are connected by flying leads. The measurements shown match our prototype and work well. The front-facing side of the PCB. siliconchip.com.au Starting with a smaller 3mm pilot hole will make it easier to align the holes and adjust them if they are not aligned. We’ve specified 7mm holes to suit the RCA sockets we’ve used, but check if a different size is required for your parts. PCB assembly Many of the components are fairly large standard SMDs. There are a few parts that are mounted in a slightly unorthodox fashion. We recommend starting by fitting the SMDs; you will need a fine-tipped iron and solder, flux paste, tweezers and good illumination. Some solder-wicking braid will be handy, as will some solvent to clean up any excess flux. Use fume removal (such as a fume removal hood) to ensure you are not exposed to smoke from the flux. If that is not possible, work outside in fresh air. Refer to the Fig.3 overlay diagram for the component placements and orientations. You should also consult the photo showing the PCB fitted with surface-mounting parts. The components are pretty close together, and IC2 is the smallest part, so start with it. Put some flux paste on the pads and align the five pins with them; they will only fit one way. Tack one lead on the side with two pins and check that all the other pins are within their pads, adjusting as necessary. Solder the remaining pins and then go back to refresh the first pin. Check for bridges and use solder wick and fresh flux to draw excess solder away, if necessary. Use a similar technique for IC1. Its pins are more widely spaced, so soldering should be easier. Make sure pin 1 of IC1 (which might be marked with a bevel along one edge) is aligned to the dot on the PCB silkscreen. The capacitors are spread around the PCB. Be sure not to mix up the two values, although the 10μF parts will probably be thicker than the 1nF parts. The different resistor values all need to go in the correct locations too. For these passives, use the same basic soldering technique. Solder one lead, then check and adjust before soldering the other lead. The single diode is a bit larger, and you must ensure its polarity is correct, with its cathode stripe towards the “K” on the PCB. If this is reversed, you risk connecting the battery directly to the USB supply, which will probably cause something to burn out. Now is a good time to clean the PCB with a flux solvent. Doing so now avoids the possibility of solvents getting into the switch mechanisms. Isopropyl alcohol is a good all-round choice. Allow the PCB to dry thoroughly before continuing. Fit slide switches S5 and S6 next. They have small leads but are easy to align as they have locating pins in their November 2023  39 Use this photo as a guide to fitting the smaller components. This stage of assembly is a good point to clean off any excess flux in preparation for adding the final components like the switches, LED, Pico and OLED. undersides that lock into holes in the PCB. Tack one lead, confirm that they are flat and then solder the other leads. Next, fit the four reverse tactile switches, S1-S4. We found it helpful to splay the leads out from the bodies so that the switch stems protrude further through the PCB holes. This makes them easier to operate. After soldering one pin, it’s also a good idea to check that the switch stems are centred in their holes through the PCB. That will ensure the front panel looks good and eliminate the possibility of the stems jamming on the PCB. Once you’re happy with them, solder the other three pins on each switch. Be sure to use a generous amount of solder to ensure that they have good mechanical strength. The tricky bits The LED is mounted unusually. While bi-colour SMD LEDs are available, they often have independent leads for the two LEDs, making the pads small and tricky to solder, so we’re using a 3mm through-hole LED as a reversed surface-mounting device. The pad marked K corresponds to the cathode of the red LED inside such a device. If you’re unsure and don’t have the means to test it, just fit the LED one way; if it is incorrect, swap the leads. Carefully bend the leads by 180° and trim them so they are slightly longer than the LED lens. As you can see from our photo overleaf, the tip of the LED is pointed at the opening in the solder mask (facing towards the PCB). Solder the LED leads to the two pads. Fine-tipped tweezers will help to position the component until one lead is soldered. Solder the other lead, then refresh the first joint. The next part is the Pico module. Before proceeding, check that the PCB (with S5 and S6 mounted) sits flush and slots neatly into the box’s notches. The top of the PCB should sit level with the surrounding box. This is to ensure that the USB connector on the Pico can align correctly with the slot in the box. Adjust the notches in the box if necessary. Working with just one end pad on the Pico, tack it roughly into place at right angles to the main PCB. The Pico’s PCB should sit back slightly from the edge of the main PCB, with the USB connector protruding slightly. Note its relative orientation, with the VBUS pin closest to the edge of the PCB and GP16 at the other end. The USB socket should be above the corresponding marking on the silkscreen too. Tack one pad at the other end and carefully adjust the Pico to be at right angles to the main PCB. Test it in the box and see that it is aligned with the slot. Remember that the top of the PCB will sit flush with the top of the box. Once you are happy with the location of the Pico, solder the remaining pins. We found it easiest to feed in the solder from the bottom of the Pico (on the side facing the switches) and apply the iron to the other side, ie, the Pico’s top. Ensure there is a generous fillet on each of the 20 pins to hold the module securely. Now cut the LED lead offcuts (or other fine wire) into four pieces, each about 1cm long. It will help if they are all slightly different lengths to stagger their insertion into MOD2’s pads. Using the tweezers to hold each one, solder them to the centre of the pads for MOD2. They should sit vertically. The Analyser is fully wired up, with its lid open. Note how the LED, OLED and Pico modules have been mounted. Extending the wires from the battery holder allows the lid to be folded open as shown; a generous amount of neutral-cure silicone helps to secure and insulate the battery leads. 40 Silicon Chip Australia's electronics magazine siliconchip.com.au Remove the protective film from the front of the OLED and place it facedown over these wires and flat against the main PCB. You will see that the backwards markings on the PCB now correspond to the OLED pins. Finally, solder each wire to the OLED. Be gentle, as there is little more than surface tension holding the pin in place to the main PCB. You might need to adjust the wire with tweezers. Verify that the OLED is accurately aligned with the silkscreen markings. If it is not, the misalignment will be evident in use. Now is a good time to run some quick tests to ensure that the OLED and Pico are correctly soldered, but the Pico will need to be programmed if it is not already. Programming the Pico Hold the white BOOTSEL button while connecting the Pico to a computer via a USB cable. You might not need to hold the button if you have a new, unprogrammed Pico. Picos supplied in kits are generally not programmed as it’s easy for constructors to do. Then copy the 0410723A.UF2 file to the RPI-RP2 drive that should appear on your computer’s file system. If everything is working, you should see the OLED screen light up after a second. If not, go back and check the solder joints and component placement. Verify that the display contents are square within the PCB cutout. If they are not, you might be able to gently twist the OLED by a small amount. Completion With the OLED aligned, use the remnants of the lead offcuts to secure its two lower holes to the matching pads on the PCB. The connection should work much the same as for the four smaller pads on the top of the OLED module. Prepare the RCA sockets by disassembling them. Cut two pieces of white wire about 4cm long and two pieces of black wire about 4cm long. The colours are not critical, but using two contrasting colours will help identify them. Solder one end of each of the white pieces of wire to the centre connection of an RCA socket. Similarly, solder one end of each black wire to the washer, which becomes the ground connection. siliconchip.com.au Parts List – Pico Audio Analyser 1 double-sided PCB coded 04107231, 83 × 50mm, with black solder mask 1 UB5 Jiffy box (83 × 53 × 30mm) 2 chassis-mount RCA sockets (CON1, CON2) [Altronics P0161] 1 single AA cell holder with flying leads 1 14500 (AA-sized) Li-ion rechargeable cell with nipple 1 Raspberry Pi Pico micro board, programmed with 0410723A.UF2 (MOD1) 1 1.3-inch (33mm) OLED module (MOD2) [Silicon Chip SC5026] 4 reverse-mount SMD tactile switches (S1-S4) [Adafruit 5410] 2 SPDT SMD slide switches (S5-S6) 4 M3 washers, 1.5mm thick 2 20cm lengths of hookup wire (eg, white and black) 1 4cm length of fine bare wire (eg, lead offcuts from LED1) 1 small tube of neutral-cure silicone sealant 1 short RCA-RCA cable (for testing & calibration) Semiconductors 1 MCP6002 or MCP6L2 rail-to-rail dual op amp, SOIC-8 (IC1) 1 MCP73831-2ACI/OT Li-ion charge regulator, SOT-23-5 (IC2) 1 bi-colour red/green 3mm LED (LED1) 1 SS34 40V 3A schottky diode, DO-214 (D1) Capacitors (all M3216/1206 size, X7R ceramic) 6 10μF 16V+ 3 1nF 50V Resistors (all M3216/1206 size, 1% 1/8W) 4 100kW 2 2.2kW Pico Audio Analyser Kit 2 22kW 2 1kW 3 10kW 1 510W SC6772 ($50): includes the PCB and 3 4.7kW everything that mounts directly on it. The Pico is supplied blank and Assemble the sockets into the will need to be programmed using a holes in the enclosure by securing computer and USB cable. the washer with the nut. Adjust them such that the wires poke out the top We do not want these to come loose, of the box, then bend them over the as there is a good chance that their end of the box. bare ends would cause the battery to Next, place the PCB upside down be short-circuited. next to the enclosure and solder the While waiting for the silicone to wires, as shown in the photos opposite cure, you might like to also add some and overleaf. The two black wires go more to CON1 and CON2 on the PCB to to the GND pads on CON1 and CON2, secure the audio connections, as well while the white wires go to the corre- as any exposed metal on the outside of sponding pads marked IN and OUT. the battery holder itself (for example, Use a generous amount of solder to ensure a firm connection. Using neutral-cure silicone or similar gap-filling glue, secure the battery holder to the bottom back corner of the box, with the opening facing outwards. Solder the wires to the BAT+ and BAT- pads on the PCB, being sure to connect the red wire to BAT+ and the black wire to BAT-. If you do not have an RCA-RCA On our prototype, we slightly cable, a simple loopback cable extended one of the battery leads to like this can be made by soldering allow the PCB to fold fully open away a short wire between the centre from the box. That simplified testing pins of two RCA plugs. Such a and assembly. cable is necessary for testing and Like the RCA sockets, use a generous calibrating the Analyser. We also solder fillet to secure the battery leads. found it handy to have a pair Apply silicone around the BAT+ and of RCA plugs fitted with jumper BAT- pads to further secure the batwires to allow connecting to a breadboard for experimentation. tery leads and insulate any bare wire. Australia's electronics magazine November 2023  41 Another close-up of the finished Pico Audio Analyser. Note that the LED is mounted upside-down, as shown in the insert. the previous step. Press OK to proceed to the next screen. Screen 5 sets the INPUT LEVEL on the ×10 range, so leave the cable connected and change S6 to the ×10 range. You will see a prompt similar to the previous step; press DOWN when it appears. Screen 6 is used to save those parameters to flash memory; press DOWN to do so, and you should see a message reporting that this has occurred. If the settings have somehow become corrupted, you can use the UP button here to restore the defaults. Operation around the battery’s contacts with the holder). After the silicone has cured fully, fit the battery, making sure to check its polarity. Switch the unit on with S5 and confirm that the OLED illuminates after about a second. If it does not, remove the battery and check for any problems. Apply power to the USB socket and see that the LED lights up red initially and then goes green when the battery finishes charging. If the LED starts green, it might be reversed. It’s a good idea to remove the battery before making any changes to the circuit. Four washers sit between the PCB and the box’s pillars to keep the PCB flush with the top of the box, so thread these over the screws as you screw them into the box. Take care that you don’t pinch any of the wires. Calibration After some calibration steps, the Analyser will be ready to use. The Analyser will function without calibration, but its accuracy will not be as good. You’ll need a multimeter or oscilloscope that can accurately measure a 500mV AC RMS signal and an RCA plug to RCA plug cable to make a loopback connection between the input and output. We used a pair of RCA plugs with a short piece of wire connecting their centre terminals (the ground connection is made via the PCB in this case). 42 Silicon Chip Power up the Analyser using a USB cable to give the battery a chance to charge. The splash screen shows for a few seconds as the bias voltages stabilise. Press the MODE button until the SETTINGS screen appears (Screen 1), then press OK. Screen 2 shows the first calibration item, the INPUT OFFSET. Ensure nothing is connected to the input and wait until the value seen on the fourth line settles to a steady value and press the DOWN button, then OK. Screen 3 is the OUTPUT LEVEL calibration. The Analyser will deliver a nominal 500mV RMS sinewave, which should be measured at the CON2 output. Use the UP and DOWN buttons to adjust the calibration ratio until your meter reads 500mV, then press OK. Screen 4 sets the INPUT LEVEL for the ×1 range. Connect the CON2 output to the CON1 input and set switch S6 to the ×1 position. Since the Analyser knows it should be receiving a 500mV signal, it can calculate the calibration ratio easily. When you see the “DOWN to set” message, press the DOWN button to load the calculated ratio. This allows us to check that a valid signal is used for the calculations. If you don’t see this message and are sure that S6 is set correctly, there could be a minor problem with the PCB, such as a resistor being the wrong value. This step also depends on the 500mV reference being set correctly in Australia's electronics magazine The remaining screens show the operating modes. The MODE button cycles between the modes, while the UP, DOWN and OK buttons provide controls within each mode. Generally, a pair of angle brackets <> highlights the value being changed. When switching between ×1 and ×10, the input mode must also be manually changed on the SETTINGS page to match. Pressing DOWN selects the ×1 mode (and uses the ×1 calibration factor), while pressing UP selects the ×10 mode. The last line of this page shows the current scaling. The top right corner of the SETTINGS page shows the battery voltage when the power switch (S5) is turned on. Take care that the Analyser is not left switched on when not in use, as there is nothing to prevent the battery from being overdischarged. The first mode (seen in Screen 7) controls the WAVE OUTPUT. This will continue to run at its last setting unless another mode needs to take control of the output. This can occur when a SWEEP is run, or the SETTINGS needs to produce its calibration waveform. The OK button cycles between the various parameters, while the UP and DOWN buttons change them. The set frequency can vary between 10Hz and 10kHz; the frequency steps are smaller for lower frequencies. Since the Pico has a crystal oscillator, we have provided no frequency calibration adjustment. The frequency accuracy of the crystal is around 30ppm (0.003%), which is good enough. The output level can be set in steps of 50mV as either peak-topeak or RMS, and the corresponding equivalent values are displayed siliconchip.com.au depending on what is selected. The ratio between the peak-to-peak and RMS values changes depending on the waveform. Values up to about 2V peak-to-peak should give clean outputs before op amp drive limits come into play, depending on the output load. The chosen op amp is quite robust and can handle an output short circuit indefinitely. The next option cycles between sine, square, triangle, sawtooth and white noise waveforms, while the last option allows the signal to be turned off or on without changing any other settings. Internally, the Analyser generates a 0V amplitude waveform when the output is off. The SPECTRUM mode displays the spectrum of the input waveform (Screen 8). The UP and DOWN buttons change the horizontal scale, while the OK button switches the vertical scale between the PEAK and TOTAL (RMS) amplitude. As the Fourier Transform includes a windowing step, even a pure sinewave will typically be spread across multiple frequency bins. The Low Frequency Distortion Analyser article from April 2015 has more information about windowing (siliconchip. au/Article/8441). The calculated peak frequency is interpolated between the bins and may also be slightly off due to rounding errors. The SCOPE mode (Screen 9) simply shows the shape of the waveform as you would see on an oscilloscope. The UP and DOWN buttons change the horizontal (time) scaling, while the OK button toggles between dots and lines for the plot. You might find the line mode clearer when many cycles are displayed. The vertical scaling is automatic and based on the amplitude, shown as a peak-to-peak value on the left. The SCOPE attempts to trigger on a positive-­ going zero crossing and, if not, will simply display the last part of the sample it has taken. Screen 1: when the Analyser is first powered up, use the MODE button to cycle through to the SETTINGS page to perform the calibrations. Press OK to start the process. Screen 6: press OK again to see this screen and then DOWN to save the calibration values to flash memory. You will see a message confirming that it was done. Screen 2: to set the INPUT OFFSET, leave the input open and allow the displayed level to settle to a steady value. Then press the DOWN button to store this value, followed by OK. Screen 7: pressing OK on the WAVE OUTPUT screen cycles between the parameters, while UP and DOWN modifies them. The USB serial port can also control the output waveform. Screen 3: use an AC RMS meter or similar instrument to measure the output and adjust (using UP and DOWN) until the meter reads 500mV, then press OK. Screen 8: the SPECTRUM display uses UP and DOWN to change the horizontal scaling, while OK toggles the vertical scale between peak and total energy. Screen 4: connect the input to the output with an appropriate RCA cable for the next steps. Ensure the range switch S6 is set to 1x and press DOWN when prompted, then OK. Screen 9: the SCOPE display also uses UP and DOWN to change the horizontal scaling. The OK button changes between dot and line displays. Screen 5: follow the prompts and set the switch to 10x. You will see a message if S6 is set to the wrong position or a signal is not detected. Press DOWN to set the scaling factor, followed by OK. Screen 10: HARMONIC ANALYSIS provides information about the harmonic content of a waveform. Connecting the input to the output is a good way to check this feature. Harmonic analysis HARMONIC ANALYSIS (Screen 10) provides information about the detected fundamental frequency, an analysis of the harmonics and the measured THD (total harmonic distortion). The UP, DOWN and OK buttons do nothing in this mode. siliconchip.com.au Australia's electronics magazine November 2023  43 Flaws in the RP2040 ADC Our initial design for the Pico Analyser had some optimistic targets. As the RP2040 microcontroller claims to have a 12-bit ADC (analog-to-digital converter), we hoped to get something near the equivalent of 14 bits of resolution with oversampling. However, connecting the output of our Audio Precision System One (with a THD+N figure of around 0.0004%) to the Analyser only gave a reading of around 0.3%, closer to eight effective bits of resolution. Some digging into the RP2040 data sheet revealed an erratum relating to the ADC peripheral that stated the claimed ENOB (effective number of bits) was, in fact, closer to eight. The ADC is a successive approximation register (SAR) type, which uses tiny capacitors arranged with binary weighting within the chip to measure voltages. The total capacitance is around 1pF, meaning the smaller capacitors are on the order of femtofarads (fF or 10-15F)! 44 Silicon Chip Some people have determined, after thorough testing, that the value of some of these capacitors is off by around 0.8%, starting at the third most significant bit (MSB); see https://pico-adc.markomo.me/INL-DNL/ The folks at the Raspberry Pi Foundation have indicated that this is due to a discrepancy between their design simulations of these sampling capacitors and the actual silicon. To test the effect on our own hardware, we temporarily modified the program to count the number of times each different ADC value (4096 possibilities) appeared within a sample set. We then used the Analyser’s wave source to generate a triangle waveform. A triangle wave should spend an equal time at each level (within the waveform’s amplitude) since the slope (amplitude/time) is constant for each half cycle. Fig.4 shows the result of this analysis. Note the zero counts at each end, showing values outside the wave amplitude. There are also slight peaks near the tips of the waveform as the slope changes direction and the Fig.4 waveform is rounded off slightly. The four prominent peaks in an otherwise fairly flat plot show that the ADC ‘thinks’ the waveform is spending longer at these values than it should. The ‘troublesome’ ADC values are 511, 1535, 2559 and 3583, all pointing to problems with the third MSB. This means that the ADC can’t accurately measure voltage around these points. While the input changes by around 10 steps, the ADC output value doesn’t change. The reading is off at times by as many as five steps, and is not responding linearly. The INL (integral non-linearity) plot from the RP2040 data sheet (Fig.5) shows this in another way. This plot shows the deviation in the perforFig.5 mance of the actual ADC from that of an ideal ADC. In practice, the line should be quite flat. The final Analyser software includes a correction stage that attempts to compensate for the ADC non-linearity. This brings the measurable THD down to 0.3% from 0.4%. The applied correction is shown in Fig.6. This makes it act like the four ADC values noted above occupy a wider space in the span. That makes the overall plot more linear, but we still cannot get around the fact that these values occupy a wider range of voltages than the others. This plot is similar to the INL plot. We also tried to apply the INL plot as a correction, as well several Fig.6 others, including some that correct for the lesser errors in some of the other ADC bits. In practice, we chose this one as it gave the best improvement in distortion readings. The correction data is stored in an array named “ADCADJ” in the “util.h” file. To see the effects before adjustment is applied, you can comment out calls to the ADCfix() function. Currently, all RP2040 chips in circulation have this flaw. We may see future chip releases which correct the issue and render the adjustment obsolete. The lesson from all this is: always read the data sheet! Australia's electronics magazine siliconchip.com.au If you are measuring the Analyser’s output, you will see THD figures around 1% for a sinewave, with about 0.7% due to the output stage and 0.3% due to the input stage. These figures will vary depending on the frequency. The final mode is the frequency sweep and response. Screen 11 shows the setup, while Screen 12 shows the results. The lower and upper frequencies can be set in powers of 10 between 10Hz and 10kHz, and up to 30 steps can be applied. Each step takes about 1/3 of a second to process. There is also the option of running a single sweep pass or a continuously updating loop. The default of 10 steps over this range gives a typical display seen in Screen 12; this is with the output connected to the input. The horizontal frequency scale is logarithmic; the dashed grid lines correspond to the second and fifth divisions of their respective decades. The vertical scale is adjustable with the UP and DOWN buttons and the intermediate grid line corresponds to the -3dB point. As an exercise, we connected a simple low-pass RC filter circuit (using a 1kW resistor and a 1μF capacitor) between the input and output. As expected, the SWEEP showed a -3dB point around 160Hz, rolling off more at higher frequencies. While a direct connection from output to input should give a perfectly flat response, there are slight dips at 10Hz and 10kHz as the low-pass and high-pass filters start to take effect. The small peak around 20Hz is a side-effect of the windowing function. Pressing OK from the graph page will end the looping behaviour, or if <OK> is shown, return to the setup menu. Screen 11: SWEEP uses the UP, DOWN and OK buttons like the OUTPUT mode. There is the option of running a single sweep pass or performing a continuous loop. Screen 12: in this display, the UP and DOWN buttons change the vertical scaling; the unlabelled horizontal line being the -3dB point compared to the set level at the output. Most of the remaining commands emulate the controls of the WAVE OUTPUT mode. Since they will work while another mode is active, they can save you the time of cycling between modes to change settings and then trying to view the results. “a” or “A” followed by a number will set the output RMS amplitude in millivolts. For example, “a500” sets the output to 500mV RMS. Similarly, “p” or “P” will set the peak-to-peak amplitude in millivolts. The “f”/“F” option sets the frequency in Hertz, the “w”/”W” command sets the type of waveform, while “o”/“O” turns the wave output off or on. Note that setting parameters too high might result in corrupted waveforms. Another command, “d”/“D”, provides a ‘data dump’ of the next scan in the SCOPE, SPECTRUM, HARMONIC ANALYSIS or SWEEP modes. The data is formatted similarly to a CSV (comma-­separated variable) file, so you can paste the data directly into spreadsheet programs that support CSV data. For a SWEEP, the dump will occur after the next pass has completed; Screen 13 shows the same data as in Screen 12 as a spreadsheet. Finally, the “~” command resets the Pico. Holding the BOOTSEL button while issuing this command will enter bootloader mode for reprogramming the Pico. siliconchip.com.au The Pico Analyser is a simple and compact device that uses little in the way of hardware apart from the Pico itself. Its performance is modest, but we think its simplicity and cost make SC it a handy tool. Screen 13: the “d” command at the serial terminal triggers a dump of data in CSV format. We pasted the data shown here, from the SWEEP mode, into a spreadsheet program. Computer control Since we have a USB port on the Pico, we use it to provide alternative controls and data outputs. We recommend using a terminal program such as TeraTerm (on Windows) or minicom (on Linux), as the Arduino serial monitor is quite basic. Most commands are followed by the Enter key, but the commands that emulate the buttons on the Analyser act instantly. For a full list of commands, type “?” and press Enter. The keys listed at the bottom emulate the four onboard buttons. Conclusion Screen 14: this view of TeraTerm shows the commands provided by the virtual USB serial port. The list can be shown by using the “?” command. Australia's electronics magazine November 2023  45