Author Topic: Impressively Low Sleep Currents w/ WDT (90nA) [SOLVED - its really 4.3uA]  (Read 5294 times)

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
I finally had some success getting my fuses set on a 328p dip on a breadboard for 8MHz internal oscillator and I've been having a good time characterizing various currents with different clock dividers.  I also did an 8s sleep on the watchdog timer and am getting very surprising, frankly unbelieveable, results and wonder if any other forums users can recreate my results with their own bare 328p and uCurrent.  I'm measuring 90nA when sleeping on the WDT at 3.3V.  My sketch wakes every 8s and pulses an LED on for 10ms and turns it back off and resumes sleeping, so I know the WDT is functioning correctly.  Can this result be correct?  I expected the WDT to use 4uA and I certainly measure that with a normal Mote.

steve v

  • NewMember
  • *
  • Posts: 18
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #1 on: August 31, 2017, 11:44:17 PM »
Hi ChemE,

I'll try to recreate your numbers here this weekend.  I'd be surprised if the Oscillator was running and you got 0.09 uA

1. Can you post a drawing of how you have your 328P schematic set up ?
2. and also post your code for the 8 second sleep. 
3. And also post your Bus Pirate fuse configs ?

4. Also Can you test your current meter by adding a 33M Ohm resistor from 3.3V to GND ?  this should also draw  0.1 uA

Sorry for so many questions but that would be exciting if you got below 0.1 uA

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #2 on: September 01, 2017, 07:54:23 AM »
I would have been surprised too.  I tested my sleep current with a set of 2xAA and got 16uA so something odd is going on; actually a few things:

1) I would not have expected a discrepancy between Vcc out from my FTDI board and Vcc out from a battery pack.  The voltages are quite comparable.

2) I'm getting a somewhat elevated sleep current now; not sure why or how to bring it back down to the 4ish uA it should be.

To answer your questions though:

Here is the addition to my boards.txt that I'm using
Code: [Select]
##############################################################

atmega328bb_noBOD.name=ATmega328 on a breadboard (8 MHz internal clock - No BOD)

atmega328bb_noBOD.upload.protocol=arduino
atmega328bb_noBOD.upload.maximum_size=30720
atmega328bb_noBOD.upload.speed=57600

atmega328bb_noBOD.bootloader.low_fuses=0xE2
atmega328bb_noBOD.bootloader.high_fuses=0xDA
atmega328bb_noBOD.bootloader.extended_fuses=0xFF

atmega328bb_noBOD.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb_noBOD.bootloader.unlock_bits=0x3F
atmega328bb_noBOD.bootloader.lock_bits=0x0F

atmega328bb_noBOD.build.mcu=atmega328p
atmega328bb_noBOD.build.f_cpu=8000000L
atmega328bb_noBOD.build.core=arduino:arduino
atmega328bb_noBOD.build.variant=arduino:standard


atmega328bb_noBOD.bootloader.tool=arduino:avrdude
atmega328bb_noBOD.upload.tool=arduino:avrdude

And here is the code running on the naked 328p

Code: [Select]
#include <LowPower.h>

#if defined(__AVR_ATmega328P__) // Macros to define the ports and bitmasks for the pins on the 328p succinctly
  #define     InpRegFromPin(pin)      pin<8 ? 0x09 : pin<14 ? 0x03 : 0x06 // Input registers for the ports
  #define     DirRegFromPin(pin)      pin<8 ? 0x0A : pin<14 ? 0x04 : 0x07 // Data direction registers for the ports
  #define     DataRegFromPin(pin)     pin<8 ? 0x0B : pin<14 ? 0x05 : 0x08 // Output registers for the ports
  #define     BitmaskFromPin(pin)     pin<8 ? 1<<pin : pin<14 ? 1<<(pin-8) : 1<<(pin-14)
#endif

// Bit-banging macros - each adds 2 bytes of sketch size and takes 1 clock cycle to execute
#define    MakeOutput(pin)    _SFR_IO8(DirRegFromPin(pin))  |=  BitmaskFromPin(pin)           // Much faster and smaller version of pinMode(Pin, OUTPUT)
#define    MakeInput(pin)     _SFR_IO8(DirRegFromPin(pin))  &=  ~(BitmaskFromPin(pin))        // Much faster and smaller version of pinMode(Pin, INPUT)
#define    PullHigh(pin)      _SFR_IO8(DataRegFromPin(pin)) |=  BitmaskFromPin(pin)           // Much faster and smaller version of digitalWrite(Pin, HIGH)
#define    PullLow(pin)       _SFR_IO8(DataRegFromPin(pin)) &=  ~(BitmaskFromPin(pin))        // Much faster and smaller version of digitalWrite(Pin, LOW)
#define    ReadPin(pin)       _SFR_IO8(InpRegFromPin(pin))  & (BitmaskFromPin(pin)) ? 1 : 0   // One line if else statement using the format [test ? true return : false return]

// Macros to mimic the native Arduino syntax
#define    DigitalWrite(pin, state) state ? PullHigh(pin) : PullLow(pin)
#define    PinMode(pin, dir)  pin ? MakeOutput(pin) : MakeInput(pin)

uint8_t seconds;

int main(void) {  // =========== the setup function runs once when you press reset or power the board ===========
  PinMode(13, OUTPUT);

  for(;;) {   // =========== the loop function runs over and over again forever ===========
   
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    DigitalWrite(13, HIGH);
    _delay_ms(10);
    DigitalWrite(13, LOW);
  }           // =========== the loop function runs over and over again forever ===========
} // End main

You can switch back to the standard Arduino functions by lowercasing the first letter; e.g. digitalWrite(13, LOW) rather than my DigitalWrite(13, LOW).  I'll post a picture momentarily showing my wiring.  Also, the largest resistor I have is 1M but I'll see how much current it adds to my reading.
« Last Edit: September 01, 2017, 08:16:41 AM by ChemE »

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #3 on: September 01, 2017, 08:28:50 AM »
Even more strange.  Now I'm getting the expected 4.3uA with the WDT running with BOD disabled in software and 4.2uA with BOD disabled with fuses.  And I'm getting the same readings from the FTDI as well as from a AA battery pack.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #4 on: September 01, 2017, 10:11:29 AM »
ChemE,
So you can't reproduce the 90nA current anymore?

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #5 on: September 01, 2017, 11:04:46 AM »
ChemE,
So you can't reproduce the 90nA current anymore?

Ah ha!  I was able to recreate it (still doubt it is real).  I'm powering my 328p through the AVCC and GND pins only (pins 20 and 22).  This causes my uCurrent to go down to 0 on the 1mV/1uA scale right after an LED pulse.  When I then switch to 1mv/1nA my multimeter reads 90mV.

Breadboard Setup


Video showing the oddity
Video

The video clearly isn't the greatest, the LED was out of frame, but it had just pulsed when I started recording.  I still don't think the measurement is real, but it is a mystery to me as to what the heck is actually going on.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #6 on: September 01, 2017, 11:22:30 AM »
Looking at the uCurrent schematic,
When you switch ranges on the uCurrent I think you might be losing power, but I would have to double check what the switch actually does.

Maybe if your setup is already in a very low power mode, an onboard capacitor (like on the Moteino) can keep it going in that split second while you switch ranges, but I don't see any larger cap in your setup.

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #7 on: September 01, 2017, 11:41:35 AM »
I switch ranges all the time and Motes and naked 328p never reboot.  Nope, no large caps in my setup unless the uCurrent has some internally.  The three caps pictured are 1,000nF.

I know powering the 328p from just AVCC is pretty naughty and it seems to be the cause of all this strangeness.  On batteries I get a sleep current of 16uA.  With the FTDI, I get a sleep current of 91nA.  Maybe some power is leaking from one of the FTDI pins somehow?  I guess I need to fool around more to fully characterize things.  Still, if somehow the 90nA were real...

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA)
« Reply #8 on: September 01, 2017, 12:04:08 PM »
Solved it.  With Pin 7 not connected to Vcc, when you plug Pin 2 into the FTDI header it draws a steady 4.1uA as read off my uCurrent.  This means almost nothing flows through the Vcc pin coming out of the FTDI which is why I was measuring 90nA.  So indeed my 90nA WDT current was an illusion as I suspected it was.  The missing power was coming from RXI on my FTDI.

EDIT: Just to close things out, when I put the missing wires back on pins 7 and 8, the current flowing over pin2 instantly goes to 0nA.  Case closed.
« Last Edit: September 01, 2017, 12:11:38 PM by ChemE »

steve v

  • NewMember
  • *
  • Posts: 18
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA) [SOLVED - its really 4.3uA]
« Reply #9 on: September 01, 2017, 04:04:17 PM »
Wow ! you've created a 0.0nA  328P  !

All kidding aside, thank you for the excellent follow up and the detective work that found the FTDI Phantom current.

Has anyone else reported less than 4uA  sleep current ?

Steve

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA) [SOLVED - its really 4.3uA]
« Reply #10 on: September 01, 2017, 05:37:40 PM »
Has anyone else reported less than 4uA  sleep current ?

Not that I'm aware of excepting listen mode or external interrupts.  Shame the WDT can't get as low as the AB1815 now there is a power efficient WDT.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Impressively Low Sleep Currents w/ WDT (90nA) [SOLVED - its really 4.3uA]
« Reply #11 on: September 01, 2017, 06:27:19 PM »
Shame the WDT can't get as low as the AB1815 now there is a power efficient WDT.
Check out the TPL5010.  This keeps pretty good time with 1% resistors (56.2K 1% in series with 1.2K 5% will yield 10 minutes +/- 4 seconds with extremely small variability) and you can power down everything waiting for the GPIO interrupt from its Wake signal.  Further, if your code goes south and you don't respond to the Wake, the device will pull Reset on the 328P.

35nA... Plus whatever leakage you've got in the rest of the HW.  The TPL5110 will actually control power to the rest of the system so 35nA is all you draw between samples.

Tom
Did I mention that the device is in an SOT23-6 package?  Easy to fab & solder (the AB1815 is a bit tricky in that department).  Felix even has a breakout board for the TPL5110 including resistor pads...

« Last Edit: September 01, 2017, 06:29:51 PM by TomWS »

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA) [SOLVED - its really 4.3uA]
« Reply #12 on: September 01, 2017, 07:14:59 PM »
True enough Tom.  I grabbed two from Felix a while ago but have never really fallen in love with them.  Now that I'm getting better with interrupts I should probably have another play.  35nA vs. 22nA is certainly trivial though I do like the ability to set an alarm for some random second 100 years from now and wake as opposed to counting interrupt signals from a fixed interval TPL5010.  But they still do beat the pants off the 328p's WDT.  Thanks for the tip!

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Impressively Low Sleep Currents w/ WDT (90nA) [SOLVED - its really 4.3uA]
« Reply #13 on: September 02, 2017, 09:20:49 AM »
Took me longer than I'd care to admit :) but I now have a breadboard Moteino running at 8MHz on its internal oscillator at 3.2V (from batteries so no FTDI phantom power shenanigans now) and sleeping peacefully on a mere 232nA but faithfully waking every minute to do useful work.  Great call Tom, thanks for making me take another look at this little beauties!

It took me a while to realize that pin 6 from the TLP5110 board is my interrupt and that I need a pulldown resistor on digital pin 3 of the 328p to be able to detect when pin 6 of the TLP5110 BoB goes high.  My preference would be to use the internal pullup on digital pin 3 and sense when the DRV signal from the TLP5110 is pulled low, but I don't think this is possible using Felix's breakout.  I don't think this signal is available on the board pins and I would have to solder on a bit of wire to the TPL5110's pin 5 to do that.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Impressively Low Sleep Currents w/ WDT (90nA) [SOLVED - its really 4.3uA]
« Reply #14 on: September 02, 2017, 06:54:32 PM »
It took me a while to realize that pin 6 from the TLP5110 board is my interrupt and that I need a pulldown resistor on digital pin 3 of the 328p to be able to detect when pin 6 of the TLP5110 BoB goes high.  My preference would be to use the internal pullup on digital pin 3 and sense when the DRV signal from the TLP5110 is pulled low, but I don't think this is possible using Felix's breakout.  I don't think this signal is available on the board pins and I would have to solder on a bit of wire to the TPL5110's pin 5 to do that.
Are you sure you're using the TPL5110?  For this device, pin 6 is an input to select continuous or oneshot mode.  Pin 5 is normally used to drive a P FET in a load switch configuration, but pin 5 COULD be used as an interrupt, but Falling at the T interval, not rising.  DONE will trigger Pin 5 to rise to VDD level.  I think that Pin 5 may even be a push pull output.

Tom