element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
Open Source Hardware
  • Technologies
  • More
Open Source Hardware
Blog Building a Logging-Capable Power Supply
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Open Source Hardware requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 23 Aug 2018 11:10 PM Date Created
  • Views 6186 views
  • Likes 11 likes
  • Comments 26 comments
  • bench top power supply
  • data-logging
  • power supply
  • frdm-k64f
  • frdm
  • project morpheus
  • morpheus
  • logging
  • frdm-family
  • data_logging
  • logging power supply
  • nxp
Related
Recommended

Building a Logging-Capable Power Supply

shabaz
shabaz
23 Aug 2018

  • Introduction
  • Background to the Project
  • Hardware Overview
  • What Functionality is Implemented?
  • Using It
  • What Performance does it have?
  • How to make it?
    • Morpheus Main Board
    • FRDM Board Software
    • Setting up and using mbed-cli
    • TFT Screen
  • Summary
  • Appendix:
    • PCB Renders
    • Issues Tracking
      • Revision 1 PCB
    • Attachments

 

 

Introduction

Sometimes it is interesting to make test equipment, even if it can’t replace commercial products. Through making it, I learn about my limitations too, but it is also an opportunity to explore and make things that commercially may never make sense due to limited appeal or functionality.

 

This project is exactly that - a unusual and fairly restrictive project today, but with some uses, and there is potential to modify and adapt it : )

 

The 3-minute video here explains the project briefly, and shows a demo of it all.

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

 

It’s main limitation today is the small output range: 5V DC max, at up to 1.5A. Due to the limitation it cannot replace a general-purpose main bench supply.

 

Anyway, enough negativity about my own project in the introduction: ) On the more positive side, this project can still offer a few handy capabilities for some projects I hope. The functionality it provides is a mix of a power supply, an ammeter and voltmeter and a data logger with dynamic display, all mashed together basically. Unlike other power supplies, this one continuously charts current consumption, so you can visually see even quite slight fluctuations in the circuit-under-test, at all times. This photo is showing the brief spikes in current every second, from a desk clock.

image

 

It is a surface-mount project, but it’s achievable with a normal soldering iron.

 

The solution overview diagram is shown below. Apart from the main board, all other parts are off-the-shelf low-cost modules.

image

 

Background to the Project

The very first project at uni that we had to work on was a bench power supply : ) It taught us how to wire mains plugs, what things to do for basic safety such as strain relief for cables, and how to heat-sink the voltage regulator so that things don’t overheat : ) Nowadays there are more tighter rules concerning mains operated projects, so it probably wouldn’t be constructed in the same way today.

 

Fast-forward into the IoT age, and I was focused a couple of years ago on testing portable low-power devices that would occasionally draw a lot of current, but for very brief periods.

 

Many devices sleep for long periods and then occasionally chew up a burst of power to process or transmit data. It’s quite difficult to catch the bursts but also capture information about how frequent the burst occur. If this information were available, it would be possible to see how long batteries may last for, or to discover if the device is transmitting unnecessarily frequently. There are many scenarios where it could be handy.

 

As a result of this need, I started Project Morpheus which was a battery simulator. It was to be used to on-the-fly simulate a battery under dynamic conditions, and predict battery charge usage. It’s still a work in progress. However, enough of it works that it can already function as a basic power supply with logging capability. When/if the code is complete, lots of functionality is opened up. Currently it can be used for powering and monitoring circuits, and logging data at several thousand samples per second, i.e. good enough to see sub-millisecond bursts of current demand, but it is possible to increase that with some more effort in the software. The code is just prototype quality currently.

image

The Project Morpheus main board detail can be found in some earlier blog posts (See Building a Battery Simulator - Part 1  and Building a Battery Simulator - Part 2  and Building a Battery Simulator (Project Morpheus) - Part 3 ). The circuit diagram and the PCB files are attached to this blog post. I still need to generate a bill of materials (BoM), that will be complete in a few days.

 

Hardware Overview

The earlier diagram shows the Morpheus board connected to a NXP FRDM boardNXP FRDM board. The FRDM board is a bit like an Arduino – it can be coded using near-identical commands.

image

 

Any controller board can be hooked up, provided a serial peripheral interface (SPI) is available. Eventually I will swap to a Linux board such as the BeagleBone Black.

 

The diagram below shows the Morpheus board functionality.

image

 

The entire left side of the board contains an adjustable voltage regulator and some heatsinking for it. Power is applied to the board at the bottom. The microcontroller board is attached to the I/O connector at the bottom-right of the board. The SPI bus is used to configure the digital-to-analog converter (DAC) that controls the adjustable voltage regulator. At the output of the voltage regulator, there is a sense resistor and amplifier circuit to create a voltage that varies as the current changes. There is a small connector that can be attached to an oscilloscope to capture this. The right side of the board contains an analog-to-digital converter to pass the measured current value to the controller board. For voltage readback (to confirm the DAC and voltage regulator are behaving correctly and for auto-calibration), a voltage proportional to the output voltage is available to the microcontroller (so that the microcontroller’s ADC can be used to monitor it). However things are still reasonably accurate (typically within 10mV) even without such calibration, for an unloaded supply. Once the supply is loaded, I see about 27mV drop at the board output terminals, at 5V 500mA load. A lot of this (15mV) is due to the sense resistor, and so power calculations can be quite accurate if this is taken into consideration in the software.

 

There are a couple of other bits of minor functionality, but the key areas have been covered.

 

For the user interface, the TFT display was an afterthought but it works quite well. But, generally so far the user interface is crude. The USB connector on the FRDM board exposes a serial connection (at 115200 baud) to a connected PC, and there is a basic menu system to select the desired output voltage. This of course is inadequate, and eventually some isolated interface (e.g. Ethernet) will be used, as well as a keypad or touchscreen control (for example). I’ve not given that much thought so far either.

 

This project is restricted to 5V output maximum, because I’d originally intended it to simulate a single LiPo cell. This is very restrictive for a general bench supply, but still lots can be done because many portable projects operate from 5V or lower voltages.

 

The maximum current is 1.5A, but the maximum measurable current can be optionally lower, depending on an on-board current sense resistor value. A future implementation of this project could have switched sense resistors. Currently I’ve soldered a 30 mOhm sense resistor to the board, which allows me to measure up to 700mA. If I need to measure up to 1.5A then I’d need to change the sense resistor.

 

Anyway, 1.5A or 700mA, at up to 5V, should hopefully be sufficient for many IoT projects. This project is really just a prototype, and it could be redone one day with higher voltage and current ranges.

 

The Morpheus board requires 5-5.5V for operation. With a 5.5V supply, the output can reach the full 5V DC, however the maximum possible output is slightly lower if a more commonly available 5V supply is connected. But for most circuits, the difference is negligible. If fitting in an enclosure, an enclosed chassis AC to DC PSU could be used, as they often have a trim adjustment for setting non-standard voltages provided it is close to the stated voltage.

 

What Functionality is Implemented?

The hardware functions, but the code needs a lot of work.

 

From the USB serial menu system, it is possible to set a value for the desired output voltage (in millivolts) and switch the output on or off. With a bit of software effort, extra features like current limiting or electronic fuse could be implemented.

 

By default the system displays on the screen a chart of current consumption, at 10Hz. This is fast enough for casual observation of current consumption perhaps. From the menu it is possible to capture at a faster rate (a few thousand samples per second today, but it could be improved), and it displays a snapshot of about two seconds of capture. There is no permanent log today (the plan is to log to a micro SD card because the FRDM board has a socket for this) but once it has filled its buffer (hard-coded currently to 10,000 samples) it does dump the measurements to the USB serial console. PC serial terminal software can be configured to capture to disk, and then the file can be imported into MATLAB / GNU Octave. It is hardly convenient, but this will be improved later.

 

Also, as mentioned earlier, there is an analog amplified output suitable for directly attaching to an oscilloscope too.

 

Using It

Here is an example of how it can be used currently. I set up Project Morpheus to supply 4V to an external device, and monitored the oscilloscope output, to see the current consumption.

 

The oscilloscope trace below shows the current consumption. It is clear that the connected load is of low power but is occasionally demanding short bursts of current (circled in red because they are hard to see). These bursts occur every second, but they could be more rare, and you may want to capture for many minutes or hours. This ‘scope has 8-bit resolution so the noisy looking stuff at the bottom isn’t very clear. Oscilloscopes aren’t intended for logging for such long periods.

image

 

Here is the output captured via the USB serial dump and then imported into MATLAB; it looks similar to the ‘scope capture:

image

But, it is possible to zoom into this. In the chart below, the vertical axis has been changed to logarithmic, so the low-level detail is clear as well as capturing the short bursts. Now it can be seen that as well as the short 10 msec bursts of heavy current, there is some small fluctuation in current consumption at other times, in a repetitive pattern.

image

Based on the sample rate, it is now possible to deduce that the tiny stuff at the bottom is remnants from a 50Hz source (UK mains).

 

Here’s another example; I attached a Raspberry Pi 2B+ onto the output, set it to 5V and turned on the output. This photo shows the chart on the TFT screen during Pi boot-up for the first 50 seconds – this is from the slower (10Hz) logging that occurs continuously, it doesn’t need any configuration. I figured that way, one is more likely to catch interesting behaviour, by having the system continuously charting always, whenever the supply is used.

image

 

I really liked having this continuous view, because I could see the slight changes in current (the vertical resolution is 2mA per pixel on this chart) whenever I typed commands or executed anything. It would be possible to optimise software for portable battery operation with this power supply.

 

As another example, I set the y-axis to 1mA per division (currently it is hard-coded so I had to edit the code to do this) and the horizontal setting to 2 seconds per division, and then attached a small analog table clock to the output. It uses a single AA cell, so the output voltage was set to 1.5V.

 

It was possible to see each spike as the clock moved its seconds hand. This is quite an extreme test for the continuous charting feature though, because each spike is very brief. Apologies for the poor photos – the resistive touchpad on the TFT screen is very glossy : (

image

 

From the menu system the high-speed capture was started, and it logged to a buffer for a brief period of time. Here is the output:

image

 

Currently the x-axis doesn’t update for the high speed capture. Also, it just plots data points (with no attempt to join the dots) in the high-speed logging mode.

 

Anyway, it can be seen from the circled content in the photo above that the burst seems to have two mini spikes. To see more detail, the analog output connector on the board can be attached to an oscilloscope:

image

 

What Performance does it have?

Performance has not been measured. Things seem reasonably accurate for the use-case. For resolution below 100uA, it would be worth using a different sense resistor. Most home battery-powered IoT devices demand bursts of current nowhere near 700mA or 1.5A, so changing the sense resistor value could be a reasonable compromise.

 

For more accurate measurement of standby current, an ammeter should be used. But for seeing trends such as bursty increases of current consumption, Project Morpheus could be handy hopefully.

 

How to make it?

There are just a few steps. The Morpheus board needs to be constructed of course, but it is a straightforward exercise. The board files are attached to this blog post, for sending to a PCB factory. The parts values can be found from the schematic, but the bill of materials will be supplied shortly too.

 

Then, it needs to be attached to the FRDM board (using jumper wires). Next, the FRDM board software needs compiling and downloading into the board. That should be sufficient to test the solution, using the USB serial menu capability! Finally, the TFT screen can be attached. All the steps are detailed below.

 

Morpheus Main Board

The Morpheus board is nearly all surface-mount, but most of the parts are very easy to solder on although a few take a bit more care (but feasible with a normal soldering iron). There is a DC jack for supplying 5-5.5V DC to the board.

 

A load of jumper wires can be used to patch out to the FRDM board. Eventually I may make an ‘interconnect PCB’ to simplify this, for either the FRDM board or BeagleBone Black.

image

 

FRDM Board Software

Next, the software for the separate microcontroller board needs compiling and programming into the board. There are two main ways to do all this. One way is to get a free account at mbed.com and use the online text editor and compiler. Once you click on ‘Compile’ in the browser, the binary output file will be downloaded to your PC and you can drag-and-drop it to the microcontroller board (it has a USB connection that looks like a USB memory stick). The other method is to download an environment to your PC, called mbed-cli. It allows for the software to be coded and compiled on the PC instead. For this project, I took the latter approach and it is discussed below.

 

Setting up and using mbed-cli

Follow the instructions here: ARM mbed-cli

 

As part of that, download and extract gcc-arm in a folder.

Then notify mbed-cli about its location, using this command (change the path to suit where you extracted gcc-arm):

 

mbed config -G GCC_ARM_PATH "/home/shabaz/development/mbed/gcc-arm-none-eabi-7-2018-q2-update/bin"

 

Create a new project using:

 

cd development/mbed
mbed new K64F-battsim
cd K64F-battsim/mbed-os

 

Then as root user:

 

pip install -r requirements.txt
apt-get install gtkterm

 

Now go back to the development/mbed/K64-battsim project folder, become a normal user (i.e. not super-user) and type the following to install the TFT library code:

 

mbed add http://os.mbed.com/users/WiredHome/code/RA8875/

 

Download the code attached to the bottom of this blog post, and dump everything into the K64F-battsim folder.

 

Edit the Makefile. The line to modify has my username in it. Change it to your username. The FRDM board looks like a USB memory stick to the OS, so the line containing /media/shabaz/DAPLINK needs changing to whatever path your machine chooses. If you're not sure, just plug in the board and then have a look what file system path gets mounted.

 

After you've saved the Makefile, you're ready to compile the code!

 

make

 

Next, to install the code into the FRDM board (assuming it is plugged in) type:

 

make install

 

You should see a green LED close to the USB socket on the FRDM board flash briefly as the code is transferred into the FRDM board.

 

To connect to the USB console to see the menu system, as root user type:

 

make console

 

It should automatically open up a window and connect to the USB serial connection. If it doesn't work, you'll need to edit the Makefile and change the line containing /dev/tty/ACM0.

 

TFT Screen

The screen is available from many vendors on aliexpress and likely ebay too. There are several variants. The one to get should operate from 3.3V and configured for 4-wire SPI operation. There are versions with resistive or capacitive touch capability, but that has not been implemented in the code yet, so this is optional. The model number of the display is ER-TFTM050-3 and when configuring it to purchase, make sure 4-Wire SPI, and 3.3V operation (not 5V) is specified.

 

To operate the screen from the same 5-5.5V source as the rest of the project, a DC-DC converter is needed to convert to 3.3V. This could be an off-the-shelf module, or it could be constructed using an IC. I used a ST1S10 chip and followed the datasheet to construct this.

image

 

Summary

Although a lot more work needs to be done, the basics of a 5V 1.5A logging power supply were presented. It is quite a straightforward project, and I think is worth the effort to assemble, even though it will never replace a general purpose supply for the lab.

 

The next step is to get it all assembled into an enclosure and work on implementing more features!

 

 

 

 

Appendix:

PCB Renders

Most parts are installed on just one side, but a few passives and a serial Flash memory device are installed on the underside. The memory isn't used currently, but will eventually be used to store board-specific calibration data if desired.

To construct the project, the voltage regulator and DAC portion could be assembled first, and checked that the output is as expected by (say) running a test program on the microcontroller board. Next, the current sense amplifier and analog current measurement portion could be assembled and tested. Finally, the ADC part could be assembled to complete the functionality.

 

image

image

Issues Tracking

Revision 1 PCB

There are no known electrical faults with the PCB, however the following tweaks could be made in a future rev 2 board:

  • C6 pad needs to be increased from 0603 to 0805
  • Replace OUTPUT LED with a red LED instead of green
  • T2 and R13 text is touching each other
  • Move text J1 slightly right
  • Perhaps better silkscreen for the 20way connector (J4)
  • Move text J4 slightly right
  • Electrolytic silkscreen needs marking with semi-circles to indicate polarity
  • U4 silkscreen needs a dot, not an asterisk
  • Change MOSFET names T1/T2/T3 to Q1/Q2/Q3
  • Change R14 from 1M to 10k, to protect the MOSFET better
  • Consider replacing the DAC with a more coding-friendly one
  • Consider Welwyn OARS (OARS1) series current sense resistor, it has lower temp coeff. for the same price (but is physically larger)

 

 

 

Attachments

These are the attached files, linked below:

export-battsim...  : PCB Files

K64F-battsim-export.. : Source Code

main.pdf : Schematic

Attachments:
export-battsim-1-aug2018.zip
K64F-battsim-export1.tar.gz
imagemain.pdf
  • Sign in to reply

Top Comments

  • shabaz
    shabaz over 6 years ago in reply to fmilburn +4
    That's very neat : ) 12-bit is great for granular adjustment for a 5V supply. On my project, I used the DAC output (adjusted with an external op amp for suitable range) to create a voltage across R1 in…
  • Fred27
    Fred27 over 6 years ago +4
    A very nice project as usual, shabaz . fmilburn If you need to monitor the power on MSP430 projects have you looked at some of the devices that support EnergyTrace? I believe the power tracking on that…
  • shabaz
    shabaz over 6 years ago in reply to michaelkellett +4
    I thought I'd take a stab at it, and the guts of it kind-of-works, but needs lots of tuning. There was a ready-made library called CMSIS DSP with some PID functions, so I used that. I only set the 'P,…
  • Problemchild
    Problemchild over 6 years ago in reply to mcb1

    Agreed the situation is near impossible ...we can try however!!!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 6 years ago in reply to Problemchild

    so maybe we'll catch up on a few

    Yeah ... No

    As much as I finish one project, another one turns up.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Problemchild
    Problemchild over 6 years ago in reply to shabaz

    Shabaz I may thieve a few ideas from the supply in terms of the current measurement etc.

    I think I may go fully Linux powered mainly 'cos it's now as cheap as a controller and gets the data logging and storage for nearly free computationally also a free WIFI and or NIC for remote control etc.

    Ive bought a few instrumentation cases for projects this winter so I'll be building them in to those I bought at the Telford Rally today !

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Problemchild
    Problemchild over 6 years ago in reply to mcb1

    Unfortunately  thats a problem for most of us as projects just billow over our tables.

    Now it's September the nights will start drawing in so maybe we'll catch up on a few. Im sure a concerted attempt to finish all those part projects will fill any length of winter.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 6 years ago

    Nice work.

    Not sure how I missed this one earlier.

     

    As tempting as your pcb offer is, I really don't need another distraction ....

     

    Cheers

    Mark

    • Cancel
    • Vote Up +2 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