timer or clock function on BS2?
Archiver
Posts: 46,084
I'd like to be able to periodically send data to my computer from a
BS2. In Pseudo-code, here's what I mean
kInterval con 1000 'interval between data transmission
top:
do some processing
if (interval > kInterval) then transmit data
goto top:
How do I do this? I can't seem to find a non-blocking way to make
something happen on an interval basis. SLEEP, NAP, PAUSE all cause
processing to stop. The fact that SLEEP et. al. exist implies that the
BS2 has an onboard timer, so it seems that a solution that doesn't
require external bits should be possible.
What am I overlooking?
cheers,
_murat
BS2. In Pseudo-code, here's what I mean
kInterval con 1000 'interval between data transmission
top:
do some processing
if (interval > kInterval) then transmit data
goto top:
How do I do this? I can't seem to find a non-blocking way to make
something happen on an interval basis. SLEEP, NAP, PAUSE all cause
processing to stop. The fact that SLEEP et. al. exist implies that the
BS2 has an onboard timer, so it seems that a solution that doesn't
require external bits should be possible.
What am I overlooking?
cheers,
_murat
Comments
every pass through the program loop, etc. When the counter is greater
than some pre-set variable, then you transmit your data.
This approach would be 100% accurate, as each pass through the program
loop may take a differing amount of time, depending on what is being
done, but you should be able to achieve granularity of a few seconds at
worst.
If you program is fairly small, then you make have to implement a
time-waster, like a useless for-next loop.
If you're not worried about processing other data while waiting to
transmit you can do somethine like a SERIN on an usused pin, with a
timeout of "x" seconds (whatever is appropriate for you). Since the pin
is usused, the SERIN command will always fail after "x" seconds,
resulting in a fairly decent "SLEEP" of many seconds.
On Mon, 2002-11-25 at 07:04, m wrote:
> I'd like to be able to periodically send data to my computer from a
> BS2. In Pseudo-code, here's what I mean
>
> kInterval con 1000 'interval between data transmission
>
> top:
>
> do some processing
>
> if (interval > kInterval) then transmit data
>
> goto top:
--
Brian <stamp@k...>
increments so you won't have to stop the Stamp or waste time in delay
loops.
That is how we can do multi-tasking with a Stamp.
Details are on the website. www.bluebelldesign.com
If you only have one time to count, you can use an external timer
chip (like a 555) and periodically check if it is done.
Harry
Stamp Robotics to the next level
www.bluebelldesign.com
--- In basicstamps@y..., m <murat_stamp@e...> wrote:
> I'd like to be able to periodically send data to my computer from a
> BS2. In Pseudo-code, here's what I mean
>
> kInterval con 1000 'interval between data transmission
>
> top:
>
> do some processing
>
> if (interval > kInterval) then transmit data
>
> goto top:
>
>
> How do I do this? I can't seem to find a non-blocking way to make
> something happen on an interval basis. SLEEP, NAP, PAUSE all cause
> processing to stop. The fact that SLEEP et. al. exist implies that
the
> BS2 has an onboard timer, so it seems that a solution that doesn't
> require external bits should be possible.
>
> What am I overlooking?
>
> cheers,
>
> _murat