Silicon ChipArduino Programmable Load - June 2023 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Back Issues: Hare & Forbes Machineryhouse
  6. Publisher's Letter: Powerful projects
  7. Feature: Technology comes in different shapes and sizes by Max the Magnificent
  8. Feature: Net Work by Alan Winstanley
  9. Project: Arduino Programmable Load by Tim Blythman
  10. Project: 500 WATTS POWER AMPLIFIER by JOHN CLARKE
  11. Project: High-Power Buck-Boost LED Driver by Tim Blythmhman
  12. Feature: CJMCU-7620 Gesture Recognition Module by Jim Rowe
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Feature: Circuit Surgery by Ian Bell
  15. Feature: Make it with Micromite by Phil Boyce
  16. Feature: AUDIO OUT by Jake Rothman
  17. Feature: PE hands-on product review by Julian Edgar
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the June 2023 issue of Practical Electronics.

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

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Arduino Programmable Load Project by Tim Blythman To test devices like power supplies, driver circuits and current sources, you often need a particular or variable load resistance that can handle a bit of power. This Programmable Load is based on an Arduino shield that is easy to understand, build and use. It can be controlled manually or automated in a way that suits your application. D uring the design and testing of our High Power BuckBoost LED Driver (starting on page 32), we wanted to check how it handled various loads to test the robustness and versatility of the design. To do that, we came up with this design, and it was so handy that we have turned it into a standalone project. Do note that this design is not infinitely adjustable and is not intended to sink a constant current. Instead, it uses switched resistance elements that apply discrete load resistance steps. But being connected to an Arduino microcontroller means that it’s possible to add some smarts. The circuit also includes components to allow the applied voltage and sunk current to be measured. This means that it can also calculate the power dissipated in the Programmable Load (P = V × I). Thus, you can program the Load to behave differently depending on the application. Its functions include fixed-resistance or current-tracking modes. It can even be programmed to provide a dynamic load so that you are able to test equipment under changing conditions. A typical test for a power supply or regulator is to see how it responds to sudden changes in load resistance, and it is capable of doing that. Our sample code provides just the basic features, including manual resistance and current-tracking modes, but it’s easy to modify the code to add custom features. Our sample code also displays all the data that is collected. Circuit details Some variable load designs use a MOSFET bolted to a large heatsink as the load element. That requires some Features and Specifications ∎ Handles up to 70W continuous, at up to 15V and 4.7A ∎ Presents a load resistance between 3.1W and 47W in 15 steps, or 43kW when ‘off’ ∎ Sinks 255mA to 3.83A in 255mA steps from a perfectly-regulated 12V source ∎ Manual control of unit loads or resistance ∎ Software provides an approximately constant-current mode ∎ Measures voltage up to 20V ∎ Measures current up to 6.5A ∎ Calculates power up to 130W 16 careful circuit design so that the Load can respond to dynamic conditions. On the other hand, our Programmable Load consists of 15 high-power resistors which have no trouble dealing with rapidly changing conditions. Crucially, there is no chance of them presenting a short circuit as long as the circuit is operated within its working voltage range. The concept is simple. There are four groups of 5W 47W power resistors. The groups consist of one, two, four and eight resistors respectively, which can be switched into any combination from none to 15 resistors in parallel. The Load is optimised for use with voltage sources up to 12V nominal. But we’ve kept in mind that there can be some variation in voltage; for example, a 12V battery could put out up to 14.4V during charging, and a 12V LED might require 13V or more to produce full power. So we’ve selected components that will handle up to 15V continuously (more on a pulsed or intermittent basis). 47W is the lowest E24 series resistor value that produces less than 5W of dissipation with 15V applied across it, hence our use of 47W resistors. Fig.1 shows the circuit we came up with. Four N-channel MOSFETs, Q1-Q4, switch the resistors in and out of circuit. Their sources are connected to circuit ground, and their drains go to the groups of one, two, four or eight resistors, respectively. Practical Electronics | June | 2023 Fig.1: four MOSFETs, Q1-Q4, are used to switch up to fifteen 47W resistors, applying a varying load resistance across CON1. IC1 and the 15mW shunt allow the load current to be measured, while the 33kW/10kW divider measures the voltage, allowing the dissipation to be calculated. Arduino-based Programmable DC Load Their gates are held low by 10kW resistors, so usually they are off. The gates also connect to four digital I/O pins (D3, D4, D5 and D6) of an attached Arduino board via 470W resistors. The resistors provide a degree of protection in the event of a catastrophic failure. Otherwise, the circuits are entirely separate, apart from their common grounds. The other end of the load resistors connects to a 15mW current-­measuring shunt and then to the Load’s positive terminal. The connection to the external circuitry is via screw terminals (CON1). Also connected to the top of the load resistors is a 33kW/10kW divider with a 100nF capacitor across the lower resistor. This allows the attached Arduino board to measure up to 21.5V, assuming Practical Electronics | June | 2023 it has a 5V analogue-to-digital converter (ADC) reference voltage. The divided and smoothed voltage is fed to the attached Arduino board’s A0 analogue input pin. This divider means that the Arduino Programmable Load always presents a minimum load of 43kW. The voltage across the shunt is measured by IC1, an INA282 current shunt monitor with a gain of 50. A current of 1A results in a 15mV drop across the 15mW shunt resistor, and thus an output of 750mV at IC1’s pin 5. The maximum measurable current with a 5V reference is therefore 6.67A. This voltage goes to another ADC channel at the Arduino A1 pin via a 10kW resistor, and it is filtered by a 100nF capacitor. The output voltage of IC1 is set to be referred to circuit ground by its pins 3 and 7 being connected to ground. IC1 is fed with a 5V supply to its pin 6 with a 100nF bypass capacitor from the attached Arduino board, and its power ground connection is at pin 2. By changing which of Arduino pins D3-D6 are high or low, the load presented can be varied between the value of 1-15 parallel 47W resistances, or even disconnected completely. The Arduino monitors the voltage and current and reports them along with calculated power dissipation. Depending on its programmed mode, the Load can provide a fixed resistance or attempt to emulate constant current, or even a changing load to check the response of the supply. 17 Arduino board selection We’ve specified an Arduino Uno in the parts list, but any 5V Arduino board, including other AVR-based R3 shield-compatible boards like the Leonardo or Mega, should work fine. The sample code doesn’t use any pin-specific peripherals, so it isn’t tied to a particular board. But 5V digital I/O levels are necessary to ensure that the MOSFETs turn on fully. If you really want to use a 3.3V board, you could do so with some changes, but note that many are not compatible with the R3 shield form factor (they typically use the MKR form factor instead). One exception is the Due. We have not tested the design with a 3.3V Arduino board, but we believe it will work with the following changes: n Ensure you use the IPP80N06S4L-07 (or similar MOSFETs) because the CSD18534KCS are not suitable for 3.3V gate drive. n change the 33kW resistor to 56kW and change the 15mW shunt to 10mW. This is to avoid overloading the ADC pins with voltages above 3.3V and assumes a default ADC reference of 3.3V (as per the Due). n In the sketch, change the V_CONST define to 0.0212695 and the I_CONST define to 0.0064453 to account for the different component values. Construction The Load is presented as a bare shield PCB with external screw terminals. It’s expected to be used similarly to the Arduino PSU (February 2022), as a bare board on top of an Arduino-­ compatible microcontroller board. The lack of enclosure actually helps us somewhat. With up to 70W of dissipation, a good amount of free air convection is necessary to avoid overheating. Ideally, a fan should be pointed at the module when it is used at or approaching its maximum power rating. The Load is built on a double-sided PCB coded 04105221, which measures 89 x 54mm and is available from the PE PCB Service. Fig.2 shows where all the components go. Start by fitting the small components. IC1 is an SMD part in an SOIC-8 package and is best soldered with the aid of flux paste and tweezers, although you might get away without them. Apply flux to the pads and tack one lead in place with a clean iron tip, ensuring pin 1 is aligned with the dot on the PCB. If the part is still correctly aligned, solder the remaining pins; otherwise, adjust it using tweezers until you can do so. The 15mW shunt resistor adjacent to CON1 can also be 18 handled similarly, although it is not as fiddly to mount. Clean up any excess flux at this point as the remaining parts are all throughhole. Note that the PCB will also accept a through-hole resistor for the shunt if that suits you better. Remember that you will have to tweak the calibration in the software if you change its value. Next, fit the remaining small axial resistors, as marked on the PCB silkscreen. Check the resistors with a multimeter if you are unsure of their values. Follow with the three 100nF capacitors, all of which are near IC1. These are not polarised. Trim all leads close on the underside of the PCB. Screw terminal CON1 can be soldered next. Ensure that the lead entries face out of the board. The next tallest components are MOSFETs Q1-Q4, all of which are the same type. Make sure to orient them correctly, with the tabs aligning to the silkscreen markings. You can also refer to the photos and Fig.2 to confirm the mounting arrangement for these MOSFETs. The MOSFETs are mounted freestanding and vertically. They do not drop much voltage when on and do not handle much current relative to their ratings, so they do not need heatsinking. Prepare the 5W ceramic resistors by bending one lead 180° down one side so that they can be slotted vertically onto the PCB. Bending the lead down the side opposite the markings gives the neatest result (see photo below). When fitting the 5W resistors, it will also help to stand them slightly above the PCB to allow more room for air to circulate; again, you can see this in our photos. We’ve made a 3mm gap, although the length of their leads might limit you in this. Start with the resistors near the centre of the PCB and work outwards, trying to keep the tops level for uniformity and square up the parts within their pads. Note that some parts are We suggest that the Load is used without a case, although you should ideally add some tapped spacers to stand it off your work surface. There isn’t any point in using stackable headers, as there is no room for a shield above, and it would limit convection cooling of the resistors. not on the ‘grid’ to provide clearance from the DC socket and USB socket. Trim the leads neatly and flush against the rear of the PCB. The only remaining parts are the pin headers. First, plug them into the Arduino board so that they are correctly aligned, then slot the shield on top. Before soldering them, check for any conflicts below. The in-circuit serial programming (ICSP) headers on the Uno board are exposed high points and are the most likely to foul any pins on the Load PCB that are not trimmed short enough. Also ensure that the PCB is down firmly against the pin headers, then solder them together from above. Programming it Our fundamental control sketch (program) for the Load is controlled through the Arduino Serial Monitor for simplicity. The voltage, current and power are also reported this way. Screen 1 shows a typical display on the Arduino Serial Monitor during use. If you don’t have the Arduino IDE (integrated development environment), start by downloading it from https://bit.ly/pe-jun23-ide and then install it. Now open the sketch file (download from the June 2023 page of the PE website at: https://bit.ly/pe-downloads) and select your board (eg Uno, Leonardo or Mega) and serial port from the Tools menu. Upload the sketch and then open the Serial Monitor from the Tools menu. Set the baud rate to 115200. You should start to see an output similar to Screen 1, with updates occurring several times per second. Note that the measured voltage is across the Load itself, so the power shown is what is being dissipated in the Load. Testing and usage A good way to test the Load is to connect a multimeter to CON1 to measure Reproduced by arrangement with SILICON CHIP magazine 2023. www.siliconchip.com.au Practical Electronics | June | 2023 the resistance between its terminals. The positive multimeter lead should connect to the ‘+’ terminal and the negative to ‘–’. Note that if a reverse current is applied, it will be conducted by the MOSFET body diodes (and thus all the resistors) and will appear as a 3W load. There are three modes that our software can operate in. The first is manual mode, selected by typing the letter ‘m’ into the Serial Monitor, followed by a number from 0 to 15. This is simply the number of resistors that will be paralleled and presented as the load. So for ‘1’, Q1 is switched on, while ‘2’ means that Q2 is on, ‘3’ results in both Q1 and Q2 being on, and so on. This continues up to ‘15’, when all the MOSFETs are switched on. For example, typing ‘m1’ and pressing Enter (ensuring the ‘CR’ line ending is selected) will cause a 47W load to be presented on CON1. Entering ‘m2’ will choose a 23.5W load. You can check these with your multimeter, although you might see slightly higher values than expected due to lead resistance. The ‘m0’ command will disconnect all resistors – a good one to remember if something goes wrong. The second mode is where a resistance is entered using the ‘r’ command. The software finds the nearest possible resistance value to the entered value. Of course, there are only 15 discrete steps, so it will hardly ever be exact. But it is a good way to approximate resistive loads of a known value. The emulated constant-current mode is started with the ‘i’ command, and it attempts to match the measured current to the setpoint by ramping up and down the number of unit loads. With the limited number of steps, it too can only approximate the set current, and will not respond to rapidly changing conditions. In practically all cases, it will jump between two adjacent load levels, and the current will zigzag around the setpoint. Screen 1 Parts List – Arduino Programmable Load 1 double-sided PCB coded 04105221, 89 x 54mm, available from the PE PCB Service 1 5V Arduino-compatible board (eg, Uno, Leonardo or Mega) 1 10-way 2.54mm-pitch pin header 2 8-way 2.54mm-pitch pin headers 1 6-way 2.54mm-pitch pin header 1 2-way 5/5.08mm pitch screw terminal block (CON1) Semiconductors 1 INA282 current-shunt monitor, SOIC-8 (IC1) 4 CSD18534KCS, IPP80N06S4L-07 or similar N-channel logic-level MOSFETs, TO-220 (Q1-Q4) [2 x Cat SC4177 or 4 x Cat SC6184] Capacitors 3 100nF MKT capacitors Resistors (all 1% 1/4W axial unless otherwise stated) 1 33kW 6 10kW 4 470W 1 15mW 1-3W M6332/2512-size SMD [Cat SC3943] 15 47W 5W 10% wirewound Q1-Q4 could be just about any logic-level (ie, suitable for 5V drive) N-channel MOSFETs in TO-220 packages with sufficient voltage and current ratings. shows this, with the Load switching between 3 and 4 resistors to maintain a current near 70mA. This was set using the ‘i0.07’ command. If the voltage rises above 15V or the power goes over 70W for an extended Fig.2: the board is easy to assemble, but it’s best to take some care to line up the 5W resistors neatly or it will look messy. Watch out for the orientation of the MOSFETs and IC1. Also, check the underside of the PCB when it is fitted to the Arduino board to ensure that none of the shield component leads short against anything on the Arduino. The 15mW shunt can be fitted as an SMD or through-hole resistor. Practical Electronics | June | 2023 period, shut the Load down with the ‘m0’ command to avoid damage to the resistors. There should not be any damage to the MOSFETs as long as the voltage stays below the MOSFETs’ rated drain-source voltage, which is 60V for the recommended types. Remember that the displayed voltage cannot go above 21.5V, so it might be much higher than shown if it is above 20V. More usage tips Connect the Arduino Programmable Load’s negative terminal to your circuit ground (remember that it is also commoned with the computer controlling it) and the ‘+’ terminal to a positive output. For example, a power supply should be connected ‘+’ to ‘+’ and ‘–’ to ‘–’. If other loads need to be inserted in series, they should be connected between the PSU ‘+’ and Load ‘+’ to ensure that the Load ‘–’ stays at ground potential. 19 The Load is well suited to testing solar panels, with the proviso that the MOSFET drain-source voltage is respected, especially under open-­ circuit conditions when panels produce their highest voltages. This limits it primarily to solar panels with a nominal 24V output; these can produce up to 44V under open-circuit conditions. A manual scan of the sixteen different load levels will create sixteen data points that can be plotted on an I/V or P/V curve. But note that we are also designing a Solar Panel Tester which will have more features than the Load can offer, so stay tuned for that in the near future. Making modifications The software is written with most parameters set by #define statements near the start. If you wish to modify the load resistors, all must remain the same resistance (unless you make significant changes to the software). The unit load resistance is specified by the R_ CONST value. A higher test voltage might require a different divider to change the range (although you will need to check that the MOSFETs can also handle a higher voltage). A different divider will mean Screen 1: the Serial Monitor (or other serial terminal program of your choice) is used to control the unit and show its status. It has current, voltage and power read-outs, and the applied load is displayed in ohms and the number of 47W units. In the ‘constant current’ mode used here, the load resistance is controlled to keep the current near a setpoint. that the V_CONST multiplier will need to change. To calculate the new value for V_ CONST, work out what applied voltage will deliver 5V to the A0 pin of the Arduino, then divide that higher voltage by 1024. The default value of 0.0209961 is simply 21.5V divided by 1024. We have used (as much as possible) PWM-capable pins so that it is possible to emulate intermediate resistance values by applying PWM signals to the MOSFETs. We have not tried this technique, but you could experiment with it if you need finer resistance controls than the discrete steps presented here. Note that this will present a pulsed load to the current/voltage source, and depending on what it is, it might react in an unexpected manner. Teach-In 8 CD-ROM Exploring the Arduino EE FR -ROM CD ELECTRONICS TEACH-IN 8 FREE CD-ROM SOFTWARE FOR THE TEACH-IN 8 SERIES FROM THE PUBLISHERS OF This CD-ROM version of the exciting and popular Teach-In 8 series has been designed for electronics enthusiasts who want to get to grips with the inexpensive, immensely popular Arduino microcontroller, as well as coding enthusiasts who want to explore hardware and interfacing. Teach-In 8 provides a one-stop source of ideas and practical information. The Arduino offers a remarkably effective platform for developing a huge variety of projects; from operating a set of Christmas tree lights to remotely controlling a robotic vehicle wirelessly or via the Internet. Teach-In 8 is based around a series of practical projects with plenty of information for customisation. The projects can be combined together in many different ways in order to build more complex systems that can be used to solve a wide variety of home automation and environmental monitoring problems. The series includes topics such as RF technology, wireless networking and remote web access. PLUS: PICs and the PICkit 3 – A beginners guide The CD-ROM also includes a bonus – an extra 12-part series based around the popular PIC microcontroller, explaining how to build PIC-based systems. £8.99 INTRODUCING THE ARDUINO • Hardware – learn about components and circuits • Programming – powerful integrated development system • Microcontrollers – understand control operations • Communications – connect to PCs and other Arduinos PLUS... PIC n’MIX PICs and the PICkit 3 - A beginners guide. The why and how to build PIC-based projects Teach In 8 Cover.indd 1 04/04/2017 12:24 PRICE £8.99 Includes P&P to UK if ordered direct from us SOFTWARE The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series. ORDER YOUR COPY TODAY! JUST CALL 01202 880299 OR VISIT www.epemag.com 20 Practical Electronics | June | 2023