High speed, high dynamic range current logger for emdedded debugging (we did it) - Page 1
Forum section: electronics / projects

author: Oleg Artamonov
author_rank: Contributor
timestamp: February 11, 2019, 11:08:53 pm
content: Hi everyoneRecently we (www.unwds.com, don't bother, its in Russian anyway) started to look for decent current logger for low-power embedded system debugging and battery life prediction. The problem is, we needed something likemax 10 us acqusition period and min 50 kHz bandwidth, otherwise it will miss short eventsmin 10^7 dynamic range, from 1 uA (sleeping MCU) to a few amperes (2G modem at full power)cheap, to put it on every developers' table and make them use itObviously, $50 SiLabs devboard is not an option (we have some, but 6 kHz sampling rate and 50 mA max current...), Keysight N6705B is nice but is not something I'm ready to put on every table in the office. CurrentRanger seems nice, but overpriced and some specs and technical details (mostly related to software) are unclear for me — it is Arduino based, so I'm not sure about actual performance and latency.Long story short, we build it.Specs:3 us sampling rate, 50 kHz analog bandwidthover 10^7 dynamic range with 3 switchable shunts — 0.1 uA to 3 A; ranges are overlapping and there's some hysteresis10 us typ, 20 us max shunts switching latency40 mV maximum burden voltageonboard 2.0...3.5V (in 0.1V steps) 3A DC/DC supplyexternal power supply up to 18Vsupply voltage measurements (useful for testing battery powered systems with real batteries)onboard LCD with uA max, mA*h accumulated and mW*h accumulatedUSB interface and powerUSB CDC (virtual UART) console with time, average voltage, average current and accumulated energy reporting every 10 to 1000 ms (user selectable)UART-to-USB bridge for DUT console/bootloader/etc.SWD/DAPLink interface for DUT programmingBOOT and RESET signals for DUT control/programmingmatchbox sized (37×50 mm)$50 retail priceThe very first version (back in December 2018) used INA214, so specs were worse, but after taking some preorders and ideas and playing with prototypes we changed schematics (price rose a bit, but its still reasonable).As for now, it consists of:OPA2376 + LM7705 "true zero" amplifier (LM7705 provides low-noise negative supply voltage, so we don't care about "rail-to-rail" being actually "20 mV apart from rail")0.01 Ohm, 1 Ohm and 100 Ohm shunts, 0.1 % low-ppm resistorsIRLML6344 or IRLML2402 MOSFETs for low-current shunts, IRLHS6242 (14 mOhm @ 3V Vgs) for 3A shuntlow-side current measurements (so we don't need expensive instrumentation amplifier)47 MOhm + 4.7 MOhm voltage divider for voltage measurements (so parasitic leakage is less than 0.1 uA @ 3.6 V), buffered by OPA2376ST1S10 DC/DC (I really love it, I failed to kill a single one of them in all the years I use them), output voltage set exclusively by 16-pos rotary switch, so you can check voltage before even powering itTXB0304 for UART and SWD interfaces (fully symmetrical, unlike TXB01xx and most other level shifters)TIC33M LCD displaySTM32F042K6 CPU (32 KB flash, 6 KB RAM, 48 MHz, crystall-less USB)Some choices were based on components availability from local distributors, because we were in a bit of a hurry to build it, still, actual specs are very pleasing. Anyway, we don't want to compete with Keysight, we needed reasonably priced and reasonably working device for everyday use.Firmware is based on dap42 SWD-DAPLink project, sources are free and available athttps://github.com/unwireddevices/dap42/tree/umdk-emb(build target is UMDK-EMB, you'll need arm-none-eabi-gcc + make), main file ishttps://github.com/unwireddevices/dap42/blob/umdk-emb/src/stm32f042/umdk-emb/target.c(I know, it's 995 lines of code, I promise, we'll split it... someday). The whole thing is based on libopencm3.ADC triggered by hardware timer and uses DMA with 200-words circular buffer, range switching is based on ADC analog watchdog feature. Buffer is being read twice every cycle, when half-full and complete full, so no data is lost during processing; when switching ranges, data accumulated prior to switching are processed and then DMA is resetted. Voltage is measured once every 10...1000 ms (same as reporting period), so a few current sample are missing here.Basic functions (power on/off, display mode, target boot mode, SWD on/off) are accessible via hardware buttons, but there are UART console commands too, so it can be controlled by some script or application running on PC.UART console is ASCII-only, no binary data, so it can be used on any OS with regular RS232 terminal. Anyway, we wrote a simple logging application for PC/Windows.Can be used without PC connection, e.g. if you need to check real-world power consumption of some device, just power it from USB adapter, leave it for a week and then check how much milliampere-hours DUT gobbled (extremely useful with "send-data-once-a-day" IoT devices like water or electricity meters).Drawbacks:doesn't have crystal, so without PC connection timings are not exactly accurate (±4 % at 25 °C); with PC connection, it syncs with USB frames, so timings are ±0.5 % accurateI'm not exactly happy with precision at the lower end of current ranges because of ADC offsetwould like to have ability to take high-resolution graphs, but it takes a lot of RAM, so we need bigger, faster, pricey CPU for thatI was told UART bridge doesn't work with TI CC3200 bootloaderSome pictures below — photos, console output, PC software, current range switching waveform (yellow is a voltage across the load, other lines are Vgs of MOSFETs controlling shunts — one pic is switching from range 0 to range 1 with 0 to 35 mA load step, another is range 0 to to range 2 with 0 to 2 A* load step, so all three shunts are involved).* — actually it was a short circuit through some thin wiresWe didn't publish schematics yet, but I think we will, maybe with the next HW revision. Anyway, if you want to build something like this by yourself and have questions, ask.Can be ordered, of course. Price is $50 plus packing and international shipping $10, so $60 total, Paypal oleg@olegart.ru (we registered business account, but it is "being verified" for something like 3 weeks now). If you live in Russia, Belarus or Kazakhstan and want to order, please contact me directly at oleg@unwds.com or better place your orderhere, for EACU countries we have other shipping options.If you have any ideas about software/hardware/functionality, please share.