Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

30 days delay ---------- help

Status
Not open for further replies.

hassan1980

Full Member level 4
Joined
Jan 14, 2005
Messages
204
Helped
9
Reputation
18
Reaction score
6
Trophy points
1,298
Activity points
1,340
Hi, There

I want your help

I want to make a delay to turn on the led about 30 days then turn off it using 16f84a.

would you please help me?

I am waitng your replies
 

Hello,
Try this code. I am not sure if this works, but in my calculation, it should trigger on the 30th day.

The code is not complete; I have not coded the port setup and Turning the LED On and OFF. In the code I only include the subroutine to make a delay for approximately one day and to trigger on the 30th day.

Futhermore use a 4.63Mhz Clock.

Hope this help
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
Here so that you don't have to download the file
:D

;30 - Days Delay
;This program turns on an LED for 30 days and turn off after that
;Author: Jack Emund Wong
;email: neoaspilet11@yahoo.com
;







Delay
Loop1 decfsz Count1 ;1 MC
goto Loop1 ;2 MC, 255 X 1 + 254 X 2 = 763 MC
Loop2 decfsz Count2 ;1 MC
goto Loop1 ;2 MC, 255 X 1 + 254 X 2 X (Loop1) = 387,859 MC
Loop3 decfsz Count3 ;1 MC
goto Loop1 ;2 MC, 255 X 1 + 254 X 2 X (Loop2) = 197,032,627 MC
Loop2 decfsz Count4 ;1 MC
goto Loop1 ;2 MC, 255 X 1 + 254 X 2 X (Loop3) = 100,092,574,771 MC
retlw 0 ;Note if your clock is running at 4.63 MHz this
;subroutine is excuted for approximately 84473 seconds or 1 day with
;an offset of 473 seconds. You can refine the clock to minimize this offset
;by computing the proper clock speed.



Main
MainLoop call Delay
incf DayCount,1
movlw 1E ;w = 30DEC
xorwf DayCount ;w = w xor DayCount
btfss STATUS,Z ;check Z flag
goto MainLoop ;Z =0
;Z =1 Code here to turn off you LED
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
Thanks alot for your reply

On the other hand, what is the calculator you are using to calculate the delay.

Please let me know.
 

Hello Hassan,

By the way that Second Loop2 in the Delay Subroutine should be Loop4. What I did is just simple: count the number of Machine cycles at which the code is executed. Then divide that to 86400, because there are 86400 seconds in 24 hours. Then you will arrive to a number that is telling you that how many millions of instructions per second (MIPS) your PIC should execute. Multiply this MIPS to 4 you get your clock speed.
thanks
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top