Discussion in "Project Addition or Changes" started by    koushal    Apr 21, 2007.
Sat Apr 21 2007, 05:49 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, 02:28 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, 01:03 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, 07:07 AM
#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, 05:19 PM
#5
thanks mr.RICKEY ( THE ONE )!!!
 tienduhieu like this.
Sat May 05 2007, 04:16 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, 07:00 AM
#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, 05:09 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, 07:23 AM
#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, 03:26 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

Conversation

Thu Jun 11 2020, 02:27 AM
anudee
sir could please send the code for I2C and wifi interfacing with 8051
scena
Tue May 19 2020, 06:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 03:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 09:39 AM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 06:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 08:55 AM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 01:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 12:58 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 06:12 AM
Pearl Olin
Hello,
Wed Jan 22 2020, 02:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 74, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123