HOW TO SET 5 DIFFERNET ALARMS IN THE DIGITAL CLOCK PGM
i just want to know how to set 5 different alarms and store it in rtc ram location ,i am getting confused....
eg you create two variables, alarm_hr and alarm_min
alarm_hr will have the address where hr of the alarm is going to be stored and alarm_min will have the address where min of the alarm is going to be stored, so before calling the alarm set routine, you fill these variables with the addresses, where you want to store the alram.
say...
for alarm 1: hr is stored in 20H and min is stored in 21H
for alarm 2: hr is stored in 22H and min is stored in 23H
for alarm 3: hr is stored in 24H and min is stored in 25H
for alarm 4: hr is stored in 26H and min is stored in 27H
for alarm 5: hr is stored in 28H and min is stored in 29H
so whenever you want to set alarm.. say you want to set alarm #3
you call the routine something like this..
mov alarm_hr,#23H
mov alarm_min,#24H
lcall set_alarm
so this way you are actually passing address where your alarm time is going to be stored. so this way you can do the alarm set... for any number of alarms you want.
setting alarm, this is just an example...
eg you create two variables, alarm_hr and alarm_min
alarm_hr will have the address where hr of the alarm is going to be stored and alarm_min will have the address where min of the alarm is going to be stored, so before calling the alarm set routine, you fill these variables with the addresses, where you want to store the alram.
say...
for alarm 1: hr is stored in 20H and min is stored in 21H
for alarm 2: hr is stored in 22H and min is stored in 23H
for alarm 3: hr is stored in 24H and min is stored in 25H
for alarm 4: hr is stored in 26H and min is stored in 27H
for alarm 5: hr is stored in 28H and min is stored in 29H
so whenever you want to set alarm.. say you want to set alarm #3
you call the routine something like this..
mov alarm_hr,#23H
mov alarm_min,#24H
lcall set_alarm
so this way you are actually passing address where your alarm time is going to be stored. so this way you can do the alarm set... for any number of alarms you want.Rickey
sir can u tell me how to compare 5 different alarms
and where exactly r u ciomparing the actual time and alarm time
PASS: inc r1 mov a,#0C7h acall command mov a,@r1 mov 51h,@r1 mov alarm_chk_min,@r1 acall disp_val PASS1: inc r1 mov a,#0c4h acall command mov a,@r1 mov 52h,@r1 mov alarm_chk_hour,@r1 mov r4,a
here i am moving the current time to alarm_chk_hour and min registers so that i can use them while comparing.
inc r1 inc r1 inc r1 mov a,@r1 cjne a,52h,PASS6 inc r1 mov a,@r1 cjne a,51h,PASS6 setb alarm_ring setb alarm_ring PASS6: ret
Here at the end of the display RTC routine i am reading the alarm time from RTC and comparing it with current time. I used 52H and 51H i could have used alarm_chk_hour and min...
for your 5 alarm case.. you can make use of these variables and pass them to a new routine alarm check where you are going to do all the compares.
I'm working on a clock project but using different code. Please see the attachment.
I want to use the value displayed (LCD) in the alarm time (alm_hour and alm_min in the attached code) as input values (in seconds) for my below timer code as I want to turn on/off lamp with the duration according to the value displayed.
For example, lcd display 20 for alm_hour will be treated as 20 second by below timer. My problem is the value displayed on lcd was converted (BCD to ASCII ?). Please see the attached code (attchment).
This is my timer code.
TIMER:
MOV TMOD,#01H
MOV TICKS,#20
MOV SECONDS,#00
AGAIN_A:
MOV TH0,#76
MOV TL0,#01
SETB TR0
WAIT_A:
JNB TF0,WAIT_A
CLR TF0
CLR TR0
DJNZ TICKS,AGAIN_A
MOV TICKS,#20
INC SECONDS
MOV A,SECONDS
CJNE A,ALM_HOUR,AGAIN_A
RET
Rickey, please help me solve the problem.
Thanks,
SGH
make sure that only for displaying you are converting to hex then again u have to change it back to decimal.
in my code, there are two small routines for hex to dec and dec to hex. i am using them for the same purpose. you take a look at them and use them in your program.
In my previous post dated May 05 with clock code attached, how to modify the I2C routine so it can be used for SEEPROM AT24C01A ?. I'm confused with the ACC.7 in one line of the Send_Byte routine.
Which line in the codes needed to be changed ?. Other routine looks ok (for me), any changes required for other routines ?.
Thanks,
SGH
JNB ACC.7,NOTONE SETB SDA JMP ONE NOTONE: CLR SDA
in the above code, its checking if the MSB is 1 then make SDA 1 otherwise make SDA 0.
because in I2C the data is transferred MSB to LSB. so ACC.7(MSB of ACC) first.
using EEPROM is little tricky, you have to see the datasheet for coding information. coz after writing a byte to EEPROM you need some kind of delay. I dont have any EEPROM IC with me so never tested I2C code.
I want to add a Totalize Timer function into my RTC w/DS1307 + AT89S51.
Here some details how it will work. The totalize timer will check the condition of port 1.0 (port number for example only, other port available). When this port in low state, it will start the timer to count the time how long this port in low state. When the port in high state, time counting process is terminated and duration of time counted then stored in DS1307 RAM. The process will continue until total time counted equal with preset value.
Other example, Port 1.0 in low state for 5 seconds then turn high for 40 second and turn low again for 15 second, etc.. The timer will have a value of 5 second + 15 second = 20 second.
Could you please give me some hints how to implement it. If possible I'm avoiding external timer interrupt. Also I don't want to be stucked with this counting process (of course if possible).
Thanks,
SGH