Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

FACULTY OF ELECTRICAL

AND ELECTRONIC ENGINEERING


2020 – 2021
-------*-------

SENSORS AND INSTRUMENTATIONS

Homework 6

Lecturer: Dr. Nguyen Trong Tai

Students: Le Ngoc Thinh - 1751094


Nguyen Anh Tuan - 1751108
Nguyen Thuyet Hieu - 1751029
Ho Chi Minh City, 4/2021

2
CONTENTS
1. Abstract................................................................................................................3
2. Introduction.........................................................................................................3
3. Implement............................................................................................................4
3.1 In Proteus........................................................................................................4
3.2 in CodeVision AVR........................................................................................6
4. Result....................................................................................................................8
5. Conclusion............................................................................................................9
6. References............................................................................................................9

3
1. Abstract
This report introduces the basic background and study the thermistor by using
Proteus and CodeVision AVR.

2. Introduction
1 1
 β− parameter equation : R = R0.e β .( T − ¿ ) (1)

 R0 is the thermistor resistance at temperature T0.


 Β is a curve fitting parameter.

4
3. Implement
3.1 In Proteus

Figure 1. Set up Proteus

5
Figure 2. Load hex file from AVR

6
3.2 in CodeVision AVR

Figure 3. Selecting ATmega8 chip

Figure 4. Set up ADC

7
Figure 5. Set up USART to use Virtual Terminal

#include <mega8.h>

#include <delay.h>

#include <math.h>

// Standard Input/Output functions


#include <stdio.h>

#define ADC_VREF_TYPE 0x00


#define Vref 5
#define R1 20000
#define R0 20000
#define T0 298
#define beta 4052

// Declare your local variables here


unsigned int adc_value;
float Vin, x, y, ToK, ToC, NTC;

8
while (1)
{
// Place your code here
adc_value = read_adc(6);
Vin = (Vref * adc_value * 1.0f) / 1023;
x = adc_value * 1.0f / 1023;
NTC = (x * R1) / (1 - x);
y = log(NTC / R0);
ToK = 1 / ((y / beta) + (1.0f / T0)); //temperature in Kelvin
ToC = ToK - 273; //temperature in degree Celsius
printf("ADC value = %d; Vin = %f; Temp = %f \r\n", adc_value, Vin, ToC);
delay_ms(1000);
}

4. Result
T = 31 °C

T = 40 °C

9
T = 25 °C

5. Conclusion
In this report, we have tried to study the basic concept and how to use
Proteus and CodeVision AVR to simulate the operating way of Thermistor.

6. References
https://circuitdigest.com/microcontroller-projects/how-to-use-adc-in-avr-
microcontroller-atmega16

10

You might also like