Accurate track of time while doing something else?
Genesis
Posts: 42
Hi folks...
I don't think this can be done, but I thought I'd ask.... [noparse]:)[/noparse]
My application needs to be able to set an output high, and then come back at it after some period of time and turn it back low.
The duration exceeds that of the "PULSOUT" command.
What I've been doing is:
HIGH DEFINED-PIN
PAUSE MILLISECONDS
LOW DEFINED-PIN
Which works fine.
However, what I'd like to be able to do is go off and run other parts of the program, and then determine if "X" milliseconds (or more) have elapsed.
The DS1307 would at first blush appear to have what I need on-chip for a polling implementation but on second look it appears that the resolution is too fine, plus there is no latch (its a square wave output) which gets me in trouble on both counts.
Also, there is a potential further "gotcha" that I can see here in that writing characters to a serial LCD (for example) potentially exposes you to a long period of time during which poll status is not checked (e.g. write 10 characters @9600 bps, you are "unpolled for as much as 10ms) which leaves you with the distinct possibility of "missing" one or more poll events.
Finally, the poll-run is not an interrupt, so state is not saved - you transfer ocntrol but can't get back to where you were, since you don't know where you were when the poll "hits".
Am I pretty much square on this?· My first blush was that I could get more-or-less what I wanted with polled inputs, but the more I look at it the more it appears that this is unrealistic, and that I probably need to feed the SQW output from the DS1307·into a counter with an enable controlled by the BS2, and then read that back to determine "where I am" in terms of elapsed time.
·
I don't think this can be done, but I thought I'd ask.... [noparse]:)[/noparse]
My application needs to be able to set an output high, and then come back at it after some period of time and turn it back low.
The duration exceeds that of the "PULSOUT" command.
What I've been doing is:
HIGH DEFINED-PIN
PAUSE MILLISECONDS
LOW DEFINED-PIN
Which works fine.
However, what I'd like to be able to do is go off and run other parts of the program, and then determine if "X" milliseconds (or more) have elapsed.
The DS1307 would at first blush appear to have what I need on-chip for a polling implementation but on second look it appears that the resolution is too fine, plus there is no latch (its a square wave output) which gets me in trouble on both counts.
Also, there is a potential further "gotcha" that I can see here in that writing characters to a serial LCD (for example) potentially exposes you to a long period of time during which poll status is not checked (e.g. write 10 characters @9600 bps, you are "unpolled for as much as 10ms) which leaves you with the distinct possibility of "missing" one or more poll events.
Finally, the poll-run is not an interrupt, so state is not saved - you transfer ocntrol but can't get back to where you were, since you don't know where you were when the poll "hits".
Am I pretty much square on this?· My first blush was that I could get more-or-less what I wanted with polled inputs, but the more I look at it the more it appears that this is unrealistic, and that I probably need to feed the SQW output from the DS1307·into a counter with an enable controlled by the BS2, and then read that back to determine "where I am" in terms of elapsed time.
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
The 2pe is extremely useful to me as it has onboard EEPROM for data logging, which is also part of this, and it also has very "nice" power consumption numbers. It also has returned impressive development speed thus far!
I can "get there" by using HIGH/PAUSE/LOW, but it means suspending execution of other things during that interval. Ideally I'd like to be able to recognize a button press and respond to it while the output in question is "on"; that means being able to set it and continue execution, then check back for a timer to see if it has expired.
It may be that what I need to do is add an off-board programmable timer that I can load with the desired "countdown", use the DS1307s SQW output as a clock into that chip, and then have the output from the timer wired to an input. This would give me an independant one-shot programmable timebase with resolution closer than seconds.
That'll definitely do the job but I'm trying to avoid it if I can. If I can't, well, then I can't!
The SX chipset at a "raw" level will definitely do the job; perhaps down the road that's a second - or third - cut at this beast.... looks like the SX48 is the chip that's ON the 2pe, if I read the part numbers right (squinty eyes these days - I'm not 20 any more!); I may end up there somewhere down the road, but for the present I'm trying to avoid it.· Certainly at a production level the pricing is attractive - if this thing "goes" then I may look towards reimplementing on that chipset simply due to cost considerations.· However, from what I can see on the SX, even the SX/48, I'll end up implementing a P-code interpreter anyway just due to code requirements (what I have now running consumes most of six partitions - while a goodly bit of it is messages and can be stuck on an EEPROM for display, I bet what's left as instructions doesn't fit in the on-chip code space, especially when the 16-bit math and such is handled.....)
I can live with the controller simply going "offline" to this I/O when it is having parameters adjusted in this application (at least at the prototype level) but if I can avoid it that's even better.....
Maybe I'll pick up an SX chip and "Key"..... although I still think I can get this to work on the 2Pe as it stands, although I may need to add one offboard piece of silicon to keep track of elapsed time with the granularity I need [noparse]:)[/noparse]
Post Edited (Genesis) : 12/27/2005 4:01:17 AM GMT
There are other chips that give you a good periodic reference:
www.rhombus-tek.com/co-processors.html
8 pin chip puts out a 50 millisecond reference
Peter Anderson was selling timing reference clock with 11 different frequency ouputs at
www.phanderson.com/
but the "clock" link seems to be broken at the moment.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I can live with a pass through the code being aborted if the timer fires; that can be coded around and just re-enter at the top, since in terms of passes it doesn't happen that often.
The Rhombus chip will do the job but I bet I can come up with a cheaper solution than $12, given that I have a timebase already in the 1307....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com