BASIC stamp manual v2.2

SLEEP – BASIC Stamp Command Reference
Page 442 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
To ensure accuracy of SLEEP intervals, the BASIC Stamp periodically
compares the watchdog timer to the more-accurate resonator time base. It
calculates a correction factor that it uses during SLEEP. As a result, longer
SLEEP intervals are accurate to approximately ±1 percent.
If your application is driving loads (sourcing or sinking current through
output-high or output-low pins) during SLEEP, current will be interrupted
for about 18 ms (60 µs on the BS2pe) when the BASIC Stamp wakes up
every 2.3 seconds. The reason is that the watchdog-timer reset that
awakens the BASIC Stamp also causes all of the pins to switch to input
mode for approximately 18 ms. When the interpreter firmware regains
control of the processor, it restores the I/O directions dictated by your
program.
If you plan to use END, NAP, POLLWAIT or SLEEP in your programs,
make sure that your loads can tolerate these periodic power outages. The
simplest solution is often to connect resistors high or low (to +5V or
ground) as appropriate to ensure a continuing supply of current during
the reset glitch. The demo program demonstrates the effects of this glitch.
Figure 5.45: SLEEP Example LED
Circuit.
Demo Program (SLEEP.bs2)
' SLEEP.bs2
' This program lights an LED and then goes to sleep. Connect an LED to pin
' 0 as shown in the description of SLEEP in the manual and run the program.
' The LED will turn on, then the BASIC Stamp will go to sleep. During
' sleep,the LED will remain on, but will blink at intervals of
' approximately 2.3 seconds due to the watchdog timeout and reset.
' {$STAMP BS2}
Setup:
LOW 0 ' turn LED on
NOTE: This example program is written
for the BS2, but it also can be used with
the BS1 and all other BS2 models by
changing the $STAMP directive
accordingly.
1
A
ll
2