Temperature Dependent Speed Controller Using Thermistor Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

This project is a standalone automatic fan speed controller that controls the speed of an electric fan according to our requirement. This closed loop feedback control system is efficient and reliable by using embedded technology . Micro controller (AT89C51) allows dynamic and faster control. Liquid crystal display (LCD) makes the system user-friendly. The sensed temperature and fan speed level values are simultaneously displayed on the LCD panel. It is very compact using few components and can be implemented for several applications including air-conditioners, water-heaters, snow meltars, ovens, heat-exchangers, mixers, furnaces, incubators, thermal baths and veterinary operating tables. AT89C51 micro controller is the heart of the circuit as it controls all the functions.

The temperature sensor thermistor senses the temperature and converts it into an electrical (analog) signal, which is applied to the micro controller through ADC. The analog signal is converted into digital format by the analog to-digital converter (ADC). The sensed and set values of the temperature are displayed on the 16x2-line LCD. The micro controller drives control relays by means of ULN driver circuit to control the fan speed with the help of high wattage tagged wire wound resistor. Single pole dabble throw (SPDT) relays are connected to the micro controller through a ULN driver circuit. The relays require 12 volts at a current of around 50 mA, which cannot provided by the micro controller. So the ULN driver circuit is added. The relays are used to operate the electrical fan or for operating any other electrical device. Normally the relays remain off. As soon as pin of the micro controller goes high, the relays operate

This project uses regulated 5V, 500mA & 12V, 500mA power supply. 7805 and 7812 three terminal voltage regulators are used for voltage regulation. Bridge type full wave rectifier is used to rectify the ac out put of secondary of 230/12V step down transformer. This project is useful in process industries for maintenance and controlling temperature.


There are different types of processors and controllers available in the market. Industrial and control application/may require automation of the process such as temperature, pressure, liquid flow, etc., in order to minimize manual intervention. To automate any application an intelligent controller plays a major role. One such controller proposed for the project is AT89C51, an 8-bit microcontroller.

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM). The device is manufactured using Atmel's high density nonvolatile memory technology and is compatible with the industry standard MCS-51â„¢ instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a con- ventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control appli- cations

The AT89C51 provides the following standard features: 4Kbytes of Flash, 128 bytes of

RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt

architecture, a full duplex serial port, on-chip oscillator and clock circuitry.In addition,

the AT89C51 is designed with static logic for operation down to zero frequency and

supports two software selectable power saving modes. The Idle Mode stops the CPU

while allowing the RAM, timer/counters, serial port and interrupt system to continue

functioning. The Power-down Mode saves the RAM contents but freezes the oscillator

disabling all other chip functions until the next hardware reset.


As the system under consideration is using AT89C51 microcontroller it has 4K Bytes of In-System Reprogrammable Flash Memory and EPROM for its purposes. The ATMEL AMR code is stored in an inbuilt flash memory. Flash memory cannot be reprogrammed constantly. The temperature sensor device also supports the storage of last ten pairs of measurements and new measurements are over written to the older one. Hence this system is using EEPROM as a data storage memory. Even though EEPROM is slower than Flash memory it can be rewritten as many number of times as wanted.

Memory Organization

The information presented in this chapter is collected from the Microcontroller Architectural Overview, AT89C51, AT89LV51, AT89C52, AT89LV52, AT89C2051, and AT89C1051 data sheets of this book. The material has been selected and rearranged to form a quick and convenient reference for the programmers of Atmels microcontroller family of devices. This guide pertains specifically to the AT89C51, AT89LV51, AT89C52, and AT89LV52.

Memory Organization

Program Memory

The AT89C Microcontroller has separate address spaces for program memory and data memory. The program memory can be up to 64 Kbytes long. The lower addresses may reside onchip. Figure 1 shows a map of the AT89C51 program memory, and Figure 2 shows a map of the AT89C52 program memory. The AT89C10512051 do not have off-board memory expansion. Figure 1. AT89C51 Program Memory

Flash Microcontroller Memory Organization

Figure 2. AT89C52 Program Memory


Data Memory

The AT89C can directly address up to 64 Kbytes of data memory external to the chip. The MOVX instruction accesses the external data memory. (Refer to the Instruction Set section in this chapter for a detailed description of instructions). The AT89C51 has 128 bytes of on-chip RAM (256 bytes in the AT89C52) plus a number of Special Function Registers (SFRs). The lower 128 bytes of RAM can be accessed either by direct addressing (MOV data addr) or by indirect addressing (MOV Ri).


ADC0804 (Analog to Digital Converter)

Figure 3 illustrates the main function of the ADC0804 i.e. to convert the input signal from temperature

sensor device to voltage form that has 8-bit output. This device acts as a memory location or port entry

to the microprocessor and does not require additional logic extension.

ADC0804 design.

To prove that this design is according to the specifications hardware, the formula used is as


ADC out = Ain / Vmax X 256 (1.2)

where ADC out = digital output value

Ain = Input Gain

Vmax = Maximum voltage

Using formula (1.2), it is found that:

without amplifier, ADC out = Ain / Vmax X 256

= (1/5) X 256

= 51 D

= 00110011 B

So that, the temperature value is = 100 / 51 = 1.96°C ≅ 2°C

If using amplifier, ADC out = Ain / Vmax X 256

= (5 /5) X 256

= 256 D

= 1111 1111 B (Proved)

ADC 0804 Analog to digital converters find huge application as an intermediate device to convert the signals from analog to digital form. These digital signals are used for further processing by the digital processors. Various sensors like temperature, pressure, force etc. convert the physical characteristics into electrical signals that are analog in nature.


ADC0804 is a very commonly used 8-bit analog to digital convertor. It is a single channel IC, i.e., it can take only one analog signal as input. The digital outputs vary from 0 to a maximum of 255. The step size can be adjusted by setting the reference voltage at pin9. When this pin is not connected, the default reference voltage is the operating voltage, i.e., Vcc. The step size at 5V is 19.53mV (5V/255), i.e., for every 19.53mV rise in the analog input, the output varies by 1 unit. To set a particular voltage level as the reference value, this pin is connected to half the voltage. For example, to set a reference of 4V (Vref), pin9 is connected to 2V (Vref/2), thereby reducing the step size to 15.62mV (4V/255). 


ADC0804 needs a clock to operate. The time taken to convert the analog value to digital value is dependent on this clock source. An external clock can be given at the Clock IN pin. ADC 0804 also has an inbuilt clock which can be used in absence of external clock. A suitable RC circuit is connected between the Clock IN and Clock R pins to use the internal clock.


Pin Diagram: 

An ADC is an electronic device that converts continuous signals to discrete digital numbers. The reverse operation is done by a DAC. The digital output may be using different coding schemes such as binary and two's compliment binary.

Most ADC's are of a type known as linear which means that the range of input values that map to each output value has a linear relationship with the output value.

The ADC used is an IC, ADC 0804.


 Compatible with 8080 µP derivatives-no interfacing logic needed - access time - 135 ns

ï‚· Easy interface to all microprocessors, or operates "stand alone"

ï‚· Differential analog voltage inputs

ï‚· Logic inputs and outputs meet both MOS and TTL voltage level specifications

ï‚· Works with 2.5V (LM336) voltage reference

ï‚· On-chip clock generator

ï‚· 0V to 5V analog input voltage range with single 5V supply

ï‚· No zero adjust required

ï‚· 0.3[Prime] standard width 20-pin DIP package

ï‚· 20-pin molded chip carrier or small outline package

ï‚· Operates ratiometrically or with 5 VDC, 2.5 VDC, or analog span adjusted voltage reference


Many scheduling algorithm have been studied to guarantee the real time constraints of real time process. Scheduling decisions of this algorithm is usually based on parameters which are assumed to be crisp. However, in many circumstances the values of these parameters are vague. The vagueness of parameters suggests us to make the usage of fuzzy logic to decide in what order the request should be executed to better utilize the system and as a results reduce the chance of a request being missed. Our main contribution is proposing a fuzzy approach to microprocessor/microcontroller real time scheduling in which the scheduling parameters are treated as fuzzy variables.


The temperature measurement device Resistance Temperature Detector a measure temperature in the range of -25-150 degree Celsius. But in this application the temperature inside the container is maintained at 25 degree Celsius. There is no much deviation of temperature inside the container. The container temperature doesn't vary that much in a second. The resolution of the device is 0.1 degree Celsius if the temperature inside the container varies more than the 0.1 degree Celsius the temperature sensing device can able to detect and the output will be shown. Suppose the temperature inside the container is changing at the rate of 0.1 degree Celsius per second the output has the frequency of 1 Hz. So the sampling rate for the device to sample or measure the temperature needn't be that high. So the device is using a sampling rate of 1 for measuring temperature i.e. temperature measurement device is having a sampling frequency of 1 HZ. Number of bits per second will be 10 bits per second (1 HZ*10 bits) which can be easily handled by 10 bit ATMEL ADC.

Temperature Sensor Resolution - 0.1 degree Celsius

Temperature change inside the container - 1 degree Celsius per minute

So the frequency would be - 0.6 HZ

Sampling frequency = 0.6*5 = 3Hz (to be greater)

Sampling rate = 0.3 Seconds 


There are basically four types of real times scheduling algorithm

Round Robin

Round Robin with interrupt

Function queue scheduling

RTOS( Real Time Operating System)


It is the simplest algorithm. The Round Robin algorithm is characterized by the absence of interrupts. The algorithm consists of a main loop that checks each I/O device in turn and Service them if needed. it cannot suffer from shared data problems. Latency is limited by the maximum duration of a loop cycle. Attractive for simple environments. At the same time the disadvantage for the algorithm is it cannot set priorities. Its worst case wait for an important task code is the sum of execution time of all the other task code.


The main advantage of Round Robin with interrupt routines deals with the very urgent needs of devices. Interrupt routines set flags to indicate the interrupt happened. Main while loop polls the status of the interrupt flags and does any            follow up process required by a set flag. It moves more control over priority.


The advantage of function queue scheduling is latency for high priority devices can be reduced compared to Round-Robin with Interrupts. In Round-Robin with Interrupts every loop may end up executing every follow-up task. Function-Queue Scheduling guarantees that at most a single follow-up task is executed per loop iteration. The main disadvantage is latency for low priority tasks can increase. Low priority tasks can actually starve. Queuing algorithm may be complex/costly to run/code. If a low priority follow-up task is very time consuming the latency for higher priority response times will suffer.


The advantage of RTOS is interrupts signal the need for follow-up tasks. But, unlike Function-Queue Scheduling, this is handled by the Real-Time Operating System and not by the interrupt routines manipulating flags or a queue. Instead of a loop deciding what to do next the RTOS decides. One follow-up task can be suspended by the RTOS in favouring of performing a higher priority task.-Queue. Suspension of tasks allows the worst case wait for the highest priority item to be zero. Built-in scheduling mechanism yields a system with very stable response characteristics even when changes to the code occur. Widely available for purchase.

This embedded system is using Round Robin Scheduling as real time scheduling algorithm. The device is used to control only the temperature inside the steel container and so round robin architecture can be set here.


The system will fail only if the temperature exceeds the range of the temperature sensor.

Since it is a room temperature controller the variation in the room is very slow.


As the performance measure of system is totally dependent on PID Controller performance. So the PID controller performance can be evaluated by the periodic of the parameter hereafter against some baseline values. The performance improvement actions are taken accordingly on a periodic manner. So the

Process Variable



Steady state error

Settling time


Must be calculated by different values of PID controllers

Controller tuning methods provide the controller parameters in the form of

formula or algorithms. They ensure that the obtained control system would be stable and would meet. These methods require certain knowledge about the controlled process. This knowledge, which depends on the applied method, usually translates into a transfer function. The objectives which should be achieved by the application of the control system are associated with the  control system features Regulating performance, Tracking performance, Robustness, noise attenuation.