Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

How to put wixel to sleep, and current savings


I have a project where only one of my wixels needs to transmit, and it is powered by a single 200mAh Li-PO cell. When idle, the project only transmits one short packet every 200mS, so the total “average” current seems to be only about 8mA. Because it is battery powered however, and especially because running a Li-PO battery down to far is not good for it, I’d like to add a simple inactivity timer to my project, and put it into sleep/low power mode after the timer expires. I don’t need any special scheme for re-awakening the wixel, as long as turning the power off and then on again restarts the app, along with its timer.

So my first question is, what do I need to do to put the wixel in the lowest possible power mode. Second, without hacking the wixel electrically, what is the lowest current draw I can expect after executing this code. I think if I can get down around 2mA, that will be adequate to protect the battery from the typical case of accidentally leaving the circuit running overnight for several days. If I can’t, and since i don’t want to alter the wixel electronics, I may have to find a power management IC to make a more complete disconnect.



For information on low-power operation of the Wixel, you should look at the CC2511 datasheet and this forum post:

I think you should put your Wixel into sleep mode 2. Without hacking the Wixel electrically, it will probably draw around 80 microamps of current.




I’ve been trying things like the example you pointed me to, but whenever I put in code like this…

__asm nop __endasm;
__asm nop __endasm;
__asm nop __endasm;

Eclipse says its a syntax error. Strangely it does compile, and it does go to sleep most of the time. But since it doesn’t work every time, I wonder if those "nop"s are being ignored.


Eclipse’s idea of valid syntax doesn’t exactly match SDCC’s idea. You can use “#ifndef CDT_PARSER” to tell Eclipse to ignore that part. The NOPs are probably there in the compiled code, and you can check by looking at some of SDCC’s human-readable listing output files.

I am not sure why it would fail to go to sleep sometimes.



Well this seems to work well now. Operating off a single cell Li-PO battery at 3.9V, the current drops to to about 0.8mA with the code in that example. That’s still 10x more then you had hoped, but its perfectly adequate to prevent accidentally running my LiPO battery down too far if its left on. (Actually there’s another “happy accident” safeguard too… when the voltage drops below 2V, and you’re already in sleep mode, the current drops another 10X!)


Just FYI, I had copied verbatum the code in that example, but I guess that example was intended for situations where you needed to be able to wake the Wixel from sleep using some pins. Looks like if I just turn all the pins into inputs prior to sleep, I can indeed get down to about 80 uA of current. That’s really great!

P0DIR = P1DIR = P2DIR = 0;
P0SEL = P1SEL = P2SEL = 0;
	   SLEEP = (SLEEP & ~3) | 2;    // SLEEP.MODE = 2 : Selects Power Mode 2 (PM2).
	   __asm nop __endasm;
	   __asm nop __endasm;
	   __asm nop __endasm;
	     if (SLEEP & 3)
	       PCON |= 1;    // PCON.IDLE = 1 : Actually go to sleep.