0

Feather NRF52 I2C power issue
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Feather NRF52 I2C power issue

by pcaddict on Wed Feb 13, 2019 7:25 pm

When the floating point unit is used there is a power consumption penalty. I cannot find the number right now but it is not insignificant. Check the following: High power consumption when using FPU.

pcaddict
 
Posts: 52
Joined: Thu Aug 31, 2017 9:24 pm

Re: Feather NRF52 I2C power issue

by wb8wka on Wed Feb 13, 2019 7:47 pm

OMG, cross my fingers but power consumption dropped about 600ua after I added this:

Code: Select all | TOGGLE FULL SIZE
#define FPU_EXCEPTION_MASK 0x0000009F

/* ~~~~~~~~ */

//   Put in FPU shutdown here

/* Clear exceptions and PendingIRQ from the FPU unit */
__set_FPSCR(__get_FPSCR()  & ~(FPU_EXCEPTION_MASK));     
(void) __get_FPSCR();
NVIC_ClearPendingIRQ(FPU_IRQn);

/* Call SoftDevice Wait For event */

  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
  waitForEvent();
}


THANK YOU THANK YOU

So as it stands now, I'm beaconing every 2000ms and reading a I2C sensor every 10 seconds with a average current consumption of 68ua. I had planned on converting the SHT31 lib to integer anyways, since I then could lower the TICK rate to 4hz from the present 1024hz, but I think this is it.

Thanks again!!

P.S. that is WITHOUT the earlier I2C shutdown code, since I noticed the wire library already had a wire_end() call in it, and I don't think my module has the silicon called out in the errata.

wb8wka
 
Posts: 45
Joined: Fri Sep 21, 2018 5:09 pm

Re: Feather NRF52 I2C power issue

by pcaddict on Wed Feb 13, 2019 10:07 pm

Glad we were able to figure it out. The whole FPU issue crossed my mind a few days ago but when I looked at your code snippet I didn’t see you doing any floating point math. Just didn’t look deep enough I guess.

On a side, and totally unrelated note, would you mind providing a little detail on how you’re measuring current on your feather? I usually stick a meter inline with a battery but I have my doubts about the readings I get. Doesn’t help that my meter isnt remotely high end.

pcaddict
 
Posts: 52
Joined: Thu Aug 31, 2017 9:24 pm

Re: Feather NRF52 I2C power issue

by wb8wka on Wed Feb 13, 2019 10:16 pm

I'm using a Current ranger feeding a Agllent VOM on the averaging setting.

I have a 3.6 volt battery that powers it to get around the fact the current ranger needs to be floating to use a scope on it. The battery has a 0.5 Farad cap across it along with a 220uf cap. Here is a pic of the setup. The board in the foreground is my target, a low current spin of the Adafruit feather.

IMG_0790 (1).jpg
IMG_0790 (1).jpg (460.27 KiB) Viewed 112 times

wb8wka
 
Posts: 45
Joined: Fri Sep 21, 2018 5:09 pm

Re: Feather NRF52 I2C power issue

by wb8wka on Wed Feb 13, 2019 10:20 pm

Here is a link to the current ranger along with a video review. I had a uCurrent gold prior to this and the current ranger is a nice upgrade to it.

https://lowpowerlab.com/guide/currentranger/

I also have a Rigol DS1054 scope that has a integrate function on it, but still learning how to use that.

wb8wka
 
Posts: 45
Joined: Fri Sep 21, 2018 5:09 pm

Re: Feather NRF52 I2C power issue

by pcaddict on Wed Feb 13, 2019 10:34 pm

Thanks for the link. I’ll have to pick one of those up.

pcaddict
 
Posts: 52
Joined: Thu Aug 31, 2017 9:24 pm

Re: Feather NRF52 I2C power issue

by p2w on Thu Feb 14, 2019 8:59 am

I just use a 1 Ohm resistor in series with the battery and measure voltage drop. Seems to do the trick just fine. I checked with a Keithley DMM7510, the difference between those two is minimal.

p2w
 
Posts: 66
Joined: Fri Dec 15, 2017 5:29 am

Re: Feather NRF52 I2C power issue

by wb8wka on Thu Feb 14, 2019 6:17 pm

p2w wrote:I just use a 1 Ohm resistor in series with the battery and measure voltage drop. Seems to do the trick just fine. I checked with a Keithley DMM7510, the difference between those two is minimal.


The DMM7510 is a nice box, but $~4100. The Current Ranger is $115 and works with a cheap VOM or scope. At 10uA, the voltage drop across a 1 ohm resistor is 10uV, that's a challenge for most VOM's to measure. The Current ranger has a 100x amplifier built into it, on the uA range, they use a 10 ohm resistor so it reads out at 1mV per uA, 0.01ohm resistor for the mA scale, and 10K for the nA range.

wb8wka
 
Posts: 45
Joined: Fri Sep 21, 2018 5:09 pm

Re: Feather NRF52 I2C power issue

by wb8wka on Thu Feb 14, 2019 6:20 pm

wb8wka wrote:So as it stands now, I'm beaconing every 2000ms and reading a I2C sensor every 10 seconds with a average current consumption of 68ua. I had planned on converting the SHT31 lib to integer anyways, since I then could lower the TICK rate to 4hz from the present 1024hz, but I think this is it.


Didn't convert the SHT31 lib yet, and the lowest it will work at is 64 ticks, but with reading the sensor once ever 30 seconds and a 5 second BLE beacon, I'm now down to ~15.6uA

wb8wka
 
Posts: 45
Joined: Fri Sep 21, 2018 5:09 pm

Re: Feather NRF52 I2C power issue

by pcaddict on Thu Feb 14, 2019 6:32 pm

That's really impressive. I'd imagine the last thing you could probably do to shave any significant amount of power is to power off the sensor between readings. Though the sleep current is already in the single uA range for the SHT31 right?

pcaddict
 
Posts: 52
Joined: Thu Aug 31, 2017 9:24 pm

Re: Feather NRF52 I2C power issue

by monsun on Fri Feb 22, 2019 8:57 am

Hello,
I'm trying to build a device on Particle X enon board, which is a little more complex nRF52 Express version.
Because i'm using BLE not Particle Mesh,i've changed bootloader to one provided by Adafruit and write own Variant.h for this board,
and of course i'm using Bluefruit library.
Everything works perfect besides power consumption.
Code: Select all | TOGGLE FULL SIZE
#include <bluefruit.h>

// Beacon uses the Manufacturer Specific Data field in the advertising
// packet, which means you must provide a valid Manufacturer ID. Update
// the field below to an appropriate value. For a list of valid IDs see:
// https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers
// 0x004C is Apple (for example)
#define MANUFACTURER_ID   0x004C

// AirLocate UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
uint8_t beaconUuid[16] =
{
  0xE2, 0xC5, 0x6D, 0xB5, 0xDF, 0xFB, 0x48, 0xD2,
  0xB0, 0x60, 0xD0, 0xF5, 0xA7, 0x10, 0x96, 0xE0,
};

// A valid Beacon packet consists of the following information:
// UUID, Major, Minor, RSSI @ 1M
BLEBeacon beacon(beaconUuid, 0x0000, 0x0000, -54);
int battery=0;

void setup()
{
  pinMode(PIN_CHARGE,OUTPUT);
  digitalWrite(PIN_CHARGE,LOW);

  battery=analogRead(PIN_BAT);
 
  Bluefruit.begin();

  // off Blue LED for lowest power consumption
  Bluefruit.autoConnLed(false);
 
  // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
  Bluefruit.setTxPower(0);
  Bluefruit.setName("Bluefruit52");

  // Manufacturer ID is required for Manufacturer Specific Data
  beacon.setManufacturer(MANUFACTURER_ID);

  // Setup the advertising packet
  startAdv();

  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
  sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);

  // Suspend Loop() to save power, since we didn't have any code there
  //suspendLoop();
}

void startAdv(void)

  // Advertising packet
  // Set the beacon payload using the BLEBeacon class populated
  // earlier in this example
  Bluefruit.Advertising.setBeacon(beacon);

  // Secondary Scan Response packet (optional)
  // Since there is no room for 'Name' in Advertising packet
  Bluefruit.ScanResponse.addName();
 
  /* Start Advertising
   * - Enable auto advertising if disconnected
   * - Timeout for fast mode is 30 seconds
   * - Start(timeout) with timeout = 0 will advertise forever (until connected)
   *
   * Apple Beacon specs
   * - Type: Non connectable, undirected
   * - Fixed interval: 100 ms -> fast = slow = 100 ms
   */
  //Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_ADV_NONCONN_IND);
  Bluefruit.Advertising.restartOnDisconnect(true);
  Bluefruit.Advertising.setInterval(160, 3200);    // in unit of 0.625 ms
  Bluefruit.Advertising.setFastTimeout(5);      // number of seconds in fast mode
  Bluefruit.Advertising.start(0);                // 0 = Don't stop advertising after n seconds 
}

void loop()
{
  __set_FPSCR(__get_FPSCR() & ~(0x0000009F));
  (void) __get_FPSCR();
  NVIC_ClearPendingIRQ(FPU_IRQn);
  waitForEvent();
  // loop is already suspended, CPU will not run loop() at all
}

I've tried this example code with delay, suspend and waitForEvent versions.
I've even force FPU IRQ reset.
All of them are very close about 700uA in current consumption.

Code: Select all | TOGGLE FULL SIZE
#define configUSE_TICKLESS_IDLE                                  1
#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG                     1 /* See into vPortSuppressTicksAndSleep source code for explanation */
#define configCPU_CLOCK_HZ                                       ( SystemCoreClock )
#define configTICK_RATE_HZ                                       1024


I've tried tickrate change but it doesn't change any thing,
anyone have idea what i'm doing wrong?

monsun
 
Posts: 2
Joined: Thu Feb 14, 2019 4:02 am

Re: Feather NRF52 I2C power issue

by hathach on Fri Feb 22, 2019 2:13 pm

@momsun people reported that with the current code, nrf52840 uses more power than nrf52832. That could be the reason.

hathach
 
Posts: 905
Joined: Tue Apr 23, 2013 1:02 am

Re: Feather NRF52 I2C power issue

by monsun on Mon Feb 25, 2019 5:00 am

I've been looking into the problem but i can't figure anything out.
https://devzone.nordicsemi.com/f/nordic-q-a/35073/high-power-consumption-of-softdevice
I've tried change something to port_cmsis_systick.c but without any success.
Screenshot_2.jpg
Screenshot_2.jpg (65.63 KiB) Viewed 25 times

1mV=1uA
independently from configTICK_RATE_HZ circa 8khz power picks looks the same.

monsun
 
Posts: 2
Joined: Thu Feb 14, 2019 4:02 am

Please be positive and constructive with your questions and comments.