Meter/datalogger for low current measurement

This device has a high sampling rate and long duration ideal for measuring current consumption for low power device that uses sleep mode.

Similar projects worth following
I need something that can take samples of current at a high sampling rate and average over a long period of time. Multimeter isn't very good for this and my oscilloscope while can sample very fast, but it doesn't have high resolution. So something like this would be a useful tool for optimizing low power design.

Microcontroller based devices can wake up do something for a few tens of microseconds and go back to sleep mode for seconds or minutes to save power. Measuring this type of current consumption pattern is very hard as multimeter do not typically do not sample more than a few times per second while typical oscilloscopes can sample at very rapid rates do not usually have more than 6-7 bit of resolution nor have long sampling time.

The following screen cap is from Silabs Energy Profiling tool in Simplicity Studio. It is used as an example of what the current of such a device may look like.

The idea is to be able to sample at very high speed to capture fine details of short duration current spikes. The current is averaged for that sampling period and stored on the SPI FLASH. This averaging allows for high sampling rate and yet cut down on the amount of data and the data rate to be recorded. There is always a limit on storage capacity and write data rate.

Block diagram

Here is a block diagram of what I have in mind. The device operates on battery and can data log DC current consumption of low power devices over a long period of time. I am also trying to limit the cost of BOM to $10 U.S. to make it an affordable DIY hacker's tool.

The current of the device under test is sampled by a series resistor. The resistor value is kept small to minimize the effects of the voltage drop. The voltage drop across the resistor is fed to two amplifier circuits with different gains for different current ranges and sampled by with the on chip 12-bit ADC with (up-to) 1M samples/sec. The ADC data is DMA into a circular buffer in the ARM's internal RAM.

The two ranges allows for higher dynamic range for the measurement. e.g. 200mA and 200uA full scale ranges could be used to measure the active and sleep mode power consumptions. The firmware can sample the two channels at the same time and decide afterwards which range should be used for the calculating the average for that duration.

An average of the current is computed by the ARM core and store in a buffer to be written into SPI FLASH using DMA. Data captured can be display on the LCD as an average downloaded to a PC. The connection to the PC is isolated to prevent possible ground current loop between the device under test and the PC.

  • Microcontroller prototype

    K.C. Lee04/27/2016 at 22:08 2 comments

    I soldered up a STM32F030F4 modules for this project. (It is part of a batch I build today.)

    I haven't put on the header as this module might be wired directly inside the battery case.

    This is what I wired up so far:

    I am using a ferrite for the analog power VDDA as I'll be using the onchip ADC for the project.

  • Power Supply Design

    K.C. Lee04/04/2016 at 16:58 0 comments

    Here is what I have as the power supply so far. I still have to calculate the values and likely optimize the design as the circuit evolves.

    The AP3012 is a 1.5MHz boost SMPS. The datasheet specified the part to operate above 2.6V, but I have tested two of the parts from the same lot and they both starts at around 2.2V. This circuit runs off 2 AAA (rechargeable) batteries, so that's a convenient under-voltage cut off.

    Charge pump (D2, D3, C14, C15) provides a negative rail (~-3V) for the shunt reference U7 which generates the -VR reference voltage for trimming the opamp.

    The STM32F030F4 part use the analog rail for ADC reference and the datasheet requires that VDDA to be same or above VDD, so I need to have a reference grade power supply for the VDD.

    Most of the regulators in my stock have 50-100ppm/°C or worse (no specs for AP3012!), I have decided to make my discrete LDO using a voltage reference TL431AC. Pretty interesting that the smaller SOT23 packages having a higher typ, but a lower max. TCO.
    Note: Circuit is operating with IKA = 1mA, so the results might be different.

    The shunt reference U1 is used to regulate the output voltage for the discrete LDO. Charge pump (D4, C10, C16) forms a high voltage positive bias rail for Q1 which allows the circuit to have low drop out (~ 0.1V)

    Here is the preliminary layout. It looks like the routing could be done single sided with a solid ground plane on the back to improve EMC.

    I put in the shunt reference for the negative reference for trimming the opamp.

  • Current sensing

    K.C. Lee03/31/2016 at 22:02 1 comment

    I have been looking at various opamp at my disposal that can be used for sensing DC current. With an opamp circuit, it would look something like this. It is a non-inverting amplifier that does ground sensing. There are issues with hidden ground path in a system.

    The main problem I have with opamp wired up in non-inverting amplifier at high gain is that their Vos (input offset voltage) also get amplified. The input DC offset is usually around a few mV but can be in the hundreds mV range at the output for modest amount of gain. That's one of the reasons why I look at the bandwidth requirement to see if I can do better with opamp that are built for low Vos instead of speed.

    While digging through my collection of parts, I came across TI's INA201 High Side Current Shunt Monitor. It is specifically design for high bandwidth (300kHz), low offset (+/-2.5mV max) at 50X gain and common mode range of -16V to +80V. That last part is very nice as it means that I can optionally measure the input voltage.

    When used with a 0.25R current sense resistor, the full scale current is about 0.25A.

    The voltage across the resistor is: 0.25A x 0.25R = 0.0625V which is small enough to not affect the circuit under test.
    0.25A x 0.25R x 50 V/V = 3.125V Voutput swing is (V+-0.15V typ)
    ADC resolution: 0.25A/4096 = 61uA

    Using a non-inverting amplifier for the low current range, I can increase the resolution to uA range. I just have to deal with the consequences of opamp's Vos and calibrating it out in firmware.

    Ooops. I guess this High Side Current Shunt Monitor doesn't work too well when the voltage is below 20mV i.e. 80mA, so this is no good for my application.

    The fine prints says:

    As VSENSE approaches 0mV, in these VCM regions, the device output accuracy degrades. A larger-than-normal offset can appear at the current shunt monitor output with a typical maximum value of VOUT = 300mV for V SENSE = 0mV. As VSENSE approaches 20mV, VOUT returns to the expected output value with accuracy as specified in the Electrical Characteristics.

    I guess I have go back to the ground sensing using non-inverting amplifier.

    For small amount of Vos, I would rather subtract it off in the firmware, but not for this application due to the high amplification. Analog Device app note: MT-037 shows the way to provide a DC offset for opamp in non-inverting configuration. I can use this technique to compensate for the Vos.

    I guess I should throw some of the links here on current sensing as a bookmark on the subject:

    I have used TI's INA145 difference amplifier for current sensing in a project.

    Maxim's parts:
    MAX44285 common-mode range: 2.7V-76V BW: 80kHz
    MAX44284 common-mode range: -0.1V-36V BW: 3kHz
    MAX4239 Ultra-Low Offset/Drift opamp used in uCurrent - A Professional Precision Current Adapter for Multimeters.

    My previous Project log:

  • Goldilocks and the three bears - she is just a fuzzy eater!?

    K.C. Lee03/31/2016 at 16:10 0 comments

    I have been doing a bit of thinking. A low pass RC filter is an integrator. Since we are trying to find out the average current over a period of time, numerically the actual bandwidth doesn't matter (as long as the integration time is much larger than the time constant to capture all the information.)


    Here is what I simulated. I have a pulse of 100ns at 1V. I use LTSpice to integrate the area under the curve over 1ms of the waveform at 3 points: the voltage source, the first RC (100ns time constant) and the second RC (10us). All three comes out to be 100uV give or take some values after the decimal point.

    Reality and conclusion

    • It is difficult to measure the source waveform directly to preserve the shape. Fortunately, I am not building an oscilloscope here. I don't care too much about the actual shape of the waveform, but rather the area under it.
    • It is far more difficult to get an accurate result out of the second RC with the larger time constant as the voltage is around 10mV. The signal can get swarm out by DC offsets, ADC errors etc.
    • The first RC filter is good enough and it can also act as an antialias filter.

    This basically tells me that the bandwidth of the analog frontend is not as critical as I think, but I would still try to use a high sampling rate to calculate the area under the curve.

    Note: In LTSpice, press the control key while clicking the title (e.g. V(n003)) to get an average or RMS value of the zoomed waveform.

  • Proof of Concept Case & Power

    K.C. Lee03/30/2016 at 09:27 0 comments

    It used to be 3 weeks, but the shipping time from China has slipped to 2 months since beginning of this year. So getting a case for the guts would be useful, so I made an impulse purchase for this. I only paid $0.65 for this thanks to a sale. :)

    It is a battery holder/case for 4 AAA batteries. I'll convert it to hold 2 batteries and jam the guts of this project in the vacated space. This project is probably going to be a ghetto built, as I really can't afford to be wasting 2 months of my schedule waiting for a PCB. Two years ago it was 2 weeks, last year 4+ weeks and it doesn't need a genius to figure out the next number for that sequence for this year. I blame Canada customs and Canada Post.

    I'll be using some of the spare parts from last year for this project. A 1.5MHz boost converter regulates the voltage from 2 NiMH batteries. I may be cleaning that with a LDO. I'll mount a "Nokia LCD" cover it with a piece of plastic and some buttons on the other side of the case.

    The battery case finally showed up today. The battery case is decent looking and made of very solid (ABS?) plastic. The size is just about right for the LCD which would be mounted outside of the case. I'll use a piece of thin plastic over the LCD to protect it from scratches.

    The battery contacts are removable and I have converted it to a two AA cell configuration with the remaining space for the electronics. The wiring is a bit flimsy, so I'll replace them at some point with better wiring.

    I removed the divider by scoring on the edges and carefully cracking the plastic with a plier. There is about 0.8" x 1.8"x 0.44" (20.32mm x 45.72mm x 11.17mm) for electronics.

View all 5 project logs

Enjoy this project?




[this comment has been deleted]

K.C. Lee wrote 05/11/2016 at 10:32 point

I do not have the intention to move this project beyond making PCB at home.  Right now Canada Custom has a 6 weeks wait time for slow shipment from China.  I am talking about 8 weeks on average for my shipments from China that used to be 2-3 week before this year.

I do not have any cash flow at the moment to throw money at this project.  Not enough of an interest from others from what I have seen so far.

  Are you sure? yes | no

K.C. Lee wrote 05/11/2016 at 15:12 point

I was talking about importing anything from China in general since 2016.  

Canada Custom is making shipment slow because they don't have people to inspect in coming postal packages into Canada.  So for anything other than courier or EMS, add 6 weeks to delivery time in 2016.  Since my projects are for a competition with a deadline, I cannot afford the extra wait time.  I lost so much time last year because of shipping issues.

For courier shipments, there is a very expensive processing fees if the package value being shipped is over $20 Canadian.

As for PCBA, I am not going to be worrying about that until I have a project that a lot of people want to buy.

  Are you sure? yes | no

JP Norair wrote 04/12/2016 at 15:01 point

Have you considered using a LogAmp with a dividing current mirror on the input side, to shift-up the current detection range a bit? (most top out at 10mA).  I use a LOG114 EVM (i think this is it) from TI to do low current measurements in the lab.  Works great, but I don't often need sensing above 10mA.

  Are you sure? yes | no

K.C. Lee wrote 04/12/2016 at 16:41 point

I was actually looking at those logamp (MAX4206/MAX4207) on Friday for a different project.  It is an interesting idea to get the large dynamic range.  :)  In my case I only need to worry about 1uA - 100mA range.

I place an order for a couple of MAX4239 "Ultra-Low Offset/Drift, Low-Noise,  Precision SOT23 Amplifiers".  Finger crossed for the samples.  I am going to be using ground sensing and float the logger with batteries/optoisolate the serial port.

uCurrent uses this particular opamp: as a 100X amplifier.

  Are you sure? yes | no

Roman wrote 04/01/2016 at 04:18 point

Hi, I am not sure if I understand it right. It looks to me that you need two different sensing resistors. Voltage drops across a shunt resistor can be significant if resistance is too high in mA range.  In micro Amp range you can use higher shunt values as long as noise is not an issue. 

  Are you sure? yes | no

K.C. Lee wrote 04/01/2016 at 04:42 point

The issue with that is the current consumption has a large dynamic range which can change over time as the device wake up do something (probably in the 20-30mA range) and goes to sleep (probably in the 1-10uA range).  I have to be able to average those together in real time so I can't change resistors on the fly.

I try to compromise by using the smaller resistor and add additional gain stage for the lower current range.  (The amplifier will introduce more noise to the system.)

I have seen the other way of doing this is to use a high resolution ADC.  This is what the Mooshimeter does.  This adds cost and lower the overall bandwidth.

I want to try something different.

  Are you sure? yes | no

Roman wrote 04/01/2016 at 15:46 point

That makes sense. I have a similar problem with the multimeter I am working on. I have a 24 bit converter and my hope was that with 1 Ohm shunt I can get to uA range. In my case noise is a huge issue. I have 60 Hz in very low amplitude ( a fraction of a mili-Volt), but it is enough to mess up the reading.

  Are you sure? yes | no

K.C. Lee wrote 04/01/2016 at 16:23 point

Most of the multimeter chips uses an integration period that is a multiple of 50/60Hz so that the noise from the AC mains get cancelled out.

If there are AC coupling, sometime the values is smaller and sometimes the values are higher, so I hope those type of noises are cancelled out by the very long integration time in my project.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates