Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Question re: sleep mode and power consumption

Status
Not open for further replies.

Russ Sprouse

New Member
I am going through the Baseline Assembler tutorials from Gooligum, and am currently looking at Lesson 7. David explains how to put the processor into sleep mode, and explains that GPIO pins should be configured to stop sourcing or sinking current (e.g., a LED turned off) before entering sleep mode, to reduce power consumption.

He also explains that unused pins should be tied to either Vdd or Vss to prevent them from "floating" and causing unnecessary current drain. I am using a PIC 12F509, driving a single LED on GP1. I have tied GP0, GP4 and GP5 to ground (Vss) as suggested, and when the program is running, with the LED lit, the circuit is drawing about 20.4mA.

When I press the pushbutton to enter sleep mode, GP1 is programmed to go low (i.e. turn off the LED, which it does) and then enter sleep mode. But the circuit is still drawing about 11.1mA, which does not jibe with Davids statement that the circuit should now draw "less than 0.1uA." So I am wondering why my circuit is still drawing so much current.
 
The 'floating' pins thing seems mostly to be a myth, while it applied to 4000 series CMOS chips it doesn't seem to be that way on PIC's.

While I've never been able to get anything like the claimed 'nano-watt' consumption on PIC's, it's certainly pretty easy to get them nice and low in sleep mode.

Try leaving GP0, 4 and 5 floating, see what difference (if any) that makes.
 
Thanks, Nigel. You are correct, pulling the resistors I was using to pull down the unused pins had no apparent effect. So, would you consider approximately 11mA to be a reasonably "nice and low" level of current draw for sleep mode?
 
The 'floating' pins thing seems mostly to be a myth, while it applied to 4000 series CMOS chips it doesn't seem to be that way on PIC's.
I cannot comment on floating pins and power consumption, but I once had a bad experience with PIC pins configured as inputs and left floating, they caused very erratic operation. If I remember correctly they were causing spurious interrupts.
So tidying up unused inputs by means of a pull-up or pull down resistor is a good thing to do from a program stability point of view.

JimB
 
Thanks, Nigel. You are correct, pulling the resistors I was using to pull down the unused pins had no apparent effect. So, would you consider approximately 11mA to be a reasonably "nice and low" level of current draw for sleep mode?

No, not by a LONG way :D

Are you sure it's actually going to sleep?, 11mA might be the current the PIC takes just running, and the other 9mA or so was what the LED was taking.

My actual 'use' of sleep mode was for an alarm type device, it woke once a second via a timer interrupt, updated it's clock time keeping and checked for activation of the trigger - then went straight back to sleep if not triggered, or send a txt message periodically (once a month, which could be changed during setup) to say it was 'still alive' - including a reading of the battery voltage. The design brief was for an estimated five years battery life - depending on the number of triggered events. It was rather difficult to actually measure the consumption, as it had very high short term currents from the GSM module - but it was certainly no where near 1mA.
 
I cannot comment on floating pins and power consumption, but I once had a bad experience with PIC pins configured as inputs and left floating, they caused very erratic operation. If I remember correctly they were causing spurious interrupts.
So tidying up unused inputs by means of a pull-up or pull down resistor is a good thing to do from a program stability point of view.

Set them as outputs instead :D

Or leave them as inputs, but don't read them - and don't allow them to generate interrupts.

What you mustn't do though is leave MCLR floating, now that is a bad thing :p

It's a 'nice' idea adding pull up/down resistors to all unused I/O pins, but it's VERY wasteful and rather gets away from the minimal nature of PIC circuits - and not required if you set everything correctly.
 
I am pretty sure it is going into sleep mode. When the button is pressed (goes low) the next instruction is a bcf which turns off the LED, and that is immediately followed by the sleep instruction. Since the LED does turn off as expected when the button is pressed, I can't see how the sleep instruction would not be executed.

Is there some simple way I can confirm that the processor is actually in sleep mode?

I am running this on the Gooligum Training and development board, I suppose there may be things going on elsewhere on the board that are drawing some current. Maybe my next step is to build a bare breadboard version of the circuit so I can eliminate that possibility. This kind of thing makes me a bit obsessed, but it is kind of fun and satisfying when I figure things out, so I will give it a try.

And, I want to say, I really appreciate your help. I'm glad I found this forum!

~ Russ
 
Set them as outputs instead :D
I completely agree.
But until you know that there is a potential problem with poorly defined input pins...
Been there, done that, suffered the frustration, until I realised the problem.
One of those things which you only do once!
JimB
 
The schematics are included in the assembly instructions for the Training and development board kit, which is a copyrighted document, so I'd best not upload it here. But I have done some further experimentation, and have had good results.

I built a bare-bones version of the circuit on a breadboard, using a PIC 12F508, a LED and a pushbutton. I am powering it with three AA cells providing 4.7V (measured). I programmed the 12F508 with the same code I was using before.

The circuit drew 7.6mA before pressing the pushbutton, with the LED lit. After pushing the pushbutton, with the LED unlit, and the processor in sleep mode, the current draw was 0.1uA - possibly less.
 
Status
Not open for further replies.

Latest threads

Back
Top