Microcontroller Based Temperature Measurement and Controlling

April 26, 2017 | Author: Nitesh Chauhan | Category: N/A
Share Embed Donate


Short Description

Download Microcontroller Based Temperature Measurement and Controlling...

Description

“MICROCONTROLLER BASED TEMPERATURE MEASUREMENT AND CONTROLLING”

‘SUMMER TRAINING PROJECT REPORT’

SUBMITTED BY: MANISH PHOGAT ROLL NO: - 07-ECE-158 GURGAON INSTITUTE TECHNOLOGY & MANGEMENT

OF

ACKNOWLEDGEMENT This is to acknowledge that our project “Temperature controller” has been the outcome of the sincere efforts of our team and the immense, timely guidance and motivation of Mr. Ashish, Prolific Technologies, Mumbai. Our project has been a success due to the combination of his support and our handwork.

CERTIFICATE This is to certify that MANISH PHOGAT, ENROLLMENT NO. :

1571562807, a student

of E.C.E from Northern India Engineering College, IP university has done the summer training from Prolific Technologies. The project work entitled “MICROCONTROLLER BASED TEMPERATURE MEASUREMENT AND CONTROLLING” embodies the

original work done during the above project training period.

(Pooja Mendiratta) (HOD-ECE)

INDEX 1. PROFILE OF THE COMPANY. 2. PROJECT INTRODUCTION.

3. PROJECT METHODOLOGY 3.1 HARDWARE DESCRIPTION 3.1.1 8051 microcontroller 3.1.2 Temperature sensor DS1620 3.1.3 Brushless DC fan 3.1.4 LCD 3.1.5 Voltage Regulator 3.1.6 Power Supply 3.1.7 PCB 3.1.8 Capacitor 3.1.9 Resistor 3.1.10

3.2 SOFTWARE DESCRIPTION 3.3 HOW IT WORKS? 4.FUTURE PROSPECTS 5.CONCLUSION 6.BIBLIOGRAPHY

1.PROFILE OF THE COMPANY Prolific Technology Inc., a leading IC design house and ASIC design service provider, was founded in November 1997 by a group of highly experienced

and specialized technical engineers. The Company started out by developing Smart I/O IC solutions, focusing on niche USB/IEEE 1394 bridge controller products. The Company then also ventured in the Mixed-Mode technology development, successfully designing Brushless Motor Driver IC and Hall sensors. With the future towards 3C integration, the Company will devote more efforts in SOC development as well as integration of competitive multimedia (MPEG-4/JPEG/MP3) and GPS products. The Company will also continue to introduce new technologies for existing IC product base that will offer customers a wide range of product

solutions. Through System Integration technology, Prolific is envisioning herself to grow from a Professional IC Design House to a leading SOC Core Technology Pioneer. Prolific's corporate training clients include many blue-chip companies such as Sesa Goa, Aditya Birla Group companies, Ordinance factories, Garware Polyesters, Indian Rayon, Indal, ITC, Reliance Industries, India Cements, Saw Pipes, IPCL, GAIL etc.

2.PROJECT INTRODUCTION Any electronic system which has some intelligence and is dedicated to specific task are termed as embedded systems.

Embedded systems are real time and standalone. Our project “ Temperature controller” employs the use of DS1620 temperature sensor via 8051microcontroller using lcd interfacing. A Microcontroller is a single computer chip that executes a user program, normally for the purpose of controlling some device-hence the name. 8051 is a Microcontroller developed by Intel. Program can be contained in either second chip called EPROM or within the same chip as microcontroller itself. This Project is used to indicate the temperature and it is also used as controller. The system will get the temperature from the IC ( DS1620) and

it will display the temperature over the LCD and this temperature was compared with the value stored by the user and if the Room temperature goes beyond the Preset temperature then Brushless Fan is turned ON to lower the temperature of room. The System is fully controlled by the microcontroller 8051. All the above functions are monitored and controlled by the 8 bit microcontroller 8051. This Project is used to control the Fan action according to the temperature and it also indicates the temperature. The system will get the temperature from the IC (DS1620). The temperature is displayed in F or C.

With the DS1620 you may set breakpoints to turn a thermostat on/off.

3.PROJECT METHODOLOGY

3.1 Hardware Description :

Hardware used::

3.1.1 8051 microcontroller 3.1.2 Temperature sensor DS1620 3.1.3 Brushless DC fan 3.1.4 LCD 3.1.5 Voltage Regulator 3.1.6 Power Supply 3.1.7 PCB 3.1.8 Capacitor 3.1.9 Resistor

3.1.1 8051 microcontroller Difference between a microprocessor and a microcontroller

A microprocessor has no RAM , ROM or I/O ports on the chip itself .A microcontroller has a CPU( a microprocessor) in addition to a fixed amount of RAM ,ROM,I/O and a timer all on a single chip.In other words, the processor , RAM, ROM, I/o ports, and timer are all embedded together on one chip; therefore, the designer cannot add any external memory, I/O or timers to it. The fixed amount of on chip ROM, RAM and the number of I/O ports in microcontroller makes them ideal for many applications in which cost and space are critical. In 1981, Intel introduced an 8-bit microcontroller called the 8051.This has

128 bytes of RAM, 4K bytes of on chip ROM ,two timers, one serial port and 4 ports( each 8-bits wide).

Pin configuration of µC P89v51RD2+

It is a 40 pin DIP configuration which operates on 5V. Supports 12-clock (default) or 6-clock mode selection via software or ISP. •







Pin 9: connected to Reset Pin 18,19: connected to crystal (to provide the required frequency to work on). Pin 29: PSEN ,it is a read strobe to external program memory. Pin 30: ALE, It enables the address latch for port 0

Pin 31: EA (when low, enables code to be fetched from external memory). •



Pin no. 1 to 8: Port 1.



Pin no. 10 to 17: Port 3.



Pin no. 21 to 28: Port 2. •

Pin no. 32 to 39: Port 0.

PIN DESCRIPTION VCC: Supply voltage during normal, Idle and Power Down operations.

VSS: Circuit ground. Port 0,1,2,3: These are 8-bit open drain bidirectional I/O port. They receive the code bytes during EPROM programming, and outputs the code bytes during program verification. RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. The port pins will be driven to their reset condition when a minimum VIH1 voltage is applied whether the oscillator is running or not. An internal pulldown resistor permits a power-on reset with only a capacitor connected to VCC.

ALE/PROG: Address Latch Enable output signal for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during EPROM programming for the 87C51. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external Data Memory. PSEN: Program Store Enable is the Read strobe to External Program Memory. When the 87C51/BH is executing from Internal Program Memory, PSEN is inactive (high). When the device is executing code from External Program

Memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to External Data Memory. EA/VPP: External Access enable,EA must be strapped to VSS in order to enable the 87C51/BH to fetch code from External Program Memory locations starting at 0000H up to FFFFH. Note, however, that if either of the Lock Bits is programmed, the logic level at EA is internally latched during reset. EA must be strapped to VCC for internal program execution.This pin also receives the programming supply voltage (VPP) during EPROM programming. XTAL1: Input to the inverting oscillator amplifier.

XTAL2: Output from the inverting oscillator amplifier. OSCILLATOR CHARACTERISTICS XTAL1 and XTAL2 are the input and output, respectively,of an inverting amplifier which can be configured for use as an on-chip oscillator.To drive the device from an external clock source,XTAL1 should be driven, while XTAL2 is left unconnected. 3.1.2 IC-DS1620 The DS1620 Digital Thermometer and Thermostat provides 9-bit temperature readings which indicate the

temperature of the device. With three thermal alarm outputs, the DS1620 can also act as a thermostat. THIGH is driven high if the DS1620's temperature exceeds a user defined temperature TH. TLOW is driven high if the DS1620's temperature falls below a user defined temperature TL. Pin Description :-

Pin Diagram of DS1620

User-defined temperature settings are stored in nonvolatile 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. DS1620 Digital Thermometer and Thermostat requires no external components .Supply voltage range covers from 2.7V to 5.5V, Measures temperatures from -55°C to +125°C in

0.5°C increments; Fahrenheit equivalent is -67°F to +257°F in 0.9°F increments. Temperature is read as a 9-bit value Converts temperature to digital word in 1 second (max) Thermostatic settings are user-definable and nonvolatile. Data is read from/written via a 3-wire serial interface (CLK, DQ, RST ). DESCRIPTION: The DS1620 Digital Thermometer and Thermostat provides 9–bit temperature readings which indicate the temperature of the device. 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 nonvolatile memory, so parts can be programmed prior to insertion in a system, as well as used in standalone applications without a CPU. OPERATION AND CONTROL: The DS1620 must have temperature settings resident in the TH and TL registers for thermostatic operation. A configuration/status register also

determines the method of operation that the DS1620 will use in a particular application and indicates the status of the temperature conversion operation. The configuration register is defined as follows: CONFIGURATION/STATUS REGISTER: where DONE = Conversion Done Bit. 1=conversion complete, 0=conversion in progress. The power-up/POR state is a 1. THF = Temperature High Flag. This bit will be set to 1 when the temperature is greater than or equal to the value of TH. It will remain 1 until reset by writing 0 into this location or by removing power

from the device. This feature provides a method of determining if the DS1620 has ever been subjected to temperatures above TH while power has been applied. The power-up/POR state is a 0. TLF = Temperature Low Flag. This bit will be set to 1 when the temperature is less than or equal to the value of TL. It will remain 1 until reset by writing 0 into this location or by removing power from the device. This feature provides a method of determining if the DS1620 has ever been subjected to temperatures below TL while power has been applied. The power-up/POR state is a 0. NVB = Nonvolatile Memory Busy Flag. 1=write to an E2 memory cell in progress. 0=nonvolatile

memory is not busy. A copy to E2 may take up to 10 ms. The power-up/POR state is a 0. CPU = CPU Use Bit. If CPU=0, the CLK/ CONV pin acts as a conversion start control, when RST is low. If CPU is 1, the DS1620 will be used with a CPU communicating to it over the 3–wire port, and the operation of the CLK/CONV pin is as a normal clock in concert with DQ and RST . This bit is stored in nonvolatile E2 memory, capable of at least 50,000 writes. The DS1620 is shipped with CPU=0. 1SHOT = One–Shot Mode. If 1SHOT is 1, the DS1620 will perform one temperature conversion upon reception of the Start Convert T protocol. If 1SHOT is 0, the DS1620 will continuously perform temperature

conversion. This bit is stored in nonvolatile E2 memory, capable of at least 50,000 writes. The DS1620 is shipped with 1SHOT=0.

3.1.3 Brushless DC Fan Brushless DC fans are usually available at three nominal voltages: 12V, 24V and 48V. If the system has regulated power supply in one of these, then a brushless DC fan may be selected which will give the exact performance required, regardless of the AC input variables which plague AC fans. Because the speed and airflow of a typical DC fan is proportional to the voltage supplied, a single product may be

used to meet different applications by setting the supply voltage to what will give the desired airflow. Brushless DC fans do not draw constant currents. The choice of the power source along with the addition of other peripheral devices will be affected by the type and number of DC fans and their motor current characteristics. Throughout the rotational cycle and particularly at commutation, the currents will fluctuate from minimum to maximum.

3.1.4. LCD Display

Pin desriptions: Vss : GRND Vcc : Power supply RS : register

RS=0 to select command

RS=1 to select data register

R/W : R/W = 0 for write, R/W = 1 for read E

: Enable

In recent years LCD is finding widespread use due to their declining prices, ease of programming and many other reasons.

Advanced Interfacing 1 - LCD Display A Liquid Crystal Display is an electronic device that can be used to show numbers or text. There are two main types of LCD display, Numeric displays (used in watches, calculators etc) and

Alphanumeric text displays (often used in devices such as photocopiers and mobile telephones). The display is made up of a number of shaped ‘crystals’. In numeric displays these crystals are shaped into ‘bars’, and in alphanumeric displays the crystals are simply arranged into patterns of ‘dots’. Each crystal has an individual electrical connection so that each crystal can be controlled independently. When the crystal is ‘off’ (i.e. when no current is passed through the crystal) the crystal reflect the same amount of light as the background material, and so the crystals cannot be seen. However when the crystal has an electric current passed through it, it changes shape and so absorbs more light. This makes the crystal appear darker to the human eye -

and so the shape of the dot or bar can be seen against the background. It is important to realise the difference between a LCD display and an LED display. An LED display (often used in clock radios) is made up of a number of LEDs which actually give off light (and so can be seen in the dark). An LCD display only reflects light, and so cannot be seen in the dark. The LCD has 6 lines that can be connected directly to the PIC microcontroller pins. It is a good design practice to add a low value resistor (e.g. 330R) on the lines to protect against

static discharges. The 10k potentiometer connected to pin 3 is used to adjust the contrast of the display. 3.1.5 Voltage Regulator (7805) Voltage Regulator usually having three legs converts varying input voltage and produces a constant regulated output voltage. They are available in a variety of outputs.

The

most

common

part

numbers start with the numbers 78 or 79 and finish with two digits indicating the output voltage. The number 78 represents positive voltage and 79 negative one. The 78XX series of voltage regulators are

designed for positive input. And the 79XX series is designed for negative input.

3.1.6.Power Supply The power supply supplies the required energy for both the microcontroller and the associated circuits. It is the most essential part of the circuit because to run its constituent IC’s circuit has to be provided with power. A power supply is a vital part of all electronic systems.

Most

digital

microprocessors,

IC’s

including

microcontrollers

operate on a +5V supply. A regulated power supply is a power supply whose output voltage remains fairly constant even though the load and/or the input voltage changes. A load is any electrical circuit,

appliance,

device

that

is

connected to the output of the power supply.

3.1.7.Printed Circuit Board (P.C.B.)

Making a Printed Circuit Board is the first step towards building electronic equipment by any electronic industry. Printed Circuit Board are used for housing components to make a circuit for compactness, simplicity of servicing and case of interconnection. Thus we can define the P.C.B. as : Printed Circuit Boards is actually a sheet of bakelite (an insulating material) on the one side of which copper patterns are made with holes and from another side, leads of electronic components are inserted in the proper holes and soldered to the copper points on the back. Thus leads of electronic components terminals are joined to make electronic circuit.

3.1.8 Capacitors It is an electronic component whose function is to accumulate charges and then release it. To understand the concept of capacitance, consider a pair of metal plates which all are placed near to each other without touching. If a battery is connected to these plates the positive pole to one and the negative pole to the other, electrons from the battery will be attracted from the plate connected to the positive terminal of the battery. If the battery is then disconnected, one plate will be left with an excess of electrons, the other with a shortage, and a potential or voltage difference will exists between

them. These plates will be acting as capacitors. Capacitors are of two types: (1) Fixed type like ceramic, polyester, electrolytic capacitors-these names refer to the material they are made of aluminum foil. (2) Variable type like gang condenser in radio or trimmer. In fixed type capacitors, it has two leads and its value is written over its body and variable type has three leads. Unit of measurement of a capacitor is farad

denoted by the symbol F. It is a very big unit of capacitance. Small unit capacitor are

Pico-farad

denoted

by

pf

(1

pf=1/1000, 000,000,000 f) Above all, in case of electrolytic capacitors, its two terminal are marked as (-) and (+) so check it while using capacitors in the circuit in right direction. Mistake can destroy the capacitor or entire circuit in operational. 3.1.9 Resistance Resistance is the opposition of a material to the current. It is measured in Ohms

(Ω). All conductors represent a certain amount of resistance, since no conductor is 100% efficient. To control the electron flow (current) in a predictable manner, we use resistors. Electronic circuits use calibrated lumped resistance to control the flow of current. Broadly speaking, resistor can be divided into two groups viz.

fixed

&

adjustable

(variable)

resistors. In fixed resistors, the value is fixed & cannot be varied. In variable resistors, the resistance value can be varied by an adjuster knob. The most

common type of resistors used in our projects is carbon type. The resistance value is normally indicated by colour bands. Each resistance has four colours, one of the band on either side will be gold or silver, this is called fourth band and indicates the tolerance, others three band will give the value of resistance (see table). For example if a resistor has the following marking on it say red, violet, gold. Comparing these coloured rings with the colour code, its value is 27000 ohms or 27 kilo ohms and its

tolerance is ±5%. Resistor comes in various sizes (Power rating). The bigger, the size, the more power rating of 1/4 watts. The four colour rings on its body tells us the value of resistor value as given below.

COLOURS Black Brown Red

CODE 0 1 2

Orange

3

Yellow

4

Green

5

Blue

6

Violet

7

Grey

8

White

9

The first rings give the first digit. The second ring gives the second digit. The third ring indicates the number of zeroes to be placed after the digits. The fourth

ring gives tolerance (gold ±5%, silver ± 10%, No colour ± 20%).

3.2 Software Description For

the

Thermostat

development for

microcontroller options

for

fan is

of

Digital

reprogrammable necessary.

Two

reprogrammable

microcontrollers were considered. The first being the traditional ultraviolet light

(UV) erasable-memory type that has a quartz window and is exposed to UV to erase the contents prior to programming. This process can take 10 to 20 minutes to erase the memory. Microchip provides this option for the PIC16 series and the UV erasable devices are identified by the model number extension JW. These devices are produced in a ceramic dualin-line package and are identical to the OTP (One Time Programmable) version except for the packaging and cost. The other option considered was the FLASH

based AT89C51 family, which is a new series

of

devices

that

employ

electronically erasable memory. These devices are available in DIP or surface mount packages. The FLASH devices are more convenient to reprogram than the windowed version as they don't require exposure to UV light and hence the reprogramming time is much shorter.

The microcontroller chosen for the development system was the AT89S52.

This device is much cheaper than the windowed PIC16C73A-JW and since two microcontrollers are required this represents

an

immediate

hardware

saving. The AT89S52 has 8K of program memory and has the capability to write to its own memory. The use of a FLASH device for development also provides the option to use FLASH microcontrollers in the final design making the system fully up gradable. This allows modification of the microcontroller software to support expansion and the addition of other

sensors and inputs. The original intention was to use the FLASH AT89S52 to develop software using the development system and employ an AT89S52 unit in the final application. The OTP devices are cheaper and this reduces the cost per unit. There are some differences between the device families, which need to be considered when using the FLASH to develop code for the developed system.

3.3 HOW IT WORKS? Interfacing::

CODING: #include #include #include

//---------ds1620

initialization

function definitions-----------------sbit

dq=P0^0;

sbit

clk=P0^1;

sbit

rst=P0^2;

and

sbit

tcom=P0^3;

sbit

fan=P0^5;

unsigned char temp,temp1,temp2; unsigned char ds1,ds2,ds3; void init_ds1620(); void wt_ds1620(unsigned char a); void wt_ds1620_reg(unsigned char a); unsigned char rd_ds1620(); void process(unsigned char); //--------------------------------------------------------------------------

code

disp_lut[]

=

{'0','1','2','3','4','5','6','7','8','9'};

//----------lcd initializations and function definitions------------------void delay_ms(unsigned int); void data_wr(unsigned char); void cmd_wr0(unsigned char); void cmd_wr(unsigned char); void map(unsigned char); void lcd_init();

void pulse(); sbit RS=P1^1; sbit RW=P1^2; sbit E=P1^3; sbit D4=P1^4; sbit D5=P1^5; sbit D6=P1^6; sbit D7=P1^7; //---------------------------------------------------------------------------void main()

{

tcom=0; lcd_init(); init_ds1620(); while(1) { rst=1; wt_ds1620(0xee); rst=0; delay_ms(2);

delay_ms(2); rst=1; wt_ds1620(0xaa); temp2=rd_ds1620(); rst=0;

process(temp2); if(temp2>temp) { fan=1;

cmd_wr(0x80); delay_ms(5); data_wr('F'); delay_ms(5); data_wr('A'); delay_ms(5); data_wr('N'); delay_ms(5); data_wr(' '); delay_ms(5); data_wr('I');

delay_ms(5); data_wr('S'); delay_ms(5); data_wr(' '); delay_ms(5); data_wr('O'); delay_ms(5); data_wr('N'); delay_ms(5); data_wr(' '); delay_ms(5);

cmd_wr(0xc0); delay_ms(5);

data_wr('T'); delay_ms(5); data_wr('e'); delay_ms(5); data_wr('m'); delay_ms(5); data_wr('p');

delay_ms(5); data_wr('='); delay_ms(5); data_wr('='); delay_ms(5); data_wr('>'); delay_ms(5); data_wr(' '); delay_ms(5); data_wr(' '); delay_ms(5);

data_wr(ds3); delay_ms(5); data_wr(ds2); delay_ms(5); data_wr(ds1); delay_ms(5); } else { fan=0 ; cmd_wr(0x80); delay_ms(5);

data_wr('F'); delay_ms(5); data_wr('A'); delay_ms(5); data_wr('N'); delay_ms(5); data_wr(' '); delay_ms(5); data_wr('I'); delay_ms(5); data_wr('S');

delay_ms(5); data_wr(' '); delay_ms(5); data_wr('O'); delay_ms(5); data_wr('F'); delay_ms(5); data_wr('F'); delay_ms(5);

cmd_wr(0xc0);

delay_ms(5);

data_wr('T'); delay_ms(5); data_wr('e'); delay_ms(5); data_wr('m'); delay_ms(5); data_wr('p'); delay_ms(5); data_wr('=');

delay_ms(5); data_wr('='); delay_ms(5); data_wr('>'); delay_ms(5); data_wr(' '); delay_ms(5); data_wr(' '); delay_ms(5); data_wr(ds3); delay_ms(5);

data_wr(ds2); delay_ms(5); data_wr(ds1); delay_ms(5); } } } void init_ds1620() {

rst = 1;

wt_ds1620(0x0c); //writing permission to the control register wt_ds1620(0x03); //writing data into the control resiter rst = 0;

delay_ms(2); delay_ms(2); rst=1; wt_ds1620(0x01); //writing

high

temp limit to TH wt_ds1620_reg(100); // data into TH

rst=0;

delay_ms(2); delay_ms(2);

rst=1; wt_ds1620(0xa1); temp=rd_ds1620(); rst=0;

delay_ms(2); delay_ms(2);

rst=1; wt_ds1620(0x02); //writing

high

temp limit to TL wt_ds1620_reg(70); // data into TL rst=0;

delay_ms(2); delay_ms(2);

rst=1; wt_ds1620(0xa2); temp1=rd_ds1620(); rst=0; } //-----------------------------------------void wt_ds1620(unsigned char a) {

unsigned char k,b=1;

for (k=0; k
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF