Discussion in "Project Addition or Changes" started by    koushal    Apr 21, 2007.
Sat Apr 21 2007, 11:19 pm
#1
HI ,
i just want to know how to set 5 different alarms and store it in rtc ram location ,i am getting confused....
 tienduhieu like this.
Tags alarmsdigital clockpgmrtc
Sun Apr 22 2007, 07:58 pm
#2
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.
 tienduhieu like this.
Tags 24hvariablesalarm timetime is goingmov
Thu Apr 26 2007, 06:33 pm
#3


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
 tienduhieu like this.
Tags 24halarm timealarmsvariablestime is going
Fri Apr 27 2007, 12:37 pm
#4
In the display RTC routine i am checking for the Alarm
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.
 tienduhieu like this.
Tags r1movsetbchk
Sun Apr 29 2007, 10:49 pm
#5
thanks mr.RICKEY ( THE ONE )!!!
 tienduhieu like this.
Sat May 05 2007, 09:46 pm
#6
Hi Rickey,

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


 tienduhieu like this.
Sun May 06 2007, 12:30 pm
#7
you need to do HEX to BCD conversion and then send the data for display.. i mean.. if seconds are 20 in decimal then convert it to 20 in hex for displaying them and u can directly use your write_bcd routine to display them.
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.
 SGHtienduhieu like this.
Wed May 09 2007, 10:39 am
#8
Rickey, many thanks for your previous info.

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

 tienduhieu like this.
Wed May 09 2007, 12:53 pm
#9

  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.
 tienduhieu like this.
Thu May 31 2007, 08:56 am
#10
Hi Rickey,

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
 tienduhieu like this.
Tags 8051 timerDS1307 rtc

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am