Long delays/pauses

jlhooper

New Member
Hi all
Any thoughts on the best way of implementing a 48hr on - 5hr off repetitive type cycle.
This does not have to have any great accuracy, +/- 10mins would be good enough.
The picaxe does not have to go "sleep". i.e. power consumption not a problem.
Ta
Jeff
 

eclectic

Moderator
Jeff.

A few quick questions please.

1. What's the project about?

2. Can you provide an outline of your circuit / program?

3. Could you introduce, say, a DS1307 into your circuit?


e
 

jlhooper

New Member
e
Just need to switch one of the picaxe outputs (8m).
On for 48hrs then off for 5hrs, on for 48hrs then off for 5hrs....on and on.
I wanted to use a picaxe as I have them on hand and all ready to go.
(I will use it ultimately to switch a big load, via a 50A contactor), this side of it not a problem.
jeff
 

moxhamj

New Member
You can put the delays in a loop. Not 100% accurate but would be good enough eg
Code:
main:
high 1
b1=48
gosub hourdelay
low 1
b1=4
gosub hourdelay
goto main


hourdelay: ' pass b1=hours
for b0=1 to b1 ' use b0 as counter
  for b2=0 to 59 ' minutes
    for b3=0 to 59 ' seconds
      pause 1000
   next b3
 next b2
next b0
return
It could be tempting to use a longer pause than pause 1000, but 1s is short enough that the chip doesn't 'hang' on subsequent downloads and need a hard reset. So keep that delay to 1 sec and then the maths for the loops becomes more obvious anyway.
 

Andrew Cowan

Senior Member
I thought the PICAXE scans for a download during a pause?

I'm on an iPod at the moment, so can't scroll down the code box (so I've missed if the code is more complex).

A
 

moxhamj

New Member
Just for you Andrew, a version that doesn't need scrolling. You can save a little bit of code bearing in mind that loops can go up to 255 (or 65535 for words) but to me it seems simpler to keep it to seconds,minutes and hours.
main:
high 1
b1=48
gosub hourdelay
low 1
b1=4
gosub hourdelay
goto main


hourdelay: ' pass b1=hours
for b0=1 to b1 ' use b0 as counter
for b2=0 to 59 ' minutes
for b3=0 to 59 ' seconds
pause 1000
next b3
next b2
next b0
return
 

manuka

Senior Member
Keep in mind PICAXE timing errors (which may be as much as ± 1 min an hour as temperatures vary) will accumulate, & slowly alter the switch over time slots! This may soon become quite an issue if (say) water pumps were intended to come on at night, as eventually they'd be pumping during the day...

Just what is this grunty load actually doing? Perhaps even consider a day/night solar sensor (old sol will always be at the highest point at local true noon),DS1307 or cheap digital clock/watch reference? Stan.
 

jlhooper

New Member
Stan
"The Load " is 5 range elements! (all at once). Night or day, doesn't matter, nothing critical here. (except a hot room and a probable large power bill !!)
jeff
 

papaof2

Senior Member
Some diligent code tweaking can get to an accuracy of few minutes per day. First do the coarse timing: 48 hours +/-, 5 hours +/-. Then add/subtract small amounts: 1% of the delay value (1000 to 990 or 1010, as needed, etc).

I had an 18A running an LCD display and made it an hours:minutes clock to see how close the loops could be adjusted. Code is here: http://www.jecarter.us/picaxe/software-clock.html

John
 

hippy

Ex-Staff (retired)
An 08M with a watch crystal attached to LP OSC will give a very accurate timer ( as accurate as the crystal ). Would probably be ideal for this project
 

manuka

Senior Member
jlh: I imagine that such grunty hotplates are mains powered- why not just use a heavy duty time switch?
 
Top