RGB LED Current Measurement With Nordic Power Profiler Kit II

by kevinjwalters in Circuits > LEDs

2138 Views, 3 Favorites, 0 Comments

RGB LED Current Measurement With Nordic Power Profiler Kit II

ppk2-unicorn-2-65.JPG
ppk2-block-diagram-65.png
ppk2-cpb-neopixels-3white-65.jpg

The Nordic Power Profiler Kit II (PPK2) is an affordable, easy-to-use, USB-powered device which can measure tiny currents over time. This is useful to analyse the power used by a microcontroller and its peripherals if it's intended to be powered by batteries or solar power. The device can optionally act as a power supply for 0-5V up to 1A. It can also be used as a basic, low sample rate 8 channel logic analyser.

This article explores the finer points of the power consumption of two types of RGB LEDs to demonstrate the use of the PPK2 and to show how multi-colour LEDs operate.

The first example is a battery powered Blinkyparts Rainbow Unicorn soldering kit featuring four colour-cycling, multi-colour LEDs.

The second example is the NeoPixels on an Adafruit Circuit Playground Bluefruit (CPB). These pixels are bright, individually addressable, RGB light-emitting diodes (LED) where the brightness level of the red, green and blue constituent LEDs can be varied from 0 to 255.

A simple CircuitPython program controls the NeoPixels with two modes selected using the CPB's switch.

  • A sequence of red, green, blue, yellow, cyan, magenta, and white at different brightness levels. This sequence runs on one NeoPixel and then on three NeoPixels.
  • One NeoPixel at full brightness for red, green and blue to produce bright white.

The CPB is not intended for low power use but its Nordic nRF52840 processor has features for this. This makes the board viable for experimentation, prototyping and learning about efficient power techniques. This program will also work on the similar ATSAMD51-based Circuit Playground Express (CPX).

Supplies

Installing CircuitPython and CPB Pixel Current Program

cpb-pixel-current-circuitpy-files.png

If you are not familiar with CircuitPython then it's worth reading the Welcome to CircuitPython guide first.

  1. Install the latest version of CircuitPython (7.3.3 in September 2022) from https://circuitpython.org/ - this process is described in Adafruit Circuit Playground Bluefruit: Install or Update CircuitPython.
  2. Verify the installation by connecting to the serial console over USB. The REPL prompt shows the version. The version can also be checked by inspecting boot_out.txt on the CIRCUITPY drive.
  3. Install these libraries from a bundle from https://circuitpython.org/libraries into the lib directory on CIRCUITPY:
  4. adafruit_circuitplayground
  5. adafruit_lis3dh.mpy
  6. adafruit_thermistor.mpy
  7. neopixel.mpy
  8. Download the NeoPixel sequencing program to CIRCUITPY by clicking Save link as... on cpx-pixel-current.py
  9. Rename or delete any existing code.py file on CIRCUITPY, then rename the cpx-pixel-current.py to code.py. This file is run when the CircuitPython interpreter starts or reloads.

The versions used for this guide were:

  • CircuitPython 7.3.2
  • CircuitPython library bundle adafruit-circuitpython-bundle-7.x-mpy-20220827.zip

Powering the CPB With Power Profiler

cpx-ppk2-connecting-65.jpg

The Power Profiler Kit II must be connected to the host computer using the micro USB connector on the top at the right side. The lower left set of connections on the PPK2 from left to right are:

  1. GND (black);
  2. VIN (red) - only used for ammeter (AMP) mode, do not connect in source measure unit (SMU) mode;
  3. VOUT (brown) - connects to red cable on JST PH cable using test hook;
  4. GND (black) - connected to black cable on JST PH cable using test hook.

Unfortunately the connector can be inserted in two orientations necessitating some care to get the red and brown cables the correct way around. The current will measure around 0uA if the red/brown connections are swapped.

The Rainbow Unicorn was powered by removing its CR2032 battery and attaching the test hooks to the battery holder's terminals.

For current use above 500mA both USB connectors on the Power Profiler must be powered.

LED Variable Brightness

neopixel-macro-cpb-65.jpg
rgbled-phasing-v2-g2.png
rgbled-phasing-v2-g1.png

The image above is a NeoPixel on the Circuit Playground Bluefruit at its lowest brightness setting. The driver chip (small dark square) is visible at the bottom and the bondwires connecting to the three LEDs can just be seen.

There are two common technique for varying the brightness of an LED: changing the current or turning the LED on and off rapidly and relying on persistence of vision.

Current Control

The brightness of an LED could be controlled by varying the voltage but the characteristics of an LED make this more challenging and less accurate than varying the current. A variable current supply provides good control over the brightness and allows for variations in the forward voltage. The colour (central wavelength) of the LED may vary a little with changes in current.

Pulse-Width Modulation

A simple and effective approach for varying the apparent brightness is to flicker the LED at a frequency high enough for humans not to be able to see the flicker. This may be more power efficient than a variable current supply. The typical flickering technique is pulse-width modulation (PWM). This is a common feature on microcontrollers allowing trivial brightness control for LEDs driven by GPIO pins. A current limiting resistor per LED is the only additional component required.

For multiple LEDs there is a design question when using PWM. The hypothetical examples shown above are for three LEDs (red, green and blue) illuminated at 30% of maximum brightness level with a current of 15mA per LED. If they illuminate at the same time the current is much more bursty with a short 45mA peak. If they are staggered by offsetting the phase then they present an almost constant 15mA load for this particular brightness level. The latter appears more attractive to minimise fluctuations in load on the power supply.

Rainbow Unicorn Power Profiling

Nordic Power Profiler Kit II and Rainbow Unicorn

This video looks at the power consumption during the colour cycles of the Rainbow Unicorn intended for use with a CR2032 battery. The variable voltage feature of the PPK2's power supply is used to explore the behaviour at different voltages. The 3V represents a typical value for a new battery under load. The 2V is a voltage sometimes cited as the final voltage for a fully discharged CR2032.

  • 00:04 Start is pressed to start the data logging, graph shows noisy 0.25uA value.
  • 00:05 The power output is enabled at 3.005V. The unicorn starts with all four LEDs showing red (appears as orange in the video).
  • 00:08 Red at 26mA transitions to green at 20mA then blue at 12mA.
  • 00:20 (Greenish) yellow at 43mA, cyan at 29mA, magenta at 34mA, (almost) white at 50mA.
  • 01:07 Repeat of the colour cycle at an abnormally low voltage of 2.06V. The red LED is the only one that works at this low voltage with lower current consumption at 6mA. These LEDs are clearly not designed to work at this voltage.

The four LEDs on the Rainbow Unicorn start with synchronised colour cycles but quickly drift out of synchronisation.

Calculation of Battery Lifetime

ppk2-unicorn-3v-onecycle.png

The Nordic Power Profiler software presents statistics for the current window of data and for any selection. One cycle of the colour changes for the Rainbow Unicorn is shown above with an average current of 29.44mA and a peak of 47.75mA. The CR2032 batteries use a lithium/manganese dioxide cell with a nominal voltage of 3V and a capacity around 225mAH. The battery lifetime would be expected to be around 225mAH / 29.44mA = 7.6 hours.

A battery data sheet from a reputable manufacturer would provide a more detailed account of how the lifetime varies with current. The voltage for a discharging battery is not constant and the lower voltage towards the end of the battery lifetime may be below the minimum voltage for the device further reducing the practical battery lifetime.

NeoPixel Power Profiling

Nordic Power Profiler II and NeoPixels

The ten pixels on the Circuit Playground Bluefruit are individually addressable meaning they can be independently changed. This is implemented by chaining the pixels in the style of a shift register where a pixel will pass the level settings to the next one if it receives another one. This allows a large number of pixels to be controlled using just one signal line.

NeoPixel is Adafruit's trademarked name for their pixels using the wire protocol for WS2812, WS2812B, WS2811 and SK6812 RGB LEDs.

The video above shows:

  • 00:05 Start is pressed to initiate the data logging. The graph shows a noisy 0.2uA value.
  • 00:09 The power output is enabled - this is set to 4908mV. The CircuitPython interpreter initialises and flashes all ten NeoPixels.
  • 00:13 The first NeoPixel ramps from off to full red brightness with four intermediate steps. This repeats with green and blue. And then with two colours together to produce yellow, cyan and magenta. Finally, with all three producing white.
  • 00:20 The graph auto-scales as the inrush current (?) from the start of the trace scrolls off the x axis.
  • 00:26 The sequence repeats with three NeoPixels.
  • 00:50 The CPB is powered up again with the switch set to the right which sets the first NeoPixel to full brightness white consuming a constant current of 48.23mA.

Circuit Playground Bluefruit CircuitPython Startup

ppk2-cpb-poweronspike.png
ppk2-cpb-startupflashing.png

The screenshots from the Nordic Power Profiler show:

  1. An initial peak of almost 400mA for just over 1ms when the Circuit Playground Bluefruit is powered up. This spike is probably an inrush current due to the capacitors charging up across the power supply rails on the CPB.
  2. The CircuitPython interpreter briefly lights all the NeoPixels red and then flashes them yellow and then blue at startup.
  3. The CPB with an idle CircuitPython program uses around 6mA.

The idle current is likely to vary a little based on what the on-board peripherals are doing. The power intensive features of the Circuit Playground Bluefruit/Express will be:

  • all ten NeoPixels set to bright values;
  • loud, long audio played on the mini speaker;
  • heavy use and misuse of the infrared LED (only on CPX);
  • powering any high current peripherals like servos or motors.

CPB One NeoPixel

ppk2-cpb-oneneopixelfulltest.png
ppk2-cpb-oneredneopixell64tol128.png
ppk2-cpb-onewhiteneopixell10.png

The screenshots from the Nordic Power Profiler for 1 NeoPixel being illuminated show:

  1. A 12 second view across all of the colours, red, green, blue, yellow, cyan, magenta, white. When each is at full brightness the current level becomes constant as the PWM duty cycle is 100%, i.e. on all the time.
  2. The red at brightness level 128 which equates to a duty cycle of 50% where the LED spends half its time on and half off. The current is 17mA but 6mA of that is the CPB which means the red LED uses 11mA.
  3. This is white at brightness 10, approximately 4% duty cycle on red, green and blue. There is a single peak here indicating all three constituent LEDs are illuminated at the same time, i.e. there is no phase offset.

CPB Three NeoPixels

ppk2-cpb-threeneopixelsfulltest.png
ppk2-cpb-threeredneopixelsl10.png

This is the same as the previous test run but with 3 rather than 1 NeoPixels being illuminated. A simple guess would be the values are the same but with 3x more current use by the LEDs. However, the screenshots from the Nordic Power Profiler show:

  1. A 12 second view across all of the colours, red, green, blue, yellow, cyan, magenta, white. This does look the same.
  2. This is white at brightness 10, approximately 4% duty cycle on red, green and blue. This particular section of the trace shows the 3 NeoPixels and 3 LED colours are initially peaking at the same time but the single peak slowly morphs into two smaller peaks then three smaller peaks.

The change in the peaks is not too surprising. NeoPixels do not have a common clock and there's no requirement for them in have an identical PWM frequency. The internal clock on each NeoPixel is running at a slightly different frequency and the LEDs are sometimes on at the same time and sometimes not.

This demonstrates that a reasonable number of these particular pixels are likely to have a fairly steady aggregate power consumption. It's possible that changes in brightness level might synchronise them to some degree - that could be explored experimentally. If the steady current behaviour was essential for a product then it would need to be documented by the (credible) manufacturer on the data sheet.

Comparison With Multimeter and USB Tester Measurements

ppk2-cpb-onepixelmax-astroai-10a-vs-a-65-.JPG
ppk2-cpb-onepixelmax-astroai-uama-vs-ma-65-.JPG
ppk2-cpb-onepixelmax-unit-ut30a-uama-vs-ma-65-.JPG
ppk2-cpb-onepixelmax-astroai-10a-vs-ma-65-.JPG
ppk2-cpb-onepixelmax-astroai-uama-vs-a-65-.JPG
ppk2-cpb-onepixelmax-usbtester2-65-.JPG

Multimeters can be used to measure current. Most only update once or twice a second making them unsuitable for a fluctuating DC current but they can work well for a steady current. The photographs above are measurements from two inexpensive multimeters used with the PPK2 as a power source for the CPB via JST connector and a USB meter.

  • AstroAI DM6000AR: Measures 0.046A on A range and 47.10mA on mA range. Care is needed to use the appropriate socket for the positive lead, stable measurements of -0.547A and 0.25mA occur for the wrong socket!
  • UNI-T UT30A: Measures 47.2mA, sometimes 47.0mA too. The next range is 40mA preventing a more precise measurement.
  • USB TESTER: Measures 0.02A. It also shows 0.143W on the display. Converting the power to a current gives 0.143/4.96 = 0.288mA which happens to be closer to the real value.

The PPK2 measures this as 48.15mA average with a range of +/- 1.8mA.

A multimeter measures current by performing a voltage measurement across a series resistor. The voltage drop across the meter is known as a burden voltage. This voltage drop can be significant and confusing at the voltages used for microcontrollers. There is an example of this in the Andreas Spiess video featured later in this article.

A wise precaution for multimeters is to always return the positive red lead to the voltage socket after measuring current. This prevents an accidental high current (and blown fuse) if the multimeter is used next to measure a voltage with the lead in the wrong socket.

Light Bulb Power Profiling

ppk2-bulb-1.jpg

The photograph above shows the data logging for a small incandescent bulb intended for use at 2.4V 0.5A. The supply voltage has been set to a more conservative 2.018V but there's still a huge inrush current peaking around 1.4A (over the 1A maximum the manufacturer states for the device), dropping to 500mA in around 80 milliseconds before settling at 404mA. This simple resistive load still has noise on the trace with most of the values between +/- 2mA.

Note: both USB connectors are in use here to provide current above 500mA. It may be worth using a lower current threshold for dual powering and being cautious on anything which may exceed the 1A maximum for more than a few milliseconds.

Andreas Spiess Low Current Meter Comparison

#386 How to measure low Currents for ESP/Arduino? Power Profiler, Otii, µCurrent Gold, Joulescope

Andreas Spiess has an excellent, in-depth comparison of several devices for measuring small currents over time in How to measure low Currents for ESP/Arduino? Power Profiler, Otii, µCurrent Gold, Joulescope (YouTube), shown above. The table from the video summarising the five devices is included below.

Instrument Automatic Range Switching Negative Currents Displays Average Display of Curves Maximum Current Voltage
uCurrent Gold No Yes No Oscilloscope 1.25A
Current Ranger Yes Yes Yes* Oscilloscope 3.3A
Power Profiler Kit II Yes No Yes Software 1A 5V
Otii Yes Yes Yes Software 3A 5.0V**
Joulescope Yes Yes Yes Software 3A 15V

* On optional display.

** 4.55V max in auto range mode.

Going Further

ppk2-measuring-dk.png

Ideas for areas to explore:

  • Look at the power profile of the APA102 RGB LEDs AKA Adafruit DotStar.
  • Use the PPK2 digital inputs. Microcontroller GPIO can be used as outputs indicating specific activity in the application. These can be read and recorded by the PPK2 providing easier visual and programmatic correlation with activity vs power usage.
  • Check the power use for devices designed for low power applications like the Adafruit MagTag or Pimoroni Inky Frame.
  • Resolve the mystery of the Circuit Playground Bluefruit's first NeoPixel which on the first mode uses a total current of 40mA but on the second mode is 47-48mA despite being set to the same (255,255,255) value.
  • Your own low power project!

Some other LED soldering kits (available from various retailers and market places):

Further reading: