'Sleep' current consumption too high....

Mikler

Member
Help!

I am in a panic. I have a project that, when in 'sleep' mode, it MUST use very low current e.g. a few uA (without underclocking).

What am i doing wrong? The lowest current that I am getting in the 'sleep' loop is 640uA

Here is my 'hardware' setup:

I have a 28X2 (3volt version) running at 3v (2 x AA batteries)

My reset button (pin-1) is tied high via a 4K7 resistors
A0,1,2,3 (pins 2-5) are tied low with 10k resistors
I am using the standard USB-cable circuit for serial in/out

C0-C7 (pins 11-18) have 150R resistors going to LEDs that go to +V.
B0 (pin 21) has a 100K resistor going to +v (I will be using this to detect a 'low' interrupt)
B1-B6 (pins 22-27) have 150R resistors going to LEDs that go to +V.
B7 has a piezo-sounder

Here is my 'test' program:

#picaxe 28x2
high C.0, C.1, C.2, C.3, C.4, C.5, C.6, C.7
high B.0, B.1, B.2, B.3, B.4, B.5, B.6, B.7
disablebod

main:
disablebod
sleep 5
SOUND B.7,(80,10) 'give me a bleep
low C.0 'flash test LED
pause 2000 'pause to display LED
high C.0 'switch off LED
goto main 'loop

(My only thoughts are that I am driving all the LEDs with one side to the +v and the other via a resistor to the 28X2 pins - possible, I should be running them from 0V - would be a real 'pain' if I have to change this...)

(Also, could turning off the four ADC's help - if yes, please can someone tell me how - I don't know what/where to poke to do this)

Help greatly appreciated.

Thanks

Mik
 

hippy

Ex-Staff (retired)
Turning the ADC off requires clearing bit 0 of ADCON0 ...

PokeSfr $C2,0

and it may be worth setting adcsetup to zero

adcsetup = 0

However ... if there hasn't been a READADC ( as in your test program ) the ADC will not have been turned on in the first place. PEEKSFR of $C2 returns zero.

You could try configuring your 28X2-3V on breadboard with no I/O connected and see what that gives. That will let you know what affect your I/O configuration is having.

Unless someone has done ultra low power mode operation on the 28X2 it may be a case of working your way through the SFR's checking what peripherals are enabled and turning them off. The required Microchip datasheet will be for the 18F25K20 ( DS41303D is the version I have ).
 

212

Senior Member
I am using the standard USB-cable circuit for serial in/out
Are you measuring the current with this USB connected or not? I haven't tried any of the new chips yet, but I intend to, so this will help me too if you figure this out...
 

Mikler

Member
212 _ i have disconnected the serial cable

Hi 212

212 _ i had already disconnected the serial cable

Mik
 

Mikler

Member
Heeelp _ Even basic circuit is using 0.6mA

Help! - I am in a panic as this project (my first) has to be ready in a few days....

>> You could try configuring your 28X2-3V on breadboard with no
>> I/O connected and see what that gives. That will let you know what
>> affect your I/O configuration is having."

I have tried this. I have used a new picaxe. I have used the minimal circuit (P31 of manual Section-1) I have used a single LED/150R resistor. Running from two AA batteries. I have put 100K resistors from pins 2-5 (ADCs) to 0v.
I have disconnected the serial cable.

When the LED is off, I am using about 7mA. With the LED off, I am using 0.6A. (Exactly the same current reading with two DMM's)

Heeeelp!!!!

>> Unless someone has done ultra low power mode operation on the
>> 28X2 it may be a case of working your way through the SFR's
>> checking what peripherals are enabled and turning them off.
>> The required Microchip datasheet will be for the 18F25K20
>> ( DS41303D is the version I have )

I have DS41303E and have the SFR map. But I am to much of a beginner to know which ones to turn off. If you think this is the solution, can you give me some pointers here?

Any assistance greatly appreciated.

Thanks

Mik (panicking!)
 

Andrew Cowan

Senior Member
When the LED is off, I am using about 7mA. With the LED off, I am using 0.6A. (Exactly the same current reading with two DMM's)
I assume you mean
When the LED is on, I am using about 7mA. With the LED off, I am using 0.6mA. (Exactly the same current reading with two DMM's).

Did the current decrease when you made the pulldowns 100K?
 

Mikler

Member
Correction - Yes - that should have read "When the LED is on, I am using about 7mA. With the LED off, I am using 0.6A."
 

Mikler

Member
>>Did the current decrease when you made the pulldowns 100K?

The current stays the same (0.612mA) whether I have 10K or 100K
I have tried tying these to both high as well as low with no difference.

Heeelp.....
 

hippy

Ex-Staff (retired)
Unfortunately panic won't necessarily help anything and can often work against successful progress. Not many people have experience with using a PICAXE in ultra low power configurations and the 28X2-3V being recently introduced means even fewer will have experience with that. I haven't any experience myself and don't even have a meter which would measure such low currents with any accuracy.

When is the project due and what sleep-mode current will be acceptable at that time ?

How essential is lower current consumption than what you have ? Depending on the nature of the project, it may be appropriate to document that the current consumption could be reduced in future but hasn't been achieved at the present time.

On the plus side, that the current is no lower when you connect all LED's to when you connect one suggests that your hardware configuration should not be the cause of higher than expected current, though it may be necessary to revist that when the core current is reduced further.
 

Mycroft2152

Senior Member
M,

If you check the forum posts on power reduction, the last step and the final significant power reduction was the result of underclocking.

You may just have to bite the bullet and underclock during the sleep stage then return to noraml speed after waking up.

Myc
 

Mikler

Member
Hi Myc

Your comments noted - you are correct - I will try and find out how to underclock and see how this reduces the current.

Thanks
 

Mikler

Member
Hi Hippy

My panic is very controlled :) I suppose if I underclock my brain, the deadline will take longer to arrive.... :)

>>I haven't any experience myself and don't even have a meter
>>which would measure such low currents with any accuracy.
I actually purchased a second low cost $40 digital multimeter and it confirms the reading of my larger one....

>> When is the project due and what sleep-mode current will be acceptable at that time ?
It is due by the weekend - stupidly having seen that the first page of the spec sheet quotes a 'sleep mode' current consumption of 100nA, I assumed that I have no problem. (I don't have an exact figure as to current consumption that I require, but the product runs on two batteries, and when not being used (sleep mode), it should hardly drain the battery.)

>>How essential is lower current consumption than what you have ?
Absolutely vital.

Forgive me - I am not sure if you are actually part of 'PicAxe', but if you are, any idea how long it would take for someone to look at this?

Better still, anything that I can try?

(You mentioned earlier playing with the SFR register to turn stuff off - any pokes that you can suggest for me to try? I note that in the PIC data sheet, in the DC characteristics section, it mentions a few features that use considerable current (The ADC is one of them) - Regretfully my technical knowledge is not good enough for me to do this, but if you can assist, I am happy to try anything....)

I don't know how to underclock _ i will look through the forum to see postings on this, in case it gives a dramatic improvement....

Yours (very cool :)

Mik
 
Instead of giving a bleep after sleep, PEEK the OSCON register and read it back after after wakeup. What do you get, and how does that relate to the dc characteristics, if at all? How can you change it, and will it improve the sleep current? Do RC_IDLE and PRI_RUN come into play?, use same peek poke analogy.
 

Mikler

Member
Possible solution? 3uA?

Hi Guys

Good news with my minimal breadboard model....

I don't know if this is legitimate but if I tie pin 9 of the resonator down to ground, via a 100k resistor, the consumption plummets... unless I have my decimal point wrong, it is giving me .003mA which I think is 3uA.
(a 1M resistor has the consumption up to .09mA)

Presumably pin 9 is a high impedance input? Was it causing instability if left floating?

Any comments?

Do you feel that this could damage the chip?
Any other, better value?
Is there a way to 'switch off the resonator pins' via a command....

I will do some further testing but this could be an enhancement for other picaxes?

Mik
 

Mikler

Member
OK

Seems like good news. By grounding the Resonator 'input' via a 100k resistor, it brings my consumption when in 'sleep' down to 3ua. I can't find anywhere, whether on the picaxe site or the PIC tech sheet, that suggests this, so I am rather nervous in case I have made a mistake.

This has however worked on two different boards (one a breadboard with a minimal 1-led design, the other on some 'stripboard' with multiple leds and a 'pushbutton'-triggered interupt. (Obviously, it could be that I have a similar mistake on both boards causing instability?)

I would be grateful for comments from 'more techie people' as to whether this is a legitimate mod and whether the value is correct.

I wonder if there is a way to 'switch off' this input from software.

Thanks for everyones help and suggestions

Kind regards

Mik
 

hippy

Ex-Staff (retired)
I don't know if this is legitimate but if I tie pin 9 of the resonator down to ground, via a 100k resistor, the consumption plummets... unless I have my decimal point wrong, it is giving me .003mA which I think is 3uA.
Looks like you're ahead of the curve on this one.

To be able to work with both an internal and external oscillator the oscillator block has to be enabled, HS mode selected and PLL enabled. I think your analysis of it being a high impedance floating input and picking up noise is correct and I can see no harm in tying it to 0V via a 100K.

It's not clear if you are using an external oscillator or not. If not simply tie it to 0V. If you are, connecting it to an I/O which can go low when you need low power operation may do it. You may be able to connect it to 0V in both cases.

The details of low-power oscillator configuration is quite involved ( over 20 pages of the datasheet ) and 3uA is a respectable low current draw. Squeezing it down towards 100nA may take considerable effort and time as well as intimate knowledge of the PICmicro architecture and operation and there may be some parts you cannot disable due to necessary hardware configuration. I'm not certain but it seems that the watchdog which has to be enabled for PICAXE operation will draw 2uA.
 

BCJKiwi

Senior Member
You could try issuing a;
#setfreq m8
to ensure that the 28X2 knows which resonator (internal/external) it should be using - OK I know it should default to internal (m8). Alternatively, if you have an external resonator, you could try that (on the breadboard) and, for example, #setfreq em32 for an 8MHz resonator.


Crossed with Hippy's reply - might still be worth a try though.
 
Last edited:
All the more reason to peek/debug the OSCCON register to see whether its in idle or full sleep mode and other bits of info. Also peek/debug the OSCTUNE register to see whether the HFINTOSC or LFINTOSC source is being used. Checking the OSCCON bits against the datasheet table 3-1 power managed modes should be telling. The instruction after sleep always gets executed, so that's where to put the peek command to verify the exact state.
 

hippy

Ex-Staff (retired)
Due to the PICAXE firmware handling exit from sleep mode, by the time its come to execute the Basic comand after SLEEP the formware will likely have re-initialised the PICmicro hardware, so peeking OSCON will tell what it is doing now rather than what it was during sleep
 

Mikler

Member
Hi Hippy

I am using the internal oscillator (is this a simple C/R oscillator or a higher precison one?). Looking at the manual, pin 9 is indeed an input so the resistor does seem to make sense. I wonder whether with the higher frequency of the 28X2, that proper RF PCB design would help... However, I got the identical problem and then and identical solution (3ua) using both a veroboard (stripboard) design and a breadboard, neither of which is 'rf-friendly'.

Note that I am sure that 3uA is fine, although I would like to check, as suggested earlier, what sort of improvement I get by underclocking just before going into sleep mode.

BCJKiwi - I shall try that.

Nickelflipper - thank you for your suggestions - regretfully, I don't have the technical knowledge to adequately do what you suggest (I don't even understand it :) Short of step-by-step instructions, don't know what to do....

Thanks to everyone for their help

Mik
 
Nickelflipper - thank you for your suggestions - regretfully, I don't have the technical knowledge to adequately do what you suggest (I don't even understand it :) Short of step-by-step instructions, don't know what to do....
Mik
The very good manual has examples on how to peek, poke, and debug. You will not break anything by trying it out. I could be barking up the wrong tree, but when you executed your original code, does the bleep happen right after sleep, wait a X amount of seconds, then the led,s come on? Or does the bleep happen after the X seconds then leds immediately come on. If it is the latter than my idea of getting the state of the OSCCON register after sleep is out the door but worth the try. If it is the former then using the below code will give us useful information on how the OSCCON is set during sleep.

Checking out what the low level settings of your device registers is not necessarily a beginning topic, but then neither is getting the lowest current setting possible during sleep. So getting at the low level information will help describe what state the Picaxe is in. With this information, those register can be Poked with values to achieve your stated goal. Tell us what the OSCTUNE, and OSCCON (if possible) readout is.

#picaxe 28x2
high C.0, C.1, C.2, C.3, C.4, C.5, C.6, C.7
high B.0, B.1, B.2, B.3, B.4, B.5, B.6, B.7
disablebod

main:
disablebod
PeekSfr $9B,b0 'get OSCTUNE register value
Debug b0 'display OSCTUNE value
pause 3000
sleep 5
PeekSfr $D3,b1 'get OSCCON value after sleep command?
Debug b1 'display OSCCON value
pause 3000
SOUND B.7,(80,10) 'give me a bleep
low C.0 'flash test LED
pause 2000 'pause to display LED
high C.0 'switch off LED
goto main 'loop
 

Mikler

Member
Hi Nickelflipper

>> Or does the bleep happen after the X seconds then leds immediately come on

Yes :)

Thanks anyway!

Mik
 
Top