A sensor is a transducer which converts physical data such as temperature, light intensity, flow, and speed to electrical signals. Depending on the transducer, the output produced is in the form of voltage, current, resistance, or capacitance. Temperature sensors are precision integrated-circuit whose output voltage is linearly proportional to the temperature.
The following are the general pins in ADC.
D0 – D7: The digital data output pins. The converted data is accessed only when CS = 0 and RD is forced low.
CS: Chip select is an active low input used to activate the ADC chip.
RD: This is an input signal and is active low. RD is used to get the converted data out of the ADC chip. RD pin is also referred to as output enable (OE).
WR: This is an active low input used to inform the ADC to start the conversion process.
INTR: This is an output pin and is active low. It is a normally high pin and when the conversion is finished, it goes low to signal the CPU that the converted data is ready to be picked up.
Program to read temperature and put it on port 0.
The following are the general pins in ADC.
D0 – D7: The digital data output pins. The converted data is accessed only when CS = 0 and RD is forced low.
CS: Chip select is an active low input used to activate the ADC chip.
RD: This is an input signal and is active low. RD is used to get the converted data out of the ADC chip. RD pin is also referred to as output enable (OE).
WR: This is an active low input used to inform the ADC to start the conversion process.
INTR: This is an output pin and is active low. It is a normally high pin and when the conversion is finished, it goes low to signal the CPU that the converted data is ready to be picked up.
Program to read temperature and put it on port 0.
ORG 0H | ||
MOV P1, #0FFH | ; make P1 as input port | |
CS BIT P2.4 | ||
READ BIT P2.5 | ||
WRITE BIT P2.6 | ||
INTR BIT P2.7 | ||
CLR CS | ; CS = 0, chip enable | |
SETB INTR | ; INTR = 1, clear end of conversion | |
BACK: | CLR WRITE | ; WR = 0, clear start conversion |
SETB WRITE | ; WR = 1 to start conversion | |
HERE: | JB INTR, HERE | ; wait for end of conversion |
CLR READ | ; conversion finished. Enable read | |
MOV A, P1 | ; move data to accumulator | |
ACALL CONVERSION | ; convert hex to DEC | |
ACALL DATA_DISPLAY | ; Display it on port 0 | |
SETB READ | ; prepare for next round | |
SJMP BACK | ||
; convert hex to dec (00 - FF to 000 - 255) and then to ASCII | ||
ORG 300H | ||
RAM_ADDR EQU 40H | ||
CONVERSION: | ||
HEX2DEC: | ||
MOV R0, #RAM_ADDR | ||
MOV B, #10 | ||
DIV AB | ; divide by 10 | |
MOV @R0, B | ; save lower digit | |
INC R0 | ||
MOV B, #10v | ||
DIV AB | ||
MOV @R0, B | ; save the next digit | |
INC R0 | ||
MOV @R0, A | ; save last digit | |
RET | ||
DATA_DISPLAY: | ||
MOV R0, #RAM_ADDR | ||
MOV P0, @R0 | ||
INC R0 | ||
ACALL DELAY | ||
MOV P0, @R0 | ||
INC R0 | ||
ACALL DELAY | ||
MOV P0, @R0 | ||
ACALL DELAY | ||
RET | ||
; some delay | ||
DELAY: | MOV R6, #50 | |
HERE2: | MOV R7, #255 | |
HERE1: | DJNZ R7, HERE1 | ; stay until R7 = 0 |
DJNZ R6, HERE2 | ; stay until R6 = 0 | |
RET | ||
END |
Related topics:
8051 External Program Memory Interfacing | 8051 External Data Memory Interfacing | 8051 Memory Mapped IO | 8051 LED Interfacing | 8051 Switch Interfacing | 8051 Keyboard Interfacing | 8051 7-Segment Display Interfacing | 8051 LCD Interfacing | 8051 ADC Interfacing | 8051 DAC Interfacing | 8051 Relay Interfacing | 8051 Stepper Motor Interfacing | 8051 DC Motor Interfacing
List of topics: 8051
No comments:
Post a Comment