Hello,
How to use the Elapsed Timer Demo in a PIC12F675 to maintain a on led by 5 days and then goes off. ¿It is possible to do this?
Hello,
How to use the Elapsed Timer Demo in a PIC12F675 to maintain a on led by 5 days and then goes off. ¿It is possible to do this?
If you just want 5 days then -
LED = ON
For X = 1 to 7200 (60 minutes/hour X 24 hours/day X 5 days)
PAUSE 60000 ; one minute
Next X
LED = OFF
Charles Linquist
Hi, Leonardo
looks Still some way to reach Leonard's code ...
ALL you have to do is check each second ( or min, if not so precise required !!!) Days-hours-mins-secs ( which are already existing variables ) and match your own values.
But forget the // LCD screen ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hello,
This is the code I've tested with 1 minute and works well, then put 7200 can achieve the 5 days with a good presicion?.
[HTML]led1 var portb.0
x var word
HIGH LED1
Top:
For X = 1 to 1 '(60 minutes/hour X 24 hours/day X 5 days)
PAUSE 60000 ; one minute
Next X
LOW LED1
goto Top[/HTML]
Thank you
The accuracy will be good if you are not using the internal oscillator. You need a crystal or external "can" oscillator for better than 2-3%. If you need really good accuracy, you can (temporarily) shorten the time interval to one day (or so) and compare it to a clock. For example: if you are 1.3% "fast" then increase the value after the PAUSE by 1.3% (60780). That should get you close enough.
Charles Linquist
Yup, that'll work.
As long as it's the only thing the chip will be doing.
But to answer the original question...
> How to use the Elapsed Timer Demo in a PIC12F675 to maintain a on led by 5 days and then goes offOr you can add a blinky LED to show that it's still counting...Code:CLEAR LED VAR GPIO.0 CMCON = 7 ANSEL = 0 Include "Elapsed.bas" Gosub ResetTime ' Reset Time to 0d-00:00:00.00 Gosub StartTimer ' Start the Elapsed Timer HIGH LED ; Start with LED on Loop: if DaysChanged then DaysChanged = 0 if Days = 5 then LOW LED ; Turn off LED endif Goto LoopAnd you can still do other stuff at the same time.Code:CLEAR LED VAR GPIO.0 StatLED VAR GPIO.1 CMCON = 7 ANSEL = 0 Include "Elapsed.bas" Gosub ResetTime ' Reset Time to 0d-00:00:00.00 Gosub StartTimer ' Start the Elapsed Timer HIGH LED ; Start with LED on Loop: if DaysChanged then DaysChanged = 0 if Days = 5 then LOW LED ; Turn off LED endif IF SecondsChanged then SecondsChanged = 0 Toggle StatLED endif ; Rest of the program goes here Goto Loop![]()
DT
Hey Darrel,
In compiling I get this error because it will be.
<a href="http://imageshack.us"><img src="http://img231.imageshack.us/img231/9863/errorcv5.jpg" border="0" alt="Image Hosted by ImageShack.us"/></a><br/><a href="http://g.imageshack.us/img231/errorcv5.jpg/1/"><img src="http://img231.imageshack.us/img231/errorcv5.jpg/1/w626.png" border="0"></a>
open ASM_INTS.bas file, there you'll discover ..
Code:' --- IF any of these three lines cause an error ?? Simply Comment them out to fix the problem ---- wsave1 var byte $A0 SYSTEM ' location for W if in bank1 wsave2 var byte $120 SYSTEM ' location for W if in bank2 wsave3 var byte $1A0 SYSTEM ' location for W if in bank3
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Steve,
I've done some testing with minutes and works extremely well using a 4-MHz crystal, the oscillator's internal PIC12F675 is not very accurate there is any way to use it with good presicion?.
Thank you
Try adding ...when using the internal OSC.Code:DEFINE OSCCAL_1K 1
DT
Steve,
Perform tests on a 4-MHz external crystal setting 1 hour and was led off in 56:41 minutes of taking a delay time of 3:06 minutes. Is it normal that delay?.
Thank you
Can't tell, i never used it before. Would be of great help if you could post the whole schematic, code and configuration fuses.
I would guess you just use the internal OSC... probably where the huge gap come from.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Steve,
I'm using an external 4MHz crystal and the code is this for PIC12F675.
[HTML]CLEAR
LED VAR GPIO.0
CMCON = 7
ANSEL = 0
Include "Elapsed.bas"
Gosub ResetTime ' Reset Time to 0d-00:00:00.00
Gosub StartTimer ' Start the Elapsed Timer
HIGH LED ; Start with LED on
Loop:
if HoursChanged then
HoursChanged = 0
if Hours = 1 then LOW LED ; Turn off LED
endif
Goto Loop[/HTML]
![]()
Last edited by Leonardo; - 19th November 2008 at 18:37.
Bookmarks