DC Electronic Load

by vikvardo in Circuits > Electronics

77 Views, 0 Favorites, 0 Comments

DC Electronic Load

Thumbnail.jpg

This Instructable is brief overview of working principle and build of digitally controlled DC constant current / power electronic load.

This is absolutely not a guide on how to build it! If you want to build it, read all of this first!

Electronic load can be used in various scenarios, where you need to draw constant current from some circuitry. It is basically a substitution for a power resistor. You can also use it to draw constant power. I also included a way to set a cut-off voltage, so it can be used for discharging batteries.

Supplies

The first thing to say is that I apologize if I missed any part but it was built over a long period of time.

The generic parts, I am not going to link here. For specific parts, I will provide links to where they can be purchased (at least within the EU). For most of the parts, I got them from EU supplier TME.eu.

The BOM is available in PDF format here, and an Excel spreadsheet is on the linked Google Drive.

Downloads

Base Info

The device is based on ARM microcontroller, the STM32F030C6Tx, programmed in C using HAL (Hardware Abstract Layer).

The maximum voltage is 60 V (its based on the voltage divider on the ADC), but a change of resistor can make it up to 500 V (at the cost of sensitivity), which is the limit of the MOSFETs.

It features up to 24 A continuous current (theoretical limit, it is not tested and recommended). The current is measured as voltage drop on 5 mΩ resistor in series with each MOSFET.

Cooling is provided by massive 50x50x150mm aluminum heatsink and two 50mm fans. One of the fans is on the back of the heatsink, pulling the hot air out. The second is mounted on top of the case, blowing air into the box. The temperature is measured by I2C thermometer, mounted on the heatsink.

The display is 4 rows 20 characters LCD display (LCD2004), with the I2C module.

The controls consist of 3 buttons and one rotatory encoder (with button). There is also a signal LED to signalize the on/off state of the load. These components are on separated front panel PCB. On this PCB are also mounted the two input 4mm banana plugs.

Working Principle - Hardware

DC_LOAD_v2.drawio.png
Schematic_Active DC constant current electronic load-1.png
8_Main.jpg
10_PCB_top.jpg
11_Front_inside.jpg
6_Inside_PSU.jpg
DC_LOAD.drawio.png

In this part, I will explain the working principle

Power rails

There are two power rails on the device: +12 V and +3.3 V.

The whole device is powered from mains voltage, connected via IEC connector mounted to a rear panel as well as the main switch.

The +12 V is taken directly from an SMPS (MEAN WELL RS-15-12). It is protected by 500 mA reusable polymer PTC fuse (MF-MSMF050-2) and TVS diode (SMAJ12). To filter spikes there is 1uF capacitor and place where to put bigger filtering capacitor in case of unstable input voltage.

The +3.3 V rail is also protected by 500 mA reusable polymer PTC fuse (MF-MSMF050-2) and TVS diode (SMAJ33). It is lowered down from the input 12 V by DC/DC convertor (TRACO POWER TSR 1-2433). There are two 10 uF capacitors on the input and output of the converter.

Voltage measurement

The voltage is lowered by a resistor divider consisting of a 56kΩ and 3kΩ resistor, from which the output is taken. A 100nF capacitor and a reverse 4.7V Zener diode are connected in parallel to the 3kΩ resistor to protect the ADC from overvoltage.

The resolution of the ADC is 12-bit, so there is 4096 values. The sense resolution is approximately 15 mV.

Current measurement

The current is measured on each channel separately. It is measured as voltage drop across 5 mΩ measuring resistor, that is in series with each MOSFET.

Based on Ohm's Law, the voltage at the maximum current of 6A will be 30mV. This is then amplified 100 times by an operational amplifier (INA199A2), designed specifically for this type of application. This means the voltage at the ADC can reach up to 3V.

A 100nF capacitor is also connected in parallel to filter out noise. Additionally, a 1kΩ resistor in series and a reverse 4.7V Zener diode in parallel are used to protect the ADC.

The 12-bit resolution of the ADC provides 4096 values. The sense resolution is approximately 1.6 mA.

Temperature measurement and control

The temperature is measured by I2C thermometer, the TC74A0, mounted directly to the heatsink. The precision is 1°C.

Active cooling is provided by two 12V, 50mm fans. One fan is mounted on the back of the device, attached to the heatsink, and pulls hot air out. The second fan is mounted on top of the case, blowing cold air into the box. This improves airflow through the heatsink and also cools the entire PCB. A 100nF capacitor and an antiparallel diode are connected across the fan connectors.

The fans turn on at 32°C and trun of at 30°C.

MOSFETs

There are 4 N-channel MOSFETs (IRFB11N50A). By increasing the Ugs the MOSFETs resistance will get lower, so more current will be able to pass through.

They are driven by 20 kHz PWM signal from the microcontroller. The duty cycle can acquire 2400 values. Since the PWM voltage from the microcontroller is only 3.3 V, it is amplified to 12 V by 4 channel MOSFET driver (TC4469COE).

After the amplification, the signal is filtered on two stage passive RC filter. It is a low pass filter designed to 100 Hz sine. The component values are: first stage - R=160 Ω, C=10 µF; second stage - R=1.6 kΩ, C=1 µF. Than there is one more 1.6 kΩ resistor acting as discharge current limiter. This provides an analog voltage to control the MOSFETs, meaning they are driven by a voltage level, not directly by the PWM signal.

User interface

The user interface consists of 4x20 LCD (LCD2004), equipped with I2C communication interface (it is connected to the front panel board).

Then there is signal LED, that signalizes the state of the load (if its on/off).

There are 3 push buttons. Their names function are: MODE - shows the menu, where you can select the mode (current/power) and confirms the value. CANCEL - it resets the set mode/value to the previous one. ON/OFF - this one turns the load on/off.

The rotatory encoder is used to change the value. Pressing its button changes the digit cursor position.

All these components are placed on the front panel PCB, connected to the main board via 12 pin IDC connector.

The input banana plugs are also mounted on this PCB as well.

Downloads

Working Principle - Software

Program.drawio.png
Menu_1.jpg
Menu_2.jpg
Menu_3.jpg

The program is written in C using HAL (Hardware Abstract Layer). I used the STM32Cube IDE to create it.

Since the code has more than 1000 lines I am not going to explain it all, line by line here. So there are some simple blocks:

Interrupt

Each millisecond, there is an interrupt called. In this interrupt, the ADCs are read. Than the values are calculated with their own conversion constants that does need to be finetuden (the resistors has some tolerance and the amplification is also not exactly 100 times). If the load is on, the device also sets the individual channels.

Serving channels

When the load is on, the device adjusts the channels each millisecond according to the set and read value

Since the real current sensing resolution is not as good, it is better to use less channels for smaller currents, so the channels are activated according to the set current (less than 0.5 A - 1 channel; less than 1 A - 2 channels; less than 1.5 A - 3 channels, more than 1.5 A - 4 channels).

The routine of controlling the channels is really simple. The set current is divided by the number of active channels. When the read current for the specific channel is smaller than the set, the PWM of this channel increases by 1. When its bigger, the PWM decreases. There is only one problem with this: it can take some time before its reaches the set value (it changes by 1 per millisecond). It functions the same in the power mode.

Drawing LCD

The static letters on the LCD are drawn once so it does not consume time, and the LCD does not flick. The dynamic values (current, voltage, power, etc) are drawn periodically each second. Each 100 ms one of the values gets redrawn. The displayed values are calculated as an average from the last 1000 readings (corresponds to 1 s). Also the temperature measurement happens only once each 1 s.

I made custom library for interfacing with the LCD. There is a function that converts double number into array of characters. This function can draw the number at specific number of characters with the decimal point on specific point. So it also rounds the numbers

Menu

When the load is off, the MCU is checking for the menu controls and serves the menus.

The ON/OFF button is used for switching the load on and off. The mode button is used as ok/select. By pressing it you will go into the mode selection, by pressing it again you will select the mode. In the value selection its used to confirm the entry. By pressing the CANCEL button you cancel any selection. With the encoder you go through the menu, or change the value. By pressing the encoder button, you scroll through the decimal point.

The 3 individual menu stages are shown in attached pictures.

Dev mode

The device also features a development mode, that you can access by holding the MENU and CANCEL buttons when powering on. Than you need to press the ON/OFF button, or you will get back to the default mode.

In this menu, you can calibrate the ADC multiplication values, etc.

Physical Build

2_Inside_top.jpg
5_Inside_heatsink.jpg
9_Main_fan.jpg
4_Front_off_sideways.jpg
12_Frame.jpg
13_Top.jpg
14_.jpg
15_Bottom.jpg

In this part, I am going to cover the case and all 3D printed body parts.

Heatsink

The most important part is the heatsink. Its 50x50x150mm Since its made from aluminum, its fairly easy to drill a hole and a thread into it. The MOSFETs are secured with M3 screws and electrically isolated with kapten thermal conducting stickers.

The heatsink is aligned with the end of the PCB and a silkscreen line. Its secured to the board with two screws from he bottom. For better strength, there are two 3D printed brackets mounted between the board and the front side of the heatsink.

To improve the airflow through the heatsink, the open back side is covered with a 3D printed part.

To increase the air flow there is 50x50x15 mm 12 V fan mounted to the end of the heatsink with 2 M4x20 screws. The fan must be modified, so a screw with countersunk head will fit.

Case - frame

The electronic load is fitted into TECO AUS 22.9 black ABS case. I chose it because it already had air vents, so I do not have to create my own. To fit everything inside, I made a custom frame that matches the case mounting holes. This gave me more space to maneuver the components inside. There are five M3 nuts imprinted into it.

The MEAN WELL power supply is mounted using another special bracket, because the mounting holes on it are not positioned ideal.

The second think mounted to the frame is the main PCB with the heatsink itself. As mentioned before, these two are screwed together. This whole assembly holds in the frame by 3 M3 screws, one in the PCB and two in the heatsink. The two in the heatsink are not screwed directly to the heatsink. They are screwed into brackets (I call them "T-REXes" since they look like them).

Case - rear

The back side of the case is closed with 3D printed plate. It has an extension, where the fan mounted to the heatsink is located. There are also the IEC mains connector with fuse and rocker switch to turn the power to the device on/off.

Case - front

The front panel is also 3D printed. The LCD is screwed into its back as well as the front panel PCB. There are holes for the buttons, encoder, LED and the terminals to stick through. The encoder has its own 3D printed knob. For the LED I made a spacer, that is putted between it and the PCB, so it slays leveled.

The buttons have special caps with spring mechanism. They are printed separate and welded to the panel itself. They make the buttons look and feel way better.

Printing on the front

The text on the front is printed on special silver self-adhesive paper on laser printer. Over this is a sheet of transparent self-adhesive foil. The foil is here to protect the print from getting rubbed of or getting greasy and dirty. Its cut out with exacto knife. The round holes are punched through with a set of die cutters.

Case - top

Since the heatsink is to big to fit, two of the mounting points on the top part of the case were cut of.

Also there is a fan mounted to it, that is blowing air in. I used two M4 screws that are hot glued to the fan, to secure it onto the 3D printed frame. This frame is then screwed to the two mounting points the case.

Stand

The stand is 3D printed. It consists of two parts. They are screwed to the bottom of the case. Its necessary to drill two holes to the case. The holes for the front and back parts must be positioned at specific distance from each other. I made a template for marking those holes onto he case.

The stand features two positions - flat and tilted. The front part is made from two pieces that are screwed together. The screw makes turnable joint. You need to pull (bend a bit) the front piece apart to be able to turn it. Afterwards it latches itself back so it does not flop around.

There are 4 rubber feet for each position so it does not slip.

Measurements and Tests

NoNoice4A.png

As for the measurements, I measured the overall characteristics from 0 to 10 amps. The current, power and voltage graphs are shown in the first three graphs. As the loaded source I used a 12 V car battery, so the voltage source contained zero noise. The current was measured with UNI-T UT139C multimeter. The voltage was measured on the input terminals with OWON CM2100 clamp multimeter. For the currents 4 A and higher the fans were on.

The voltage without loading was tested from OWON SPE6103 switch mode power supply and checked with UNI-T UT139C multimeter.

From the AV characteristics I was able to calculate the dynamic resistance at value of 245 mΩ.

I also measured the current noise. It was measured at 4 A drawn from the car battery (so no noise from there), as a voltage drop at 1,035Ω 100W resistor in series with the load using modified Hantek 6022BE oscillosope. It was under the noise level of the surrounding (the measured noise is under the resolution of the scope or it might have been inducted on the connecting wires).

Downloads

What Can Be Improved

Reverse polarity protection

This is the biggest fear that I have with it in the current version. There is a series diode missing. I am worried that reversing the polarity at the input terminals will destroy my ADCs. The problem is that with average voltage drop of 0.8 V on a diode and a current up to 24 A, the power loss on the diode could reach values up to 20 W. This means that the diode will need to be mounted onto the heatsink.

Software

The second biggest thing that can be improved in the next version is the code. My plan is getting rid of the dependence on the HAL library, because it consumes almost half the memory which size is only 32 kB and with the current code, its almost 100 % filled. This causes that I can't even use debug mode.

I am planing on rewriting the code, with my own abstract layer. This means directly controlling the registers. I also want to write in C++ using object oriented programming.

This will allow me to add a constant resistance and constant voltage modes. I also want to add a power consumption tracking variable as well as some other features.

I might update the code that I've shared at some point.

Better thermal characteristics

One of the other problems now is that there is fairly big temperature resistance between the MOSFETs and the heatsink. I tested this with 65 W, when the MOSFETs were at 65°C but the heatsink had only 45°C.

This can be improved by using different MOSFETs with better juncton-case thermal resistance or using better thermal conducting pads. Also using different heatsink might help. I do have my eye on using two of Fischer LAM 7 K but they are really pricey (around 50€ for one). This modification will need a complete mechanical redesign including using bigger case.

EEPROM memory

Another big thing that should be added is some power independent memory that will store some config and the last set value. If someone is going to inspire from me, this is a thing that I 100 % recommend adding to your version. As for me, I would add some I2C EEPROM chip, with at least 1kB of memory. For example the STM M24C02-RMN6TP.

4 wire measuring

Another thing that is eligible to add is an input for an external voltage sense. The supply cables do have some ohmic resistance, there will be significant voltage drop at higher currents. This can heavily affect the constant power mode, where the power measured by the load can be way lower than the actual power. This can be done by adding second voltage measuring circuit with separate connectors on the front of the device connected to another ADC channel.

Some other stuff

It might be handy to have a special channel, that will be designed for currents lets say only up to 500 mA, but it with higher precision. It could be handy when a small load is needed (like 10 mA).

Also some type of external digital connectivity might be handy at some point (logging data to PC, remote control,...). It can be achieved by adding some USART to USB convertor and a USB connector at the back.

Source Files

Since Instructables are made in the way that they are made, there is no possible way (or I did not found it yet) how to add KiCad files. There is basically no way to add any repository directly to here, I am going to put here a link to a Google drive from where you can download all the files. You can find the KiCad files, STM32Cube project as well as all the 3D models and a lot more there:

Link to the Google drive with all source files.

I apologize, but some of the files may contain outdated data. I made some changes between creating the source files and posting this, which are not reflected in some of the files. For example, I am fairly certain that the BOM contains some outdated values. If you want to check the parts the KiCad schema is the only file that gets normally updated.

Also the PCB that is uploaded is what I have and it does not correspond to the schema!

A Few Words at the End

This whole build took me almost 9 months. I am fairly happy with the result despite the fact that there are some things that can be done better, but there is no time when you do not say that...

I am planning on making a version two of this. I learned a lot of useful things during this build. Unfortunately, I don't have time to continue working on it right now, but as I said, I plan to do so in the future.

I also reserve rights for mistakes, I am open to any objections, comments and recommendations.

Regarding the Fusion 360 files, I am not a 3D modeling expert, so some of the models may be quite disorganized, and I apologize if they are difficult to edit.

Since this build is an open-source project, all the source files are available, and they can be modified.

I needed it to be published and didn't have time to properly get it properly corrected, so I apologize for any grammatical errors and typos.

It is shared under Creative Commons 4.0 International - Attribution Noncommercial - Share Alike