Show by Label

Friday, September 20, 2024

Building a DIY Dynamic DC Load

 VB Dynamic DC Load

Construction and Build Instructions
Calibration & Verification
Battery Tester





[UPDATE] March 17, 2026

Bud and I teamed up again to enhance the firmware, and design a completely new ported version for the Batt Tester application. The two are now very tightly integrated, and have many new enhancements and more automatic settings making it even easier to use. As a small example, when you start the Batt Tester app and connect a serial port to the Dynamic Load, it will automatically enter the BT Mode, and is ready to accept the parameters to start a discharge test.

The Batt Test app has been ported from Delphi-7 to Python, making it also portable for Windows, MacOS and Linux platforms.

The DL firmware has seen some significant improvements, making it more reliable and more precise. I switched from the Arduino IDE to Virtual Studio Code and platform.io, taking advantage of the much more advanced programming environment. Especially the BT mode, but also the CV mode has been upgraded. Instead of recompiling the code with a different calibration value, we have added a native calibration mode that accepts commands to enter the values over a serial connection. All you have to do is to keep the rotary encoder button pressed during the boot sequence.

We have provided binaries for the DL that can be uploaded without building the code yourself, and an executable .exe file for the Windows Batt Test app. MacOS and Linux executables need to be build on those platforms, and we provided detailed instructions for you to do that.

The original Github repo has been completely reorganized and is updated with all the hardware and software sources, executables, build instructions and very detailed readme files.

NOTE
During the testing of the new Calibration Mode, we stumbled into a nasty artifact of serial monitors resetting or even hanging the ESP (or Arduino boards). This is not new or a firmware issue but is a result of how serial monitors implement the RTS/DTR activity in combination with the two transistor circuit on all ESP and Arduino boards. We have a hardware fix for the starting of these monitors by populating C44 on the DL PCB with a 22uF value capacitor. Closing the monitor will need a workaround that we provide and describe in the documentation below. Previous builders of the DL should now always add C44.

Here is the Github repo for the project: https://github.com/paulvee/Dynamic-DC-Load


Build instructions for the hardware

Below is a list of items and instructions that will help you to build a Dynamic DC load instrument. 

The design process for the instrument is documented on this Blog here:
https://www.paulvdiyblogs.net/2024/04/build-diy-dc-dynamic-load-instrument.html

The two BOM's, Gerbers, Firmware and other required files can be downloaded from the GitHub. Note that I recently added files that Bud created and will allow you to 3D print your own enclosure and that includes the backpanel and feet.|
https://github.com/paulvee/Dynamic-DC-Load

I also added the instrument details as a Shared Project on the PCBWay site so you can order the boards directly from there:
https://www.pcbway.com/project/shareproject/DIY_Dynamic_DC_Load_8643ddca.html
https://www.pcbway.com/project/shareproject/DIY_Dynamic_DC_Load_Face_PLate_12899b9c.html
https://www.pcbway.com/project/shareproject/DiY_Dynamic_DC_Load_Back_PLate_cda4ffcf.html

Bud, the designer of the instruments hardware core, started his own Hackaday project to document the design here: https://hackaday.io/project/195380-dynamic-electronic-load
I took all his stuff from there and copied it in the design process Blog, so it's all in one place.



The Specifications:

  • Input voltage: 1..100VDC.
  • Reverse polarity protection to -100V and a 10A fuse.
  • DUT is disconnected by a relays for invalid inputs like reverse polarity.
  • Maximum current of 10A @ 40V
  • Maximum power 180W @25 degrees ambient temperature (heatsink temp 85C)
  • Off state DUT current 1.9uA at 2V, 57.7uA at 60V.
  • Volt Accuracy: 0.4%
  • Current Accuracy: 0.4% (using a two-point calibration for best precision)
  • Native Calibration mode with commands entered over a serial connection
  • Power input: 12VDC Wall-wart 0.5A with reverse polarity protection to -24V and PTC fuse
  • CC, BT & CV modes with real-time operation regulated with hardware.
  • In the BT mode, the operation is controlled by a seperate App that is tightly integrated.
  • CP and CR modes have active regulation supported in software (resolution +/-156uA).
  • Pulse/transient mode supported by an external Function Generator. 5V=10A
  • Current monitoring with a DSO. 1V=10A
  • GUI: 128x128 OLED 1.5' color display and a rotary encoder with dual button functions.
  • Two temperature controlled fans.
  • Protection for over voltage, over current, over power and over temperature limits
  • Watchdog protection for stalled software and for the serial connection in the BT mode
  • Overall dimensions: 21cm long, 18cm wide and a height of 118cm.
  • Weight: approx. 1110 grams

  • Parts & Components

    I will show a few parts and components in this description, but all the main PCB parts are listed in a BOM with their order numbers, and the additional off-board parts are listed in a separate BOM, both are available on the Github site.


    The Printed Circuit Boards

    The Printed Circuit Boards (PCB's) are available through PCBWay, who are sponsoring my activities by providing the PCB's free of charge. I have been using their service for several years now and the boards are of excellent quality, every time.



    To create a professionally looking instrument, and to aid with the construction, I have also created a front panel and a back panel PCB. Both also available through PCBWay.





    The back of the front panel has 4 solder pads that can be used to glue the OLED display into position, so the visible portion will be positioned in the middle of the square cut-out.

    NOTE Bud designed an enclosure that can be 3-printed, and that includes a backpanel. See the Github for the .stl files.

     

    Stuffing the PCB

    Adding components to the PCB should be a straightforward job, except maybe for soldering the minute packages for the ADC, the reference, the two analogue switches and the MCP6V51 Opamps.

    I highly recommend you use a socket for the ESP32. To that extend, make sure you order the WROOM 4MB DEVKIT V1 module without the headers installed. The one below has the blocking diode installed, more details below. Note the pin layout and make sure you get one that has the same layout!

     I use the following headers and sockets for the ESP32, I buy them by the strip.






     


    To add the components to the PCB, my recommendation is to start with all the passive components like resistors, capacitors and then the active transistors, MOSFET’s (not the main NFET’s M1, M2), diodes and the voltage regulators U9 and U12. Do not install the relay and the snubber circuit yet. What I then would do is to connect a Lab Power Supply with a setting of 12V and 50mA to the DC input of the board. If it powers-up without getting into current limitation, you will probably not have any shorted rails to ground, and can proceed to test the +12, +9 and +5 supply voltages. If they check-out, you can add the ICL7660 and test the -5V rail. After that, you can add the REF5040 and check the presence of  4.096V. If that also checks-out, you can add the trimmers, connector strips, DAC, ADC, MOSFET switches (U14, U15), all the Opamps and finally, the main relay and snubber circuit. Basically, everything except placing the ESP32 module in its socket, and soldering the main NFET’s (M1, M2) and the LM35.

     

    Obtaining the correct ESP32 variation

    There are many, many variations of the ESP32 board. I'm using a version that is smaller in width and shorter in length. This is my preferred version of the ESP32, because it fits prototype boards. Most of the others are too wide and you have to connect two prototype boards next to each other to make the ESP board fit.

    The version I'm using is also called the ESP32 DEVKIT V1 from DOIT. If you Google this, you will most likely find them. However, there is more to watch out for.

    This board only has 30 pins, and the pin rows are about 25mm apart, which is why it will fit in a single prototype board. To make absolutely sure you have the correct version, you also need to look at the available pins on the board. The most important thing to look for are the pins at either end of the board. They must match the picture below.

    Even then, there could be two other issues that I describe in a section further below. The board above has the blocking diode installed, visible just to the left in the pic of the voltage regulator.

    The other recommended ESP32 board is the VROOM 4MB DEVKIT V1. 

    However, I have found that there are slight variations or differences for two components on various sources for this board. One is the capacitor that should ensure a reset after a download of new firmware. On one of my boards, this capacitor was there, but not well soldered to the chassis part of the USB-mini. On another one, there was no diode to block the incoming 5V through the USB, and the VIN supplied to pin 1 of the board. Having no diode but a 0R resistor means that the VIN supply will back-feed 5V into the USB port of your PC. Not recommended!

    To avoid having to mess with the ESP board and 0402 size parts, we have made provisions on the DL PCB to help fix these two issues.

    Verify that the ESP32 module has a 1uF 0402 capacitor most likely connected to the solder pad of the EN button. It may be soldered at a 45-degree angle, see the left blue arrow. If the capacitor is not installed, you need to install C44 on the PCB. (in the schematic C44 has a red cross through the part, to avoid placing this part when not needed) 

    UPDATE: To circumvent serial monitors used in the new calibration procedure rebooting the ESP32, you now have to always install C44 with a ceramic 22uF 0805 value!

    Also make sure that there is a diode installed and not a 0 Ohm 0402 resistor (marked 000) as you see here on the board. See the middle blue arrow below for the location. The picture of the ESP32 further up in the Blog does have a diode, which can be easily identified.

    If there is a 0 Ohm resistor on the board, you need to either remove it or do not install R53 but install D10 on the main PCB. See the schematic below. (in the schematic D10 has a red cross through the part, to avoid placing this part when not needed)




    The Back Panel

    At this moment in the build process, it will help to mount the fan on the back panel so you can use it to double check the space between that fan and the second heatsink/fan combination that will be mounted on the bottom shell later.

    The back panel fan will be mounted using the flexible silicon mounts that come with the fan.

    To help the installation by pulling on these flexible thingies, it is helpful to first counter sink the 4 holes in the PCB on either side so the silicon will more easily slide into position when you pull them in.




    Note the position of the fan on the back panel, and where the wires need to come out (top left).

    The four wires from the fan come standard with a pretty stiff heat-shrink tube. That's too stiff to my liking, so I cut it off, exposing the four wires.

     

    Modifying the enclosure

    The bottom shell of TEKO AUS33.5 enclosure needs to be modified so we can mount a fan on the bottom to suck fresh air directly into the heatsink fins inside the enclosure. The fan mounted on the back panel will suck the hot air away from the heatsink to the outside of the enclosure.

    A number of holes need to be drilled in the bottom shell to get enough airflow to the heatsink. I used Excel to create a raster for the 6mm holes. The picture shows an earlier position of the fan, I later moved it further down and added another number of extra holes.


    To feed plenty of fresh air from the bottom of the enclosure to the fan, we need to mount 4 feet that are about 1cm in height to lift the instrument from the shelf or desk to create the space.




    The bottom fan needs to be mounted in the middle of the enclosure, and the mounting holes 25mm away from the back edge of the bottom shell, to make room for the fan that is mounted on the back panel. Before you drill the holes, use the back panel with the fan mounted on it to double check the space you need. The minimum space between the two fans should be at least 2mm.

     

    The bottom fan and heatsink

    The bottom fan will be mounted on the shell by four 30mm long M3 screws. Because of the plastic, and the two hole positions in the ventilation area, I recommend you put M3 or M4 rings on the bottom and on the inside of the plastic shell. Use a normal (flat) M3 nut to tighten the four screws to the enclosure while making sure that the fan will easily fit. After the fan is positioned on the four mounting screws, use an isolated M4 ring (teflon?) on top of the fan before you mount the brackets holding the heatsink.

    The heatsink will be mounted about 6mm above the bottom fan by two strips of a 90 degree angle 15x15mm piece of aluminum. These strips can be found in your local hardware store and probably come in a length of 1mtr. Use a metal hacksaw to cut two pieces with a length of 90mm, which is the same as the size of the fan. Drill two holes of 3mm each 15mm from each end, that will hold the self-tapping screws mounting the bracket to the heatsink.

    I used very short 3mm self-tapping screws to mount the angle pieces to the heatsink. I also drilled the hole through the second flange of the heatsink, to make room for the tip of the screw, so it does not bend the thin flanges.

    Drill two more holes in the other flank of the L-shape brackets that are 81 mm apart, so the screws holding the fan to the bottom of the enclosure will go through these holes. Make sure that these holes are spaced such that when the L-strips are mounted on the heatsink, the holes of the fan will pass through the four 30mm long M3 screws.

    Because the heatsink can get very hot, I used four 3mm insulating rings of the type that are used to mount TO220 type devices isolated to a heat sink. For us they also serve to electrically isolate the screws from the potential of the heatsink, that can be up to 100V DC. The two NFET's are not isolated from the heat sink to get maximum heat transfer, that is the reason the heatsink will be at the voltage potential of the DUT voltage.


    You’ll need a fifth one to isolate the LM35 from the heatsink later. These rings should fit the holes of the brackets, if not, drill the holes a bit larger to 3.5-4.0mm to create some wriggle room. I then used a Teflon ring on top of the insulators and used self-locking M3 nuts to loosely secure the heatsink, so you don’t need to tighten the nuts too much and put too much pressure on the plastic frame of the fan. You want to minimize the transfer of the mechanical vibration from the fan to the enclosure. It should be a fairly loose fit. 

    The thermal paste you see in the pictures is because I took my instrument apart to make these instructions and the pictures after I finished my build.


    Mounting the Main NFET’s and the LM35

    Before you mount the heatsink on top of the fan, you need to create three M3 tapped holes in the heatsink to mount the two NFET’s and the LM35 temperature sensor. If you don’t have a good quality and sharp M3 tapping set and the right size drill (2.5mm), you can also use 3mm self-tapping screws. In that case it is even more important that you counter-sink these holes well after drilling, so the aluminum material does not come-up and push the devices up from the heatsink when you fasten the screws. If you use the M3 taps, lubricate the drill and the taps well and clean the taps and lubricate them regularly while you are tapping, to make sure that the threads are not damaged. The NFET’s and the LM35 will need to be tightened to the heatsink well, to get the maximum heat transfer, so the threats need to be well made.

    I created M3 threaded holes for the two NFET’s 23mm from the back-end of the heatsink, 33.5mm apart, and each about 23mm from the edge of the heatsink.

    The LM35 goes in the middle of the heatsink and 27mm down from the back. Countersink the holes and make sure everything is flat. Use a fine file or very fine sandpaper with a stiff support if needed.

     









    The other four holes you see are from previous mounting positions and are no longer used.


    The front of the main PCB will be supported by two extenders towards the front of the enclosure. I used two 30mm long M3 extenders screwed together. You can use any length parts, as long as they are 60mm in total. The height can be further adjusted when the PCB is mounted. The position of the holes in the bottom enclosure for these supports is best determined when the PCB with the NFET’s and the LM35 is mounted on the heatsink.

    As you can see from the picture below, the bottom fan is positioned such that the wires come out at the left-hand side. The open side of the fan must be facing the bottom of the enclosure so it sucks the air into the enclosure. 

    Because the four wires for the fans have a shrink-wrap tube, they are too stiff to my liking, so I took the tubing off.


    The NFET’s and the LM35 will be mounted flat on the heatsink. The main PCB needs to be mounted as high as possible away from the heatsink, to minimize heat transfer. With earlier prototypes, I found that there is a surprising amount of heat transferred through the NFET leads to the PCB. Keeping the legs long helps.

    The challenge is to move the body of the NFET's as far away from the PCB as possible, to again reduce the heat transfer by way of the leads, and also the heatsink heating the bottom of the PCB. We also need to create space away from the PCB to mount the two smaller TO220 heat sinks on top of the NFET's without them touching the PCB. The place where you bend the leads of the NFET's upwards is critical to accomplish this. I bend the leads of the NFET's after about 6mm from the case with 90 degrees (not too sharp!) upwards. 

     

    You can position the three devices loosely with a screw using the M3 holes you created earlier, and then position the PCB on top of them, with the leads protruding through the holes in the PCB. At this moment, you can use the two mounting extenders to support the other end of the PCB so it is about horizontal, or use something else to keep the PCB horizontal and stable. I also used two spacers of 8mm to support the PCB near the NFET’s so you can position the PCB horizontally in order to solder the leads, and keep them the right amount away from the PCB. Make sure that the PCB is positioned high enough such that the NFET leads only just protrude 1-2mm through the PCB holes to allow for proper soldering. The LM35 leads are a bit longer, so that’s OK. I suggest that at first you solder only the middle leads at this moment. Be careful not to drop the other end of the PCB and bend the NFET leads.

    Once you are happy and double checked the position of the PCB and the three devices, you can mark the position of the two front supports in position on the bottom shelf and then remove the three screws holding the three devices and remove the two extra 8mm standoffs.

    You can now finish the mounting of the two front supports by drilling the holes in the bottom enclosure. I suggest that you use 3.5 or 4mm rings on both sides of the plastic for support. After you have secured the bottom portions of the extender to the enclosure, you can roughly adjust their total height by the second extender. 

    Before you finally mount everything again, apply heat paste to the NFET positions on the heatsink and use an insulated silicon pad with an insulator ring for the LM35. Loosely tighten the 3 screws again and use an Ohmmeter to make sure that the LM35 tab is insulated from the heatsink, because the NFET’s are not, and their pads will connect to the DUT voltage of up to more than 100V to the heatsink.

    When everything is in position, you can tighten the screw for the LM35 and again check that the tab is still isolated. Unscrew the two NFET’s screws again and now add the extra TO220 heatsinks on top of them, using plenty of heat transfer paste.


    Make sure that the heatsinks do not touch the PCB. You can now carefully tighten the screws for the NFET’s.

    After that, you can do a final adjustment of the two front supports so that the PCB is horizontally mounted inside the enclosure. When that is done, re-heat the middle pins of the three devices, to let the stress out, and then solder the other pins. Use plenty of solder for the NFET leads, they will get stressed by the developing heat (up to 100 degrees C).

     

    Preparing for a first power-on

    After you have finished the above steps, we can start to power-up the board again and verify some of the vital signs.

    You only need to add the 12V DC power to the board, but I recommend you use a Lab supply initially with a current setting of 100mA. If there is no large current, indicating a short or another issue, you can now switch to the 12V DC wall wart.

    Do not install the ESP32 in its socket at this moment until you have verified the power rails.

     

    Verifying the Power Rails

    You can now verify all the power rail voltages:

    ·         DC Input 12...15V at J4

    ·         +12...15V at pin 1 U9 (LM7809)

    ·         +9V at pin at pin 3 of U9

    ·         +5V at pin 3 of U12 (LM7805)

    ·         -5V at left side of C31 or pin 5 of U5 (ICL7660)

    ·         +4.096V on either side of R60

    When that is OK and within specifications, you can go to the next step, but first disconnect the 12V DC input again.


    Adjusting the OLED display in position on the front panel

    The OLED module connects to J6 on the PCB. The display module comes with flying leads that each have their own 1-pin connector. I recommend you change these single connectors to a 7-pin connector so you can’t make mistakes with the order, and it’s a lot tidier and easier to remove and install.

    Do not apply the main 12V at this moment, it is not needed for this step.

    For this step we need to install the ESP32 module on the PCB and load the ESP32_OLED_Test_V1.ino firmware. This file is located on the Github site in a folder with the same name.
    Here: https://github.com/paulvee/Dynamic-DC-Load

    Locate the file and download it to your PC. Save it in a new directory called “VB Dynamic DC Load” in a directory on your PC. It will only be used once.

    After you saved it, you can use the Arduino IDE, or VSC to locate the file and load it into the IDE.

    You can connect your PC to either the mini-USB of the ESP32 module, or start to use the mini-USB to USB-C adapter. When you have made the connection, the red power LED on the ESP32 module should light-up and your PC probably will give a signal that a new device is connected.

    After loading the firmware in the Arduino IDE, in Tools select Board and search for the DOIT ESP32 DEVKIT V1 in the esp32 branch. That’s the ESP module we use, and the firmware will most likely only work with that module. If you use VSC, look for the platformio.ini file located in the firmware folder.

    Under Tools again, select the connected COM port to establish communication to the ESP32.

    Compile and download the firmware and see if it gives you any errors.

    If there are, you need to figure out what the problem is. There are too many possibilities to help you from here.


    The OLED display board is probably just lying on your desk and that's OK. Install the connector from the OLED display to J6 on the main PCB, and position the module so you can see the screen and the white connector on the back is on the right-hand side of the display. When done, you can now connect the main 12V power again, because it is needed to power the OLED. You need to press the EN button on the ESP32 module to force a reboot after you supplied the 12V. When successful, you should first see a splash screen with the version number for a few seconds and then see a white square on the OLED screen because all pixels are lit. Congratulations if you got this far!

    The text of the splash screen will show the proper orientation of the OLED display. You could change the orientation of the display in this test code and repeat that later in the firmware, but if you keep to the instructions, and have the white connector on the right-hand side of the OLED module, you should be good to go.

    The inside edge of the square hole in the front panel will be of a grey color. I used a permanent black felt tip pen to make the edges black. Do this from the back such that an accidental slip of the pen will not be on the front op the panel.

    You can now proceed to mount the OLED display in position on the Front Panel.

     

    Mounting the OLED display on the Front Panel

    To prepare for the mounting of the OLED display in position on the back of the Front Panel, we need to change the mounting hardware that came with the display.



    During all these operations, keep the screen protector foil on, or apply it again. It will prevent you from scratching or smutching the glass. Use gloves when appropriate.

    Remove the four M2 screws and standoffs. Keep the four screws, but we will not need the standoffs. You need eight extra M2 nuts and four M2 washers to prepare to mount the contraption on the font panel.

    Add an M2 nut to the M2 screws. Stick them through the hole of the board, and add an M2 washer and then another M2 nut. Tighten loosely. The M2 washer is needed to create some extra space between the glass of the OLED and the Front Panel, so don’t skip it. You may otherwise break the OLED display. Do this for all the 4 holes of the OLED board so it looks like the pictures below. In the next step, the four nuts will be glued to the PCB pads.



    You can now position the OLED board to the back of the Front Panel and check the fit. It should slide on the four nuts, not the glass.

    Apply the 12V main power again and do a reset of the ESP32 (press EN) to verify the orientation of the text from the splash screen and then see if you can position the white rectangle in the center of the open square of the front panel. You can now peel the protective cover of the glass, because that may be difficult or even impossible later on. I strongly suggest you use gloves and avoid any finger prints or worse, glue getting on the glass.

    Before you do the next steps, I suggest you practice the next moves once or twice to make sure you can position the OLED properly without tangling the wires or moving the OLED display that you just glued in position. If you are not happy using Superglue, then use normal glue that you can still move a bit, but you then should tape the two together and let it dry for a few hours.

    I use Super Glue paste, not the liquid, to avoid dripping the goo all over the place. 

    With the OLED module powered and showing the white square, hold the OLED board with the display side up in one hand, with the white connector on the back to the right-hand side and add a drop or two of (Super)glue on each of the 4 nuts that will connect to the solder pads on the back of the Front Panel.

    With your other hand, pick-up the front panel and position and hold it just above the OLED screen with the silkscreen text from the front panel up and make sure the white LED rectangle square is in the middle of the square hole in the front panel. When satisfied, slowly lower the front panel and press the two together and let the (Super) glue dry. After a few seconds with Superglue, you can carefully turn the Front Panel together with the OLED board face down so the OLED stays in position and you can let it dry a bit more. 

    If you used normal glue, you then need to secure the OLED in position with sticky tape so it will not move while you let it dry for several hours.

    Turn off the power and disconnect the USB connection to the ESP32.

    Wait with the next steps until you are sure the OLED display glue is dry! Give it enough time to dry or you will regret it.

     

    Loading the Dynamic DC Load firmware

    The firmware for the Dynamic Load is located on the GitHub site and needs to be downloaded before you can load it into the ESP32. The firmware is needed to operate the instrument, and at power-up will make sure everything starts in a known and safe state. 

    The firmware is on the Github repo in a folder called firmware/release in a file with the name of the version number. Put all the required files a project directory or the directory you created earlier for the OLED test file. 

    Use the readme file in that folder that has detailed instructions how to install the firmware binaries, so you do not have to setup VSC and compile the sources.

    First firmware turn-on

    Do not supply the 12V yet and also do not connect the two fans to the PCB at this moment yet. Position the front panel with the OLED connected to the main board such that you can easily see the display. The front panel does not need to be mounted to the enclosure yet, but you could temporarily do that.

    When there are no download errors, the firmware is loaded and started, and with the red power LED on the ESP32 module already on, the blue LED hart beat indicator now starts to flash. If that is the case, then congratulations are in place again. Well done!

    With the USB power applied, and even when you now supply the 12V main power, the ESP32 is not getting a reset. You need to do a manual reset (press the EN button on the ESP module) again so the firmware is restarted, the OLED now becomes operational and after the splash screen with the version number, you should see the following start screen.

    Great if you got this far! Don't worry about the "negative" or "invalid" warning in red for the voltage. That is because nothing is connected yet and the inputs are floating.  The temperature reading for the heatsink in the lower right corner should be OK though.


    Connecting the fans

    Turn off the 12V and remove the USB connector. If you still use the Lab Supply, raise the current to 350mA. You can now connect the two fans to the PCB and go to the next step. 

     

    Boot sequence

    When you apply the 12V main power, the red power LED on the ESP32 module will switch on, and both fans will start to run at full speed. After about 2 seconds, the splash screen appears and the blue LED on the ESP32 module will start to flash. The LED flashing is an indication for the execution of the firmware main loop, showing the "hart beat". The splash screen makes place for the initial screen display and the fans will be turned off. That actually completes the boot sequence. The instrument is now ready to make measurements and accept commands.

    If you got this far again, great!

     

    The front panel

    It is now time to finish the front panel installation, and connect the remaining leads and parts to make the unit fully functional.

    In the picture below you can see my wiring on the back of the front panel.


    To connect to the rotary encoder, I used a ready-made and assembled wire-harness that I purchased in different pin sizes. Here I’m using a 5-pin version. On the rotary encoder itself, I bridged the middle of the 3-pin connector which is GND to one of the two switch pins. The VCC pin of the connector is not used. It is there in case you have a rotary encoder with a debounce circuit that needs power. The firmware works well enough with the rotary encoder without hardware decoding support.

    The main power leads for the DUT are heavy duty and I used so called car connectors to make it easy to mount them. Make sure they can handle 10A.

    It’s a little hard to see, but there is a 10nF capacitor directly soldered on the Current Monitor BNC, to take care of a nasty glitch caused by the induction of the cables.

    For the main DUT and sense inputs, I used these 4mm Banana binding posts. They have the correct 19mm distance and you can use wires to connect to the DUT as well.


    The wiring of the sense switch is quite simple. I connected leads between the main Banana terminals and the sense terminals with solder lugs and used two wires connected to the center pin of the switch to go to J3 on the PCB.

    The power switch is in between the plus lead coming from the DC jack on the back panel and the positive connection of J4 on the main board. The ground lead from the DC jack goes directly to J4.

    I used 2-pin wire harnesses for the Current Monitor and the Transient Input connectors, and used these BNC connectors:


    The main power switch and the USB adapter are not showing in the picture.

    To make sure you don’t pull out the USB-micro to USB-C adapter from the ESP32 socket, I positioned the adapter with everything mounted, and used a tie-wrap flush to the front panel to secure it. To make sure it stays in position, I then used some glue to fix the tie-wrap into position.


    With the USC-micro to USB-C adapter connected to the ESP32, you may need to adjust the front supports of the main PCB so the adapter easily fits the hole in the front panel.

    When that is done, you can put the front panel and all the wires to the main PCB in position, and secure the front panel with the two bottom screws to the enclosure. Do not install the top cover just yet.

    With everything thus far installed, you should have a fully working instrument that should look like this:

     



     



     

    You are now ready to move on to the Calibration & Verification section.


    Calibration & Verification

    Remove the top cover of the enclosure. You need access to the trimmers and test points.

    To counter a nasty surprise when we added the Cal Mode, C44 must now always be populated with a 22uF value capacitor. Check that you did so.

    The reason is that serial monitors have different ways of asserting the DTR/RTS signals. All boards in the Arduino/ESP family have a two transistor circuit that will use these two signals allow a downloading of the firmware, followed by a reset. Unfortunately, this circuit will also get triggered when a serial monitor opens the COM port, and that will reset the processor through the EN pin by a short duration pulse to ground. To prevent this unwanted reset, C44 must be installed to prevent it. This added value does not interfere with the programming and subsequent reset though.

    The other nasty artifact is that when a serial monitor is closed, most will assert the DTR/RTS signals and this will force the EN signal to ground. This will hold the processor in a constant reset mode, and there is nothing that you can do, other then cycle the power. The work-around we created is that after the calibration has ended, you need to pull the USB cable from the DL, -before- you terminate the serial monitor. This is described in detail in the Calibration Guide available in the Github repo, and the updated firmware will give plenty of guidance and warnings.

    Performing the calibration

    There are two phases in the calibration procedure.

    1. We will first calibrate the DL hardware by trimmers for the correct voltage and current settings against externally measured sources. After that, the DL will function correctly.
    2. We will then obtain calibration factors to optionally calibrate the firmware for higher precision of the values shown on the OLED display.
      Most software calibrations may not be needed, the DL is already precise, with the exception of the CV tripping point, you should always do that calibration.

    Initial step

    Make sure you have the latest firmware version (V7.1.6 or higher) installed that is available on the GitHub. 

    This version will also give you access to the native calibration mode, read on for more information.


    Hardware Calibration

    Calibrate the OLED voltage measurement display

    1. Set a Power Supply to 2.50V, or use a voltage reference, connect it to the main terminals of the Dynamic Load (DL). Use a DMM to verify the actual voltage.

    2. Set the remote sense switch to off.

    3. Make sure the NFET’s are OFF so there is no current flowing.

    4. Use the OLED display for Voltage and adjust RV1 on the PCB (Voltage Gain Trim) so the OLED shows the same voltage or as close as you can get it. (due to the averaging and the resolution, take your time - it may help to reset the averaging by disconnecting the input for a few seconds) At this voltage level, the measurement resolution is 0,75mV, the display cannot show that and will round off.

    5. Use a Power Supply to raise the voltage to just below 100V or as high as your supply supports (stay below 105V), and verify using a DMM. At this voltage level, the measurement resolution is 3mV.

    6. The difference between the DMM measurement and what the OLED shows should be less than +/-0.5%. If it is more, you can activate the optional calibration below.

    Obtain the two-point calibration factors for the voltage display

    1.  Note the voltage of the low reference value (2.500V?)

    2. Note the voltage you used for the high voltage level you applied to the input.

    3. Note the voltage shown on the OLED when you applied the high voltage check point. 

    4. You need to enter all three values to activate the 2-point calibration shown below.

    2. When you have entered these values in the Calibration Mode below, come back here to verify the values again.


    Calibrate the current circuit

    1. Set the Power Supply for a voltage of 10.0V and a maximum current of 1.5A.

    2. Connect a DMM to the DAC output test point (TP5 called DAC) and a GND test point (TP2) nearby on the main PCB and use the rotary encoder to get a reading closest to 400mV on the DMM. The Set current on the OLED display will be close to 1000mA +/-10mA.  Turn the load on and let the system warm up for a few minutes and readjust the rotary encoder if needed. 

    A reading of 400mV at the DAC output should result in a 1000mA output current due to the multiplication factor of 2.5 by the current control circuit. The trimmer is used to get that precise, to eliminate resistor tolerances in the input attenuation circuit.

    3. Adjust RV2 (Current Gain Trim) on the main PCB to get a current of 1.000A on the power supply or measure the current with a DMM. Note that the current on the OLED display itself may not be accurate yet, it still needs to be calibrated in a next step.


    Software Calibration & Verification


    IMPORTANT
    Enter the Calibration Mode (see the procedure below) and verify that the relevant calibration factors are all set to 1.00, unless you do a partial calibration, in which case only the relevant settings must be set to 1.00.

    • Run SET  RESET to clean-out all calibration factors. 
    • When you only want to do a certain procedure again, only reset those cal factors. As an example, if you're only going to redo the calibration for the two-point current, use the SET CURRL 100 100 and SET CURRH 3000 3000 to reset only those two cal factors to 1.00.

    Verify this with CAL SHOW, and do not forget to use CAL SAVE before you run CAL EXIT.

     

    Verify the sense switch operation

    1. Set the Power Supply to 30V and a current of at least 1.5A. Connect sense leads from the DL sense inputs to the Power Supply. Directly connect them at the Power Supply connections. Make sure the load is OFF.

    2. Switch the sense switch to on and verify that the DUT voltage is the same in both on and off settings.

    3. Turn the DL input ON with a short press of the decoder button, and check that there is no current flowing yet. Adjust the rotary encoder of the DL load such there is at least 1A flowing as a load.

    4. Alternate the sense switch in both positions to show the effect of the external sense input that will compensate the voltage reading for higher currents flowing through the main leads, that will cause a loss and therefore a voltage drop. If you switch to higher currents, the effect will even be larger.


    Verify the DAC-ADC and the Power Section accuracy

    1. Measure the voltage at the DUT_I test point on the main PCB -- it should be between 396 and 404mV which represents an accuracy of +/- 1%.

    2. Store the measured value in mV in DUTC in the calibration mode so you keep a record of the component and devices tolerance.

        With the optimum tolerances, the value should be 400.00mV (it is currently not used however)

     

    Obtain the two-point calibration factors for the current display

    In this calibration step we are using the current value set by the encoder to match the measured current on the OLED display. This method allows for a consistent user interface. The actual current load as shown on the DMM or power supply may be slightly off, although still within 1%.

    Because we use a two point calibration to do the extrapolation between the two to get better precision, you need to make two measurements and record four values.

    1. Verify that the calibration factors for the current are set to 1.0 before you start this procedure.

    Make sure to use the sense leads and turn the sense on. Connect the 4 leads to a power supply, set the voltage to 10V and the current limit to just over 3 or 6A. Activate the DL with a current of 1A and let it warm-up for a few minutes.

    2. In the CC mode, with the load ON, set the current with the encoder to 100mA. Verify that the Power Supply shows a current of approx. 100mA +/- 8mA, or use a DMM in current mode to measure the current. Note the set current value (100mA) as low_set_mA, because you need that later.

    3. Note the current value on the OLED display and record that value as low_oled_mA, because you need that later.

    4. Now set the highest available current you have available with the rotary encoder, and note that value as hi_set_mA, you will need that later.

    5. Read the OLED current on the display and note that as high_oled_mA. You will need that later.

    6. You can enter these four values into the system using the Cal procedure below.

    7. When you have done that, you can verify that the OLED current measurement matches the Set current value and that it is still virtually the same as the Power Supply or DMM current at different load values. 

    Verification: 

    Here is the result that I measured using a calibration with the minimum of 100mA and the maximum of 6A. (my Siglent SPD3303X-E with the higher resolution display hack, in the parallel mode)


    In the horizontal axis is the Set mA by the rotary encoder, OLED is the deviation in percent's of what's shown on the screen, and PS is what my Power Supply is showing as the actual current. (The PS is not calibrated)

    Recommendation:
    Although the precision is quite good, it makes sense to calibrate the DL with a typical maximum current you will be using regularly. In my case that is well below 3A, so I'll calibrate against a maximum of 3A to get even better accuracy. If your current demands are not so much below 250mA, you could also calibrate with a minimum current of 250mA, to get rid of the hump at 500mA, which is the sum of the DAC and ADC INL.

    Below is the result of calibrating with a minimum of 250mA and a maximum of 3000mA:



    Obtain the CV mode tripping voltage

    Because this mode relies on correct voltage levels, it is best to enter the above values in the calibration mode, verify them, and then come back here.

    1. Use a Power Supply and apply a voltage of 50.00V, which is half of the maximum input, or use as high a voltage as you have available and set the maximum supply current to 100-200mA. (When the CV mode is tripping, a Lab Power Supply will go into the CC mode, and will apply the full current to keep the voltage the same. We want the current to be low, to keep the temperature low during this calibration)

    2. Activate the CV mode, the Set voltage will be automatically set to 2% higher or 51.00V. Switch the DL to ON. There should be no current flowing, if there is, raise the set voltage slowly with the rotary encoder  until there is no current flowing.

    3. Slowly dial down with the rotary encoder to make the Set voltage match the measured voltage and set it one click below and wait a little. For the first time after activating the CV mode, the regulation switches from current regulation to voltage regulation, and with this small voltage difference, it takes a little while for the Opamps to reach the regulation point. Wait for a minute. After that, there are two possibilities:

    • Current could already start to flow. If so, the Tripping voltage is too high. Dial the Set voltage further up until it stops the current flow and from there, start to slowly dial down again and make a note of the Set voltage at the point current starts to flow. Now go back up in voltage a little until the current stops to flow.
      • Calculate the cal factor by dividing 50.00 by the Set voltage and note that 0.9xxx value.

    • If current is not flowing yet, dial the Set voltage slowly further down until the current starts to flow. Go back up until the current stops, and from there, dial it down again until current starts to flow. Stop and note the Set voltage. Now go back up in voltage a little until the current stops to flow.
      • Calculate the cal factor by dividing the Set voltage by 50.00 and note that 1.xxxx value.

    4. You need to enter that value into the system with the calibration procedure further down and come back here again.

    5. After you have entered the value into the system, verify that the tripping voltage when current will start to flow is now very close to the actual voltage measurement shown on the display. (it is unlikely you will get it exactly the same, but it should be really close)

    6. Try the CV mode now with a Power Supply setting of 2.00V and verify that the tripping point is still very close. To get the automatic Set voltage based on the measured input voltage, you need to cycle through the modes by long-pressing the rotary encoder, until you are back in the CV mode, in which case the Set voltage is automatically set to 2V + 2% or 2.04V. If not, you have to manually dial the Set voltage down to 2.04V. Check that the trigger points are just below and above the 2.0V level. The calibration will not be the same as for the 50V, it's linear but will be different. If needed, you can tweak the calibration factor.

    Testing the CV Mode

    CV mode with a regulated (CV/CC) power supply

    Note that with a Lab Power Supply as a DUT, the CV mode is a bit more difficult to use due to the rapid switch of the power supply from CV to CC at the DL CV tripping point. You need to carefully adjust the encoder click by click to get to and stay in an actively controlled load with the supply not yet turning the voltage fully off. If that happends, the DL will automatically switch the load off as a safety measure. Start with a small maximum current of the power supply, and increase the current when you're more comfortable.


    CV mode with an unregulated supply

    Another way to test the CV mode and get more familiar with it, you can also use an (unregulated) power supply that does not have current fold-back or current limiting/regulation. A transformer with a (bridge) rectifier and an electrolyte filter capacitor will be much more forgiving to show the CV mode regulation in operation. This kind of DUT will clearly show the sagging DUT voltage as a result of the load that is a result of lowering the Set voltage.


    CV mode with a battery

    Basically any battery or cell will provide another DUT to get familiar with the CV operation. Be aware that some cells can deliver a lot of current. This is one of the reasons that in the firmware, the current limit in the CV mode is fixed to a maximum of 4A, hopefully preventing injuries or fire-works. Because the battery or cell will do its utmost to keep the voltage stable, you can clearly see the effect of the current changes due to the lowering of the Set voltage.


    Enter the calibration values in the ESP32 NVM

    You can start the calibration procedure after you uploaded the v7.1.8 or higher FW to the Dynamic Load. 

    Use a serial monitor like PuTTY, Tera Term, or the Arduino IDE Serial Monitor and connect the serial cable to the USB-C slot in the DL front panel. Set the correct USB port, the baud rate to 9600 and flow control to none to keep RTS/DTR inactive.

    WARNING: Do NOT use the VSC Serial Monitor. While that worked before, after a code change to the PlatformIO 6.x, it no longer works in this application. There is no fix for this terminals, don't use it. 

    There are two ways to enter the calibration mode.

    1. You have the enclosure open and have access to the EN button on the ESP32 board. 

    • You enter the calibration mode by pressing the rotary encoder button and then restart the DL by momentarily pressing the EN button on the ESP32 board.
    2. You are performing the calibration with the unit closed.

    • Pull the USB cable first (to remove power from the ESP32 module), and then power cycle the DL with the Power switch on the front panel (give it a few seconds in the off position for the power to bleed) while pressing the rotary encoder button.

    The boot process will show the splash screen on the OLED display with the FW version number and then shows the Calibration welcome screen. If you didn't get there, try the power cycle again and press the rotary button until you get into the Calibration welcome screen. 

    Connect the USB cable and startup a serial monitor. 

    In the serial monitor, enter CAL or cal to enter the calibration menu. (Sometimes the filled serial buffer will send a bunch of characters or symbols to the monitor, just enter cal or CAL to stop it.) 

    You will now see the calibration commands in the serial monitor and on the OLED screen. In that menu you can enter the calibration values that you collected and noted with the procedures above. Save the values by entering CAL SAVE and then CAL EXIT.

    When you have typed CAL EXIT, disconnect the USB serial cable to prevent the EN-ESP lock-up!

    Now press the rotary button to reboot the system. It will from now on use the entered calibration values. More information is in the Calibration Guide on the Github repo.

    Here are the available Cal Menu commands:

      CAL SHOW                                         - Display current values
      CAL CV <value>                                 - Set cvCalFactor
      CAL VH <actual_V> <oled_V>          - Set high-point voltage cal
      CAL VREF <voltage>                          - Set low anchor voltage (default 2.5V)
      CAL DUTC <value>                            - Set DAC_ADC_TOLERANCE
      CAL CURRL <set_mA> <oled_mA>  - Calibrate low current point in mA
      CAL CURRH <set_mA> <oled_mA>  - Calibrate high current point in mA
      CAL SAVE                                            - Save to persistent storage
      CAL RESET                                          - Reset to defaults
      CAL EXIT                                             - Exit calibration mode

    IMPORTANT
    When you start to collect the calibration factors in the procedure above, make sure you first set all relevant factors to 1.00 before beginning, or when you start from scratch, use CAL RESET. Verify the settings with CAL SHOW, and always use CAL SAVE.


    The Battery Mode PC software


    Note:
    The original author of the Batt Tester program, John Lowen most likely passed away a number of years ago. We worked together on a newer version years ago, and at that time he mentioned that he was ill. Luckily, and grateful, he trusted me with the source code in Borland Delphi-7 Pascal. I didn't have any experience anymore with the Delphi programming, although I knew Pascal very well, so that project was postponed almost indefinitely, until Bud told me a while ago that he wanted to test battery packs, which was not possible. When I also learned that VCS supported Delphi-7 and an AI agent could help me, that was the moment to get started. 

    Bud and I with the help of agent Claude Sonnet have now developed a very new version that was ported to Python and is portable across platforms and tightly integrated into the DL firmware. The Batt Tester app executable is available for download in the Github repo. Look for it on the main page in the right hand menu under Releases.

    The new Battery Mode application that communicates with the Dynamic Load over a USB serial cable, sets-up the instrument and does the graphing of the discharge voltage and current. It's a single executable that you can install on your PC wherever you like, and you can run it from there. 

    We have made provisions in the App software that will prevent the RTS/DTR reset issues that plague serial monitors as described in the calibration mode.

    Take your time to read the information about the new Batt Tester app that is available on the Github repo in the folder called Batt-Test-App.

    Batt Tester app safety feature and the PC sleep function
    There is one important detail that should not be forgotten. As a safety measure, the combination DL and Batt App have a watchdog provision to let the DL stop the discharge process if a watchdog times out. That can happen when the serial cable is pulled, the app is forcefully terminated by the scheduler, when it crashes, or when MS decides to update your PC and powers it down or restarts it. (Happened to me during a 10hr test and how I found this issue and could fix it.)

    However, that will also happen when the PC goes to sleep. In all these cases, the Batt Tester App process is stopped, just like you selected the Cancel command and the watch dog is no longer fed. Moral of the story, if you have a long discharge process selected, disable the sleep or hibernation feature of your PC.


    Setup screen for the Batt Tester App

    Here is where you select the battery type, the number of cells (if they are in a pack), the discharge current and the capacity of the cell. The software calculates the cutt-off voltage, that you can override if you want.
    Below it is a field where you can enter the weight of the cell, which is a good quality indicator and will be included when you use the Print command to get a paper copy of the measurement.
    The selected discharge current and the capacity determines the maximum discharge time.
    The amount of time in the Recovery field will continue to track the voltage when the discharge has been removed, so you can see the cell recovery in the graph.

    On the right hand side, you can select the maximum discharge current that will be used as an extra safety measure.
    The Verbose mode will show all traffic between the app and the DL, below it is the title that will be used when you print the graph.



    In both Graph and Setup screens, there are tool/button/field highlights with messages to help you selecting them.

    Graph screen for the Batt Tester App

    When you select Start for a measurement with the button at the bottom of the screen, the app will send the setup data to the DL, the DL will show what it received and start the discharge cycle automatically and starts sending data packets to the app.

    The discharge process will start for a moment only registering the voltage without a load and then ramp-up the current. This allows you to register the starting voltage of the cell. 

    The Controller Message window will show the commands going back and forth, and if you have selected the Verbose option, you will see everything, including the data packets. The HB message is the heart-beat message for the serial watchdog. 

    The Stop button on the bottom will normally end the discharge cycle and enter the Discharge period. The Cancel button will forcefully terminate the process. In both cases, the DL will terminate the measurement and will be ready to accept commands for another test.

    There are many parameters saved in a Config.ini file, located in the same folder as the binary is located. You can have a look what's in there, and even change it if you want. Every time the Batt Tester starts, it will load the parameters in that file. It allows for a rapid setup for testing the same technology cells.



    In the above graph, you can see the first few seconds with the cell voltage without a load, then the load is ramping-up to the set discharge current (250mA) after which the discharge period starts. That will normally end when the cut-off voltage (0.9V) has been recorded. The cell voltage is averaged so it discards glitches and noise to make a clean cut-off voltage decision. After the cutoff voltage has been detected, the load is removed, and the recovery phase is started where you can see that the cell voltage has gone up a bit again. 

    The last message in the Controller Message window is that the Recovery period (I set it to 1 min) is completed. 


    The Copy command will copy only the graph, so it can be used in documentation:



    The Print command will add the pertinent data to the graph so you have a full record of the test.



    Finally, the Export CSV command will create a CSV file that you can use for further analysis.



    In this file you can see the start period and the ramping-up of the current in detail.


    Note
    The disparity between the asked for current of 250mA, and the DL applied actual current of 242mA is caused by an older calibration for my DL that I need to do again. It will never be exact, but should be very close.







    A final precaution

    Do not turn the Dynamic Load power off with a DUT connected. The decaying voltage rails may turn the load on, causing a current to flow in the DUT, even though the NFET's were turned off.

    For the best protection of your precious DUT, always disconnect the DUT from the Dynamic Load before you turn the power on or off.


    I may add more later... Stay tuned...

    Friday, April 5, 2024

    Designing a DIY DC Dynamic Load Instrument

     





    The Design Process of Building a DIY DC Dynamic Load

    The conclusion of a very long time investigating the building of a combined AC-DC Dynamic Load (DL) led me to the realization that this is not really possible. At least not without making drastic compromises about accuracy and precision. The AC measurements do not need to be very precise and are, in my case, only occasionally needed, but DC measurements typically need to have the highest precision, stability and accuracy.

    The attempts for this combined AC-DC DL are described in another Blog post. There is a lot of information there, so get some fresh Java and have a look. https://www.paulvdiyblogs.net/2022/08/dynamic-acdc-load-cc-cv-cw-batt.html

    The above picture shows a stage in the development with the new DC DL prototype as the basis.

    To help design this new version of the instrument, I asked for the help of my friend Bud. He is a real and accomplished designer, and we've done a number of projects together, like the high current RPi UPS, the VBA Curve Tracer and the 100MHz Differential Probe all described on this Blog in different posts.

    Bud started a Blog post on Hackaday mostly for the hardware design aspects that can be found here: Dynamic Electronic Load | Hackaday.io I have added that same information in a section below here, so it's all together in one place.

    At this moment, we have finished the design of the new version and the final board with V5.1 has been produced by my sponsor PCBWay.

    Although we have a stable fully working system, I'm still tweaking the software side a bit, because this instrument will do some things a bit different, compared to many other DIY DL designs.

    I'll explain that later in more details but here are some pictures to hopefully wet your appetite from the previous prototype V5: (this is almost the final version, read on...)



    Specifications:

    • Input voltage: 1..100VDC.
    • Reverse polarity protection to -100V and a 10A fuse.
    • DUT is disconnected by a relays for invalid inputs like reverse polarity.
    • Maximum current of 10A @ 40V
    • Maximum power 180W @25 degrees ambient temperature (heatsink temp 85C)
    • Off state DUT current 1.9uA at 2V, 57.7uA at 60V.
    • Volt Accuracy: 0.4%
    • Current Accuracy: 0.4%
    • Power input: 12VDC Wall-wart 0.5A with reverse polarity protection to -24V and PTC fuse
    • CC, BT & CV modes with real-time operation in hardware.
    • CP and CR modes have active regulation supported in software (resolution +/-156uA).
    • Pulse/transient mode supported by an external Function Generator. 5V=10A
    • Current monitoring with a DSO. 1V=10A
    • GUI: 128x128 OLED 1.5' color display and a rotary encoder with dual button functions.
    • Two temperature controlled fans.
    • Protection for over voltage, over current, over power and over temperature limits
    • Overall dimensions: 21cm long, 18cm wide and a height of 118cm.
    • Weight: approx. 1110 grams

    Available modes:

    CC = Constant Current mode

    CV = Constant Voltage mode

    CP = Constant Power mode

    CR = Constant Resistance mode

    BT = Battery Test mode (special CC mode)


    Testing the V4 prototype

    This earlier version for the AC-DC attempt is still using the Arduino Nano as the processor. It also had provisions for an on-board transformer, but that got too hot so I took it off.


    The Nano is not fast enough to process the CP and CR modes, which are regulated in software. At this time, I was planning on implementing the CV mode in software as well, but that did not work at all with this prototype. While looking for a faster processor, I eventually settled on the ESP32. It has all that we need, even though we won't be using the BLE and WIFI capabilities.

    This was the first time I really started to work with the ESP32 so I started to experiment with it. This processor is not only much faster than the Arduino Nano, it has a dual core and it has a native RTOS. (real-time operating system) I was hoping that these two features would overcome the Nano limitations.

    In the picture below you can see how I tested the ESP32 in-place of the Nano. I simply took the Nano out of it's socket, and used jumper leads to connect the ESP32.


    The next step was to test the ADC that we were planning to use, the 16-bit ADC1115 instead of the on-board 8-bit ADC from the Nano. The on-board ADC for the ESP32 has too many issues, so we can't use it with this application. The ADC1115 has double the resolution, the down side is that the communication with the chip through i2c is much slower.


    In the above picture you can see that I wired-up the ADS1115 ADC on a break-out board. With this prototype, I still used the 16-bit PWM functionality, but we were already planning to use a hardware 16-bit DAC.

    So after checking and verifying the changes, this resulted in a new prototype, that we called V5.


    Testing the V5 prototype

    Version 5 incorporated the ESP32, the 16-bit ADS1115 ADC, the REF5040 4.096 Voltage reference for the DAC, the 16-bit DAC8571, test hardware for the CV mode and Bud's vastly improved circuitry to drive the MOSFET's.

    Unfortunately, we discovered a few layout issues that we needed to fix by jumper wires and Manhattan style additions. We also found that the ADS1115 was happy with 3V3 i2c voltage levels, but the DAC, that we could not test earlier because of its tiny package, did not. That called for two bi-directional 3V3 to 5V level convertors, and I used a 4-channel circuit board connecting it Manhattan style to test that. To be able to increase the i2c clock speed, I changed the 10K pull-ups to 2K2.

    We then figured out a slightly different circuit for the CV mode, eliminating an extra DAC that we were planning to use. Using that earlier method would actually be cumbersome to drive with the planned user interface so the new method uses two CMOS switches to automatically change the configuration to use the same DAC for the CC mode and also for the CV mode.



    Unfortunately, we also found out that the heatsink I was planning to use, that would fit nicely in the enclosure I also wanted to use, could not handle the heat transfer. Not even close. Not only did things got really hot, we were far away from the specifications! I measured the NFET package temperature at well over 160 degrees C, and the heatsink temperature rose to almost 100 degrees, and that at a mere 90W for only a few minutes. Bummer!

    The obvious solution is to use a different heatsink with a significantly larger surface. 

    Unfortunately, larger heatsinks are very hard to find, unless you go for the typical PC CPU coolers. The ones that are available literally tower above the NFET, and it's not easy to use them for two NFET's or find an enclosure for this construction. 

    We found two heatsinks that looked promising and I ordered both of them. Luckily, the most promising arrived early, so we could start to test with it. This is the one on the left. It has the largest amount of contact surface. 

    The one on the right relies on a fan at the end (or even both ends) to blow the air through. Unfortunately, that calls for a small diameter fan and they have difficulty getting enough air displacement, unless they rotate faster, making a lot more of a whining noise. Which is another reason why it is not my favorite.


    The one on the bottom is the one I had been using. I purchased a number of them for other projects many years ago. I did an extensive search, but I could not find anybody offering them anymore. 

    The different heatsink called for a drastically different construction because the length of the leads to the NFET's and the critical components on the PCB are very critical. We did not want to split the NFET's and give them each their own heatsink, or mount them on either side of the heatsink.

    This is why we ended-up with the contraption below to just try it out. It did not need many PCB changes, so was relatively easy to setup and test. The original fan is now moved from the top to the bottom, getting its air from the bottom of the enclosure. The fan is blowing directly to the fins of the heatsink. We will need to use a second fan to suck the hot air out of the enclosure, which has some ventilation slots.

     

    The first test already showed that we could now easily handle 90W for quite some time, which was not possible with the previous setup. The enclosure we selected later required us to rotate the heatsink 90 degrees horizontally, so a fan mounted on the back panel can suck the hot air out.



    A longer-term test at 150W showed that we were on the right track. Everything stayed at manageable temperatures.


    At this moment, let me explain what you see on the above OLED display.

    On the top, you see the actual DUT (Device Under Test) voltage in blue and below it, the actual DUT current value in green.

    Below that is a line that shows the mode (CC = Constant Current) the NFET's are driving the DUT (ON)  and the actually calculated DUT power in Watt. The display is in red because the power approaches the maximum value and is there to warn the user.

    Underneath the horizontal line is the parameter you set with the rotary encoder. The mA suffix changes with every mode. The last line shows the actual 16-bit DAC value (while testing) and the heatsink temperature in degrees Celsius. The color is orange to warn the user that the temperature is above 60, it turns to red above 90 degrees.

    The colors are used to warn the user for conditions like over temperature (90), over-power (150), low (<1V) or negative DUT (wrong polarity), Voltage too high (>100V), over current (>10A), etc.

    The discrepancies in the display values for set/actual current are caused by the fact that for this test I didn't use the sense inputs yet so the drop in resistance due to the high power and long leads is not accounted for. Yet.

    The User Interface to drive the instrument is kept as simple as possible, and I let the software do most of the setup underneath the hood.

    The rotary encoder that you see mounted on the PCB is there so I can more easily test the setup with this prototype. It will later be placed on the front panel. In the CC mode, as you see above, you set the current by turning the knob. The knob currently has two speeds. If you turn it fast, the resolution goes to 10x so you get to your destination rather quickly. Short pressing the rotary encode button toggles the DUT output to on and off, by turning off the drive to the NFET's. A long press switches to the next mode. You simply cycle through the modes in a loop, so from CC to CV, to CP, to CR and from the BT mode back to CC. When you switch to another mode, the output is automatically disconnected, and the instrument is prepared for the next measurement. The mA suffix you see in the Set line, changes with the modes, so from mA, to V, to W, to R and in the BT mode back to mA. There is no separate transient or "pulse" mode, because this feature can be used in all modes. That may not be very practical in all modes but the pulse functionality is as versatile as your function generator supports. (amplitude, frequency, pulse form, pulse width, rise/fall times and offset)

    On the front panel, in addition to the rotary encoder and the OLED display, there will be two toggle switches, one for selecting the sense input terminals, and one to power on the unit. There are two BNC connectors, one for the transient/pulse input and one for the DUT current sense output to a DSO. There will be a USB-C connector to the ESP32 that is required in the Battery Mode and also allows for updating of the firmware. And finally, two sets of 4mm Banana connectors for the power connections and two 4mm Banana connectors for the sense inputs. Simple and efficient. And no, there is no keypad. It is not needed. I dislike keypads so did my best to design around it.


    A suitable enclosure

    The heatsink has been tested and verified that we can now easily get to 150W, but that is still outside of the enclosure. Because of the height of the contraption, we also had to find another enclosure that would accommodate this construction. Unfortunately, there are not many compact enclosures that answered our requirements.

    We prefer a plastic enclosure, because the heatsink is connected to the DUT through the non-isolated NFET's and that can get up to 100V DC.

    We also need to modify the enclosure to get enough air in and out. That's a lot easier to do with a plastic enclosure. And we want to be able to make a PCB-based front and back panel.

    The height of at least 9cm dictates that you will get (instrument) enclosures that are very wide, and not very deep. They are unsuitable for our requirements, but it's up to the other makers to select what they want.

    The enclosure we selected is from the company TEKO. They have many enclosure types, but we selected the AUS series that is pictured below. The top one in the picture below is the one I already used for several of my designs, and was planning to use for the DL. With the new hardware construction, it is not deep and high enough. The middle one is wider, but has the same height. We settled on the bottom one, the  TEKO AUS33.5.  TEKO is a German manufacturer but with a little Google-action, you can find them all over the world, and there are suppliers that send them all over the place. I use www.tme.eu a lot for my purchases, and they carry these enclosures.

    So with this version of the prototype, I have been very busy with the testing, implementing and again testing the changes we needed/wanted to make, and all the while further developing the software.


    Final Version 5.1 PCB

    Based on the now fully working V5 prototype, we have redesigned the board for the new heatsink configuration and made several other changes and corrections. The PCB has been produced again by my sponsor PCBWay. They financially sponsor this project by producing the boards and sending them to me free of charge. The turn-around is mostly within a week, and the quality is excellent.



    The small TO220 heatsinks you see on top of the NFET's help to disperse their heat better, because they are in the forced airflow. Instead of one 4-pin fan, we now have two connectors (the white ones top left) so the first fan sucks fresh air through the bottom of the enclosure and blows it to the heatsink. The second fan sucks the hot air out of the enclosure through the back. Both fans are temperature PWM speed regulated by the sensor on the heatsink.

    We also switched to another OLED display source, because the one I purchased many years ago was no longer available. We selected a good quality and commonly available version but that has a different pin-out so we fixed that on the PCB as well.

    Here is a quick sneak preview of the completed instrument. Note that I switched to even larger TO220 heatsinks on top of the NFET's to get rid of even more heat now that these fins are in the airflow of the second fan.

    Here is an overview of the construction.



    The unit has been stress tested with a 180W 15 minute test while using an IR-camera to keep an eye on the temperatures. I believe we can support 200W, but I don't have a large enough current source to test it out. 


    Above is a picture of the completed instrument. The sheet metal front panel that came with the enclosure was used to experiment and try out the connections. It will eventually be replaced with a PCB that will have the silkscreen indicating the functions and connections.

    Top left is the 12V DC power switch. The larger empty hole to the lower right of the power switch was a mistake. The power switch was in that position earlier, but it was too close to the ESP32 board so I had to moved it away.

    The black oval next to it is the USB-C to USB-micro adapter providing access to the ESP32. The USB connection to a PC is required in the Battery Mode, and can also be used to debug the firmware or upload newer versions.

    The four empty holes around the OLED display stem from an earlier attempt to fasten it to the front panel. At this moment, I use sticky tape to mount it. I have an idea that I will try when I design a PCB as the front panel that will not show any holes or screws.

    To the right with the large knob is the rotary encoder with push button that controls the setup of the instrument and the measurements.

    Lower left is the pulse/transient input BNC connector. It can connect to a Function Generator. The input voltage is 5V for a DUT current of 10A.

    Below it are the two 4mm Banana jack sense input connectors.

    To the right is the sense toggle switch, switching the voltage measurement to the sense inputs or to the main inputs. Using the sense inputs is really needed with high currents, due to the voltage drop over the main DUT leads.

    To the right are the main 4mm Banana jack DUT power connections.

    Slightly above that is the DUT current monitor BNC connector. The output is 1V for 10A of the DUT current.

    The back panel has the second 90mm fan mounted and also the 12V DC input connector.


    Battery Test Mode

    The Battery Mode application that runs on a PC, communicates with the Dynamic Load, sets-up the instrument and does the graphing during the run. The executable is available on the GitHub site. It's a single executable file that you can install on your PC wherever you like, and you can run it from there.

    There is a separate Blog post that has more information about the stand alone battery discharge project here: 
    https://www.paulvdiyblogs.net/2019/03/a-pretty-universal-battery-cell-tester.html
    My project was based on the work from John Lowen and his details can be found here:
    Unfortunately, it seems that John passed away, he is not returing any mails. He mentioned health issues earlier and that may have been fatal for him. He will be missed, I had a great and good working relationship with him when we were extending the capabilities of his design, that I used before, and are using now again.

    For this project, I modified the original code that was running on the Arduino, made it work in the ESP32 environment of the DL and integrated it into the main menu structure.

    Below is an example of the Battery Test mode. I'm using a Lithium 3.7V 14500 cell. The cell is several years old and had not been used. The specification is 650mAh and I tested it with a discharge current of 2500mA. The cut-off voltage was set to 3V.

    These values are entered into the Battery Test PC program below on the bottom left hand side.
    The test is started from this program, and it sends the parameters to the Dynamic Load and starts the measurement. 

    During the measurement, the display is refreshed with the parameters coming from the Dynamic Load, such as the voltage, the current, the time and the calculated mAh value, shown on the bottom right. The graph is dynamically updated during the measurement.




    As soon as the Dynamic Load measures that the cell voltage has dropped below the cutoff voltage of 3V, the measurement stops and removes the load. 

    Just above the green Test Ended message, the Controller Message shows a Serial Time-out, instead of the Cutoff Voltage, because it was waiting for another measurement that took too long to send the data. The DL terminates the waiting loop and restarts the reception of the setup parameters or a mode change automatically.

    This was a test of an EFEST 14500 IMR cell of 650mAh. These IMR cells can deliver up to 9.75A for short periods, or up to 6.5A continuous. Bud and I used these cells in the Raspberry Pi 3 UPS, to supply enough voltage to let the RPi ride out a power glitch or let it power down safely. I had not used these cells for many years and just charged them again for a few times to run this test. 

    With just over 550mAh, the test shows that the cell is no longer meeting the specifications of 650mAh, but is still usable.  

    In order to test at higher currents, you really need to use the sense inputs, which I did. I also used a metal battery holder, plastic ones would melt with these high currents.
     
    Note that I faked the Rated Capacity of the cell in mAh from 650mAh to to 2000, to overcome the calculated  time limitation in the software (rated mAh/current), which would terminate the measurement prematurely. You can save the details including the graph in a file on the PC, and when you do, you can enter more information about the cell and also add the weight of the cell, which is a good give-away indication for poorly "specified" or plane fake cells.

    When the measurement is terminated or ended, you can restart the measurement from the PC software and test another cell. Long-pressing the rotary encoder switch on the DL brings you back to the CC mode. The original hardware that was intended for this PC program would also re-start the Arduino Nano controller. We don't need to do that, the DL software automatically takes care of all that.

    [UPDATE] March 2026
    Bud and I teamed up again to create a brandnew version of the Battery Tester software, to add some desired functionality, like testing multiple cell battery packs and many others. That also required changes to the DL firmware to further integrate it and we made some enhancements to that code as well. More information is in the Building post, and on the Github site that has been completely revamped with a lot more information.

    Sunday, January 28, 2024

    Transformer snubber design using Quasimodo test-jig

    This is a little post about the transformer snubber design tool using the Quasimodo test-jig, designed by Mark Johnson.

    The link to the overall post is here and the pcb's can be ordered here.

    I've had this jig for almost 10 years and used it every time I need to add a transformer to my designs.



    The test-jig helps you to create an optimum snubber configuration for transformer windings having critical damping, without requiring any calculations and without measuring the transformer's inductance or capacitance.


    From the website: 
    A power transformer snubber is a wonderful thing for reducing or eliminating RFI from rectifier-induced LCR ringing. Unfortunately it's a huge pain to design and optimize a snubber. First you have to measure the transformer's leakage inductance and secondary capacitance, at about 100 kHz, which is not especially easy. Then you have to estimate the capacitance of your rectifier(s), which does not always appear in datasheets. Finally you plug these numbers into a formula that spits out snubber values -- and then you hope it's all correct.



    Here is the schematic of the Quasimodo test-jig:



    The name Quasimodo is used because it was the bell ringer of the Notre Dame. I like that name, it rings a bell! In essence the test-jig creates a 555 generated frequency and a fast MOSFET to create a pulse with a very sharp edge, ringing the transformer winding. The snubber is used to limit the ringing.


    Here is how you need to connect the transformer winding connections/shorts for various transformers. Note that the tranformer primary windings are all configured for 115V mains voltages. For 230V the windings need to be in serial. On the left side is the intended application with serial or parallel windings, on the right the way to use the test rig.  Make sure you short all windings except the one you want to measure:


    Below are some real test results on a Triad PP28-180 transformer with two independent primary and two independent secondary windings. See the first picture of the post for the setup.

    First, banging one of the secondary windings without a snubber:



    With a 10nF and a 1K resistor snubber:



    After tuning the snubber to 680 Ohm with 10nF:



    No more ringing, the bell is silent now. 


    An additional 150nF across the winding results in even more damping:





    Here is the result in my application (AC/DC Load):



    An observant user pointed out that the two electrolyte capacitors in the negative supply (C30 and C36) are upside down in the schematic.😕 
    Thank you Kirstin!




    Highly recommended!


    Saturday, July 1, 2023

    Building a 10MHz Master Clock



    Even though I have a GPSDO, and in the process to upgrade it, I still would like to build a 10MHz reference clock.

    I have a spare Oscilloquartz 8663-XS OCXO that I wanted to use for my GPSDO, but the lack of room on the PCB stopped me in my tracks.

    This OCXO is too good to not use, so I embarked on a little side project to put it to good use.

    For a very long time, I already collected information from another user (Gertjan Miedema) that built a frequency reference with that same OCXO, so I borrowed some of his ideas.

    Here is the link to that design : https://www.circuitsonline.net/forum/view/126987/1

    It's a Dutch forum but I take it you can either follow it, or use Google translate.

    There are three areas where I'm going to deviate from that original design. First of all, I'm not going to create a separate power supply for it. The unit will be on 24x7 and I did not want a normal transformer to power the unit. I have a nice 15VDC 1A wall-wart, so I'm going to use that. The stability and precision of the 15V is not that important for this design.

    The other area I'm deviating is by using different output transformers. There was a large effort to create very special hand-made transformers, but I did not want to go that far. I'm going to use the commercially available transformers that I already use for several other projects.

    Lastly, I'm not going to use the Oscilloquartz reference voltage to power the frequency setting circuit. It seems the logical thing to do, but this so called reference voltage is anything but a stable reference voltage. They are typically created by using a Zener (reference) diode like the TL431 inside the OCXO, but that is simply not good enough as you will see.

    During my work with the Reciprocal Counter, described in another post here, I found to my dismay how poor that reference voltage really is. Have a look at that post and search for the following update: "Testing the counter (11-05-2023)" towards the end.

    Here is a display of the Vref output that shows what I mean:


    This OCXO has been powered for many weeks 24x7 and is in a plastic container isolating it from drafts, but not the room temperature of course. It's easy to see that using the Vref of the OCXO will fall short when you really want a very stable 10MHz, because any variation in the Vref output, as little as micro Volts,  will show-up as a change in the output frequency.

    The Oscilloquartz is currently running while using the following circuit, put together after my "discovery". Here it is using a 10V reference I had in my stash already. This prototype is built on protoboard.



    My plan is to use the above frequency setting circuit, but with a REF5050, which is a 5V reference.

    Here is the schematic I decided on, with values corrected/tuned during the testing.


    Another deviation is that I only need two isolated 10MHz sine wave outputs, not 4.

    Most of the resistor values are taken from the original design and they work perfectly.

    My intent is to put the circuit in a metal enclosure, but put all the electronics in an isolated foam box inside the enclosure so the OCXO will warm-up the inside far enough above the maximum room temperature, hopefully reducing the temperature dependencies of the components.

    This is a side-project so may not get a lot of attention while I'm working on the GPSDO version 4 and the Reciprocal Counter.

    [update July 2023]

    I did manage to create a PCB layout.

    The two long multi-turn trimmers top left are from my old part stash, even through they date back to the 70's, they are genuine and of very good quality. They are Bourns 3059P trimpots. The adjustments of these course and fine trimmers will protrude through the front panel, the same as the two SMA output connectors. The length is 125mm and the width of the board is 99.5mm so it will slide in the typical enclosures I use.

    [Update November 2023]
    I got the PCB's and populated them. I found some issues with the silk screen and some footprint errors that I corrected in a V1.1b you see below. That is the actual version you can find in the Shared Project section of PCBWay. The files are also on my Github site here.

    Based on the specification for the Oscilloquartz 8663, I made a change to the supply. The voltage specification for the OCXO is 12V +/-5%. Originally, I wanted to use a 12V supply but the Schottky protection diode and the series resistor will bring that too much below that specification. The series resistor can be omitted, I left it in there because Gertjan measures the voltage drop and has a circuit that will show the oven activity. I decided to omit that for the moment, because I don't see the practical use when the unit is powered-on all the time. It makes more sense to indicate a stable output after the oven has finished the warm-up period. The additional circuit can be easily added by using a small separate PCB. 

    I now changed the raw DC voltage input to 15V and added an LM340 (or LM7812)  12V regulator that is mounted (isolated) on the side of the enclosure.




    There are some footprint refinements and silk screen errors on this V1.1b that are not reflected on the real PCB V1 below. This PCB was manufactured by PCBWay and as usual, has an excellent quality. One of the giveaway's is to look for holes that are drilled in pads. The hole should be exactly in the center, which they are. The gold plating of the pads makes it very easy to solder the components.



    I also designed a Face plate for the enclosure. Make sure you order the black color.


    Below is the actual PCB from PCBWay. The black finish with the white silkscreen makes it very professionally looking.


    After putting it all together and trying to calibrate the output with my GPSDO, I'm pretty impressed.

    I first tuned the output frequency to that of my GPSDO with the course adjustment, and then switched to the finer adjustment over longer times.


    Here I'm measuring the drift by using the maximum persistency of the DSO, while correcting the drift with the "fine" adjustment.

    It's a little hard to see on this screen shot, but the sine wave output is exactly 2Vpp into 50 Ohm as measured by the DSO.

    Here are some more pictures on how the inside of the enclosure looks and what I did to insulate the components as much as possible from room temperatures. It does not show the later added LM340 12 V regulator.


    Below is the insulation "box" or rather a cover, that I made out of 6mm Styropor. The box rests on top of the PCB. The bottom of the PCB is not insulated, but that is much less affected by drafts etc.

    I mounted the OCXO about 1-2 mm above the PCB so that there is minimal heat transfer to the PCB itself. There is also no ground plane below the OCXO again to reduce the heat transfer to the PCB. Obviously, the inside of the box will be heated by the temperature of the OCXO oven, but that will happen pretty uniformly.

    There are some holes in the insulation cover, but that is not a major deal I hope. It also prevents overheating of the OCXO as well.



    I use a small trip of Styropor on top of the insulation box such that the cover of the enclosure presses the insulation box on top of the PCB.

    Initially, I hooked the reference to my DSO, together with the GPSDO, to calibrate it. It's still drifting a bit after having been powered on for a month or so.

    At this moment I'm now feeding the output to my counter and will attempt to adjust the frequency, and also register the min-max and avg values.



    Running the tests and tuning the calibration is a matter of a lot of patience watching the deviation on the counter and making small adjustments to fine-tuning the frequency (;-)).

    The latest Gerber files can be downloaded from the PCBWay site here: 

    https://www.pcbway.com/project/shareproject/10MHz_OCXO_frequency_reference_1_of_2_ba8a8ef2.html

    And from my Github site here:

    https://github.com/paulvee/10MHz-frequency-reference/tree/main


    Purchasing various parts

    I was advised by the support people at PCBWay that my BOM is not complete enough for them to automatically populate the PCB, so I added some more information. The trouble is that I have not figured out how to add this information to the BOM I get out of KiCad, so use the BOM on the Github site.

    For FB1, 4 and 5 I used this Digikey partnumber: 240-2551-1-ND
    For FB3 I used Digikey pn 240-2391-1-ND 
    This is a 2A part, but you can also use the 1Amp version I used for FB1. 
    For FB2 I used Digikey pn 1934-1411-ND
    For U1, the REF02, I used Digikey pn 505-REF02CSZ-ND 
    For R4, you can use pn CSRN2512FKR500 but the footprint also supports the CSR1206FKR500CT-ND this is an optional resistor that you can also bridge.

    It’s is OK to use a 2.2uF capacitor for C14 and C16, this is not a critical value at all.
    For D1 I used general purpose Schottky diodes I have in stock. You can use the S1G with Digikey pn 1655-S1GCT-ND
    The Oscilloquartz OCXO is a used version I typically buy from vendors that advertise on eBay or Aliexpress. Just Google for “Oscilloquartz 8663-XS” to get the right version and then select the price. Here is one: https://www.ebay.com/itm/204065244750 
    I have very good experiences with seller Queen*s_land https://www.ebay.com/str/bluegirl5

    The enclosure I use has partnumber bi0002562 and is described as a "high quality aluminum project box/enclosure case" with the sizes 150x105x55mm. Here is a link that hopefully stays up for a while:

    https://www.aliexpress.com/item/32766709803.html


    Some assembly tips

    Before you solder the two SMA connectors in place, slide them into position on the PCB, they have a pretty tight fit. Then slide the PCB in the bottom enclosure and also mount the front panel to the bottom part of the enclosure. Move the SMA connectors so they are centered and protruding through the holes of the front panel. Tack them in place to the PCB with your solder iron. Now add the two trimmers and make sure they are aligned in front of the two adjustment holes in the front panel. Use some tape to secure them in position, slide the PCB out of the enclosure and solder one of the leads of the trimmers and check the alignment again. Only then solder all connections of the SMA connectors and the trimmers. With these four parts in place and the PCB in position, mark the place for the 3.5mm mounting hole in the bottom enclosure such that the PCB will always be in the right place.

    The red power LED will slide in the 3mm hole of the front panel, I use some glue on the back side to keep it there and use leads and a connector to mount it to the PCB.

    The four mounting holes on the front panel PCB need to be counter-sinked on the outside to use the screws that come with the enclosure.

    Enjoy!

    Paul


    If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw