Thermistor Interfacing with PIC16F676 Microcontroller for Temperature Sensing


Title: Thermistor Interfacing with PIC16F676 Microcontroller for Temperature Sensing

Introduction

In this project, we will explore how to interface a thermistor with the PIC16F676 microcontroller to measure temperature and display the results on a 7-segment display. Thermistors are temperature-sensitive resistors, which change their resistance with variations in temperature. This property can be used to measure temperature in a variety of applications.

This project utilizes the following components:

  • PIC16F676 microcontroller
  • Thermistor (HS-TMP2)
  • 7-segment display
  • Resistors, capacitors, diodes
  • Transistors
  • LED indicators (Red and Green)

Components Overview

1. PIC16F676 Microcontroller

The PIC16F676 is an 8-bit microcontroller with internal analog-to-digital conversion (ADC), which allows us to measure analog signals like the voltage from a thermistor. It has 10 I/O pins and is well-suited for small embedded systems like temperature monitoring.

2. Thermistor (HS-TMP2)

A thermistor is a temperature sensor whose resistance decreases as the temperature increases (NTC – Negative Temperature Coefficient). This sensor is interfaced with the microcontroller to measure the surrounding temperature.

3. 7-Segment Display

The 7-segment display is used to show the temperature reading in digits. The PIC16F676 drives this display by sending the required signals through its output pins.

4. LED Indicators

Two LED indicators are used in the system:

  • Red LED: Lights up when the temperature crosses a certain threshold.
  • Green LED: Remains on during normal operation.

Circuit Design

The PCB design is a simple yet effective layout for temperature sensing. Below is a step-by-step explanation of the connections:

  1. Thermistor (HS-TMP2) Interfacing
    The thermistor is connected in series with a resistor, forming a voltage divider. The divided voltage is fed to the analog input pin of the PIC16F676. The microcontroller reads this voltage using its ADC module and converts it into a temperature value.
  2. Power Supply
    A regulated power supply (likely 5V or 3.3V) is connected to the microcontroller and other components such as the LEDs, thermistor, and display.
  3. 7-Segment Display Connection
    The 7-segment display is connected to the PIC16F676 through appropriate current-limiting resistors. The display shows the temperature in a human-readable format.
  4. LEDs and Indicators
    The LEDs are connected through current-limiting resistors to prevent damage from excessive current. The microcontroller controls these LEDs based on the temperature thresholds.
  5. Capacitors and Resistors
    Additional resistors and capacitors are used for noise filtering, debouncing, and ensuring stable operation of the system.
  6. IC (Microcontroller) Placement
    The PIC16F676 is mounted centrally on the PCB with connections made to the thermistor, display, and LEDs. A bypass capacitor (usually 100nF) is placed across the supply pins to smooth any power fluctuations.

     Working Principle

  1. Temperature Measurement
    The thermistor’s resistance changes with temperature, which results in a varying voltage across the resistor-thermistor voltage divider. This analog voltage is read by the ADC in the PIC16F676.
  2. Conversion to Digital Value
    The microcontroller converts the analog voltage into a digital value, representing the temperature. Calibration is required to ensure the correct temperature is displayed on the 7-segment display.
  3. Displaying the Temperature
    The digital temperature value is displayed on the 7-segment display. The microcontroller sends the appropriate signals to light up the correct segments corresponding to the temperature reading.
  4. LED Indication
    The red LED lights up when the temperature crosses a preset threshold, indicating an over-temperature condition. The green LED remains lit under normal conditions.

Code Explanation

The PIC16F676 is programmed using MPLAB and the XC8 compiler. Here’s a basic overview of the code:

  • ADC Configuration: The ADC is set up to read the voltage from the thermistor.
  • Temperature Calculation: The digital ADC value is converted to a temperature based on the characteristics of the thermistor.
  • Display Control: The temperature is then sent to the 7-segment display by controlling the segments through the I/O pins of the microcontroller.
  • LED Control: Based on the temperature, the red or green LED is turned on.

///////////////////////////

// Pseudo-code for Temperature Measurement
ADC_Init(); // Initialize ADC
while(1) {
adc_value = ADC_Read(TEMP_SENSOR_PIN); // Read thermistor voltage
temperature = ConvertToTemperature(adc_value); // Convert ADC value to temperature
DisplayTemperature(temperature); // Show on 7-segment display
if (temperature > THRESHOLD) {
Red_LED_On();
} else {
Green_LED_On();
}
}

///////////////////////////

Conclusion

This project demonstrates how a simple thermistor can be used for temperature sensing in combination with a PIC16F676 microcontroller. The system provides real-time temperature monitoring with visual feedback on a 7-segment display and LED indicators for threshold crossing.

This type of circuit can be extended to various applications, including HVAC systems, industrial temperature monitoring, and home automation. By understanding the principles behind thermistor interfacing, you can easily adapt this project for different temperature ranges and display formats.