Shop OBEX P1 Docs P2 Docs Learn Events
Timing long periods — Parallax Forums

Timing long periods

Brian D.Brian D. Posts: 12
edited 2011-08-02 11:01 in General Discussion
Hello Parallax scientists!

Back to the automated Bird Bath (YouTube vid to follow when I finish this project, so thanks for all the help.)

I need to time approximately 8 hours with a variable or equation (not Pause - the program needs to flash some LED's during this time period). After the 8 hours (approximate - does not have to be exact), the Bird Bath will do a drain & refresh with it's valves.

Thanks for any ideas!

Brian <attached photo of the copper birdbath & BS2 controller>
1024 x 768 - 78K
1024 x 768 - 170K

Comments

  • FranklinFranklin Posts: 4,747
    edited 2011-07-31 16:14
    A RTC chip is really the way to go. You could use a 555 and a decade counter to count and set a pin high when it reaches a value. If you have a loop in your code you could count how many times it goes through the loop.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-07-31 16:21
    I, too, suggest that you use a Real Time Clock (RTC) chip. But if you're not picky about timing, I suppose you could also use a light sensor to have the bath refresh at dawn and refresh at sunset - just a thought.

    Hey, those sure are some lucky birds!
  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-31 18:18
    You could also use a cog to implement a clock. You'd use the system clock (CNT) to give you a one second tick. You could use that to provide a clock / calendar. You might use something like
    pub dayClock( days, hours, minutes, seconds)  | nextWait
    nextWait := cnt
    repeat
       waitcnt(nextWait += clkfreq)
       if ++seconds == 60
          seconds~
          if ++minutes == 60
             minutes~
             if ++hours == 24
                hours~
                ++days
    
    seconds, minutes, hours, and days are global variables. You would use COGNEW to start this method and provide an initial time. After that, it would keep the time with an accuracy determined by the crystal you use for the Propeller's clock. You can use the same structure to also keep a date. You'd need a table of the number of days per month and you'd need to adjust for leap years if you want to go that route.
  • RDL2004RDL2004 Posts: 2,554
    edited 2011-07-31 18:39
    If you have one spare pin, you could use a CD4521B with an appropriate RC oscillator. The chip costs way less than a dollar.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-08-02 03:34
    A BasicStamp1 will do it quite easily
  • Mark_TMark_T Posts: 1,981
    edited 2011-08-02 03:44
    With the Prop you could switch to RCSLOW clock and then CNT has a wrap-around time of more than a day...
  • RDL2004RDL2004 Posts: 2,554
    edited 2011-08-02 04:44
    Seriously, this is a 50 cent problem. You guys want to spend $5, $7, $30 ?

    Franklin is on the right track with the decade counter. There is a family of CMOS chips called "frequency dividers" 4060, 4040, 4021, 4521, etc. I used the 4521 as an example because with 24 stages you don't need to cascade multiple chips to get really long delays.

    Attached is an example (I didn't draw it). You can change the input clock to whatever you want, it can be any oscillator (doesn't have to be a crystal if you don't need that kind of accuracy). This is also a good way to get an accurate 1 Hz frequency if you want to build some kind of digital clock.
    413 x 361 - 35K
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-08-02 09:59
    A 555 chip for your input to the decade counter would likely be good and slow enough. You could use a CMos version for extremely long battery life.
  • RDL2004RDL2004 Posts: 2,554
    edited 2011-08-02 10:44
    If I did the math right, a 555 running at about 291 Hz as the input to the 4521 will give you a square wave on the 224 output (pin 1) with a period of 16 hours (8 high, 8 low). Just read it every now and then, save its state, and when it changes - drain and refill the birdbath.

    I think with any other counter/divider you will have to cascade more than one to get the delay long enough..
  • wasswass Posts: 151
    edited 2011-08-02 11:01
    I've used a 4060B with a BS2 for long period timing. The 4060B is a 14-stage binary counter with a built-in oscillator. If you run this chip at a few Khz with a capacitor then you only need to sample the 2^14 bit output occasionally (once a second) with the BS2 looking for a change, the BS2 can sleep in between. If you use a 32Khz crystal you need to sample at least 4 times a second but you'll have watch-like accuracy for very low cost (under $1 for the crystal, two 6pf caps and the 4060B).

    -Katie
Sign In or Register to comment.