element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Test & Tools
  • Technologies
  • More
Test & Tools
Documents Programmable Electronic Load
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Test & Tools to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 23 Dec 2016 1:09 PM Date Created
  • Last Updated Last Updated: 11 Oct 2020 8:05 AM
  • Views 16074 views
  • Likes 20 likes
  • Comments 401 comments
Related
Recommended

Programmable Electronic Load

Peter, Jon and Jan are building a programmable electronic load. This document is the common design sheet.

It's obviously work in progress. And fun.

 

image

 

 

We're building a programmable DC load. The focus is on making a real world working instrument.

Hardware and firmware are open source.

  • 20 V, 6 A
  • SCPI controlled

 

To keep this document readable, this main post gives an overview of the design.

All detailed explanations are broken out in separate posts.

 

Hardware

The load design is modular.

 

image

 

Two out of box modules:

  • MSP432 LaunchPad
  • LCD Shield (optional)

3 new designs

  • DAC-ADC module
  • Analog control module
  • Power module

 

DAC-ADC BoosterPack

image

This module is a generic, isolated DAC / ADC boosterpack. It's the interface between the analog controller and the microcontroller.

It can also be used outside this project, for your other analog - digital conversion needs.

The board design is broken out in a separate post: Programmable Electronic Load - DAC / ADC BoosterPack.

 

Analog Controller and Driver Board

This is the core of the analog constant current block. Here lives the circuit that will translate desired constant current into the driver signal for the power MOSFET.

It integrates the feedback coming from that power board. This is a closed analog control loop.

There are also components to provide the on-off functionality and buffers/amplifiers for the analog data-points that fly back to the ADC module.

image

The board, schematics and BOM are documented in Programmable Electronic Load - Analog Controller and Driver Board.

 

Power Module - the MOSFET Board with Fan

 

image

 

For details  of the design of the power stage, check Programmable Electronic Load - Power Stage.

 

BoosterPack Header Use and Pin Allocation

This info is broken out in a separate post: Programmable Electronic Load - BoosterPack Header Use.

 

Firmware

 

Prerequisites:

  • CCS 8 with MSP432 compiler TI v 16.12.0.STS or >
  • TI-RTOS for MSP43X, any SimpleLink version
  • MSP432 LaunchPad (not the black pre-prod because it's out of support)

 

The firmware is for the MSP432 microcontroller. But the harware can be driven from any controller, processor, PSoC or computer that can deliver i2c and power between 3V3 and 5V.

That includes Arduino, Raspberry Pi, BeagleBone, Warp7, IOT20xx, the ST Neo family, ... As long as they match that voltage range and have I2C master, it 'll work.

The ADC/DAC board takes care that the logic side is galvanicaly isolated from the power side (that is, if you leave the P1 and P2 jumpers open).

 

The only requirement is that you have a positive supply between 3V3 and 5V, a ground, and I2C signals (the board has I2C pull-ups that connect to the positive supply that you provide. If you don't want that (maybe your dev board already has 'm), leave R1 and R2 off.

ADC, DAC and Enable are all I2C driven.

 

GITHUB location: https://github.com/jancumps/msp432/tree/master/MSP432_SCPI_ElectronicLoad

download latest source files as a zip : https://github.com/jancumps/msp432/archive/master.zip

doxygen generated API documentation: https://jancumps.github.io/msp432

GIT artifacts don't contain CCS project files, only sources - get a zip with CCS project from the attachments at the end of this document.

image

 

SCPI interface and Error Handling

The SCPI commands are documented in this breakout post: SCPI interface.

 

UART Configuration

Together with SCPI, UART is the programming interface of this instrument.

The approach, and how to compile for USB or TTL, is documented in this breakout: UART.

 

RTOS and Posix Configuration

The TI-RTOS documentation is in breakout post RTOS Config.

 

LCD Display

Check here for a detailed explanation: LCD Display

The firmware supports SHARP LCD display,

 

 

 

image

image

 

ADC

 

I've broken out the ADC description to a separate post, because I'm working on improvements:

Programmable Electronic Load - ADC Firmware

 

 

DAC

 

DAC output is set on command, using RTOS MailBox and messaging.

The payload for a DAC message contains the DAC channel that needs to be set, and the value.

 

typedef struct MsgDAC {
    uint8_t module;
    uint16_t value;
} MsgDAC;

 

The DAC task is started by RTOS. It inialises the DAC settings, then waits until it receives a message.

 

void *threadDAC(void *arg0) {


    MsgDAC d_msg;
    d_daci2cTransaction.writeBuf = d_dactxBuffer;
    d_daci2cTransaction.readBuf = d_dacrxBuffer;
    d_daci2cTransaction.slaveAddress = DAC_I2C_ADDR;
    d_daci2cTransaction.writeCount = 3;
    d_daci2cTransaction.readCount = 0;


    mqd_t mq;
    struct mq_attr attr;


    attr.mq_flags = 0;
    attr.mq_maxmsg = 1;
    attr.mq_msgsize = MSGDAC_SIZE;
    attr.mq_curmsgs = 0;
    mq = mq_open(QUEUE_NAME_DAC, O_CREAT | O_RDONLY, 0644, &attr);


    while (1) {
        ssize_t bytes_read;
        bytes_read = mq_receive(mq, (char *)&d_msg, MSGDAC_SIZE, NULL);


        /* wait for mailbox to be posted by writer() */
        if (bytes_read) {
// ...

 

The waiting doesn't take processor time. RTOS takes care that it will only get a slice of clock cycles when there is a message.

Two things in the RTOS configuration make this happen:

The mailbox with room for exactly one message, and a receive event.


Because there is usually no message in the mailbox, the execution of the DAC logic becomes inactive at this line:

 

        bytes_read = mq_receive(mq, (char *)&d_msg, MSGDAC_SIZE, NULL);

 

When we send a DAC message somewhere else in the code (e.g.: when the user requests a new setting of the electronic load), RTOS reactivates the process and hands over the payload message.

The DAC task sets the output of the requested channel and returns to the point where it waits for a new message.

 

   while (1) {
        ssize_t bytes_read;
        bytes_read = mq_receive(mq, (char *)&d_msg, MSGDAC_SIZE, NULL);


        /* wait for mailbox to be posted by writer() */
        if (bytes_read) {
            d_dactxBuffer[0] = getAddressFromModule(d_msg.module); // set value direct
            d_dactxBuffer[1] = d_msg.value >> 8; // MSB
            d_dactxBuffer[2] = d_msg.value; // LSB
            if (! I2C_transfer(i2c_implGetHandle(), &d_daci2cTransaction)) {
//                System_printf("I2C Bus fault\n");
//                System_flush();
            }
        }
    }

 

You select the DAC channel by setting bit 2 and 1 in the control byte (tx_buffer[0]). There's a helper function that gives a correct control record.

 

// address 7 - 6: 0, load mode 5 - 4: 01 direct from i2c, 3: reserved 0, 2 - 1: channel select, 0: pwr down 0
#define DAC857X_CFG_H0 0b00010000
#define DAC857X_CFG_H1 0b00010010
#define DAC857X_CFG_H2 0b00010100
#define DAC857X_CFG_H3 0b00010110

 

 

static const uint8_t array_DAC857X_CFG_H[4] = {DAC857X_CFG_H0, DAC857X_CFG_H1, DAC857X_CFG_H2, DAC857X_CFG_H3};

/**
 * get the hex address for the requested DAC module
 */
uint8_t getAddressFromModule(uint8_t module) {
    return array_DAC857X_CFG_H[module];
}

 

Bits 7 - 3 and 0 are all fixed.

 

image

image

 

Input Enable

 

The functionality to activate and deactivate the load is documented here: Programmable Electronic Load - Input Enable Functionality .

 

Control Strategies

 

The firmware uses strategies to handle the different types of load operation (e.g. constant current, constant, voltage, ...).

 

A strategy is a set of functions that you can plug in, and that together run that particular operation type (this is a c version of the Gang of Four's Strategy Design Pattern).

The goal is to avoid that the firmware is riddled with if or switch statements whenever different behaviour is needed depending on the instrument's mode.

Each operation strategy will have the same set of functions that run the instrument in that mode.

The price to pay is not expensive - speed and memory burden is low. It is a little more complex to understand than the c++ version. Once you step trough it with a debugger, things become clear.

The code also tries to hide that we're using strategies

 

Currently starting to implement constant current strategy. The more difficult operation types can be added later, one by one, with not too much impact on the existing code across the firmware.

. Only the eload API (see below) knows about it. All code goes via that eload API.

API for the stategies is minimal now:

 

    controlFunction;
    getMode;
    getChar;

 

  

eload API

 

The eload API offers an abstraction layer for the strategies, so that the rest of the firmware doesn't have to know about it. It simplifies switching operation mode and driving the instrument.

 

Example: The eload API offers a simple function eloadGetMode() to check what the instrument's current mode is.

 

eload_mode eloadGetMode() {

    return getControlStrategy()->getMode();

}

 

In the background, it uses the strategy mechanism to fetch the mode from the currently active strategy and call the implementation function.

 

return getControlStrategy()->getMode();

 

The eload API also has the common eload functions that don't need a strategy because they are always valid, regardless of mode.

 

Calibration and Configuration Data

 

The functionality to store calibration and configuration data in Flash is described in a separate article: Programmable Electronic Load - Calibration Data in Flash.

The calibration and configuration procedures are documented in Programmable Electronic Load - Calibration Steps

 

Changes To Standard MSP_EXP432P401R.c

 

The standard file generated by the TI-RTOS application wizard has defaults for peripherals.

The following has changed: none - I removed this section because with the external ADC/DAC board and the SimpleLink RTOS version, everything is kept standard.

 

Remote Software

 

Teminal

 

Serial communication to the USB UART port.

9600/8/1/None

image

SCPI is a non-echoing protocol. To make the characters you type show in the Terminal, set Local echo to Force on.

If you also set Local line editing to Force on, you have the opportunity to correct characters in the current line before they are sent to the serial port.

image

 

Test:

*IDN?;SYST:ERR:COUN?

Should return

THEBREADBOARD,ELECTRONICLOAD,0,01.00;0

 

Windows GUI

 

There are two image. A .NET made by Peter, a Java version made by Jan.

 

The .net GUI supports reading the 4 ADCs, setting one of the DACs abd shoot any SCPI command.

There's a window for SCPI output and a status window that shows SCPI errors.

image

Source and binary available from https://github.com/thebreadboard/SCPI_DC_LOAD_WIN

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

The Java GUI is made as a POC that cross-platform instrument GUIs are possible.

It allows for switching the load on and off, set constant current and replicate the LCD values.

Additionally, you can requesst error status and run arbitrary SCPI commands.

Programmable Electronic Load - Java GUI Part 1: Basic Functionality

 

image

 

 

LabVIEW

 

The instrument comes with a LabVIEW library: Programmable Electronic Load - Write a LabVIEW Library part 1: Initialise Block

image

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

 

Related blog

Programmable Electronic Load - Input Enable Functionality
Programmable Electronic Load - Power Stage
Programmable Electronic Load - Temperature Protection
Programmable Electronic Load - DAC / ADC BoosterPack
Programmable Electronic Load - Analog Controller and Driver Board
Programmable Electronic Load - SCPI interface and Error Handling
Programmable Electronic Load - UART
Programmable Electronic Load - RTOS Config
Programmable Electronic Load - Calibration Data in Flash
Programmable Electronic Load - Calibration Steps
Programmable Electronic Load - LCD Display
Programmable Electronic Load - ADC Firmware
Programmable Electronic Load - Current Sense Circuit
Programmable Electronic Load - BoosterPack Header Use
Programmable Electronic Load - ToDo and Done
Robert Peter Oakes articles:
Electronic DC Load - Design and Build to test PSU Project
youtube: Electronic DC Load Design and Testing
youtube: Full Build Analogue DC Load
youtube: Electronic DC Load - Performance Improvements
Raspberry PI 2, Fun with I2C DACs and ADC's
jc2048 articles:
Programmable Electronic Load: Dynamic Behaviour: Part 1 Overview
Programmable Electronic Load: Dynamic Behaviour: Part 2 The Servo Loop
Programmable Electronic Load: Dynamic Behaviour: Part 3 Effect of Output Inductance
Programmable Electronic Load: Dynamic Behaviour: Part 4 Effect of Output Voltage Change
Programmable Electronic Load: Dynamic Behaviour: Part 5 Stability
Programmable Load Build
Jan Cumps articles:
Programmable Electronic Load - ADC and DAC BoosterPack test
Programmable Electronic Load - Analyse the Summing Node Zero Point
Programmable Electronic Load - Measurements Part 1: Control Circuit
Java GUI
Programmable Electronic Load - Java GUI Part 1: Basic Functionality
Programmable Electronic Load - Java GUI Part 2: Support for Current Mode, Input On/Off, Error Log
LabView
Programmable Electronic Load - Write a LabVIEW Library part 1: Initialise Block
Programmable Electronic Load - Write a LabVIEW Library part 2: Read Output Block
Programmable Electronic Load - Write a LabVIEW Library part 3: Close Block
Programmable Electronic Load - Write a LabVIEW Library part 4: Function Set Block
Programmable Electronic Load - Write a LabVIEW Library part 5: Input Control Block
Programmable Electronic Load - Write a LabVIEW Library part 6: Raw DAC Block
Programmable Electronic Load - Write a LabVIEW Library part 7: Raw ADC Block
Programmable Electronic Load - Automating a DC Switcher Efficiency Test with LabVIEW
Programmable Electronic Load - LabVIEW Test Automation: Characterise the Instrument
Programmable Electronic Load - LabVIEW Test Automation: Characterise the Instrument Pt 2: Oscilloscope Measurements
Example LabVIEW Scenario: test a design with a Rigol PSU and a Keithley DMM
TI-RTOS: Switching to the SimpleLink Distribution
Switch from TI-RTOS to SimpleLink POSIX: Threads and Semaphores
Switch from TI-RTOS to SimpleLink POSIX: EEPROM API
Switch from TI-RTOS to SimpleLink POSIX: From MailBox to Message Queue
Switch from TI-RTOS to SimpleLink POSIX: LCD Display Driver
Switch from TI-RTOS to SimpleLink POSIX: Sleep when Idle
Attachments:
pcb_proto.zip
eload_v1_20170227.zip
eload_1_2a.zip
https://community.element14.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-21/bom.ods
MSP432_SCPI_ElectronicLoad_20180102.zip
eload_power_20180104.zip
eload.zip
eload_examples.zip
MSP432_SCPI_ElectronicLoad_20180514.zip
measureefficiency.zip
measureefficiency_5V_10V_600mA_RAW.zip
MSP432_SCPI_ElectronicLoad_v_00_0_0_1_20180914.zip
MSP432_SCPI_ElectronicLoad_20190706.zip
  • load_cell
  • metrology
  • msp432
  • ti-rtos
  • launchpad
  • laboratory
  • instrument
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 5 years ago +4
    Revisiting the eLoad design - there's definitely room for approval. The very low currency (minus 3 mA) is awful. And the calibration is off. I've set it to 0.5 A- and it thinks it's drawing that current…
  • Jan Cumps
    Jan Cumps over 7 years ago in reply to Jan Cumps +3
    All components are now in and soldered. Time to test. I'll first check out the power rails in isolation. If they are ok. I'll mount LaunchPad, LCD and and DAC board and do measurements. Hang on
  • Jan Cumps
    Jan Cumps over 7 years ago +3
    good news: I finally got persistent saving of calibration/setup sorted out. At first I had issues getting the in-ROM Flash api recognised by the compiler when using it with RTOS. That turned out to be…
  • Jan Cumps
    Jan Cumps over 5 years ago

    API documentation is now availabe on the github pages: https://jancumps.github.io/msp432

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Robert Peter Oakes
    Robert Peter Oakes over 5 years ago in reply to Jan Cumps

    Much more specific and clear.

    I know you know Jan, my comment was for other newer engineers that may be reading this and may have got the wrong idea

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to jc2048

    I've done the measurements, from 0 to 1 A, with DAC increments of 100 : Programmable Electronic Load - Current Sense Circuit. Spreadsheet attached to the new post.

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to jc2048

    I'm running a loop of 101 measurements, starting from DAC 0, 100 increment per step. PSU set to 4 V, same as the manual measurements.

    It will run into the power supply current limit that I set to 600 mA (I was obviously not thinking when I configured the flow - noticed when it was in loop 36 image ).

     

    I think I'm going to create a fresh post for this exercise - tired of navigating to comment page 16.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jc2048
    jc2048 over 5 years ago in reply to Jan Cumps

    The gain is the slope of your curve. To see what it's doing, calculate the gain for each segment like this

     

    image

     

     

    It's falling off a little at the top end. You'd be able to see much better if you did this from your automated test data with smaller steps [but don't make the steps too small or you won't have the resolution to calculate the gain accurately].

     

    I think you can work out the offset at the input to the op amp from those figures as well. The offset at the output is 2.57mV (get that by projecting the line back to the horizontal axis), then the offset at the input is 340uV [output divided by the gain]. I think that's right. If not, one of our resident experts will correct me, I'm sure. That's within the datasheet range of +-1000uV [FET input op amps aren't usually too good on voltage offset]. It's a bit higher than the TYP figure of 250uV, but not too far off.

     

    BTW I'm really NOT an op amp expert. I learned the theory a long time ago, and reading datasheets properly is second nature to me now, but I don't have all the experience that someone who works regularly with this kind of circuitry has.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to jc2048

    jc2048  wrote:

     

    This is what it looks like plotted. Gain [slope] is a bit off, but you also have an offset too [doesn't go through (0,0)].

     

    image

    I've made a setup to get an automatic measurement. Using a relay to switch the meter probe between shunt resistor and the x7.8 OpAmp (U3C) output.

    image

     

    I'll collect the results in a spreadsheet.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to Jan Cumps

    Jan Cumps  wrote:

     

    I'll update the schema to make that more obvious too.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to Robert Peter Oakes

    Robert Peter Oakes  wrote:

    ....

    one tip I would also suggest is not to draw the inputs of the opamp (Via the 100k resistors) connecting to the same points as the fet connects to the resistor or the output terminal. it could be miss-understood by a beginner. this is effectively a 4 wire Kelvin connection and that is why in the original diagram I showed the connection as close to the body of the resistor as possible. wiring this incorrectly will introduce significant errors due to wiring resistance, especially at higher currents

    image

    Hope this helps understand my thinking

    It is layed out like that on the PCB, with Kelvin traces to the resistor pads directly.

     

    image

    I'll update the schema to make that more obvious too.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to Robert Peter Oakes

    Robert Peter Oakes  wrote:

     

    This would imply that the OP Amp is non linear in the region being used, or it is very close to its operational limits.

    what op-amp are you using here and what supply rails to the op-amp ?

    The device is an LT1058

    Rails are +12 and -5.

    All is well within the range, when measured relative to the 0V node.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Robert Peter Oakes
    Robert Peter Oakes over 5 years ago in reply to Jan Cumps

    This is shaking of some cobwebs lol

     

    Also please note that in the diagrams here, the node showing 0V is not a real 0V but a virtual one if you like.

    As a complete power supply, the entire analogue system is floating on the positive RAW supply rail. this is treated as 0V by the op amps etc.

    As a DC Load, the analog 0V is again not the loads 0V, it is on the positive side of the sense resistor, the loads 0V is on the negative side so as the current increases the analog 0V will rise relative to the load 0V. only by the voltage drop across the sense resistor, but a rise never the less. As the supplies to the op-amp exceed any sense voltage, the op-amps never go outside their operational range

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube