Shop OBEX P1 Docs P2 Docs Learn Events
Pause vs Sleep Alternatives — Parallax Forums

Pause vs Sleep Alternatives

stevertrstevertr Posts: 14
edited 2010-08-28 20:50 in BASIC Stamp
First, thanks to all for the help over the last week. It's quite the learning curve, but I think we've got most of it nailed down.

OK, so it appears we're being tripped up by the fact that the PAUSE command is limited to the 64000ms. I discovered the SLEEP command, which can do things in longer time periods, although I'm not able to figure out how to do things in parallel so I'm reaching out for ideas again.

In short, here's what we're up to as we ready our programmed module for it's first near space flight.

Our BS2 needs to do a few simple tasks, separated, unfortunately, by time increments greater than those allowed in the PAUSE command.

We launch at T=0.
At T=10 minutes, we send a PULSOUT command to the servo at PIN 14 to open the payload bay doors.

At T=90 minuter, we send a PULSOUT command to the servo at PIN 14 to close the payload bay.

At T=91 minutes, we cut down the Balloon by sending (via a relay through a darlington array) a 1 minute pulse of power at PIN 1 to a piece of nichrome wire that will burn off the balloon cord.

HIGH 1
PAUSE 60000
LOW 1

At T=150 minutes, we turn on the audible tracking beepers at PIN 2 (again through a relay) and they stay on from this point until recovery.

HIGH 2

At T=240 minutes, we cut down the parachute (in case we're caught in a tree), with a 1 minute pulse of power at PIN 3

HIGH 3
PAUSE 60000
LOW 3

END


It would seem that I can deal with the time issue, by using the SLEEP command in between these different events, is that correct?

Now, here's the bigger problem. I'm not sure I can use the SLEEP command at all, because while the BS2 is conducting the simple program items above, it is also storing to a memory card the external temperature and GPS position each minute, so that when it returns we can pop that card in and see what the temp was at each minute and at each GPS coordinate during the flight.

So now I'm stuck, and need the experts big time....

Hope someone has a solution because I've looked everywhere with no luck. I thought I could somehow run the items above with SLEEP in between, while at the same time allowing it to store the other info at the datalogger card.

Regards

Steve

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-28 20:50
    Unfortunately, the Stamp is a "single threaded" microcontroller. It can only do one thing at a time. If it's timing something by waiting using PAUSE, SLEEP, or NAP, it can't do anything else. If it's reading sensors, massaging the data, and writing it to some kind of memory for datalogging purposes, it can't do any kind of accurate timing. Since your timeframes are long, you should be able to attach some kind of real-time clock to your Stamp that will independently keep track of the elapsed time. You have only to check the clock from time to time. Your datalogging loop (read sensors, massage data, write to external memory card) gives you a periodic function. Just add another task to this periodic loop ... that of checking the real-time clock to see if the time has passed the threshold for the next action to take place (open payload doors / close payload doors / cut down balloon / start tracking beepers / cut down parachute).

    The Maxim/Dallas DS1302 is a readily available real-time clock that's easily controlled by a Stamp. There's plenty of sample code available for this. It requires 3 I/O pins. Have a look at Nuts & Volts Column #33 for details. You don't have to set the clock to the actual time and date (although you could). It would be enough to zero the time and date at launch time, then use the minutes information to do your timing. The clock could be used to time stamp your data.
Sign In or Register to comment.