Shop OBEX P1 Docs P2 Docs Learn Events
SLEEP command question — Parallax Forums

SLEEP command question

ArchiverArchiver Posts: 46,084
edited 2004-07-23 00:50 in General Discussion
In a message dated 7/22/2004 4:43:01 PM Eastern Daylight Time,
wschini03@y... writes:


> To anyone who might know,
> I am using the BS2pe for datalogging operations and I want to
> set up a sample rate. I am thinking of using the SLEEP command to
> cause the BS2pe and other circuitry to pause and go to low power mode
>

The acutal duration of the sleep command is 2.3 secs for 1, 2.3 seconds for
2,
4.6 secs for 3 and so on. The actual duration is the multiple 0f 2.3 that is
closest to the duration you specify. 30 sec duration would acutally be 32.2
secs, which is the closest multiple of 2.3 to 30. If you want to calculate
the actual duration, divide you intended duration, say 60 secs, by 2.3, then
round it up to the next integer. 60/2.3 = 26.086, so round it up to 27. 27 *
2.3 = 62.1
secs, which would be the actual duration.

Sid


[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-07-22 21:37
    To anyone who might know,
    I am using the BS2pe for datalogging operations and I want to
    set up a sample rate. I am thinking of using the SLEEP command to
    cause the BS2pe and other circuitry to pause and go to low power mode
    while waiting for the next sample time. The Stamp Manual is quite
    confusing in what the timing is for the Period of the SLEEP command.
    Is the period 1 second or 2.304 seconds? Their example states that
    the command "SLEEP 10" is 11.52 seconds long (5 x 2.304s). This does
    not make sense. Should'nt "SLEEP 10" give you either 10 seconds or
    23.04 seconds. Also, the maximum time for the command should either
    be 65,535 seconds (18.204 hours) or 65,535 x 2.304s = 150,992.64
    seconds (41.9424 hours). They give the example of "SLEEP 10" as if
    the period is 2.304 seconds, but the maximum SLEEP time as if the
    period is 1 second. Please help me with this if you can. They are
    very vague in the explanation for the timing of the SLEEP command.
    Thank you,
    Bill Schini, KC9CFO
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-23 00:50
    Hi Bill,

    Quick answer to your question, SLEEP XXX will give XXX seconds of
    sleep, but probably a second or two longer than XXX.

    Long answer: The SLEEP command is governed under the Stamp hood by
    an RC timer that is built into the Ubicom SX48 micro. It is somewhat
    temperature dependent, and it's period is different from one Stamp to
    the next.

    On the original PIC-based BASIC Stamp the period was around 2.3
    seconds. (one digit precision--that 2.304 figure in the manual is
    totally bogus precision!) On the SX-based BASIC Stamps (2sx, 2e, 2p
    and 2pe), the period is shorter, closer to 2 seconds. Often around
    1.9 seconds in my experience.

    When you command SLEEP 10, the result will have a granularity of
    about 2 seconds (depending on the individual stamp and on the
    temperature). The interval will be close to but a little longer than
    10 seconds.

    You might think that longer intervals might become wildly inaccurate,
    as the Stamp cannot really guess what the period of its own RC
    watchdog timer is. But no, the Stamp _can_ and in fact _does_ know
    the period of its own watchdog and calibrates longer intervals
    against its ceramic resonator. So intervals of minutes will turn out
    at +/- only a few seconds.

    If you have an RTC in your data logger, you can use that in
    conjunction with SLEEP to make things happen with great regularity.
    If your RTC has an interrupt output, you might also look into the
    POLLWAIT feature of the BS2pe.

    The same internal watchdog timer is behind the timing of the NAP and
    POLLWAIT commands, and its timing can be adjusted down to about 15
    milliseconds. I have an essay on the BS2pe and about SLEEP posted at
    these URLs:
    <http://www.emesystems.com/BS2pe.htm>
    <http://www.emesystems.com/BS2power.htm>

    -- best regards
    Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
    mailto:tracy@e...



    >To anyone who might know,
    > I am using the BS2pe for datalogging operations and I want to
    >set up a sample rate. I am thinking of using the SLEEP command to
    >cause the BS2pe and other circuitry to pause and go to low power mode
    >while waiting for the next sample time. The Stamp Manual is quite
    >confusing in what the timing is for the Period of the SLEEP command.
    >Is the period 1 second or 2.304 seconds? Their example states that
    >the command "SLEEP 10" is 11.52 seconds long (5 x 2.304s). This does
    >not make sense. Should'nt "SLEEP 10" give you either 10 seconds or
    >23.04 seconds. Also, the maximum time for the command should either
    >be 65,535 seconds (18.204 hours) or 65,535 x 2.304s = 150,992.64
    >seconds (41.9424 hours). They give the example of "SLEEP 10" as if
    >the period is 2.304 seconds, but the maximum SLEEP time as if the
    >period is 1 second. Please help me with this if you can. They are
    >very vague in the explanation for the timing of the SLEEP command.
    >Thank you,
    >Bill Schini, KC9CFO
    >
Sign In or Register to comment.