DS1620 interfacing with AT89S52 with 7 segment Display - Temperature Monitoring System
Download the project Report
This project is the property of Mr. Omer Younis, student of Electronics Engineering at National University of Science ans Technology, Pakistan. Feel free to contact at elprojects@ymail.com
Introduction
The objective is to design a temperature sensor complete with a display unit that will give us the temperature value in centigrade. The designing and implementation will be done by using a hardware that will sense the degree of temperature in the surrounding and display the temperature in a digital output i.e.: a seven segment LED display.
Project Task
To write a short program in assembly language for MCS-51 that will sense the degree of hotness or coldness in the surrounding atmosphere and display the reading taken by the DS1620 which acts as a thermistor, will send a digital display in a seven segment LED display. If the temperature goes above the given temperature range, an alarm will go off and if the temperature goes below the lower range, the alarm will still go off.
Technical discussion
· A range is give as a standard for the comparison to be done. The range can be altered with push buttons and a stop button is also installed for the immediate manual stopping of the alarm.
· IDE Platform KEIL simulation utility on the PC and then downloading the HEX file into the MCS-51 microcontroller.
- With three thermal alarm outputs, the DS1620 can also act as a thermostat.
- THIGH is driven high if the DS1620’s temperature is greater than or equal to a user–defined temperature TH. TLOW is driven high if the DS1620’s temperature is less than or equal to a user–defined temperature TL.
- TCOM is driven high when the temperature exceeds TH and stays high until the temperature falls below that of TL.
- User–defined temperature settings are stored in non-volatile memory, so parts can be programmed prior to insertion in a system, as well as used in standalone applications without a CPU. Temperature settings and temperature readings are all communicated to/from the DS1620 over a simple 3–wire interface.
- The DS1620 measures temperature by counting the number of clock cycles that an oscillator with a low temperature coefficient goes through during a gate period determined by a high temperature coefficient oscillator.
- The counter is preset with a base count that corresponds to –55°C. If the counter reaches 0 before the gate period is over, the temperature register, which is also preset to the –55°C value, is incremented, indicating that the temperature is higher than –55°C.
- At the same time, the counter is then preset with a value determined by the slope accumulator circuitry. This circuitry is needed to compensate for the parabolic behaviour of the oscillators over temperature.
- The counter is then clocked again until it reaches 0. If the gate period is still not finished, then this process repeats itself.
Hardware Design
Hardware material requirements
· I.C 8952
· I.C 1620
· Push Buttons
· Crystal (with frequency 12MHz)
· LTS542, display unit
· Resister 10K ohm
· Resister 56K ohm
· Resister 2.2K ohm
· Capacitor 1 uF
· Capacitor 33pF
· Transistor BC 547
· Power supply +5V
· Buzzer or alarm
· Connecting wires
· Soldering wire
· Soldering iron
· 40 pin base
· Strip board/Vero board
Shematic
Software Source code:
DIS_A EQU P0.2
DIS_B EQU P0.3
DIS_C EQU P0.4
DIS_D EQU P0.6
DIS_E EQU P0.5
DIS_F EQU P0.1
DIS_G EQU P0.0
DIS1 EQU P0.7
DIS2 EQU P2.7
DIS3 EQU P2.6
DIS4 EQU P2.5
ALARM EQU P2.4
PLUS EQU P1.0
MINUS EQU P1.1
SW1 EQU P1.4
SW2 EQU P1.5
DQ EQU P1.2
CLK EQU P1.3
RST EQU P1.6
RB0 EQU 000H ; Select Register Bank 0
RB1 EQU 008H ; Select Register Bank 1 ...poke to PSW to use
DSEG ; This is internal data memory
ORG 20H ; Bit adressable memory
COUNT: DS 1
SPEED: DS 1
VALUE_1: DS 1
VALUE_2: DS 1
VALUE_3: DS 1
VALUE_4: DS 1
NUMB1: DS 1
NUMB2: DS 1
NUMB3: DS 1
NUMB4: DS 1
TEMP: DS 1
ALRMTEMP: DS 1
STACK: DS 1
CSEG AT 0 ; RESET VECTOR
;---------==========----------==========---------=========---------
; PROCESSOR INTERRUPT AND RESET VECTORS
;---------==========----------==========---------=========---------
ORG 00H ; Reset
JMP MAIN
ORG 000BH ;Timer Interrupt0
JMP REFRESH
;---------==========----------==========---------=========---------
MOV SP,STACK
MOV SPEED,#00H
MOV COUNT,#00H
MOV NUMB1,#00H
MOV NUMB2,#04H
MOV NUMB3,#00H
MOV NUMB4,#00H
CLR ALARM
MOV VALUE_1,#15H ;Switch off all displays
MOV VALUE_2,#15H
MOV VALUE_3,#15H
MOV VALUE_4,#15H
CLR DIS1
CLR DIS2
CLR DIS3
CLR DIS4
MOV TMOD,#01H ;enable timer0 for scanning
MOV TL0,#00H
MOV TH0,#0FDH
SETB ET0
SETB EA
SETB TR0 ;Start the Timer
SETB CLK ; Start with CLK equal to 1
ACALL CONFIGURE ; Configure DS1620 ; wait 10 MS for Configuration to be Written
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
ACALL DELAYMS
UPP: ACALL START_CONVERT ; Send command to Start temperature conversion
ACALL DELAYS
ACALL READ_TEMPERATURE ; Get Temperature Reading111
MOV A,R3
MOV B,#02H
DIV AB ;
MOV R4,B
CJNE R4,#01H,GFG1
MOV VALUE_4,#05H
AJMP GFG2
GFG1: MOV VALUE_4,#00H
GFG2: MOV R2,A
MOV R1,#00H
MOV R3,#00D
MOV R4,#00D
MOV R5,#00D
MOV R6,#00D
MOV R7,#00D
CALL HEX2BCD
MOV VALUE_3,R3
MOV VALUE_2,R4
MOV VALUE_1,R5
MOV A,R3
XRL A,NUMB3
JNZ EDE
MOV A,R4
XRL A,NUMB2
JNZ EDE
MOV A,R5
XRL A,NUMB1
JNZ EDE
MOV A,NUMB4
XRL A,VALUE_4
JNZ EDE
SETB ALARM
AJMP SXZ
SWAP A
ORL A,VALUE_2
MOV R1,A
MOV A,VALUE_3
SWAP A
ORL A,VALUE_4
MOV R5,A
MOV A,NUMB1
SWAP A
ORL A,NUMB2
MOV R3,A
MOV A,NUMB3
SWAP A
ORL A,NUMB4
MOV R6,A
MOV A,R3
CLR C
SUBB A,R1
JZ DFD1
JNC DFD
SETB ALARM
AJMP SXZ
DFD1: MOV A,R6
CLR C
SUBB A,R5
JNC DFD
SETB ALARM
AJMP SXZ
DFD: CLR ALARM
SXZ: SETB SW1
JNB SW1,SHOW_TEMP
AJMP UPP
;**************************************************
SHOW_TEMP: CLR ALARM
CALL DELAY
JNB SW1,$
SXD1: MOV VALUE_1,NUMB1
MOV VALUE_2,NUMB2
MOV VALUE_3,NUMB3
MOV VALUE_4,NUMB4
SETB SW2
JNB SW2,UPP1
SETB PLUS
SETB MINUS
JNB PLUS,INC_TEMP
JNB MINUS,DEC_TEMP
AJMP SXD1
UPP1: CALL DELAY
JNB SW2,$
AJMP UPP
INC_TEMP: CALL DELAY
JNB PLUS,$
MOV R5,NUMB4
CJNE R5,#00H,FGG1
MOV R5,NUMB3
CJNE R5,#05H,FGG12
MOV R5,NUMB2
CJNE R5,#02H,FGG12
MOV R5,NUMB1
CJNE R5,#01H,FGG12
AJMP SXD1
FGG12: MOV NUMB4,#05H
AJMP SXD1
FGG1: MOV NUMB4,#00H
INC NUMB3
MOV R5,NUMB3
CJNE R5,#0AH,SXD1
INC NUMB2
MOV NUMB3,#00H
MOV R5,NUMB2
CJNE R5,#0AH,SXD1
INC NUMB1
MOV NUMB2,#00H
AJMP SXD1
DEC_TEMP: CALL DELAY
JNB MINUS,$
MOV R5,NUMB4
CJNE R5,#00H,FG1
MOV R5,NUMB3
CJNE R5,#00H,FG12
MOV R5,NUMB2
CJNE R5,#00H,FG12
MOV R5,NUMB1
CJNE R5,#00H,FG12
AJMP SXD1
FG1: MOV NUMB4,#00H
AJMP SXD1
FG12: MOV NUMB4,#05H
MOV R5,NUMB3
CJNE R5,#00H,DXC1
MOV NUMB3,#09H
MOV R5,NUMB2
CJNE R5,#00H,DXC2
MOV NUMB2,#09H
MOV NUMB1,#00H
AJMP SXD1
DXC1: DEC NUMB3
AJMP SXD1
DXC2: DEC NUMB2
AJMP SXD1
;**************************************************
;**************************************************
HEX2BCD: MOV B,#10D
MOV A,R2
DIV AB
MOV R3,B;
MOV B,#10 ; R7,R6,R5,R4,R3
DIV AB
MOV R4,B
MOV R5,A
CJNE R1,#0H,HIGH_BYTE ; CHECK FOR HIGH BYTE
SJMP ENDD
HIGH_BYTE: MOV A,#6
ADD A,R3
MOV B,#10
DIV AB
MOV R3,B
ADD A,#5
ADD A,R4
MOV B,#10
DIV AB
MOV R4,B
ADD A,#2
ADD A,R5
MOV B,#10
DIV AB
MOV R5,B
CJNE R6,#00D,ADD_IT
SJMP CONTINUE
ADD_IT: ADD A,R6
CONTINUE: MOV R6,A
DJNZ R1,HIGH_BYTE
MOV B, #10D
MOV A,R6
DIV AB
MOV R6,B
MOV R7,A
ENDD: RET
;***************************************************************************
; This routine writes the value in A to the DS1620
WRITE1620: MOV R0, #08H ; Set Counter for 8 bits
NEXTBITWRITE: CLR CLK ; Start clock cycle
RRC A ; Rotate A Right into Carry Bit(Lowest Bit in A goes to C)
MOV DQ, C ; Move outgoing bit to DQ
SETB CLK ; Rising Edge of Clock makes one clock cycle
DJNZ R0, NEXTBITWRITE
RET
;***************************************************************************
; This routine reads a value from the DS1620 and puts it in A
READ1620: MOV R0, #08H ; Set Counter for 8 bits
SETB DQ ; Set DQ to 1 to enable it as an input pin
NEXTBITREAD: CLR CLK ; Start clock cycle
MOV C, DQ ; Move incoming bit to DQ
SETB CLK ; Rising Edge of Clock makes one clock cycle
RRC A ; Rotate A Right through Carry Bit(C goes to Highest Bit of A)
DJNZ R0, NEXTBITREAD
CLR DQ
RET
;***************************************************************************
; Routine to Configure DS1620
CONFIGURE: SETB RST ; Make 1620 reset go High to start transfer
MOV A, #0CH ; Send the "Write Config" command to 1620
ACALL WRITE1620
MOV A, #00001010B ; CPU = 1, 1Shot = 0, THF = 0, TLF = 0
ACALL WRITE1620 ; Send the Configuration Byte
CLR RST ; Make 1620 reset go Low to signal end of transfer
RET
;***************************************************************************
; Routine to Start Temperature Conversion on 1620
START_CONVERT: SETB RST ; Make 1620 reset go High to start transfer
MOV A, #0EEH ; Send the "START CONVERT" command to 1620
ACALL WRITE1620
CLR RST ; Make 1620 reset go Low to signal end of transfer
RET
;****************************************************************************
; Routine to Read Temperature from 1620
READ_TEMPERATURE: SETB RST
MOV A, #0AAH ; Send the "Read Temperature" command
ACALL WRITE1620
ACALL READ1620 ; Get first byte of temperature
MOV R3, A ; Store Byte in R1
ACALL READ1620 ; Get second byte of temperature
MOV R1, A ; Store Byte in R2
CLR RST ; End Transfer
RET
;****************************************************************************
; Routine to Write Temperature High 1620
WRITE_HIGH: SETB RST
MOV A, #01H ; Send the "Read Temperature" command
ACALL WRITE1620
MOV A,R3 ; Store Byte in R1
ACALL WRITE1620
MOV A,R1 ; Store Byte in R1
ACALL WRITE1620
CLR RST ; End Transfer
RET
;****************************************************************************
; Routine to Read Temperature from 1620
READ_HIGH: SETB RST
MOV A, #0A1H ; Send the "Read Temperature" command
ACALL WRITE1620
ACALL READ1620 ; Get first byte of temperature
MOV R3, A ; Store Byte in R1
ACALL READ1620 ; Get second byte of temperature
MOV R1, A ; Store Byte in R2
CLR RST ; End Transfer
RET
;*************************************************************************
DELAYS: ;One second delay routine
MOV R6, #00H ;put 0 in register R6 (R6 = 0)
MOV R5, #004H ;put 5 in register R5 (R5 = 4)
LOOPB: INC R6 ;increase R6 by one (R6 = R6 +1)
ACALL DELAYMS ;call the routine above. It will run and return to here.
MOV A, R6 ;move value in R6 to A
JNZ LOOPB ;if A is not 0, go to LOOPB
DEC R5 ;decrease R5 by one. (R5 = R5 -1)
MOV A, R5 ;move value in R5 to A
JNZ LOOPB ;if A is not 0 then go to LOOPB.
RET
;**************************************************************************
DELAYMS: ; ;millisecond delay routine
MOV R7,#00H ;put value of 0 in register R7
LOOPA: INC R7 ;increase R7 by one (R7 = R7 +1)
MOV A,R7 ;move value in R7 to Accumlator (also known as A)
CJNE A,#0FFH,LOOPA ;compare A to FF hex (256). If not equal go to LOOPA
RET ;return to the point that this routine was called from
;**************************************************************************
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
; 7 SEGMENT DISPLAY ROUTINE
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
DISP: MOV R2,SPEED
CJNE R2,#00H,AAS1
CLR DIS_A
CLR DIS_B
CLR DIS_C
CLR DIS_D
CLR DIS_E
CLR DIS_F
SETB DIS_G
RET
AAS1: CJNE R2,#01H,AS2
CLR DIS_B
CLR DIS_C
SETB DIS_A
SETB DIS_D
SETB DIS_E
SETB DIS_F
SETB DIS_G
RET
AS2: CJNE R2,#02H,AS3
CLR DIS_A
CLR DIS_B
CLR DIS_D
CLR DIS_E
CLR DIS_G
SETB DIS_C
SETB DIS_F
RET
AS3: CJNE R2,#03H,AS4
CLR DIS_A
CLR DIS_B
CLR DIS_C
CLR DIS_D
CLR DIS_G
SETB DIS_E
SETB DIS_F
RET
AS4: CJNE R2,#04H,AS5
CLR DIS_B
CLR DIS_C
CLR DIS_F
CLR DIS_G
SETB DIS_A
SETB DIS_D
SETB DIS_E
RET
AS5: CJNE R2,#05H,AS6
CLR DIS_A
CLR DIS_C
CLR DIS_D
CLR DIS_F
CLR DIS_G
SETB DIS_B
SETB DIS_E
RET
AS6: CJNE R2,#06H,AS7
CLR DIS_A
CLR DIS_C
CLR DIS_D
CLR DIS_E
CLR DIS_F
CLR DIS_G
SETB DIS_B
RET
AS7: CJNE R2,#07H,AS8
CLR DIS_A
CLR DIS_B
CLR DIS_C
SETB DIS_D
SETB DIS_E
SETB DIS_F
SETB DIS_G
RET
AS8: CJNE R2,#08H,AS9
CLR DIS_A
CLR DIS_B
CLR DIS_C
CLR DIS_D
CLR DIS_E
CLR DIS_F
CLR DIS_G
RET
AS9: CJNE R2,#09H,AS10
CLR DIS_A
CLR DIS_B
CLR DIS_C
CLR DIS_D
CLR DIS_F
CLR DIS_G
SETB DIS_E
RET
AS10: CJNE R2,#15H,AS11 ;symbol for -
SETB DIS_A
SETB DIS_B
SETB DIS_C
SETB DIS_D
SETB DIS_E
SETB DIS_F
CLR DIS_G
RET
AS11: CJNE R2,#16H,AS12 ;switch off all disp
SETB DIS_A
SETB DIS_B
SETB DIS_C
SETB DIS_D
SETB DIS_E
SETB DIS_F
SETB DIS_G
RET
AS12: MOV SPEED,#00H
AJMP DISP
;**********************************************************
; INTRRUPT ROUTINE TO REFRESH THE DISPLAY
;**********************************************************
REFRESH: PUSH PSW ; save current registerset
MOV PSW,#RB1
PUSH ACC
INC COUNT
MOV R4,COUNT
QA1: CJNE R4,#01H,QA2
MOV SPEED,VALUE_1
SETB DIS1
CLR DIS2
CLR DIS3
CLR DIS4
CALL DISP
AJMP DOWN
QA2: CJNE R4,#02H,QA3
MOV SPEED,VALUE_2
CLR DIS1
SETB DIS2
CLR DIS3
CLR DIS4
CALL DISP
AJMP DOWN
QA3: CJNE R4,#03H,QA4
MOV SPEED,VALUE_3
CLR DIS1
CLR DIS2
SETB DIS3
CLR DIS4
CALL DISP
AJMP DOWN
QA4: CJNE R4,#04H,QA5
MOV SPEED,VALUE_4
CLR DIS1
CLR DIS2
CLR DIS3
SETB DIS4
CALL DISP
AJMP DOWN
QA5: MOV COUNT,#01H
MOV R4,COUNT
AJMP QA1
DOWN: MOV TL0,#0FFH
MOV TH0,#0F0H
POP ACC
POP PSW
RETI
;**********************************************************
FLASHING: CALL DELAY ;Display on/off for 2 times
CALL DELAY
MOV VALUE_1,#16H
MOV VALUE_2,#16H
MOV VALUE_3,#16H
MOV VALUE_4,#16H
CALL DELAY
CALL DELAY
MOV VALUE_1,NUMB1
MOV VALUE_2,NUMB2
MOV VALUE_3,NUMB3
MOV VALUE_4,NUMB4
CALL DELAY ;Display on-off for 2 times
CALL DELAY
MOV VALUE_1,#16H
MOV VALUE_2,#16H
MOV VALUE_3,#16H
MOV VALUE_4,#16H
CALL DELAY
CALL DELAY
MOV VALUE_1,NUMB1
MOV VALUE_2,NUMB2
MOV VALUE_3,NUMB3
MOV VALUE_4,NUMB4
;**********************************************************
DELAY: MOV R1,#0FFH
REPA2: MOV R2,#0FFH
REPA1: NOP
DJNZ R2,REPA1
DJNZ R1,REPA2
RET
END
Posted by Unknown
on 10:27. Filed under
DS1620 PROJECT,
Electronics Projects
.
You can follow any responses to this entry through the RSS 2.0.
Feel free to leave a response