I need to include a six hour delay in a project I am working on. Was contemplating just using
delayms(1000 * 60) = 600 seconds or 10 minutes I think? but going out to 6 hours??delayms(1000 *
Just need to toggle a port for 20 minutes every 6 hours. I looked over the modules in SF but? I realize using delayms is not very accurate but in the application I don't need dead on accuracy.
programming a 6 hour delay
Moderators: Chuckt, Garth, bitfogav
-
- I practically live here!
- Posts: 372
- Joined: Fri Feb 18, 2011 4:24 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: programming a 6 hour delay
I may have located an old file I had on a hard drive that kinda went south but was able to recover some of the data.Not sure if this is really what I want but will ponder the results etc. but any better solutions perhaps?
Code: Select all
}
Interrupt MyInt()
TMR2IF=0
Count=Count+1
If Count=50 Then
Count=0
IntFlag=1
EndIf
End Interrupt
Sub Delay(Seconds As Word)
Dim x As Word
For x=0 To Seconds
While(IntFlag=0)
Wend
IntFlag=0
Next
End Sub
OSCCON = $72 // select 8MHz internal clock
ADCON1 = $7f //all digital
NOT_RBPU=0 //WPUs on port B
T2CON = %01001110 //pre=16 post=10
PR2 = 249 //=8000000/4/16/10/250 = 50Hz
TMR2IE=1 //enable timer 2 interrupts
Enable(MyInt) //set interrupt going
While true
LED(1) //light LED 1
Delay(5) //wait 5 seconds
LED(2) //light LED 2
Delay(1) //wait 1 second
Wend
Re: programming a 6 hour delay
There's Several ways you could do it?.
A really simple but hacky way would be to use a For Loop, especially if your not looking for accuracy.
But your programme will be stuck in this For Loop for 6hours, so your programme won't be able to do other things, thats if you want it too?:
Another way is to use Swordfish ISRTimer.bas Module, set a timer event handler and a counter to count secs?.
Or like you have posted use ISR, There's some good information here about timers Soft RTC
A really simple but hacky way would be to use a For Loop, especially if your not looking for accuracy.
But your programme will be stuck in this For Loop for 6hours, so your programme won't be able to do other things, thats if you want it too?:
Code: Select all
Dim i as word
For i = 1 to 21600 // 21600 secs in 6hours
DelayMS(1000) // 1sec delay
Next
Or like you have posted use ISR, There's some good information here about timers Soft RTC
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: programming a 6 hour delay
bitfogav's ideas would certainly do the trick.
I was thinking you could get a cheap real time clock module from ebay (for about $2) but then realised the microcontroller can do this all by itself!
I was thinking you could get a cheap real time clock module from ebay (for about $2) but then realised the microcontroller can do this all by itself!
-
- I practically live here!
- Posts: 372
- Joined: Fri Feb 18, 2011 4:24 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: programming a 6 hour delay
Biogravs HACKY method looks easy enough. I like to KISS. Just need to insert the ds18B20 section in between the counting. Then a 20 miniute delay.
This is for a beer cooler that I got working last year but still have issues with the evaporators freezing up. Was told that I need a defrost timer. Contemplating an adjustable defrost timer.
This is for a beer cooler that I got working last year but still have issues with the evaporators freezing up. Was told that I need a defrost timer. Contemplating an adjustable defrost timer.
Re: programming a 6 hour delay
MrDeb.. If I was making a project to cool down a beer cooler and to stop the evaporators freezing up then I would probably want to monitor the DS18B20 temp sensor constantly? Or maybe switch the cooler on for an hour and then check the temperture? if the evaporators are freezing up then have some sort of delay to switch the cooler off for a period of time?.MrDEB wrote:Biogravs HACKY method looks easy enough. I like to KISS. Just need to insert the ds18B20 section in between the counting. Then a 20 miniute delay.
This is for a beer cooler that I got working last year but still have issues with the evaporators freezing up. Was told that I need a defrost timer. Contemplating an adjustable defrost timer.
Then recheck the evaporators temp, if all ok then switch the cooler back on?.
In fact I might have two temperature sensors 1x for the beer cooler and 1x for the evaporator?.
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: programming a 6 hour delay
Where does the 6 hour delay play a part?
Who is online
Users browsing this forum: No registered users and 2 guests