27
This Document is created by Mr. Amol Shah for ©DNA Technology PC based Temperature Controller Project Information

PC based Temperature controller

Embed Size (px)

Citation preview

Page 1: PC based Temperature controller

This Document is created by Mr. Amol Shah for ©DNA Technology

Page 2: PC based Temperature controller

Page

Table of Content

TABLE OF CONTENT 2

AIM: 4

INTODUCTION: 4

On/Off Control: 5

Proportional Control: 5

PID Control: 5

BLOCK DIAGRAM: 6

1. Microcontroller : 7

2. ADC: 7

3. Temperature Sensor: 7

4. MAX 232 7

5. PC: 8

6. Relay Driver: 8

7. Relay: 8

8. Power Supply: 8

ALGORITHM: 9

CIRCUIT DIAGRAM: 11

EXPLAINATION OF CIRCUIT DIAGRAM: 12

Microcontroller: 12

MAX 232: 13

Temperature Sensor: 14

Relay and Relay Driver Section: 15

Page 3: PC based Temperature controller

Page

Keypad Section: 16

Power Supply: 16

LIST OF COMPONENTS: 19

LAYOUTS: 20

FUTURE SCOPE AND APPLICATION: 22

ADVANTAGES: 22

DIS-ADVANTAGES: 22

BILL OF MATERIAL: 22

BIBLIOGRAPHY OR REFERENCES: 22

Page 4: PC based Temperature controller

Temp Input Control Output System

Fig. Simple Schematic of Temparature Controller

MPU

Page

PC based Temperature controller

Aim:

The aim of the project is to accurately control process/system temperature without extensive operator involvement.

Intoduction:

A temperature control system relies upon a controller, which is connected to a temperature sensor. It compares the actual temperature to the desired control temperature, or set point, and provides an output to a control element. Mostly the control element is a heater.

The controller is connected to a Personal Computer using RS232 protocol. The Current Temperature can be seen on the PC. Whereas the Temperature Set Point can also be changed through the PC. The relay is used to Turn ON/OFF a Relay. When the current temperature is less than the Set Temperature the relay is turned ON which in turns ON the heater. When the Current Temperature rises above the Set Temperature the relay is Turned OFF.

There are three basic types of controllers:

1. On-off2. Proportional3. PID.

Depending upon the system to be controlled, the operator will be able to use one type or another to control the process.

Page 5: PC based Temperature controller

Page

On/Off Control:

An on-off controller is the simplest form of temperature control device. The output from the device is either on or off, with no middle state. An on-off controller will switch the output only when the temperature crosses the setpoint.

For heating control, the output is on when the temperature is below the setpoint, and off above setpoint.

Since the temperature crosses the setpoint to change the output state, the process temperature will be cycling continually, going from below setpoint to above, and back below. In cases where this cycling occurs rapidly, and to prevent damage to contactors and valves, an on-off differential, or “hysteresis,” is added to the controller operations. This differential requires that the temperature exceed setpoint by a certain amount before the output will turn off or on again. On-off differential prevents the output from “chattering” or making fast, continual switches if the cycling above and below the setpoint occurs very rapidly.

On-off control is usually used where a precise control is not necessary, in systems which cannot handle having the energy turned on and off frequently, where the mass of the system is so great that temperatures change extremely slowly, or for a temperature alarm. One special type of on-off control used for alarm is a limit controller. This controller uses a latching relay, which must be manually reset, and is used to shut down a process when a certain temperature is reached.

Proportional Control:

Proportional controls are designed to eliminate the cycling associated with on-off control. A proportional controller decreases the average power supplied to the heater as the temperature approaches setpoint. This has the effect of slowing down the heater so that it will not overshoot the setpoint, but will approach the setpoint and maintain a stable temperature.

This proportioning action can be accomplished by turning the output on and off for short time intervals. This "time proportioning" varies the ratio of “on” time to "off" time to control the temperature. The proportioning action occurs within a “proportional band” around the setpoint temperature. Outside this band, the controller functions as an on-off unit, with the output either fully on (below the band) or fully off (above the band). However, within the band, the output is turned on and off in the ratio of the measurement difference from the setpoint. At the setpoint (the midpoint of the proportional band), the output on:off ratio is 1:1; that is, the on-time and off-time are equal. if the temperature is further from the setpoint, the on- and off-times vary in proportion to the temperature difference. If the temperature is below setpoint, the output will be on longer; if the temperature is too high, the output will be off longer.

PID Control:

Page 6: PC based Temperature controller

MAX 232

Computer

MICROCONTROLLER

ADC Temperature

POWER SUPPLY

Relay Driver Relay

Page

The third controller type provides proportional with integral and derivative control, or PID. This controller combines proportional control with two additional adjustments, which helps the unit automatically compensate for changes in the system. These adjustments, integral and derivative, are expressed in time-based units; they are also referred to by their reciprocals, RESET and RATE, respectively.

The proportional, integral and derivative terms must be individually adjusted or “tuned” to a particular system using trial and error. It provides the most accurate and stable control of the three controller types, and is best used in systems which have a relatively small mass, those which react quickly to changes in the energy added to the process.

It is recommended in systems where the load changes often and the controller is expected to compensate automatically due to frequent changes in setpoint, the amount of energy available, or the mass to be controlled. OMEGA offers a number of controllers that automatically tune themselves. These are known as autotune controllers.

Block Diagram:

Figure shows the block diagram of system.

Page 7: PC based Temperature controller

Page

Application consists of the following section:

1. Microcontroller :

The controller is the heart of entire system, and the whole system should be analyzed in selecting the proper controller. The following items should be considered when selecting a controller:

Type of input sensor (thermocouple, RTD) and temperature range

Type of output required (electromechanical relay, SSR, analog output)

Control algorithm needed (on/off, proportional, PID)

Number and type of outputs (heat, cool, alarm, limit)

We will be using ATMEL’s AT89S51 microcontroller. It is a 40 pin microcontroller with 128 bytes RAM & 4kb flash memory.

It performs all the functions like getting data from ADC, Comparing the current temperature to set temperature, Turning ON/OFF the relay & displaying the temperature & Set Point on the LCD.

2. ADC:

The output of the temperature sensor is an analog signal & cannot be directly given to the microcontroller. We need to convert this analog signal into digital so we will be using MCP3201 which is a successive approximation 12-bit ADC. The controller communicates with this device using SPI Protocol.

3. Temperature Sensor:

We are using LM 35 as temperature sensor. LM 35 is a precision temperature sensor whose output is linearly proportional to Celsius Temperature. The LM35 is rated to operate from -55° Centigrade to 150° Centigrade with a linear scale factor of +10mv/° C.

4. MAX 232

Microcontroller communicates with the PC using its inbuilt Serial Port. The voltage levels are 0 & 5 Volts, but for the controller to communicate with the PC we are using RS232 protocol so for converting the CMOS (0-5) voltage levels into RS232 (±12) voltage levels we will be using MAX 232.

The MAX232 is an integrated circuit that converts signals from an RS-232 serial port to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS signals.

The drivers provide RS-232 voltage level outputs (approx. ± 7.5 V) from a single + 5 V supply via on-chip charge pumps and external capacitors. This makes it useful for implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V to + 5 V range, as power supply design does not need to be made more complicated just for driving the RS-232 in this case.

Page 8: PC based Temperature controller

Page

The receivers reduce RS-232 inputs (which may be as high as ± 25 V), to standard 5 V TTL levels. These receivers have a typical threshold of 1.3 V, and a typical hysteresis of 0.5 V.

5. PC:

The PC is used to display the Set/Current Temperature as well as edit the set temperature. VB based software is used to display & edit the information.

6. Relay Driver:

The Relays require suitable ‘PULL IN’ current or ‘HOLDING’ current (around 70ma) to turn it ON. Moreover the Relay coil voltage (12volts) is more that what the controller can handle. So to provide the necessary current & at the required voltage a relay driver circuit is required.

7. Relay:

Relays are components which are basically used to turn ON/OFF high current or Voltages devices. A relay is TURNED ON when a sufficient holding current is passed through its coil. We are using 12v SPDT relay i.e. the voltage required to energize the coil is 12v and of Single Pole Double Throw (SPDT) type i.e. it consists of one common Pole & two outputs namely the Normally Open (NO) & Normally Closed (NC) outputs.

8. Power Supply:

We require regulated 5 volts for microcontroller, ADC, Temperature Sensor, LCD & approximately 12 volts for the Relay. These voltages are generated from 230v line voltage.

Page 9: PC based Temperature controller

Page

Algorithm:

1. Start

2. Initialize Input & Output Pins.

3. Initialize Baud Rate for serial communication.

4. Initialize Timer for Half second.

5. Set the default Temperature Set Point as 45°C.

6. Check if any data received from PC if YES GO TO 13.

7. Check if half second over if no GO TO 6.

8. Get reading from ADC.

9. Convert the ADC reading into Temperature.

10. Compare the CURRENT Temperature with the SET Temperature.

11. If Current Temperature ≥ SET Temperature then Turn OFF the Relay and GO TO 6.

12. If Current Temperature < SET Temperature then Turn ON the Relay and GO TO 6.

13. Is COMMAND received from PC is UPDATE SET TEMPERATURE?

14. If YES then get the new SET Temperature & GO TO 6.

15. Is COMMAND received from PC is SEND SET TEMPERATURE?

16. If YES then SEND the SET Temperature to PC & GO TO 6.

17. Is COMMAND received from PC is SEND CURRENT TEMPERATURE?

18. If YES then SEND the CURRENT Temperature to PC & GO TO 6.

19. GO TO 6.

20. Stop.

Page 10: PC based Temperature controller

Page

Circuit Diagram:

Page 11: PC based Temperature controller

Page

Explaination of Circuit Diagram:

Microcontroller:

A microcontroller (sometimes abbreviated µC or uC) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals.

Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, and toys. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems.

Microcontroller, which is a single IC containing specialized circuit and functions that are applicable to Mechatronics system design. It contains a microprocessor, memory, I/O capabilities and other on chip resources. It is basically a microcomputer on a single IC. Examples of microcontrollers are Microchip's PIC, Motorola's 68HC11, Atmel’s 89C series and Intel's MCS-15 series etc. Micro-controllers are becoming essential in industrial products (as opposed to PCs) since they provide functionality at lower costs. They are portable and cheaper.

89c series Microcontroller:

The 89c series is a low-power, high-performance CMOS 8-bit microcomputer with Flash programmable and erasable read only memory (PEROM).

Here We are using ATMELS AT89c/s51 microcontroller. The controller executes instructions as per the clock cycles; this clock is generated using a crystal which is connected to the XTAL1 & XTAL2 pin of the microcontroller, the two capacitors C1 & C2 are connected between the two XTAL pins & the ground. They are required for the crystal to oscillate.

A Power ON reset circuit is connected to the RESET pin of the microcontroller, the controller must be reseted properly whenever is power is turned on, which is done by applying a Vcc to the reset pin & for normal operation of the controller the pin should be pulled low. So an RC (R1, C3) circuit is connected to the RST (9) pin of the microcontroller. Whenever the power is turned ON the Capacitor is fully charged & the RST pin gets 5 v. Then the capacitor slowly discharges through the resistor & is then pulled to ground. Microcontrollers Port 0 does not have an Internal Pull Up resistor so we need external Pull Up resistors on port 0. For which we use 9-Pin SIP resistor which are basically eight resistors with one end common.

Features of Microcontroller:

80C51 core architecture 32KB of on chip Flash memory

Page 12: PC based Temperature controller

Page

2KB of on chip flash for boot loader Three-Level Program Memory Lock 128 x 8-Bit Internal RAM 32 Programmable I/O Lines Two 16-Bit Timer/Counters Six Interrupt Sources 2KB of on chip EEPROM Read slash write cycle: 100K 14-source 4 level interrupts Compatible with MCS-51™ Products 4K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Programmable Serial Channel Low Power Idle and Power Down Modes

Components: XTAL=11.0592 MHz, C1=C2= 33pf, R1=10kΩ, C=10uf

MAX 232:

MAX 232 is a line driver intended for RS 232 protocol. It works on 5v but for RS 232 protocol it generates ±12 volts. So basically it requires converting 5 volts to ±12 volts, for which it has inbuilt Voltage Doubler circuit & a Voltage Inverter circuit. For these two inbuilt circuits we require to provide external capacitors. Capacitors C6 & C7 are for the Voltage Doubler circuit where as capacitor C8 & C9 are for the Inverter circuit. Capacitor C10 is connected between the Vcc & ground it is basically as a decoupling capacitor to decrease the noise generated in the Vcc.

Features of MAX232:

Superior to Bipolar Operate from Single +5V Power Supply (+5V and +12V

—MAX231/MAX239) Low-Power Receive Mode in Shutdown

(MAX223/MAX242) Meet All EIA/TIA-232E and V.28 Specifications Multiple Drivers and Receivers 3-State Driver and Receiver Outputs Open-Line Detection (MAX243)

Page 13: PC based Temperature controller

Page

Temperature Sensor:

Since we are using LM 35 as the temperature sensor we can directly connect it to the ADC. The output of LM 35 is linear changing at +10mv/°C this change can be easily detected by the ADC hence there is no need of an amplifier circuit.

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling.

Features of LM35:

Calibrated directly in ° Celsius (Centigrade) Linear + 10.0 mV/°C scale factor 0.5°C accuracy guaranteeable (at +25°C) Rated for full −55° to +150°C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts Less than 60 μA current drain Low self-heating, 0.08°C in still air Nonlinearity only ±1⁄4°C typical Low impedance output, 0.1 W for 1 mA load

Components: Temperature Sensor= LM35

ADC:

Analog to digital conversion is an electronic process in which continuously variable (analog) signal is changed, without alternating its essential contents, into multilevel (digital) signal. It compares the analog input voltage to know reference voltage and then produces a digital representation of this analog input. Output of an ADC is digital binary code. By its nature, an ADC introduces quantization error. This is the simply the information that is lost, because for continuous analog signal there are an infinite no of voltages but only a finite no of ADC digital codes. The more digital code that the ADC can resolve the more resolution it has and the less information lost to quantization error.

The digital data can be stored, manipulated for further use. Less storage space compared to mechanical data storage devices strip charts. High speed data acquisition is possible. These are available as 8-bit, 12-bit, 24-bit etc. also called as resolution. Data available at discrete time step.

Types of ADC:

Successive Approximation Converters.

Page 14: PC based Temperature controller

Page

Flash Converters. Dual Slope A to D Converters Charge Balancing Converter Sigma-Delta Converter

We are using MCP 3201 ADC. MCP 3201 is a 12 bit ADC with SPI Interface, so we require only three lines to communicate with it. Since the microcontroller has an internal pull up resistor of 10KΩ the controller cannot provide the necessary current for the ADC to detect if the pin is HIGH or LOW so external pull ups are required on all the lines. As you can see three pull up resistors R7, R8 & R9 are used one for each line.

Features of 3201 ADC:

12-bit resolution On-chip sample and hold SPI™ serial interface (modes 0,0 and 1,1) Single supply operation: 2.7V - 5.5V 100ksps max. sampling rate at VDD = 5V 50ksps max. sampling rate at VDD = 2.7V Low power CMOS technology Industrial temp range: -40°C to +85°C

Components: ADC= MCP 3201, Resistor R7, R8 & R9=4.7kΩ.

Relay and Relay Driver Section:

Relays are devices which allow low power circuits to switch a relatively high Current/Voltage ON/OFF. For a relay to operate a suitable pull-in & holding current should be passed through its coil. Generally relay coils are designed to operate from a particular voltage often its 5V or 12V. Over here we have used a 12v relay with which we can switch 5A load current. This relay is also commonly known as CUBE Relay. The relay basically consists of five terminals, two of them are used for the coil & the remaining three consists of a common pole & one Normally Closed (NC) & Normally Open Pole.

The function of relay driver circuit is to provide the necessary current (typically 50 to 100ma) to energize the relay coil. The relay driver section consists of NPN transistor BC547 which is labeled as Q1. The transistor is driven into saturation (turned ON) when a LOGIC 1 is written on the PORT PIN thus turning ON the relay. The relay is turned OFF by writing LOGIC 0 on the port pin.

A diode (1N4148) is connected across the relay coil; this is done so as to protect the transistor from damage due to the BACK EMF generated in the relay's inductive coil when the transistor is turned

Page 15: PC based Temperature controller

Page

OFF. When the transistor is switched OFF the energy stored in the inductor is dissipated through the diode & the internal resistance of the relay coil.

An LED is used to indicate the status of the Relay; the LED is turned ON when the relay is turned ON. The resistor R4 in series with the LED is current limiting resistor as the LED cannot be directly connected across the coil of the relay.

A resistor is connected between the Vcc & the base of the transistor this resistor is called as a Pull Up resistor. Inside the controller there is a similar 10KΩ pull up resistor. So when the Port pin is pulled high the current flows through this 10kΩ resistor. Because of this resistor the maximum current base current will be Ibase = 5v/10KΩ = 0.5ma, The Transistor BC547 has a DC current gain (hfe) of about 100. So the maximum collector current will be 0.05ma X 100 = 50ma. This is not sufficient to Turn ON the Relay, so an external pull up resistor R6 is used. We will be using a 4.7 KΩ resistor so now when the port pin is High the current will flow through the controllers internal 10 KΩ resistor as well as the external 4.7 KΩ resistor so the maximum base current will be Ibase = 5v/10KΩ + 5v/4.7KΩ= 0.5 + 1.06ma ≈ 1.5ma, so the maximum collector current will be 1.5ma X 100 = 150ma, which is sufficient to turn ON the relay.

Components: R4=R6=4.7KΩ, Q1= BC547, D5= 1N4148, Relay= 12v, 5A SPDT Cube relay, LED=3mm Transparent RED LED

Keypad Section:

In all 2 switches are connected to the controller. One end of the switch is connected to the controller & the other end is connected to Ground. Normally the port pins are pulled high. So when a switch is pressed the controller pin gets a low signal. There is a problem in practically interfacing these switches to the controller. In the above case you have considered the switches to be an IDEAL SWITCH where when the switch is pressed the controller directly gets LOGIC 0. But practically when a switch is closed the contacts open & close rapidly for about 20ms. This is called as SWITCH BOUNCING. Even though 20ms is very short time in human terms for a microcontroller it is a very long time. Without SWITCH DEBOUNCING the controller will think that the switch was pressed many times. To avoid such a problem the code has been modified where the switch is polled continuously for some time & if in that duration the switch does not get HIGH it is assumed that the switch has been pressed properly.

Power Supply:

Power supply is supply of electrical power. A device or system that supplies electrical or other types of energy to an output load is called a power supply unit or PSU. There are different types of power supplies e.g. Battery power supply, unregulated power supply, linear or regulated power supply etc.

All digital circuits require regulated power supply. In this article we are going to learn how to get a fixed regulated positive supply from the mains supply.

Page 16: PC based Temperature controller

Step DownTransformer Transformer

VoltageRegulator

Filter Capacitor FCapacitor

Rectifier230V AC

Regulated

Voltage

Page

Fig given below shows the basic block dig of fixed regulated power supply.

We require 5 volts for microcontroller, LCD, EEPROM & approximately 12 volts for the Relay. These voltages are generated from 230v line voltage. Initially A step down Transformer is used to step down 230volts to 9olts, so a 0-9; 500ma step down transformer is used. The output of the step down transformer is also AC, we convert this AC voltage into DC by using a Full wave bridge rectifier consisting of Diodes D1, D2, D3 & D4. During the positive half cycle diodes D1 & D4 conduct whereas in the negative half cycle diodes D2 & D3 conduct thus the diodes keep switching the transformer connections so we get positive half cycles in the output.

Even though half wave & full wave rectifier give DC output, none of them provides a constant output voltage.

For this we require to smoothen the waveform received from the rectifier. This can be done by using a capacitor at the output of the rectifier this capacitor is also called as “FILTER CAPACITOR” or “SMOOTHING CAPACITOR” or “RESERVOIR CAPACITOR”. Even after using this capacitor a small amount of ripple will remain.

We place the capacitor at the output of the rectifier the capacitor will charge to the peak voltage during each half cycle & then will

Page 17: PC based Temperature controller

Page

discharge its stored energy slowly through the load while the rectified voltage drops to zero, thus trying to keep the voltage as constant as possible.

If we go on increasing the value of the filter capacitor then the Ripple will decrease. But then the costing will increase. The value of the Filter capacitor depends on the current consumed by the circuit, the frequency of the waveform & the accepted ripple.

C=VrF/I

Where,

Vr= accepted ripple voltage.( should not be more than 10% of the voltage)

I= current consumed by the circuit in Amperes.

F= frequency of the waveform.

After filtering the rectifier output the signal is given to a voltage regulator. The maximum input voltage that can be applied at the input is 35V.Normally there is a 2-3 Volts drop across the regulator so the input voltage should be at least 2-3 Volts higher than the output voltage. If the input voltage gets below the Vmin of the regulator due to the ripple voltage or due to any other reason the voltage regulator will not be able to produce the correct regulated voltage. We require 5v output so we use IC 7805 where 78 indicates that it’s a positive series & the 05 indicates the output voltage.

Another capacitor C4 is used after the voltage regulator, this is used to remove any ripples or noise generated in the Vcc. D7 is an LED used to indicate the Power Status.

Components: Transformer: Step Down 0-9; 500ma, Diodes: 1n4007 (D1, D2, D3 and D4), Capacitor (c11) = 1000uf, Voltage Regulator= 7805, Capacitor C4 = 100uf, Resistor R10 =2.2KΩ. LED1 = 3mm Transparent white LED.

List of Components: Resistors

R1=100K

R2=1K

R3-R7=2.2K

Capacitors

Page 18: PC based Temperature controller

Page

C1,C2=33pf

C3,C6-C9=10uf

C4,C5,C10=100uf

C11=470uf

Integrated Circuits

U1=AT89C52,

U2=MAX232,

U3=MCP 3201,

DIODE

D1-D4=IN4007

D5=4148

CONNECTORS

CON1=FROM TRANSFORMER

CON2=RELAY O/P

CON3=TO PC

CON4=LM34

CRYSTAL

X1=11.0592Mhz

RL1=RELAY

T01=7805,Vtg regulater

T02=BC547

LED1,LED2=POWER LED

Page 19: PC based Temperature controller

Page

Layouts:

Page 20: PC based Temperature controller

Page

Future Scope and Application:

Advantages:

Dis-advantages:

Bill Of Material:

Bibliography or References: