A small current monitor and logger for power debugging.
Thought has become action and action has given way to existence. That which once was not now is.
I have assembled the first Clogger board.
In the process, I noticed that I forgot to put decoupling caps on the fancy 24 bit ADC, so we will see if it even works - I might have to do the first board rev just to fix that.
I can't really test it until I have drivers for the ADC, so I am working on drivers for the ADC now.
I decided to follow the suggestion by K.C. Lee to use a current sense amplifier, but to add a dummy load to push it into the linear region.
The advantage to using the current sense amplifier is that the clogger will work for a wider range of supply voltages (for the device under test). The max4428f is also less expensive than most of the instrumentation amplifiers that I was looking at.
The power supply for the device under test is reverse voltage protected. The Teensy 3.2 has 5v tolerant pins, so I decided not to level shift the uart and flag signals.
K.C. Lee referred me to the MAX44284, which was helpful. Its specs were close to those of the MAX9923F that I was looking at, but it smaller and almost half the price at scale!
|v offset||i bias||gain error||CMRR||Vo min||$pk|
Maxim also offers a spice model of the MAX44284f on their website, so I set up a simulation just to confirm the problem I noticed the other day.
The purpose of learning is to expose the lies we have accepted in our model of the universe. To pursue truth is to feel more acutely its absence. If anyone would learn, they must remember what they have 0.00005forgotten that they did not know.
The MAX9923 is not going to work. Actually, none of the amplifiers that I picked are going to work. While looking for a spice model of the MAX9923 I came across a good article by maxim about estimating error sources for current sense amplifiers.
They identified five different sources of error, explained what they mean and how to calculate them, and linked to a useful online calculator. As I expected, a large portion of my error came from the offset voltage of the amplfier, but the error due to the common mode rejection ratio was actually way higher (228uV vs a conservative 50uV on the output side).
The common mode rejection ratio described the ability of the amplifier to reject variation on the input signals that is common to both. They way that they say to estimate the error from this term is to compare the common mode voltage that you expect your system to use to the common mode voltage at which it was characterized. The datasheet says that tthe MAX9923 was characterized at a common mode voltage of 12V, and I am expecting use voltages between 4.2V and 2.9V. According the maxim article, unless I use common mode voltages close to 12V, I am going to get errors that completely drown out my signal. Even though the datasheet says that common mode voltages can range from 1.9V to 28V, the further the common mode voltage is from the voltage it was optimized for, the larger the effects of the common mode rejection error are going to be. None of the amplifiers I looked at were optimized for the range in which I want to work.
On top of that, the error calculator revealed to me that the MAX9923 has a specified output range. According to the datasheet, the min output voltage is between 1mV(typical) and 10mV(max). Using the highest gain amplifier, I would have to use a sense resistor of ~8Ohms to product satisfactory output voltages at my minimum current spec of 5uA. At my max current spec of 100mA, this would mean a voltage drop of 0.8V - way too much.
What does this mean? 1) common mode voltages are going to make it very hard to measure small currents. 2) I am either going to need higher gains or an amplifier with a lower minimum output voltage.
Practically, I think this means that I have to give up on using a high-side measurement system. A low side system will get rid of the common mode voltage problem and will open up more amplifier options to me.
After digging through the bowels of digikey, I have picked the microchip MCP3561 for the analog to digital converter. It is a 24 ADC with a maximum sampling rate of 153.6kHz and can talk over SPI at 2MHz. It can also perform cross cycle redundancy checks to make sure that the data was not mangled in the transmission.
It would be nice to have a slightly faster sampling rate, but a comparable ADC at 250kHz is almost 10x more expensive. For a 60uS current spike we will still get almost 10 samples.
The datasheet suggests that I supply the reference voltage using an MCP1501 high precision buffered voltage reference, which sounds like a good idea.
For the microcontroller, I think it is important for it to be arduino compatible so that the device is community friendly. Since it needs to be fast and is going to interface with a computer, the teensy 3.2 seems like a good option. This will also distribute the cost of the device - people can use the teensy for other things if they want to.
The higher the value of the shunt resistor is, the lower the errors due to the amplifier input offset will be. Because I am going to place the shunt resistor above the system load, using a larger resistance value will not affect the ground value seen by the system.
I think I can tolerate a maximum voltage drop of 10mV. If I am powering my device with a single cell lipo, that would leave plenty of head room. It will make it a bit harder to test the full life of coin cells, but I think that is acceptable - you want a tolerance on that anyway, right?
At a max load of 100mA, and a max voltage drop of 10mV, I am looking at a 0.1ohm shunt resistor.
At my lowest target current (5uA) this resistor would give me 0.5uV ... which is just over 2xVos for the MAX9922t (the nominal value anyway). That's cutting it close, but it should be good enough.
0.1% tolerance resistors cost ~$3.5 per thousand, and they are rated for watts. I am going to have to calibrate these things anyway, so I am not going to opt for a perfectly trimmed resistor when I can get a 0.5% tolerance resistor for $0.29 (the FC4TR100DER).
|1.32A||132mV||3.3V||X rng||X rng|
Assuming a 24 bit ADC and a 3.3v reference voltage, the LSB of the system will be <0.2uV.
The hardest part of this project is going to be picking the correct amplifier. I want to be able to measure currents accurately across a wide dynamic range. At the least, I want to be able to measure currents down to 5uA and up to 100mA, but a higher top end would be preferable. it might be necessary to use different amplifiers for difference ranges, but I would like to avoid that if possible.
To give an idea of the types of currents that I want to be able to measure, here is a predicted current consumption estimate for the nRF52 preparing to send a bluetooth notification.
The shortest current spikes are only 60 microseconds in length, and the idle current when the radio is not active goes down to 2.0uA. I don't think it is necessary to measure nano-amps of current, it might be important for systems using coin cells, but for systems with rechargeable batteries it is enough to know that the quiescent current is ~<5uA.
In contrast to the nrf52, which is optimized for low power operation, your typical arduino program will use ~50mA - even if it isn't doing anything. Here is a power sample from a very simple arduino program that is just polling a magnetometer and feeding the data out to a serial port.
For systems with motors, large displays, or lots of LEDs, even higher ranges would be necessary, but I don't think it is going to be possible to design a single system with a dynamic range from 5uA up to 1A. For now I am just going to focus on the 5uA to 100mA range.
My first inclination was to use a current sense amplifier (sometimes called current monitors). As the name implies, the are specialized instrumentation amplifiers designed specifically for measuring high-side currents (measured above the system load) developed across shunt resistors. The cool thing about current sense amplifiers is that they can measure common mode voltages that exceed their supply voltages. This means that you can have amplifiers like the TSC101 that can measure common mode voltages ranging from 2.8V to 30V even when supplied by only 4V. This dark magic allows you to put your sense resistor above your load instead of putting it down next to ground.
The problem with current sense amplifiers is that they have huge dead-zones at low input voltages. For example, check out this plot from the TSC101 datasheet.
* the ina233 has an integrated ADC, so the bandwidth doesn't matter. How fast is the sampling rate? Well, it only has an i2c interface, so probably not that fast.
** cost is per thousand.
Annoyingly, the best looking amplifier is also the most expensive one. The NCS210RSQT2G looks pretty good and the price is appealing, but the variance on Vos is much higher than the maxim amp. I might look into the cheap...Read more »
Bearing in mind that the goal of this project is to create a tool that makes it easier to debug and optimize devices that need to operate on very low power, I think that the clogger should have at least the following features:
There are plenty of other features that would be nice, but not essential:
Based on these features, there are really just three main systems: the amplifier, the analog to digital converter, and the controller (which includes the sd card, the led indicators, and all the communication systems).