-
AuthorPosts
-
June 20, 2016 at 11:11 PM #4684DonpKParticipant
I have been using it with a 5 volt Pro Mini and in the “No Power LED, no Regulator,VCC, Pin, PDS” mode. The current draw is ca. 0.028 mA. It’s not down to what you achieved, but good enough for now.
I want to extend the sleep time from the maximum of 8 seconds to a number of hours. To do this I’m using a for loop and have include my basic sketch below.
I am noticing something I can’t quite explain. As I monitor the current draw during sleep period, periodically it spikes up very briefly from 0.028 mA level, several tens of micro-amps. Is this the code in my for loop running every 8 seconds or is something else happening?
********************************************
#include "LowPower.h" int moistureLED = 13; void setup() { } void loop() { //flash LED each time WDTimer function is called digitalWrite(moistureLED, HIGH); delay(125); digitalWrite(moistureLED, LOW); delay(125); WDTimer(3); //Call WDT } //************* Watchdog Timer Function********* void WDTimer (int wdtCounter) { int i; for (i = 0; i < wdtCounter; i++) { LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); //wake up after 8 secs. } }
June 23, 2016 at 11:41 AM #4688LIM PHANG MOHKeymasterHi,
It should be due to this:for (i = 0; i < wdtCounter; i++)
But, how long does this duration of the spike? In any case, it should not be even noticeable, as that line of code execute is few us.
To even improve your code, if your maximum argument does not exceed 255 (unsigned char), then use unsigned char as your argument. Using the int variable would mean using 16-bit signed variable. The comparison that take place in the loop when converted into machine code will yield different results. And if you can, do a count down instead of count up implementation. That way, in the machine code, it only need to do a compare zero routine which the AVR core has a single instruction to do just that.And regarding the amount of 0.028mA, is there anything else connected? Even wires that leads to nowhere?
June 26, 2016 at 5:37 AM #4693DonpKParticipantThanks for your answer.
Yes, I agree, the current spikes I’m seeing are probably due to the WDTimer function which runs every 8 seconds. When I see spikes, they occur at 8 seconds intervals, actually more like 9 seconds, since the watchdog timers are not particularly accurate (see graph on middle of this page).
As you suggested, I changed the for statement to
for (i = wdtCounter; i > 0; i--)
. Interestingly, this reduces the size of the spikes when I do see them on my multimeter. I’m surprised I see anything on my meter since the burst of code is so short.The current draw is still around 0.028mA. I’ve been working with this article which uses your low power library. In his results chart, I’m using the configuration “No Power LED, no Regulator, 5 volts at the VCC Pin, and PDS, (Power-Down Sleep with Watchdog Timer enabled)”. The author is getting 0.0058 mA, or about a fifth of the 0.028mA I’m getting.
I have no wires connected to the Pro Mini board, just the 5 volt power supply to Vcc. Do you have any suggestions?
DonJune 26, 2016 at 3:26 PM #4694LIM PHANG MOHKeymasterA multimeter has a very slow refresh rate compare to what is being captured actually. If you use a small resistor and measure the voltage across it at the input supply and use an oscilloscope, you might see the timing more accurately.
Are you using the latest version of the library? I asked because if you are not, the previous version might not compile correctly on the latest Arduino IDE 1.6.x branch due to the compiler optimization. The BOD will not be turned off although the code says so due to this optimization. BOD has strict timing in terms of instruction cycle to turn it off. Too fast or too fast will not get it to turn on/off accordingly. Your 28 uA is giving me that impression.
Other than that, just make sure all pins are output low.
And, what multimeter are you using and what is the resolution of the DC uA range?
June 29, 2016 at 12:31 AM #4695DonpKParticipantI am using LowPower library Ver. 1.40. My multimeter resolves to .001 mA.
In another article using the LowPower with the Pro Mini, the author has almost the same results as I do, 27.4 µA. I’m using a Sparkfun Pro Mini and not a clone, but I wouldn’t think that would make the difference.
In your chart, you list four different current levels for the powerDown mode, but you do not show a current level with the WDT ON, ADC OFF and BOD OFF. I thought this was the default mode for LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF).
June 29, 2016 at 1:23 PM #4696LIM PHANG MOHKeymasterWith WDT enabled, it would add around 4 uA on top of the 0.1 uA of the chip in power down.
So, there’s some stuff still sucking some current somewhere in your setup. I just tested my Mini Utra 8 MHz and it is 1.7 uA (on-board regulator consume 1.6 uA) in power down. Turning on the WDT of 8 s results in 6.0 uA which is spot on with the values from the datasheet.
Using Arduino IDE 1.6.8. Meter has a 0.1uA resolution. Running at 5V & 3.3V shouldn’t be that far off.The regulator totally removed from the board?
June 30, 2016 at 9:08 AM #4697DonpKParticipantThe voltage regulator and power LED have been removed from the board. I also added the following code:
for(byte pin = 0; pin<22; pin++) { pinMode(pin,OUTPUT); digitalWrite(pin,LOW); }
I am using Arduino IDE 1.6.9 (the latest) and the Low Power readme file says: “Low-Power Lightweight low power library for Arduino.Version:1.40 Date: 15-01-2016” I assume this is the latest version of the library? I’ve also tried several different Pro Mini boards with the identical 28uA current draw on each.
Any other ideas?
June 30, 2016 at 10:41 AM #4698LIM PHANG MOHKeymasterVersion:1.40
This is the root cause. Please use version 1.50 and above. It’s a compiler optimization issue which causes the BOD to be enabled without you noticing it.
for(byte pin = 0; pin<22; pin++)
{
pinMode(pin,OUTPUT);
digitalWrite(pin,LOW);
}You don’t have to.
June 30, 2016 at 10:56 AM #4699DonpKParticipantCan you give me a link to Ver.1.50 or above?
June 30, 2016 at 11:00 AM #4700LIM PHANG MOHKeymasterCan you give me a link to Ver.1.50 or above?
You can install from the Arduino IDE library manager itself.
But, if you want to install it manually, here you go.July 1, 2016 at 7:30 AM #4703DonpKParticipantI installed Low Power Library Ver. 1.60 and…success!
Using the “LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);” statement, the current in the SLEEP mode is 6 uA which is exactly what you found with the WDT on.When my sketch comes out of the sleep mode and turns the on-board LED on, the current jumps up to 27 mA which is around what one would expect.
I tried the “LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);” statement: 27mA with the LED on and “0”uA in the SLEEP_FOREVER mode. Remember, however, that my multimeter only reads down to 1uA, so the small currents you were reading with the voltage regulator removed probably wouldn’t register on my meter.
Since I only want to wake up my Pro Mini every hour or so, and I don’t want to get into external interrupts, the SLEEP_8s mode with some counter code to extend the sleep time is the way I’ll go.
Thank you very much for your patience and help in working this out and, of course, thanks for your LowPower.h library.
July 1, 2016 at 2:06 PM #4704LIM PHANG MOHKeymasterGlad that it work.
-
AuthorPosts
- You must be logged in to reply to this topic.