Real Time Clock & Eeprom

# Thread: Real Time Clock & Eeprom

1. ## Real Time Clock & Eeprom

hello for all
first sorry for my bad english

i hope i find spme help for this proplem

the problem :

1:i'm newby in picbasic

first i have a table in eeprom with a bout five specific times for 30 day

so i want to check the table every 1 minute

when the two times identical turn on a buzzer

this project for islamic prayer

if you have any another idea tell me

thanks for any help

can u give me any examples

2. Is it the same time each day? Out of curiosity what are the times?

Is it the same time for each day of the week?

Is it the same time for every day of the year?

What happens during Daylight Savings period when the clocks move an hour forwards or backwards... does the prayer time also move or does it stay constant with Universal Time?

3. ## thanks alot

in the name of god

first of all thank u very much for high speed response

i'm realy wonderfull

any way

of course the times are not constant

there r an accurate equations for those calculations but they r difficult

but as i know it's hard to implemnted in PIC

so i decided to store for now a table for one month "wich already calculated"

if this idea succes i will contune with all the year

the times as following "only examples "

fajer noon after noon sunset after sunset"isha"

e.g 6:10 12:15 16:15 19:20 20:13

6:11 12:16 .................................................

again thanks for any help

now i agree at least with this

but if u want help me to make a universal clock for all the world

i will send all the equations for u

thansssssssssssssssssssssss very mush Melanie

i'm online now for any other questions

4. ## How to Calculate Islamic Prayer Times

The following equations may be used to calculate the prayer times; copied from a WEB site which I do not remember from where. I still could not figure out how it generates the times.

One should know a little about the Islamic Prayer times to understand the concept behind these calculations. Basicly, Islamic Prayer times are location and date specific. A calculator for general use must have a location input and a date input. Location should be in terms of meridian and parallel of a city (for instance). The calculator then calculates the sun's movement based on the location and the date entered by the user; and then generates the prayer time. The time pattern is quite complex but of course there is a logic behind it.

Here is the calculation:

(R-L) T
Z = 12+ ----- + --- ........1
15 60

1 {sin(-0.8333-0.0347(H)^0.5)}-sinD.sinB
U= -- arccos -------------------------------------- ........2
15 cosD.cosB

1 -sinG-sinD.sinB
V= -- arccos --------------- ........3
15 cosD.cosB

1 sin{arccot(1+tan(B-D)}-sinD.sinB
W= -- arccos -------------------------------- ........4
15 cosD.cosB

1 sin{arccot(2+tan(B-D)}-sinD.sinB
X= -- arccos -------------------------------- ........5
15 cosD.cosB

where

B= latitude of place
L= longitude of place
R= reference longitude (i.e. TIME BAND x 15)
H= height above sea level in metres
D= declination angle of sun from celestial equator (-ve in southern hemisphere)
T= equation of time
G= twilight angle

'Names of prayer times:

Fajr = Z-V
Sunrise = Z-U
Zuhr = Z
Asr1 (Shafi) = Z+W
Asr2 (Hanafi) = Z+X
Maghrib/Sunset = Z+U
Isha = Z+V

The algorithms to calculate T and D are not shown here. These algorithms may be found in, for example, Jean Meeus' Astronomical Algorithms. Zuhr time is calculated using equation 1. The time for sunrise and sunset/ maghrib may be calculated by subtracting or adding 'U'(obtained from equation 2) to the Zuhr time respectively.

Fajr and Isha times may be calculated by subtracting or adding 'V' (obtained from equation 3) to the Zuhr time respectively. The term G (twilight angle) in equation 3 is usually set to 18 degrees. For a location with an extreme latitude, days in summer may be so long that twilight persists between sunset and the next sunrise. Under these circumstances, 'V' is undefined and Fajr and Isha have to be determined using agreed principles of fiqh.

The start of Asr time (Shafi) may be obtained by adding 'W' (obtained from equation 4) to Zuhr; Asr time (Hanafi) is calculated by adding 'X' (obtained from equation 5) to Zuhr.

----------------------------end of post------------------------------

5. ## Islamic Prayer Times - lookup table

Also, for smart_storm's problem, described above, an example can be as below.

Example: Starting from today,16.02.2006, prayer time table for the next 30 days for location: Los Angeles/USA is as below (actual times). Let say these times and dates are in an eeprom.

(six times instead of five times are given)

Date-----Time1,Time2,Time3,Time4,Time5,Time6
-------------------------------------------------
16.02.2006 5 08 6 32 12 14 15 17 17 44 18 58
17.02.2006 5 07 6 31 12 14 15 17 17 45 18 59
18.02.2006 5 06 6 30 12 14 15 18 17 46 19 00
19.02.2006 5 05 6 29 12 14 15 19 17 46 19 00
20.02.2006 5 04 6 28 12 14 15 19 17 47 19 01
21.02.2006 5 03 6 27 12 14 15 20 17 48 19 02
22.02.2006 5 02 6 26 12 14 15 20 17 49 19 03
23.02.2006 5 01 6 25 12 13 15 21 17 50 19 04
24.02.2006 5 00 6 23 12 13 15 22 17 51 19 04
25.02.2006 4 59 6 22 12 13 15 22 17 52 19 05
26.02.2006 4 58 6 21 12 13 15 23 17 53 19 06
27.02.2006 4 57 6 20 12 13 15 23 17 54 19 07
28.02.2006 4 55 6 19 12 13 15 24 17 54 19 08
01.03.2006 4 54 6 17 12 12 15 24 17 55 19 09
02.03.2006 4 53 6 16 12 12 15 25 17 56 19 09
03.03.2006 4 52 6 15 12 12 15 25 17 57 19 10
04.03.2006 4 50 6 14 12 12 15 26 17 58 19 11
05.03.2006 4 49 6 12 12 12 15 26 17 59 19 12
06.03.2006 4 48 6 11 12 11 15 27 17 59 19 13
07.03.2006 4 47 6 10 12 11 15 27 18 00 19 13
08.03.2006 4 45 6 09 12 11 15 27 18 01 19 14
09.03.2006 4 44 6 07 12 11 15 28 18 02 19 15
10.03.2006 4 43 6 06 12 10 15 28 18 03 19 16
11.03.2006 4 41 6 05 12 10 15 29 18 04 19 17
12.03.2006 4 40 6 03 12 10 15 29 18 04 19 18
13.03.2006 4 39 6 02 12 10 15 29 18 05 19 18
14.03.2006 4 37 6 01 12 09 15 30 18 06 19 19
15.03.2006 4 36 5 59 12 09 15 30 18 07 19 20
16.03.2006 4 35 5 58 12 09 15 30 18 08 19 21
17.03.2006 4 33 5 57 12 09 15 31 18 08 19 22

If you check the table carefully, minutes sometime shift for 2 and 3 minutes; not for one minute everyday; or they do not change for two-three days. Lets not think about this part much, unlike the previous post, as they will be prepared to be read.

Given the table, smart_storm can write a clock code and match the hour and minute with the lookup table from eeprom.

For instance, on date 16.02.2006, Time1=5:08 (actualy 05:08 morning time) so that we can store this in time1 and time1x variables as 05 and 08 respectively.
Time1 holds the hour and time1x holds the minute from eeprom lookup table.
If we also use an RTC chip such as DS1302 for instance, and hold the hour and minute in variables DShour and DSminute then we can come up with a sample concept as below.

DShour var byte 'variable: hour from DS1302
DSminute var byte 'variable: minute from DS1302
time1 var byte ' variable: one of six times in a day to store hour from eeprom lookup table.
time1x var byte 'variable: the sister variable of time1 variable to store the minute from eeprom lookup table.
time2 var byte 'other time etc..
time2x var byte '...etc
.....etc.

loop:
gosub do_convertion 'HEX and DEC convertions are done...

If DShour=time1 AND DSminute=time1x then GOSUB buzzer 'to match the time from DS1302 with the time from eeprom, and ifthey match buzz the buzzer.

goto loop

Hope this post and the previous one can help people write a code for prayer times.

6. ## thanks alot

MR. sayzer

i don't know how i can thank u for great explanation
both in first and second posts

so i said using equations solve all the problems
but it's very difficult not only in PIC but also using PC

so let's stay at the table solution

for now i hope MELANIE understand the problem

as for MR.sayzer when i said 1 min this is because this ensure

that two times will identical at some time

because the change is in minutes

so i hope that some one can help

excuse me but if there is no problem please don't use the RTC DS1302

or any other RTC because in our country we can't find those real time clocks

so i Prefer the programming solution for the clock

another thing you are talking with PICBASIC beginer

this is as for me

i hope mr.sayzer still with us to help

thanks for this special forum

7. smart_storm,

Pls provide more details.

How/from where do you want to get the time? If you do not want to use RTC, will you receive the time from a PC or from somewhere else?

Since the minutes are very important for prayer times, if you use classic programming to make a clock generator, it will not be as precise as an RTC, and the timer will either run faster or slower. Eventually you will end up with at least 1-hour faster running timer in one day.

I understand your difficulty of finding RTC chips, but I suggest that you try your best to find an RTC chip somehow. That would be the best solution for a precise time matching.

8. smart_storm,

I posted some amazingly short and simple code in the “Examples Section” that will keep accurate time without the use of an RTC (within 2 seconds per day – same as with RTC). The code could easily be modified to keep track of days and you could easily add your lookup table.

See

Good Luck

Paul Borgmeier
Salt Lake City, Utah
USA

9. ## thanks

thank u MR.Paul Borgmeier for your help

as for MR.sayzer can Paul Borgmeier program help me or not

if it's neccesary use RTC i will try but i don't sure i can

any way can we modified the code to do what we need

also if there is no RTC i don't care if we lose 2sec/day "this is only for me as starting point"

right now i don't see the code

i hope MR.sayzer see it and said to me your opinion

again thanks for all to care of my ques

Last edited by smart_storm; - 17th February 2006 at 20:06.