Silicon ChipArduino-based Adjustable Power Supply - February 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: New computer technology
  4. Feature: Radio Time Signals throughout the World by Dr David Maddison
  5. Feature: Follow-up: Quantum-dot Cellular Automata by Dr Sankit Ramkrishna Kassa
  6. Project: Battery Multi Logger by Tim Blythman
  7. Project: Arduino-based Adjustable Power Supply by Tim Blythman
  8. Serviceman's Log: A feline-themed cautionary tale by Dave Thompson
  9. Project: Electronic Wind Chimes by John Clarke
  10. Feature: Making Android Apps with App Inventor by Roderick Wall
  11. Feature: Making a Compact Virtual Electronics Workbench by Tim Blythman
  12. Feature: Upgrading your Computer to the latest CPU by Nicholas Vinen
  13. PartShop
  14. Feature: El Cheapo Modules: LCR-T4 Digital Multi-Tester by Jim Rowe
  15. Vintage Radio: Philips 1952 BX205 B-01 AM/SW battery valve radio by Charles Kosina
  16. Market Centre
  17. Notes & Errata: Busy Loo Indicator, January 2021; Mini Digital AC Panel Meters, January 2021; Radiating test antenna for AM Radios, Circuit Notebook, January 2021; Vintage Battery Radio Li-ion Power Supply, December 2020; Colour Maximite 2, July-August 2020
  18. Advertising Index
  19. Outer Back Cover

This is only a preview of the February 2021 issue of Silicon Chip.

You can view 34 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.

Items relevant to "Follow-up: Quantum-dot Cellular Automata":
  • QCA follow-up: Potential Energy Explanation (Software, Free)
Articles in this series:
  • Quantum-dot Cellular Automata (August 2019)
  • Follow-up: Quantum-dot Cellular Automata (February 2021)
Items relevant to "Battery Multi Logger":
  • Battery Multi Logger PCB [11106201] (AUD $5.00)
  • PIC16F1455-I/SL programmed for the Microbridge [2410417A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC32MX170F256B-I/SO programmed for the Battery Multi Logger [1110620A.hex] (Programmed Microcontroller, AUD $20.00)
  • DS3231MZ real-time clock IC (SOIC-8) (Component, AUD $8.00)
  • DS3231 real-time clock IC (SOIC-16) (Component, AUD $7.50)
  • 2.8-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $25.00)
  • SMD resistor - 15mΩ ±1% M6332/2512 3W (CRA2512-FZ-R015ELF or similar) (Source component, AUD $2.00)
  • Matte/Gloss Black UB3 Lid for 2.8-inch Micromite LCD BackPack (PCB, AUD $5.00)
  • Battery Multi Logger software [1110620A.hex] (Free)
  • Battery Multi Logger PCB pattern (PDF download) [11106201] (Free)
Articles in this series:
  • Battery Multi Logger (February 2021)
  • Battery Multi Logger - Part 2 (March 2021)
Items relevant to "Arduino-based Adjustable Power Supply":
  • Arduino-based Adjustable Power Supply PCB [18106201] (AUD $5.00)
  • SMD resistor - 15mΩ ±1% M6332/2512 3W (CRA2512-FZ-R015ELF or similar) (Source component, AUD $2.00)
  • MCP4251-502E/P dual 5kΩ digital potentiometer (Component, AUD $3.00)
  • Arduino-based Adjustable Power Supply Software (Free)
  • Arduino-based Adjustable Power Supply PCB pattern (PDF download) [18106201] (Free)
Articles in this series:
  • Making a Compact Virtual Electronics Workbench (February 2021)
  • Arduino-based Adjustable Power Supply (February 2021)
Items relevant to "Electronic Wind Chimes":
  • Electronic Wind Chimes PCB [23011201] (AUD $10.00)
  • PIC16F1459-I/P programmed for the Electronic Wind Chimes [2301120A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Electronic Wind Chimes software [2301120A.hex] (Free)
  • Electronic Wind Chimes PCB pattern (PDF download) [23011201] (Free)
Articles in this series:
  • Electronic Wind Chimes (February 2021)
  • Electronic Wind Chimes - Part 2 (March 2021)
Items relevant to "Making Android Apps with App Inventor":
  • TDR Android app (made using App Inventor) (Software, Free)
Items relevant to "Making a Compact Virtual Electronics Workbench":
  • Arduino-based Adjustable Power Supply PCB [18106201] (AUD $5.00)
Articles in this series:
  • Making a Compact Virtual Electronics Workbench (February 2021)
  • Arduino-based Adjustable Power Supply (February 2021)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 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 4 (February 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 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 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 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 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: 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, Part 2 (June 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: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)

Purchase a printed copy of this issue for $10.00.

0-14V, 0-1A Output – controlled from your PC! Arduino-based Adjustable Power Supply By Tim Blythman We have published all sorts of fancy bench supplies over the years: linear, switchmode, hybrid, high-voltage, high-current, dual-tracking… But sometimes, all you need is a basic power supply with voltage and current monitoring and limiting; something that’s convenient and easy to set up and use. That’s exactly what this is – a very useful little power supply built on an Arduino shield! L ately, like many others, I have mostly been working from home. But unfortunately, my home workshop is not equipped to the same degree as the SILICON CHIP office/lab. I could bring my 45V 8A Linear Bench Supply prototype home (published in October-December 2019; see siliconchip.com.au/ Series/339). It would do pretty much everything I need, but my space is limited, and it would be a rare event to make use of its full capabilities. So I need something more compact but still useful. I decided to base it on something I already had at home, an Arduino Uno. It’s capable of delivering up to 14V at a maximum of 1A. That is modest, to be sure, but handy enough for most smaller projects. And multiple units can be combined if you need several different voltages (eg, 5V & 3.3V). 38 Silicon Chip     Arduino considerations Australia’s electronics magazine Using Arduino hardware means that it would be possible to add one of many plentiful shields and modules to add a custom display or controls for the Supply. But as I already have a computer on my desk, I decided to use the existing screen and keyboard to control it. I wrote a small computer program that controls the Power Supply, providing all of its useful functions without taking up valuable bench space. Thus, the Supply can sit tucked away out of sight, with nothing more than the two output leads snaking out to wherever they are needed. The control program takes up only a small amount of screen space. The combination of the microcontroller on the Uno and the control program allows many features to be added with no extra hardware. For example, the control program allows five preset combinations of voltage and current to be created siliconchip.com.au and instantly activated. This makes it harder to cause damage by inadvertently setting the wrong voltage or current limit. While the Power Supply does not have any form of temperature sensing, it can estimate the thermal effects of a connected load to warn the user of any problems with either the load or the Power Supply itself. Digital controls Features & specifications • • • • • • Output voltage and current: 0-14V, 0-1A Adjusted and monitored via a computer (desktop, laptop, notebook etc) All functions under software control Voltage resolution: around 20mV Current resolution: around 20mA Arduino-based design means it can be expanded upon Fig.1 shows the circuit of the Mini Digital PSU. It is effectively a ‘shield’ or daughterboard which plugs into the top of an Arduino Uno microcontroller board. The Uno board has an ATmega328 microcontroller, a USB-serial interface IC and some voltage regulation circuitry. IC1 is an MCP4251 dual digital potentiometer; it contains two 5kΩ potentiometers with 257 digitally-controlled steps. This chip is controlled over an SPI bus by the Uno, from its SC Ó pins 4, 13 and 11 to pins 1, 2 and 3 of IC1. The ‘tracks’ of the two ‘potentiometers’ are grounded at one end, with a fixed reference voltage at the other end. So the ‘wiper’ voltages vary linearly with the programmed position, up to that reference voltage. The voltage from pin 6 (‘wiper’ 1) is proportional to the desired output voltage, while the voltage from pin 9 (‘wiper’ 0) is proportional to the desired maximum current. ARDUINO-BASED MINI POWER SUPPLY siliconchip.com.au Australia’s electronics magazine Fig.1: the Power Supply uses an Arduino Uno to adjust the output voltage and current, which it does by sending commands to dual digital potentiometer IC1. This, in combination with rail-to-rail op amp IC2 and transistor Q2, forms a control loop to adjust the base drive to emitter-follower power transistor Q1 which regulates the output voltage. Current feedback is via a 15m shunt and amplifier op amp IC3, while the voltages and output current are monitored at the Arduino’s A0-A2 analog inputs. February 2021  39 Scope1: the response to an increase in load which triggers current limiting. The yellow trace is the voltage across the shunt resistor, so is proportional to the current, while the green trace is proportional to the output voltage. There is some current overshoot, mostly due to the output capacitance, after which the current limiting kicks in, reducing the output voltage to reach a steady-state within 1ms. Scope2: the response to a step-change in the set voltage from 5V to 3.3V (with no load). It takes just under 100ms due to the 10uF output capacitor being discharged by the voltage sense divider. Any significant load would speed this up dramatically. The wiper at pin 6 must be a fraction of the desired output voltage, as the digital pot IC has a maximum 5V supply voltage; hence, it can only generate voltages up to 5V. To have a steady output voltage, we need a stable reference voltage. In this case, we’re using the Uno’s 3.3V rail. It comes from a practically unused 3.3V regulator on the Uno, and this is fed to IC1 via jumper JP1. This is also connected to the Uno’s VREF pin, for its internal analog-to-digital converter (ADC) peripheral to refer its readings to. Thus the wiper of P1 (P1W, pin 6) produces a voltage in the range 0-3.3V, which is low-pass filtered by a 10kΩ/100nF RC circuit, then fed to non-inverting input pin 3 of op amp IC2. This is an LMC6482 rail-to-rail input/output CMOS dual op amp, which allows the output to go all the way down to 0V without a negative rail, and this also makes current sensing much easier (as described later). This op amp compares the wiper voltage to a divided version of the output voltage, produced by a 51kΩ/10kΩ divider, which feeds into its pin 2 inverting input. That gives a gain of 6.1 times. Thus around 20V at the output corresponds to the 3.3V full-scale output from digital potentiometer IC1. The output from pin 1 of IC2 drives the base of NPN transistor Q1, which is configured as an emitter-follower. Its collector draws from the Arduino’s VIN supply while its emitter feeds the supply output at CON1 via the contacts of relay RLY1 (more on this later). This transistor effectively boosts the current capability of the op amp output so that it can supply up to 1A (from the VIN supply). The base-emitter voltage drop of Q1 is cancelled out since Q1 is in the negative feedback loop – from pin 1 of IC2, through Q1, then through the 51kΩ/10kΩ output divider back to pin 2 of IC2. Hence, IC2 adjusts its output voltage higher to achieve the set voltage at the common contact of RLY1. While the circuit is set up to enable an output voltage of up to 20V, in practice, other circuit elements limit the practical output voltage to around 14V. The main limit is the 5V regulator on the Arduino board, which in the case of clone boards, is only rated to 15V (see our March 2020 Arduino feature on fixing Arduino for more details, at siliconchip. com.au/Article/12582). Voltage regulation Power transistor Q1 is an MJE3055. Usually, its emitter voltage (ie, the output) is around 0.7V below its base voltage (from output pin 1 of op amp IC2). If the emitter/output voltage rises (for example, due to the load drawing less current), then its base-emitter voltage decreases, which starts to switch it off, causing its emitter voltage to drop. Conversely, if the emitter/output voltage falls, the baseemitter voltage increases and Q1 turns on harder, halting the emitter voltage fall. This ‘local feedback’ provides a very fast response to load transients. While the emitter-follower circuit is fairly good at tracking its input at its output, the base-emitter voltage does vary somewhat depending on the load. To overcome this, the op amp will adjust Q1’s base voltage to maintain the voltage at the output voltage divider near that of the reference value on the digital potentiometer. The op amp reacts more slowly, though, due to its limited gain-bandwidth. Transistor Q1 is fitted with a small finned heatsink, as it works as a linear pass device, dissipating any excess voltage Scope3: a step increase in the set voltage (this time from 3.3V to 5V with a 12Ω load) is much faster due to the Australia’s 40 ilicon Chip lower S impedance of the output transistor, taking just a electronics magazine few milliseconds. siliconchip.com.au between the supply and output. This low-profile heatsink has been chosen so another board can be stacked on top if a custom control or display needs to be added. We have designed the shield so that it does not conflict with pins used for the LCD Adaptor described in May 2019 (siliconchip.com.au/ Article/11629), meaning we could turn this into an allin-one unit by adding an LCD touchscreen in the future. But the current version of the software does not support this. A 10µF output filter provides modest output bypassing, which also improves transient regulation. This value is a compromise since too little output capacitance would worsen its regulation, and too much capacitance would limit the Power Supply’s ability to quickly limit its output current under short-circuit conditions. Between Q1 and IC2, the feedback loop has a lot of gain, so care must be taken to ensure it does not oscillate. A 100nF capacitor from the reference voltage at pins 7 & 8 of IC1 preventing transients from being seen by the op amp, which would otherwise be duplicated at the output. Similarly, the desired voltage signal at pin 3 of IC2 is stabilised with another 100nF capacitor. There is also a 100nF feedforward capacitor across the 51kΩ upper feedback divider resistor, which reduces closedloop gain by a factor of six or so for fast transients. Also, a 1nF capacitor is connected between the output (pin 1) and inverting input (pin 2) of IC2, limiting the op amp output slew rate. Another way of thinking about this is that it provides increased negative feedback at high frequencies. This prevents it from oscillating. The low-pass filter formed by Q1’s 100Ω base resistor and the 10µF capacitor from its base to ground also helps to stabilise the feedback loop. Output relay The output switching relay is a reed relay. Its coil is driven from the Arduino’s D5 digital output. This is possible since the coil current of a reed relay is modest. Unfortunately, the digital potentiometers in IC1 start with their wipers at mid-point, so a voltage will be present at the output without RLY1 disconnecting it initially. RLY1 is only energised once the regulator output voltage has settled at the desired level. RLY1 also acts as a load disconnect switch, allowing the circuit to obtain the desired output voltage without the load being connected. It can then quickly connect the load to the already correct voltage, rather than having to ramp it up. Similarly, it can quickly disconnect the load in case of an over-current or short-circuit condition. Current limiting The current limiting employs a similar feedback loop to the voltage control. Here, we use the simplest current sensing possible. A 15mΩ shunt resistor in the return current path, from pin 2 of output terminal CON1 to ground, converts the load current into a voltage. siliconchip.com.au This is fed, via a 1kΩ/100nF RC low-pass filter, to the non-inverting input (pin 3) of IC3, a second op amp. Since this only needs to handle up to around 3.3V, we’re using a cheaper MCP6272 dual op amp IC (its other half is not used). IC3 amplifies the shunt voltage by a factor of 151 (150kΩ/1kΩ + 1). The amplified sense voltage is then fed to IC2’s pin 5 (its second noninverting input). So 2.2V voltage at pin 5 of IC2 corresponds roughly to a 1A output current. This voltage is compared against the wiper voltage from the other digital potentiometer in IC1. If the output current is above the setpoint, output pin 7 of IC2b goes high, forward-biasing the base-emitter junction of NPN transistor Q2. When Q2 is switched on, it pulls the voltage at pin 3 of IC2a down, reducing the output voltage. This should lead to a reduction in the current drawn by the load until it matches the current limit, at which point the drive to Q2 is moderated, so the output voltage should stabilise at a level where the output current is close to the set current limit. There are a few things to note here. Firstly, the apparent reversal of the inverting and non-inverting inputs on IC2b is because common-emitter amplifier Q2 inverts the polarity of the signal in the feedback loop. By swapping the inverting and non-inverting inputs, we effectively re-invert it and get the correct polarity. Also, like the voltage feedback loop, stability is improved by a 1nF capacitor between the output (pin 7) and inverting input (pin 6), plus there is a 100nF capacitor stabilising the current set voltage at pin 6. The voltage and current feedback signals also go to two of the analog-capable pins on the Uno board. Thus the Uno can sense (with its ADC peripheral) the voltage and current using pins A1 and A0 respectively. The VIN supply voltage is measured via a second 51kΩ/10kΩ divider at analog input A2. That allows the micro to calculate the voltage drop across Q1, and infer its thermal dissipation. On the PCB, there are test points for the four sense/reference voltages. These are labelled VFB, IFB (voltage and current feedback), VSET and ISET (voltage and current setpoints), plus one for GND. Arduino software The Arduino firmware produces SPI data to set the desired voltage and current limits, then closes the relay to enable the output when prompted by the user. The hardware on the shield then manages the output voltage, reducing it if the current limit is reached as described above. Once the voltage and current are set, the regulator operation is automatic; it does not depend on the software for control. The microcontroller measures the supply and output voltages, and load current, then sends this data to the program running on your computer for display. Calibrating the unit consists of determining the exact relationship between digital values (ADC readings and digital Australia’s electronics magazine February 2021  41 Fig.2: this deceptively simple Arduino shield turns an Uno into a regulated bench power supply. Apart from the pin headers, the only component on the underside (and the only SMD) is the 15mΩ shunt resistor. Power transistor Q1 has a small heatsink as it can dissipate several watts. The ICs, relay and transistors are polarised so must be orientated as shown, while the other components can go in either way around. Several test points are provided, but they are not needed for calibration. And to further assist in construction, here are the matching same-size photos of the shield, from both sides. potentiometer settings) and the resulting analog voltages. These coefficients can be calculated from measured component values. The Power Supply will be fairly accurate ‘out of the box’. But its accuracy can be improved by taking readings with a multimeter, determining the exact ratios and programming these into the code. A calibration routine in the PC program simplifies this process, automatically calculating the new ratios from measurements. Construction The main part of the assembly is building the shield. The parts all fit on a double-sided PCB coded 18106201, which measures 69mm x 54mm – see Fig.2. The first decision to make is whether you want to build it with plain headers or stackable headers. You will need stackable headers if you plan to plug any shields on top of this one. But we used regular pin headers on our prototype, as we don’t plan on doing that immediately. Assembly is then straightforward. To confirm everything is going in the right place and with the correct orientation, check Fig.2, the PCB silkscreen and the matching photos as you fit the parts. Start by fitting the 15mΩ surface-mounted resistor, which goes on the underside of the PCB. Some constructors like to use a wooden clothes peg to hold an SMD component in place while soldering it. Flip the board over and tack one lead in place with your iron. If the part is flat and square within the silkscreen markings, solder the other lead. Otherwise, remelt the first pad and adjust the resistor, using tweezers if necessary, until it is placed correctly. Then solder the second lead and flip the PCB back over. 42 Silicon Chip Fit the 11 through-hole resistors on the top of the PCB, as indicated by the silkscreen markings. Check their values with a multimeter, as some of the markings can look quite similar. Follow with the eight 100nF and two 1nF capacitors, which should be marked with their values (or codes representing them, like 104 and 102 respectively). None of those are polarised; nor are the 10µF capacitors which can be through-hole or SMD types. Mount them now. Next, install the smaller transistor, Q2. Crank the leads to fit the PCB pads, ensuring that when mounted, the body sits low in case you need to add a shield above this one. Ensure that it matches the outline on the PCB silkscreen. Follow with the TO-220 transistor, Q1. It is mounted on a finned heatsink. First, bend the leads backwards by 90º around 7mm from the transistor body, then thread the leads through the PCB pads. Check that the larger mounting hole is aligned and adjust the leads if necessary. Remove Q1 from the PCB and insert the M3 machine screw through the back of the PCB. Add the heatsink on top, then the transistor and thread on the nut. Before tightening, ensure that the heatsink and transistor are square within the footprint. Carefully tighten the nut (to avoid damaging the transistor leads), then solder its leads and trim them. Most of the remaining parts are in DIL packages. Avoid using IC sockets, as not only will they have a worse connection than direct soldering; they will also cause the components to sit much higher. RLY1 has eight pins but comes in a 14-pin size package. It sits above Q2; the notch in its case faces to the right. Gently bend the leads to line up with the pads and fit them. Solder two diagonally-opposite leads and check that the part is flat; adjust if it is not. Solder the remaining leads and then go back and refresh the solder on the first two leads. Australia’s electronics magazine siliconchip.com.au IC1 is a 14-pin part; its pin 1 notch should butt right up to the adjacent capacitor. IC2 is an LMC6482, as marked on the silkscreen. Do not mix it up with IC3, which is specified as an MCP6272, although you could use another LMC6482 instead. Use a similar technique as RLY1 to fit IC1, IC2 and IC3. Once that is done, check for any bridges or dry solder joints and repair as necessary by using a solder sucker or solder braid to remove excess solder. Apply the iron and fresh solder to finish the solder joint. Headers and jumper Attach the Arduino mounting headers, along the edges of the board, next. If you are using male headers, then fitting them is straightforward. Use the Uno as a jig and plug the pin headers into the Uno, then place the PCB on top. After checking that everything is flush and square, solder the pin headers from above and unplug the assembly from the Uno. If you want to use stackable headers, then it is a bit trickier, although the Uno can still be used as a jig. In this case, the headers thread through the PCB from above and into the Uno. Flip the assembly over so that the Power Supply PCB is at the bottom. Now you have access to the pins of the stackable headers from below. That should be sufficient to tack the endmost pin of each strip to keep the headers in place. Check that the headers are flat against the PCB and adjust if needed. Unplug it from the Uno to give better access to the remaining pins. Solder them, then refresh the end pins. In this case, you will probably also need to solder a twoby-three pin stackable header block to the R3 header location on the board, to pass those signals through to a board stacked above. JP1 consists of a male header and jumper shunt. Fit the shunt to the header, slot it into the PCB and solder its pins. The shunt will keep the pins in place even if the plastic shroud melts a little. Finally, it’s time to mount the output connector, CON1. We used a two-way screw header, although you might prefer something different depending on how you want to use the Power Supply. Solder CON1 in place and then fit the PCB to the Uno. Unless the Uno is new and unprogrammed, you should remove JP1, in case the existing sketch uses a different voltage reference which could conflict with the 3.3V supply and possibly damage it. Software There are two elements to the software of this project – the first is the firmware that runs on the Uno. The second is the computer application that interfaces with it. The Ar- Parts list – Arduino-based Power Supply 1 double-sided PCB coded 18106201, 69mm x 54mm 1 Arduino Uno or compatible board 1 12V-15V 1A plugpack with 2.1mm DC plug to suit the Uno, or a similar power source 1 2-way screw terminal (CON1) 1 6-way pin header (or stackable header, see text) 2 8-way pin headers (or stackable headers, see text) 1 10-way pin header (or stackable header, see text) 1 TO-220 finned heatsink (for Q1) [Jaycar HH8502] 1 2-way pin header and jumper/shorting block (JP1) 1 2x3-way stackable header (optional; needed if another shield to be attached above) 1 5V coil DIL reed relay (RLY1) [Altronics S4100, Jaycar SY4030] supplies built with the Jaycar relay should set the current limit no higher than 500mA to avoid damage to the relay, due to this relay only having a 500mA switch rating Semiconductors 1 MCP4251-5k 5kW dual digital potentiometer, DIP-16 (IC1) [SILICON CHIP ONLINE SHOP SC5052; Digikey, Mouser] 1 LMC6482 dual op amp, DIP-8 (IC2) [Jaycar ZL3482] 1 MCP6272 dual op amp, DIP-8 (IC3; LMC6482 can substitute) 1 MJE3055 10A NPN transistor, TO-220 (Q1) [Jaycar ZT2280] 1 BC547 100mA NPN transistor, TO-92 (Q2) [Jaycar ZT2152] Capacitors 2 10µF 16V leaded X7R ceramic (or SMD M3216/1206-size) 8 100nF MKT (code 103, 100n or 0.1) 2 1nF MKT (code 101, 1n or .001) Resistors (all 1/4W 1% axial metal film except where noted) 1 150kW (brown green black orange brown or brown green yellow brown) 1 100kW (brown black black orange brown or brown black yellow brown) 2 51kW (green brown black red brown or green brown orange brown) 4 10kW (brown black black red brown or brown black orange brown) 2 1kW (brown black black brown brown or brown black red brown) 1 100W (brown black black black brown or brown black brown brown) 1 15mW 1% SMD, M6532/2512-size [SC ONLINE SHOP SC3943] duino firmware ‘sketch’ is available for download from the SILICON CHIP website. We’re assuming that you have some familiarity with the Arduino IDE (integrated development environment), although it isn’t too hard to figure out if you’re new to it. The IDE can be downloaded for free from siliconchip.com.au/ link/aatq We’re using version 1.8.5, but practically any version should be fine as the sketch is quite simple and doesn’t need any special libraries. With that installed, the next step is to load the Uno with the firmware. Connect the Uno to a USB port, select the Uno’s End-on views of the sandwiched boards – the power supply shield on top; the standard Arduino Uno (or compatible) below. siliconchip.com.au Australia’s electronics magazine February 2021  43 Screen1: our Processing application provides slider controls for voltage and current at the top, along with simple switches to switch the output on and off. Presets are displayed and selected below, along with power information. The incoming supply voltage can be monitored in the title bar. Screen2: the calibration procedure is simple. You adjust the controls until the multimeter reading matches the voltage and current readings shown at lower left, after which you simply copy the parameters to the configuration file. Screen3: the “config.txt” file contains calibration parameters and up to five named presets. You can also set the serial port and whether the application should automatically connect to it at startup. serial port from the Arduino IDE Tools menu, then ensure that the Uno board is selected as the target (Tools -> Board -> Arduino Uno). Press Upload, and once the sketch has uploaded, insert JP1 and open the Serial Monitor at 115,200 baud (CTRL + SHIFT + M in Windows). The sketch is fairly simple; it listens on the serial port for commands like “V100”, “I50” or “R1” to set the voltage, current or the relay state respectively. Since the communication to and from the Power Supply is simply over a serial line, we can also test the unit by typing commands into a serial terminal program such as the Serial Monitor. Such a simple scheme means that it can be manually controlled if necessary. But it also means the Power Supply can be very easily controlled by other software; they just have to send the correct commands and process the (simple) responses. Even if no 12V supply is available, the Uno itself will feed around 4V to the VIN pin (and thus the Power Supply) for testing. This is enough for us to do some simple, lowvoltage testing to check that the unit works as expected. host program converts the 0-1023 readings to real-world voltages and currents. To test the output with a multimeter connected to CON1, enter the command “R1”, followed by “V255” and “I255”. This should allow the output to get within about 0.7V of the VIN supply voltage (limited by the inherent diode drop of the emitter follower Q1). Try some lower values for V (eg, V25) to check that the output can be regulated to a lower level. That should give you about 2V, while V37 should give about 3V and V13 should give about 1V. To check higher output voltages, you will need to connect a 12-15V supply to the Arduino’s barrel socket (but watch that upper voltage limit!). For this testing, it would be a good idea to connect the Uno to your computer via a USB Port Protector, like our design from 2018 (siliconchip.com.au/Article/11065). That will mean that even if there is a fault in your Power Supply that results in 12V or more being fed back to the USB signal pins (which operate at 3.3V), it shouldn’t damage your computer. Testing Processing app With the Power Supply plugged in via USB and the Serial Monitor open, you should see a stream of lines showing values prefixed by J, U and S. The J and U values should be close to zero, but S will be around 200 (indicating around 4V at VIN). To test the relay, type “R1” or “R0” followed by Enter. You should be able to hear it gently clicking on (after R1) and off (after R0). You can send commands to the digital potentiometer by typing either V or I, followed by a number in the range of 0-256, then enter. These numbers are the raw digital potentiometer values, as all calibration is done on the host computer program. With the relay on and both the V and I values set to non-zero values, you should measure a voltage across the output terminals. The J, U and S values are raw ADC readings (0-1023) of the input and output voltage and current, taken several times per second by the Uno. The J, U and S letters chosen are to avoid confusion with the commands V and I. The We wrote the computer control app in the Processing language. The Processing IDE is available on Windows, Mac and Linux (including the Raspberry Pi). Using the IDE, you can run the program or compile it to a standalone executable file for your system. It’s based on Java, so you will probably need a Java runtime environment (JRE) installed to run the program. Processing can be downloaded for free from https://processing.org/download/ (we used version 3.5.3). There are no special libraries or add-ons needed. Open the Processing sketch (a file with a .pde extension) using the File menu and run it using the Ctrl-R key combination. A standalone executable can be created from File -> Export Application. Referring to Screen1, the actual and set voltages and currents are shown as bar graphs and in digital form at the top of the window. A similar display below shows the actual and set currents. Two large buttons are provided to turn the output on and off. Below this are five preset buttons 44 Silicon Chip Australia’s electronics magazine siliconchip.com.au and a button to access the calibrations page. Along the bottom are displays for output power (P) and transistor Q1 power (Q). These change colour as the power increases. At bottom right is an indicator for the serial port. The initial calibration of this software comes from our prototype, so it should be roughly correct within component tolerances. It’s easy to fine-tune it, though. Using it Press “+” and “-” on your keyboard to cycle through the available serial ports. When the Uno’s port is selected, press “s” to connect -- if the connection is successful, the serial port will turn green. If it does not connect, check that the port is not in use by another program (for example, the Arduino Serial Monitor). The “s” key has a toggle action, so it can also be used to disconnect from the Power Supply. Drag the arrows on the bar graphs with the mouse pointer to set the voltage and current. The green arrow is the setpoint, which corresponds to the leftmost digital display. The red arrow and rightmost numbers correspond to the actual voltage and current values. Click the “ON” button to energise the relay and enable the output. Note that the PSU reads the voltage before the relay, so it will show a value even if the relay is off. The “ON” button turns green when the relay is on. Use the “OFF” button to shut it off. Pressing any of the five preset buttons will load that preset into the voltage and current setpoints. In Screen1, preset three is loaded, so its button is highlighted. Calibration Pressing the ‘Calibration’ button will expand the window to show the calibration values (see Screen2). Our copy of Processing stalls for a few seconds when this happens; it is a known bug which will hopefully be fixed in a later version. To close the Calibration view, click in the lower part of the window. Calibration is achieved in two stages. The first is to calibrate the voltage, which requires a voltmeter to be connected across the Power Supply output (CON1). Turn on the output and set the current to any value above zero; this is to ensure that the current limiting doesn’t kick in, which would reduce the output voltage. Next, adjust the voltage slider until the multimeter reads as close to 6V as possible. A 12V-15V DC external supply is ideal for doing this, but even 9V DC would be sufficient. Note that the two pointers may not line up to 6V. This is expected, as we are still calibrating the unit. Now, write down the “VFACTOR” and “UFACTOR” values that are displayed in the bottom panel. To calibrate the current side, turn the output off and switch your multimeter into a mode and range capable of reading up to 400mA. You will probably need to change how the meters leads are plugged in too. Since your multimeter is effectively forming a short circuit, you can include a power resistor in series with the multimeter leads for extra protection, and to reduce dissipation in the output transistor. For example, a 10Ω 5W resistor would work well. Switch on the output and move the current pointer up until the multimeter reads 300mA, then note down the lower (“IFACTOR” and “JFACTOR”) calibration values and siliconchip.com.au turn the output off. Be quick about this, as the transistor can get quite hot during this stage. Configuration The calibration factors (along with other settings) are stored in a file called “config.txt”. This must be in the same folder/directory as the .pde file for the Processing sketch. Open it and add or modify the four calibration factors you wrote down. The result should look like that shown in Screen3. Note that the app does not care about upper or lower case in these settings. You’ll need to restart the program to load the new configuration. If you are running it from the Processing IDE (rather than an exported app), you should see that the calibrations are loaded in the log window at the bottom, like this: UFACTOR set VFACTOR set JFACTOR set IFACTOR set If these are not seen, then there may be an error, and the values have not been loaded. The configuration file also supports some other options. SFACTOR is used for calculating VIN; it is theoretically (within component tolerance) the same divider as that for UFACTOR, so you can use the UFACTOR value here too. It’s only used for display and dissipation calculations, so isn’t as critical as the other values. It is a simple scaling factor from the raw ADC result (01023) to voltage, so can also be adjusted by comparing with a multimeter reading. For example, if the displayed supply voltage is 1% too low, then increase SFACTOR by 1%. You can also set the default serial port and whether it should connect when you run the program with the PORTNAME and CONNECT parameters. The nominal supply voltage can also be provided with the VIN parameter. The PORTNAME should be set before the CONNECT line so that the correct port is opened. The naming scheme for ports will differ between operating systems. The five presets are set with PRESET1 to PRESET5, with the values being voltage (in volts), current (in amps) and name (cropped past seven characters). These parameters are separated by commas. Naturally, all configuration variables have reasonable defaults in case the configuration file is missing or empty. We’ve left a few potential lines in the file prefixed by an apostrophe; the program ignores these lines until you remove the apostrophes. Usage The Power Supply control app has been designed so that using it should be intuitive. We reckon that this way, it is much easier to use than a supply with physical controls like a few pots and a small display. It is by no means a high-accuracy piece of test gear but still very handy to have on your desk, especially since it doesn’t take up much space. We haven’t described how to fit it into any sort of enclosure, as you really can just use it as-is. If you do want to enclose it, a UB3 Jiffy Box is the simplest and cheapest option, and its generous size should allow some airflow for cooling. A pair of holes in each end will be sufficient to run all the necessary leads. SC Australia’s electronics magazine February 2021  45