5: BASIC Stamp Command Reference – SLEEP
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 317
SLEEP
BS1 BS2 BS2e BS2sx BS2p
SLEEP Period
Function
Put the BASIC Stamp into low-power mode for a specified time.
• Period is a variable/constant/expression (1 – 65535) that specifies
the duration of sleep. The unit of time for Period is 1 second, though
the BASIC Stamp rounds up to the nearest multiple of 2.3 seconds.
Quick Facts
BS1 BS2 BS2e BS2sx BS2p
Current draw
during run
2 mA 8 mA 25 mA 60 mA 40 mA
Current draw
during SLEEP
20 µA 40 µA 60 µA 60 µA 60 µA
Accuracy of
SLEEP
±1% @ 75°F
with stable
power supply
±1% @ 75
°F
with stable
power supply
±1% @ 75
°F
with stable
power supply
±1% @ 75
°F
with stable
power supply
±1% @ 75
°F
with stable
power supply
Explanation
SLEEP allows the BASIC Stamp to turn itself off, then turn back on after a
programmed period of time. The length of SLEEP can range from 2.3
seconds to slightly over 18 hours. Power consumption is reduced to the
amount described in Table 5.93, assuming no loads are being driven. The
resolution of the SLEEP instruction is 2.304 seconds. SLEEP rounds the
specified number of seconds up to the nearest multiple of 2.304. For
example, SLEEP 1 causes 2.3 seconds of sleep, while SLEEP 10 causes 11.52
seconds (5 x 2.304) of sleep.
Pins retain their previous I/O directions during SLEEP. However, outputs
are interrupted every 2.3 seconds during SLEEP due to the way the chip
keeps time. The alarm clock that wakes the BASIC Stamp up is called the
watchdog timer. The watchdog is a resistor/capacitor oscillator built into
the interpreter chip. During SLEEP, the chip periodically wakes up and
adjusts a counter to determine how long it has been asleep. If it isn’t time
to wake up, the chip “hits the snooze bar” and goes back to sleep.
To ensure accuracy of SLEEP intervals, the BASIC Stamp periodically
compares the watchdog timer to the more-accurate resonator time base. It
2
2
2
NOTE: Expressions are not
allowed as arguments on the BS1.
Table 5.93: SLEEP Quick Facts.