PDA

View Full Version : Need 15 hour wait command?



Nerd2
12-18-2009, 08:11 PM
I need my propeller to pause or wait for 15 hours what is the best what to do this?

TonyWaite
12-18-2009, 08:17 PM
Hi,

We could do with a little more information about your circuit/application and the required accuracy to best advise.

There are many ways of achieving such a delay, depending on whether there might be any trigger-events that could be captured; and a variety of timer/real-time clock possibilities

Regards,

T o n y

Javalin
12-18-2009, 08:25 PM
From memory:



repeat 54_000
' wait 1 second
waitcnt(clkfreq + cnt)

Post Edited (Javalin) : 12/18/2009 7:56:43 PM GMT

ElectricAye
12-19-2009, 12:49 AM
If you've got a few pins and a few bucks to spare, I would look into using a Real Time Clock. Then you won't have to tie up anything with a mindless repeat loop and you could wait 15 hours, 15 days, or 15 weeks, whatever floats your boat.

Beau Schwabe
12-19-2009, 01:11 AM
I'm sure there are several other RTC IC's that will do this, but how about this...

datasheets.maxim-ic.com/en/ds/DS1305.pdf (http://datasheets.maxim-ic.com/en/ds/DS1305.pdf)

...Set one of two alarms available on the RTC so that the RTC produces an interrupt. That way in your program all you need to do is use waitpeq command, and the cog is sleeping the entire time.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

Bobb Fwed
12-19-2009, 03:02 AM
Javalin said...
From memory:



repeat 54_000
' wait 1 second
waitcnt(clkfreq + cnt)



That isn't perfect, especially over a long period of time.

You would want to do this instead:



wait := cnt
repeat 54_000
' wait exactly 1 second
waitcnt(wait += clkfreq)




Or slightly more efficiently (if you care about power usage):



wait := cnt
repeat 1800
' wait exactly 30 seconds (less time spent repeating -- and never hang, even at 100MHz)
waitcnt(wait += clkfreq * 30)


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!

Some of my objects:
MCP3X0X ADC Driver (http://obex.parallax.com/objects/488/) - Programmable Schmitt inputs, frequency reading, and more!
Simple Propeller-based Database (http://obex.parallax.com/objects/493/) - Making life easier and more readable for all your EEPROM storage needs.
String Manipulation Library (http://obex.parallax.com/objects/543/) - Don't allow strings to be the bane of the Propeller, bend them to your will!
Fast Inter-Propeller Comm (http://obex.parallax.com/objects/546/) - Fast communication between two propellers (1.37MB/s @100MHz)!

Nerd2
12-19-2009, 05:19 AM
Thanks for everyone who replied. I was thinking about using the DS1307 and since you recommended a RTC I think I will order it. Here is my project someday my dad will feed our dogs and someday I will its a pain to always ask each other who fed them or if one of us leaves and doesn't tell the other. I am planning on putting a photo resistor in the dog food container so when the propeller detects light it turns off a LED waits 12-18 hours and turns the led back on showing the dogs need fed. The idea of this project is to make it as small as possible and cheap. The only reason I am using the propeller instead of a smaller micro controller is because I had one laying around. Will this work fine with out using the external crystal?

Bobb Fwed
12-19-2009, 05:26 AM
If you use the DS1307 I don't see why you would need an external crystal on the Propeller, but the DS1307 requires one.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!

Some of my objects:
MCP3X0X ADC Driver (http://obex.parallax.com/objects/488/) - Programmable Schmitt inputs, frequency reading, and more!
Simple Propeller-based Database (http://obex.parallax.com/objects/493/) - Making life easier and more readable for all your EEPROM storage needs.
String Manipulation Library (http://obex.parallax.com/objects/543/) - Don't allow strings to be the bane of the Propeller, bend them to your will!
Fast Inter-Propeller Comm (http://obex.parallax.com/objects/546/) - Fast communication between two propellers (1.37MB/s @100MHz)!

lonesock
12-19-2009, 05:33 AM
If you're really only doing a bit of timing and turning on and off a LED, it sounds like you have plenty of cogs. Instead of getting a RTC (~$0.90) with no crystal, you could skip the RTC and get a very cheap crystal (e.g. here: www.mouser.com/ProductDetail/Citizen/CSA309-55296MABKB/?qs=sGAEpiMZZMsBj6bBr9Q9acIJmDespmCn%2fTCcDET6Kjw% 3d (http://www.mouser.com/ProductDetail/Citizen/CSA309-55296MABKB/?qs=sGAEpiMZZMsBj6bBr9Q9acIJmDespmCn%2fTCcDET6Kjw% 3d), it's a weird number at 5.5296MHz, but it's only $0.15, and is good to 30PPM, which is plenty). If you have a delay which is a multiple of seconds, then you can have a delay of up to 2^31 (assuming you program in SPIN so the value is signed) seconds, or 68 years http://forums.parallax.com/images/smilies/wink.gif

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.

Ale
12-19-2009, 06:04 AM
Better than the DS1307 is the DS1337 because it is a 3.3V part instead of a 5V part. I'd go with an RTC too.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH (http://propeller.wikispaces.com/MATH)
pPropQL: propeller.wikispaces.com/pPropQL (http://propeller.wikispaces.com/pPropQL)
pPropQL020: propeller.wikispaces.com/pPropQL020 (http://propeller.wikispaces.com/pPropQL020)
OMU for the pPropQL/020 propeller.wikispaces.com/OMU (http://propeller.wikispaces.com/OMU)

mctrivia
12-19-2009, 07:31 AM
ditch the RTC. Ditch the crystal.

You do not need acurate timing. run on internal slow osicilator. it is not accurate but it should be able to hit 15 hours +- 3 as you mentioned.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
24 bit LCD Breakout Board now in. $21.99 has backlight driver and touch sensitive decoder. (http://forums.parallax.com/showthread.php?p=848975)

lonesock
12-19-2009, 07:40 AM
mctrivia said...
ditch the RTC. Ditch the crystal.

You do not need acurate timing. run on internal slow osicilator. it is not accurate but it should be able to hit 15 hours +- 3 as you mentioned.

What he said! (You may want a crystal during the debugging process, though, so you can use serial out or VGA/TV out, etc.)

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.