Professional Documents
Culture Documents
Introduction:
Temperature sensing is a crucial aspect of many embedded systems. The LM35 temperature sensor
is a popular choice due to its linear output and ease of interfacing with microcontrollers. The LM35
temperature sensor outputs an analog voltage signal that varies linearly with temperature. However,
microcontrollers typically operate on digital signals. To utilize the temperature readings from the LM35,
we employ the built-in ADC of the PIC microcontroller. The ADC converts the analog voltage signal from
the LM35 into a digital value that the microcontroller can process. By configuring the ADC appropriately,
we can ensure accurate temperature measurements with high resolution. In our experiment, understanding
the ADC's functionality and calibration is crucial for obtaining precise temperature readings.
Integrating the ADC and LCD into the temperature sensing system enhances its overall
functionality and usability. The ADC ensures accurate and reliable temperature measurements, while the
LCD provides a convenient means of displaying these measurements to the user. Together, they form a
cohesive system that can accurately sense and present temperature information in real-time. Furthermore,
by simulating and programming the ADC and LCD alongside the LM35 sensor, students gain valuable
experience in sensor interfacing, data conversion, and display output, which are fundamental skills in
embedded systems design and development.
Objectives:
• Integrate an ADC for precise temperature measurements and an LCD for clear real-time display,
improving system functionality.
• Incorporate an LCD for accessible presentation of temperature data, enhancing user experience.
• Engage students in ADC and LCD simulation and programming to cultivate essential skills in
sensor integration and data display.
Equipment Required:
Crystal Oscillator
2 Capacitors
Power supply
Procedures:
}
void main() {
Delay_ms(2000);
Delay_ms(2000);
// Moving text
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
Move_Delay();
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
Simulation Environment:
DIAGRAM
SIMULATED DIAGRAM
Source Code for Temperature Sensor:
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
//
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
//
float temperature;
float Displaytemp;
char temp [4];
//
void main(){
TRISB=0X00; //all PORTB as output
TRISA=0X0F; //PORTA0 as Input
Lcd_Init(); //initialise the LCD
ADC_Init(); //initialise ADC
//
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF); //cursor off
//
Lcd_Out (1,3,"temperature");
Lcd_Out (2,4,"sensor");
delay_ms (2000);
//
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
while (1){
temperature=ADC_Read(RA0);
floattostr (Displaytemp, temp);
Lcd_Out (1,3, "temperature");
Displaytemp=(temperature*50*10)/1023;
Lcd_Out (2, 4, Rtrim(temp));
//
Lcd_Out (2,8,"C");
delay_ms (500);
}
}
Conclusion:
Questions to answer:
1. How does the LM35 temperature sensor function, and what are its advantages in temperature
sensing applications?
Ans: LM35 IS A TEMPERATURE SENSOR THAT GENERATES AN ANALOGUE
SIGNAL PROPORTIONAL TO THE CURRENT TEMPERATURE. THE OUTPUT VOLTAGE
IS EASILY UNDERSTOOD TO PROVIDE A TEMPERATURE READING IN CELSIUS.
THE ADVANTAGE OF THE LM35 OVER THE THERMISTOR IS THAT IT DOES NOT
REQUIRE EXTERNAL CALIBRATION.
2. Explain the process of converting analog temperature readings from the LM35 sensor into digital
values using the Analog-to-Digital Converter (ADC) in the PIC microcontroller.
Ans: A FEW EASY STEPS ARE REQUIRED TO CONVERT ANALOG TEMPERATURE DATA
FROM THE LM35 SENSOR TO DIGITAL VALUES USING THE PIC MICROCONTROLLER'S
ANALOG-TO-DIGITAL CONVERTER (ADC). FIRST, THE LM35 SENSOR GENERATES AN
ANALOG VOLTAGE SIGNAL PROPORTIONATE TO THE TEMPERATURE IT MONITORS.
THIS ANALOG VOLTAGE IS APPLIED TO ONE OF THE PIC MICROCONTROLLER'S
ANALOG INPUT PORTS. THE ADC IN THE PIC MICROCONTROLLER SAMPLES THIS
ANALOG VOLTAGE AND CONVERTS IT TO A DIGITAL VALUE REPRESENTING THE
TEMPERATURE. THIS DIGITAL NUMBER IS SUBSEQUENTLY PROCESSED AND
DISPLAYED AS DESIRED, SUCH AS ON AN LCD PANEL, RESULTING IN A DIGITAL
REPRESENTATION OF THE TEMPERATURE MEASUREMENT.
3. What role does the Liquid Crystal Display (LCD) play in improving user interaction and
accessibility of temperature data?
Ans: THE LIQUID CRYSTAL DISPLAY (LCD) VISUAL INTERFACE GIVES
CUSTOMERS CLEAR AND EASY-TO-READ TEMPERATURE DATA IN REAL-TIME.
BY DISPLAYING THE INFORMATION DIRECTLY ON THE SCREEN, USERS MAY
RAPIDLY GRASP THE CURRENT TEMPERATURE WITHOUT NEEDING EXTRA
TOOLS OR CALCULATIONS. THIS IMPROVES USER INVOLVEMENT BY
REDUCING THE PROCESS OF ACCESSING AND INTERPRETING
TEMPERATURE DATA, MAKING IT MORE ACCESSIBLE AND INTUITIVE.
4. What are the key steps involved in programming the PIC microcontroller to read temperature
data from the LM35 sensor and display it on the LCD?
Ans: THE ESSENTIAL STEPS IN PROGRAMMING THE PIC MICROCONTROLLER TO
READ TEMPERATURE DATA FROM THE LM35 SENSOR AND DISPLAY IT ON THE
LCD INCLUDE INITIALIZING THE NECESSARY PINS FOR INPUT AND OUTPUT,
SETTING UP THE ADC MODULE TO READ ANALOG DATA FROM THE LM35
SENSOR, CONVERTING THE ANALOG TEMPERATURE READINGS TO DIGITAL
VALUES, PROCESSING THE DIGITAL VALUES TO OBTAIN THE TEMPERATURE IN
CELSIUS OR FAHRENHEIT, AND FINALLY SENDING THE TEMPERATURE DATA TO
THE LCD FOR DISPLAY.
5. How do you troubleshoot common issues encountered during the simulation or programming of
the ADC and LCD in the temperature sensing system?
Ans: WHEN TROUBLESHOOTING TYPICAL ISSUES WITH ADC AND LCD IN A
TEMPERATURE SENSING SYSTEM, MAKE SURE ALL CONNECTIONS ARE SECURE
AND PROPERLY WIRED. CHECK THE CODE FOR FLAWS OR TYPOS AND ENSURE IT
MATCHES THE HARDWARE CONFIGURATION. CHECK POWER SUPPLY AND
GROUND CONNECTIONS. IF THE ADC RESULTS APPEAR INACCURATE, DOUBLE-
CHECK THE REFERENCE VOLTAGE AND CALIBRATION PARAMETERS. CONFIRM THE
INITIALIZATION SEQUENCE AND PIN CONNECTIONS IF YOU ARE EXPERIENCING
LCD DIFFICULTIES. IN ADDITION, TEST EACH COMPONENT SEPARATELY TO ISOLATE
THE PROBLEM. IF THE PROBLEM PERSISTS, REVIEW THE REQUIRED DOCUMENTS
OR SEEK HELP FROM INTERNET FORUMS OR COLLEAGUES.
References:
https://www.engineersgarage.com/lm35-description-and-working-
principal/#:~:text=LM35%20is%20a%20temperature%20sensor,not%20require%20any%20exter
nal%20calibration.
https://www.electronicwings.com/pic/lm35-temperature-sensor-interfacing-with-pic18f4550