You are on page 1of 46

Automatic fan speed control by

using micro controller


Abstract
• Automatic controls play an ever-increasing role in a human way of
life. Automatic control is vast technological area whose central
aim is to develop control strategies that improve performance
when they applied to a system. the distinct characteristic of
automatic control is that it reduces the human operator. One such
gadget is the fan. The fans are generally available with speed
control, depending on the requirement the speed is set. Usually,
when the temperature is high the fan set at high speed and at
lower temperatures the fan is operated with lower speed. This is
done manually using human. In this paper, an automatic control
solution is suggested to control the fan speed. A circuit with LM35
temperature sensor, PIC16F877A microcontroller. As an additional
feature LCD is used to present the temperature. Finally, the
designed system circuit is tested in many times and performed
very well.
Introduction
• Electric fan is one of the most popular electrical devices due
to its cost effectiveness and low power consumption
advantages. It is a common circuit and widely used in many
applications. It is also one of the most sensible solutions to
offer a comfortable and energy efficient. In fact, the fan has
been long used and still available in the market. Nowadays,
the demand for accurate temperature control and air
freshening control has conquered many of industrial
domains such as process heat, automotive, industrial places
or office buildings where the air is cooled in order to
maintain a comfortable environment for its occupants. One
of the most important concerns involved in heat area
consist in the desired temperature achievement and
consumption optimization.
Cont..
• Fan can be controlled manually by pressing on the switch button.
where in this method, any change in the temperature will not give
any change in the fan speed. except the usage change the speed
of the fan which is manually. So, an automatic temperature
control system technology is needed for the controlling purpose in
the fan speed according to the temperature changes. Many
researches focusing on automatic temperature control system
application in different fields will gain the benefits. For examples,
an automatic temperature controller for multi element array
hyperthermia systems multi-loop automatic temperature control
system design for fluid dynamics, design of automatic
temperature- control circuit module in tunnel microwave heating
system , the automatic temperature system with Fuzzy self-
adaptive Proportional Integral-Derivative (PID) control in
semiconductor laser.
Cont..
• This paper will show how PIC16F877A
microcontrollers can be used and applied in a
real-world application. One practical use is to
integrate a microcontroller in a temperature
control system that can be used for
automatically controlling a room temperature.
Proposed system
• The microcontroller PIC16F877A, is the heart
of the system. It accepts inputs from the
temperature sensor, LM35 which allows for
the measurement of the current room
temperature, then the controller will give the
action to maintain the required fan speed.
LCD is used to display the fan speed and room
temperature.
Block diagram
Power
supply

LCD

Temperature
sensor pic16f877a

Relay

Fan
PIC microcontroller
This presentation contains illustrations from the book
‘Programming 8-bit PIC Microcontrollers in C’

Part 1 Microcontroller Systems


describes in detail the internal architecture and interfaces
available in the PIC 16F887A, a typical PIC chip, as well as
outlining the main features of the development system

Part 2 C Programming Essentials


provides simple example programs for the microcontroller
which show the basic principles of C programming,
and interfacing to basic I/O devices

Part 3 C Peripheral Interfaces


provides example programs for operating PIC chips with a
full range of peripherals, using timers and interrupts
Figure 1.1 Elements of a digital controller

Input Output
User input Peripherals CPU Peripherals User output

Central
Processing
ROM Unit RAM
Program Read Only Read & Write
download Memory Memory

The microcontroller contains all these elements in one chip


Figure 1.2 16F877 pin-out

The microcontroller pins have multiple functions


Figure 1.3 PIC 16F877 MCU Block diagram

Flash Program Counter


ROM (13 bits)
Program
Memory Address
8192
x 14 bits
Stack RAM
0000 – 1FFF 13 bits File
x 8 levels Registers
Instructions 368
X 8 bits

Instruction Register 000-1FF


File Address

Program address

Working (W) File Select


Register Register
Literal
Arithmetic & Logic
Unit
Status bits
Status (Flag)
Op- Register
Data Bus
code
(8 bits)

EEPROM
Instruction MCU 256 bytes
Decode & control
CPU control lines
Ports, Timers
ADC, Serial I/O

Timing control

Clock Reset
Port A B C D E

Shows the main parts of the chip in simplified form


Table 1.1 PIC16F877 simplified file register map
Bank 0 (000 – 07F) Bank 1 (080 – 0FF) Bank 2 (100-180) Bank 3(180-1FF)

Address Register Addre Register Addre Register Addre Register


ss ss ss
000h Indirect 080h Indirect 100h Indirect 180h Indirect

001h Timer0 081h Option 101h Timer0 181h Option

002h PC Low 082h PC Low 102h PC Low 182h PC Low

003h Status Reg 083h Status Reg 103h Status Reg 183h Status Reg

004h File Select 084h File Select 104h File Select 184h File Select

005h Port A data 085h PortA direction 105h - 185h -

006h Port B data 086h PortB direction 106h Port B data 186h PortB direction

007h Port C data 087h PortC direction 107h - 187h -

008h Port D data 088h PortD direction 108h - 188h -

009h Port E data 089h PortE direction 109h - 189h -

00Ah PC High 08Ah PC High 10Ah PC High 18Ah PC High

00Bh Interrupt 08Bh Interrupt 10Bh Interrupt 18Bh Interrupt


Control Control Control Control
00Ch 20 Peripheral 08Ch 20 Peripheral 10Ch 4 Peripheral 18Ch 4 Peripheral
to Control to Control to Control to Control
01Fh Registers 09Fh Registers 10Fh Registers 18Fh Registers
020h 80 General 0A0h 80 General 110h 96 General 190h 96 General
to Purpose to Purpose to Purpose to Purpose
06Fh Registers 0EFh Registers 16Fh Registers 1EFh Registers
070h 16 Common 0F0h Accesses 170h Accesses 1F0h Accesses
to Access GPRs to 70h – 7Fh to 70h – 7Fh to 70h – 7Fh
07Fh 0FFh 17Fh 1FFh
Figure 1.4 I/O pin operation

Write TRIS bit Data


Direction Tri-state
Latch Output
Enable

Output Output
CPU Data Bus
Data Current
Latch Driver
Write data bit

Input
Data
Read data bit Latch

Analogue input
multiplexer

The pin can be set for input or output data transfer


Figure 1.5 General Timer Operation

Capture signal
Capture register

Timer
Instruction Clock Overflow/
Clock Pre-scaler Post-scaler
Timeout
Source (clock Binary Counter (output
(Interrupt)
Select divide) divide)
Flag
External Pulse

Compare register Match flag

A binary counter is used as a timer when driven from the clock


Figure 1.6 ADC operation

Input volts 0-Vf ANx Setup ADC

Analogue Read ADC


to Digital
Converter
8-bit or 16-bit
Reference volts, Vf Vref+ integer result

The ADC converts an analog input into a binary code


Figure 1.7 Comparator operation

Vc+

Compartor
status bit
Vc- Vc+ > Vc-

The comparator simply sets a bit if one input is higher than the other
Figure 1.8 Parallel Slave Port operation

Chip select Interrupt


Read Parallel
Write Slave
Port

EXTERNAL INTERNAL
Data x 8 Data x 8

The PSP allows an external data bus to be connected to the MCU


Table 1.3 Interrupts sources in the PIC 16F877

Interrupt Source Interrupt trigger event CCS C Interrupt label


TIMERS
Timer 0 Timer 0 register overflow INT_TIMER0
Timer 1 Timer 1 register overflow INT_TIMER1
CCP 1 Timer 1 capture or compare detected INT_CCP1
Timer 2 Timer 2 register overflow INT_TIMER2
CCP2 Timer 2 capture or compare detected INT_CCP2
PORTS
RB0/INT pin Change on single pin RB0 INT_EXT
Port B pins Change on any of four pins RB4 – RB7 INT_RB
Parallel Slave Port Data received at PSP (write input active) INT_PSP
Analog Converter A/D conversion completed INT_AD
Analog Comparator Voltage compare true INT_COMP
SERIAL
UART Serial Port Received data available INT_RDA
UART Serial Port Transmit data buffer empty INT_TBE
SPI Serial Port Data transfer completed (read or write) INT_SSP
I2C Serial Port Interface activity detected INT_SSP
I2C Serial Port Bus collision detected INT_BUSCOL
MEMORY
EEPROM Non-volatile data memory write complete INT_EEPROM
Figure 1.9 Timer Interrupt Process

Program Execution

1 2
Start counter Run
statement Counter
until
overflow
Program Execution

3
Timeout
Interrupt
4
Jump to
ISR
7
Continue

5
Time-out
Process
(Interrupt
Service 6
Routine) Return
from
Interrupt

Time-out forces the program to be suspended and the ISR executed


Figure 1.10 USART RS232 Signal

HOST PC
PIC MCU

TX1 Transmit RX2


Line
Driver +/- 12V
RX1 Receive TX2
Interface
COM PORT
Ground Ground

Line drivers convert the signal to a bipolar, higher voltage


Figure 1.11 Typical USART RS232 signal

Bit period

0
Time
Idle Start Bit Bit Bit Bit Bit Bit Bit Bit Stop
Bit 0 1 2 3 4 5 6 7 Bit

The data bits are timed from the falling edge of the start bit
Figure 1.12 SPI Connections

Master

Serial Data Out, SDO


Serial Data In, SDI
Serial Clock, SCK

Slave 1 Slave 2

SDO SDO
SDI SDI
SCK SCK

!SS !SS

Slave Select SS1


Outputs SS2
SS3

SPI uses hardware slave selection and separate clock


Figure 1.13 SPI Signals

SDO/SDI 7 6 5 4 3 2 1 0 Data bits

SCK Clock

Each data bit is transferred on the falling edge of the clock


Figure 1.14 I2C Connections

+5V Master Slave1 Slave2 etc

SDA
SCL

Slave selection uses addresses issued by the Master


Figure 1.15 I2C Signals

Start Acknowledge
Address / Data bits

SDA 7 6 5 4 3 2 1 0

SCL

Data is strobed in using the master clock, and reception


is acknowledged by the slave by taking the data line low
Figure 1.18 ICSP target board connections

Application Board

Reset
MCU
10k
1 Vpp/!MCLR
ICSP Vdd
2
Interface Vss
3
4 PGD
5 PGC
Vdd Vss
Board +5V Supply

Connections to the target chip for programming


Figure 1.21 ICD2 program and debug system

Host PC
MPLAB PIC MCU
development ICD2 Target
system USB interface System
6-WAY
+ C Compiler connector

Block diagram of the ICD2 programming and in-circuit debugging system


LCD
LCD (Liquid Crystal Display) screen is an electronic display module and find a
wide range of applications. A 16x2 LCD display is very basic module and is
very commonly used in various devices and circuits. These modules are
preferred over seven segments and other multi segment LEDs.

A 16x2 LCD means it can display 16 characters per line and there are 2 such
lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD
has two registers, namely, Command and Data.

A command is an instruction given to LCD to do a predefined task like


initializing it, clearing its screen, setting the cursor position, controlling display
etc. The data register stores the data to be displayed on the LCD. The data is the
ASCII value of the character to be displayed on the LCD. Click to learn more
about internal structure of a LCD.
Pin Diagram:
Pin Description:
Pin
Function Name
No
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
Selects command register when low; and data register Register
4
when high Select

Low to write to the register; High to read from the


5 Read/write
register

6 Sends data to data pins when a high to low pulse is given Enable

7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-
Block Diagram of LCD Display
Temperature Sensor - LM35
Features of LM 35

• You can measure temperature more accurately


than a using thermistors. The sensor circuitry is
sealed and not subject to oxidation, etc.
• Possesses a low self-heating capability
• The output voltage is converted to temperature
by a simple conversion factor.
• The operating temperature range is from -55°C to
150°C.
• LM35 is a precision IC temperature sensor with
its output proportional to the temperature.
POWER SUPPLY
A power supply is a device which delivers an exact voltage to another device as
per its needs. There are many power supplies available today in the market like
regulated, unregulated, variable etc, and the decision to pick the correct one
depends entirely on what device you are trying to operate with the power
supply.
THE TRANSFORMER
• A transformer is an electrical device that transfers energy between two
circuits through electromagnetic induction.

• A transformer may be used as a safe and efficient voltage converter to


change the AC voltage at its input to a higher or lower voltage at its
output.
THE RECTIFIER
• A rectifier is an electrical device that converts alternating current (AC),
which periodically reverses direction, to direct current(DC), which flows in
only one direction. The process is known as rectification.

• A diode bridge is an arrangement of four diodes in a bridge


circuit configuration that provides the same polarity of output for either
polarity of input.
FILTERS
• Electronic filters are analog circuits which perform signal
processing functions, specifically to remove unwanted frequency
components from the signal, to enhance wanted ones, or both.

• TYPES

✓ ACTIVE FILTER

✓ PASSIVE FILTER
REGULATOR
• A voltage regulator is designed to automatically maintain a constant
voltage level. A voltage regulator may be a simple “Feed-forward" design
or may include negative feedback control loops.

• It may use an electromechanical mechanism, or electronic components.


Depending on the design, it may be used to regulate one or
more AC or DC voltages.
HOW IT WORKS

The AC mains are fed to the transformer, which steps down the 230 Volts
to the desired voltage. The bridge rectifier follows the transformer thus
converting AC voltage into a DC output and through a filtering capacitor
feeds it directly into the input (Pin 1) of the voltage regulator. The common
pin (Pin 2) of the voltage regulator is grounded. The output (Pin 3) of the
voltage regulator is first filtered by a capacitor, and then the output is taken.
Make the circuit on a general purpose PCB and use a 2 Pin (5A) plug to
connect the transformer input to the AC mains via insulated copper wires.
RELAY
What is relay

Relays are simple switches which are operated both electrically and mechanically.
Relays consist of a n electromagnet and also a set of contacts. The switching
mechanism is carried out with the help of the electromagnet.

Why is relay used?

The main operation of a relay comes in places where only a low-power signal
can be used to control a circuit. It is also used in places where only one signal can be
used to control a lot of circuits.
They were used to switch the signal coming from one source to another
destination. After the invention of computers they were also used to perform Boolean
and other logical operations. The high end applications of relays require high power to
be driven by electric motors and so on. Such relays are called contactors.
HOW RELAY WORKS?
The working of a relay can be better understood by explaining the following
diagram given below.
The diagram shows an inner section diagram of a relay. An iron
core is surrounded by a control coil. As shown, the power source is given to
the electromagnet through a control switch and through contacts to the load.
When current starts flowing through the control coil, the electromagnet
starts energizing and thus intensifies the magnetic field. Thus the upper
contact arm starts to be attracted to the lower fixed arm and thus closes the
contacts causing a short circuit for the power to the load. On the other hand,
if the relay was already de-energized when the contacts were closed, then
the contact move oppositely and make an open circuit.
Applications
• Can be used in factory automation.
• Can be use machine control.
• Chemical process, electric trains, robotics and
manipulators.
Conclusion
• This paper elaborates the design and
construction of fan speed control system to
control the room temperature. The
temperature sensor was carefully chosen to
gauge the room temperature. Besides, the PIC
microcontroller had been used to control the
fan speed, the fan speed in rpm and the room
temperature was successfully programmed
using C Language and their values displayed
on LCD.
References
• F. Zafrin, “Design and fabrication of infrared remote
controlled switch and sequential speed control of an
electrical load”, B.sc. Engineering project, RUET, July 2011.
• Vaibhav Bhatia, Gavish Bhatia,” Room Temperature based
Fan Speed Control System using Pulse Width Modulation
Technique,” International Journal of Computer Applications
(0975 – 8887), Volume 81 – No5, November 2013.
• http://en.wikipedia.org/wiki/PIC_microcontroller access on
22/1/2016.
• http://www.electrical4u.com/working-or-
operatingprinciple-of-dc-motor/ access at 25/1/2016

You might also like