Using SLEEP and SETFREQ K31 on a Picaxe 08M2

How will underclocking (K31) affect the sleep command. Also, will Pause 1000 result in a pause of 128 seconds?

Code:
[color=Green]'*******************************************************
'Actuator For Keith
'*******************************************************[/color]
[color=Navy]#Picaxe [/color][color=Black]08M2[/color]
[color=Green]'*** Variables ***[/color]
[color=Blue]Symbol [/color][color=Black]DLY[/color][color=DarkCyan]=[/color][color=Purple]W0[/color]
[color=Blue]Symbol [/color][color=Black]Pulse_dur[/color][color=DarkCyan]=[/color][color=Purple]W1[/color]
[color=Blue]Symbol [/color][color=Black]N[/color][color=DarkCyan]=[/color][color=Purple]b4[/color]
[color=Green]'#terminal 4800
'*** Pins ***[/color]
[color=Blue]Symbol [/color][color=Black]Merc[/color][color=DarkCyan]=[/color][color=Purple]PinC.4[/color]
[color=Blue]setfreq K31
      [/color][color=Black]Pulse_dur[/color][color=DarkCyan]=[/color][color=Navy]100
      [/color][color=Green]'high C.2
      'low C.1
      [/color][color=Blue]pause [/color][color=Black]pulse_dur
      [/color][color=Blue]setint [/color][color=Navy]%10000[/color][color=Black],[/color][color=Navy]%10000[/color]
[color=Black]Waiting:
      [/color][color=Blue]disablebod
      Sleep [/color][color=Navy]$FFFF
      [/color][color=Blue]Goto [/color][color=Black]Waiting[/color]
[color=Blue]Interrupt:
      [/color][color=Green]'sertxd ("Start cycle ******",cr,lf)
      [/color][color=Black]DLY[/color][color=DarkCyan]=[/color][color=Navy]3
      [/color][color=Blue]If [/color][color=Purple]PinC.3[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]then let [/color][color=Black]Dly[/color][color=DarkCyan]=[/color][color=Navy]6    [/color][color=Green]'3.0 imutes
      [/color][color=Blue]endif
      High C.1
      Low C.2
      Pause [/color][color=Black]Pulse_dur
      [/color][color=Blue]Low C.1
      Pause [/color][color=Navy]1000
      [/color][color=Blue]For [/color][color=Black]N[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]to [/color][color=Black]DLY
      [/color][color=Green]'sertxd (#N," 30 Seconds********* " ,cr,lf)
      [/color][color=Blue]Pause [/color][color=Navy]3000
      [/color][color=Blue]Next [/color][color=Black]N
      [/color][color=Blue]low C.1
      high C.2
      [/color][color=Green]'sertxd ("Shut Down")
      [/color][color=Blue]Pause [/color][color=Black]Pulse_dur
      [/color][color=Blue]Pause [/color][color=Navy]1000
      [/color][color=Blue]low C.2
      setint [/color][color=Navy]%10000[/color][color=Black],[/color][color=Navy]%10000
      
      [/color]
[color=Blue]Return[/color]
 

AllyCat

Senior Member
Hi,

Sleep (and nap) always operate from the 31 kHz (Watchdog) oscillator so the timing period should not change.

But yes, AFAIK PAUSE timing will be increased by a factor of about 128, and the whole program will only run at about 10 instructions (lines) per second.

Also, I don't think those SERTXDs will work unles you have a terminal that can run at around 40 baud. But you might be able to use HSEROUT which uses the same pin on an 08M2.

Cheers, Alan.
 

lbenson

Senior Member
If you're trying, with "SETFREQ K31" to minimize battery usage, you might do better on the M2 devices to use sleep or nap. I don't know that rigorous tests have been published by a user for the picaxe M2s, but I believe that is what Technical has recommended.
 

notzippy

New Member
On the 08M2 I measured no current draw difference when using "SETFREQ K31" vs omitting it. Both cases the chip drew about 75 micro amp @ 4.02 volts, and yes setting the frequency did affect the pause.
The rest of my code I alternated using pause vs sleep, once again there was no discernible different current draw alternating between using the two.

So what is the normal current draw for this chip ? I have not been able to find those types of specs...

thanks
Nz
 

AllyCat

Senior Member
Hi Nz,

On the 08M2 I measured no current draw difference when using "SETFREQ K31" vs omitting it. Both cases the chip drew about 75 micro amp @ 4.02 volts, .....
So what is the normal current draw for this chip ? I have not been able to find those types of specs...
Those figures don't tie up with mine, nor with the Microchip Data Sheet. What serial interface were you using? Maybe the PICaxe was being (partially) powered by the RS232 voltage levels on the Programming Port?

The base PIC data sheets are linked here . The current drain at different frequencies is in section 30. I think "technical" has confirmed that PICaxe's SLEEP always uses the separate Watchdog (31kHz) internal oscillator. PAUSE is a function of the master clock oscillator frequency.

Cheers, Alan.
 

Technical

Technical Support
Staff member
Sleep current is dependent on a large number of factors, the main ones to watch out for is to ensure the brown out protect is off via 'disablebod', to make sure no pins are floating (tie unused inputs high or low), and, for 28/40 pin parts, make sure a external resonator is fitted (even if not used).
 

notzippy

New Member
Hi Nz,

Those figures don't tie up with mine, nor with the Microchip Data Sheet. What serial interface were you using? Maybe the PICaxe was being (partially) powered by the RS232 voltage levels on the Programming Port?

The base PIC data sheets are linked here . The current drain at different frequencies is in section 30. I think "technical" has confirmed that PICaxe's SLEEP always uses the separate Watchdog (31kHz) internal oscillator. PAUSE is a function of the master clock oscillator frequency.

Cheers, Alan.
Your right alan, those are bad readings for a couple of reasons. So I remeasured with just the development board, I got

Readins @ 4vnormaldisableboddisablebod & setfrq k31
pause573ua565ua560ua
sleep409ua405ua404ua

On website it says
Standby Current : 20 nA @ 1.8V, typical
Active Current : 50uA/MHz @ 1.8V, typical

In the pdf it states
Operating Current: 30 uA/MHz @ 1.8V, typical

So in theory at 4MHZ the draw should be 120 - 200uA in operation mode, so I am seeing 3-4 times that, does that align with your results ?

Thanks
Nz
 

srnet

Senior Member
Those are the expected readings at 1.8V, I thought you were running the PICAXE at 4.0 volts or so ?
 

AllyCat

Senior Member
Hi,

Also, when reading the data sheet, beware that the "white background" parameters are for the "LP" (Low Power) versions and AFAIK PICAXEs use the "standard" version (grey background data). There can be very significant differences in the power consumption sections. ;)

My observed figures are very approximately 600 uA at 4MHz, 100 uA at 32 kHz and perhaps a few uA in Sleep, which I believe are in accordance with the datasheet. But it very much depends on exactly what external components/signals are connected and which internal hardware modules are (still) activated. Also note that the minimum Vdd for the 08M2 is around 2.3 volts.

Cheers, Alan.
 

Hemi345

Senior Member
Your right alan, those are bad readings for a couple of reasons. So I remeasured with just the development board
If you're using the AXE091 and measuring between the power source and the AXE091, then it's going to be much higher than just the PICAXE alone. All the other ICs populated on the AXE091 will draw current in addition to the PICAXE: the power LED, the IR receiver, EEPROM, etc.

On a breadboard, with a 14M2 @ 3.3V, all pins tied low (suggested programming resistors in place), using sleep command and disableBOD, I was seeing around ~14uA.

With the same 14M2 @ 3.3V, suggested programming resistors in place, and only I2C pins pulled high with 4.7K resistors (the rest left floating), current consumption was ~42uA with sleep command and disableBOD.
 

Hemi345

Senior Member
Your right alan, those are bad readings for a couple of reasons. So I remeasured with just the development board
If you're using the AXE091 and measuring between the power source and the AXE091, then it's going to be much higher than just the PICAXE alone. All the other ICs populated on the AXE091 will draw current in addition to the PICAXE: the power LED, the IR receiver, EEPROM, etc.

On a breadboard, with a 14M2 @ 3.3V, all pins tied low (suggested programming resistors in place), using sleep command and disableBOD, I was seeing around ~14uA.

With the same 14M2 @ 3.3V, suggested programming resistors in place, and only I2C pins pulled high with 4.7K resistors (the rest left floating), current consumption was ~42uA with sleep command and disableBOD.
 

srnet

Senior Member
You may also find that if you have a particular task to do, and after the task is completed you put the PICAXE to sleep for a while, it can be more power efficent to run the task at a higher speed.
 

AllyCat

Senior Member
Hi,

looks changing freq lower then 4Mhz does not amount to a whole lot of savings.
It's hard to say as that graph doesn't appear to go down below 1 MHz and refers to the External Oscillator (resonator) mode which the 08M2 doesn't support.

Certainly you're (very) unlikely to get a 100 times reduction in current simply by dropping from 4 MHz to 32 kHz. As I said in #9, perhaps a 6 times reduction in current, plus whatever savings are made by switching off "unnecessary" chip functions.

Cheers, Alan.
 
Top