A Temperature Controlled DC Fan is a system which automatically turns on a DC Fan when the ambient temperature increases above a certain limit.
Generally, electronic devices produce more heat. So this heat should be reduced in order to protect the device. There are many ways to reduce this heat. One way is to switch on the fan spontaneously.
This article describes two such circuits that automatically, switches the fan when it detects the temperature inside the device greater than its threshold value.
- Output Video
- Circuit 1 Temperature Controlled DC Fan using 8051
- Circuit Diagram
- Configuring ADC0804 for this Project
- Circuit Design
- DOWNLOAD PROJECT CODE
- Circuit 2 Temperature Controlled DC Fan using ATmega8
- Circuit Diagram
- Circuit Principle
- Component Description
- Declaring of internal ADC Registers
- Temperature Controlled DC Fan Circuit Design
- Temperature Controlling DC Motor – Circuit Simulation Video
- How Temperature Controlled DC Fan Circuit using Microcontroller Works?
- Temperature Controlled DC Motor Project Output Video
Circuit 1 Temperature Controlled DC Fan using 8051
The project works on the principle of Analog to Digital Conversion. The Analog data from the LM35 temperature sensor is given to the analog to digital converter ADC0804.
The temperature sensor’s analogue output will fluctuate by 10mV per degree Celsius.
ADC0804 is an ADC with an 8-bit resolution. With a 5V reference voltage, the resolution is 5V/28 = 20mV. That is, this is the smallest change in the analogue value from the sensor that the ADC IC can detect.
The ADC output is generated in response to temperature variations. The ADC’s digital output is fed into the Microcontroller, which uses it to determine temperature and drive the fan appropriately.
- AT89C51 Microcontroller
- AT89C51 Programmer Board
- 11.0592 MHz Quartz Crystal
- 33pF Ceramic Capacitor
- 2 x 10KΩ Resistor
- 10µF Electrolytic Capacitor
- Push Button
- 16 X 2 LCD Display
- 10KΩ POT
Temperature Sensor Section
- 10KΩ Resistor
- 150pF Ceramic Capacitor
- 1KΩ x 8 Resistor Pack
- 2N2222 NPN Transistor
- 1N4007 Diode
- 12V Relay
- 1KΩ Resistor
Configuring ADC0804 for this Project
The configuration of the ADC0804 is explained here. First, we need to connect the 5V regulated power supply to the Vcc pin (Pin 20). Then, connect the analog and digital ground pins (Pins 8 and 10) to the GND.
In order to use the internal clock, we need to connect a 10KΩ resistor between CLK IN (Pin 4 and CLK R (Pin 19) and then, connect a 150pF cap between pins 4 and GND to complete the oscillator circuit.
The CS pin (Pin 1) is connected to GND to enable the ADC.
In order to read the data from the ADC continuously by the microcontroller, we need to connect the RD pin (Pin 2) to the GND.
For the ADC to continuously read the analog data from the sensor, we need to short the Write pin (Pin 3) with the Interrupt pin (Pin 5).
The analog output of the sensor (LM35) is connected to the Vin+ (Pin 6) of the ADC. The negative analog input pin i.e. Vin- of the ADC is connected to the GND.
The converted digital data which is an 8-bit data will be available at DB0 to DB7 (Pins 18 to 11).
The main components of the project are 8051 Microcontroller, 16×2 LCD Display, LM35 Temperature Sensor, ADC0804, Relay and Fan.
The basic connections with respect to microcontroller include clock, reset and EA. Clock consists of an 11.0592 MHz crystal and two 33pF capacitors. The reset circuit consists of a 10µF capacitor, 10KΩ resistor and a push button. The EA pin is pulled high with a 10KΩ resistor.
Now we’ll see the connections with respect to other components.
For the LCD display, a 10KΩ pot is connected to contrast adjust pin. The three control pins of the LCD are connected to the pins P3.6, GND and P3.7.
The 8 data pins of the LCD are connected to PORT1 of the microcontroller.
The basic connections with respect to ADC are explained in its configuration. The 8 digital outputs of the ADC must be connected to PORT 2 of the microcontroller.
The next component we are going to connect is LM35. Connect the data pin of the LM35 to the analog input pin i.e. Pin 6 of ADC.
Finally, we need to connect the Relay circuit consisting of resistor, transistor and relay to the PORT0 of the microcontroller with PORT 0 pulled-up externally.
Connect the input of relay i.e. base of the transistor to P0.0 pin of the microcontroller.
The aim of this project is to design a temperature controlled fan using 8051 microcontroller, in which the fan is automatically turned ON or OFF according to the temperature. The working of the project is explained here.
In this circuit, the LM35 temperature sensor will give continuous analog output corresponding to the temperature sensed by it. This analog signal is given to the ADC, which converts the analog values to digital values.
The digital output of the ADC is equivalent to sensed analog voltage.
In order to get the temperature from the sensed analog voltage, we need to perform some calculations in the programming for the microcontroller.
Once the calculations are done by the microcontroller according to the logic, the temperature is displayed on the LCD. Like this, the microcontroller will continuously monitor the temperature.
If the temperature exceeds more than 50 deg Celsius (as per the code), the microcontroller will turn on the relay to start the fan. If the temperature drops below 40 deg Celsius (as per the code).
Circuit 2 Temperature Controlled DC Fan using ATmega8
The circuit’s fundamental premise is to turn on the fan attached to the DC motor when the temperature rises above a certain level.
The temperature of its surroundings is constantly measured by the microcontroller. The temperature sensor functions as a transducer, converting the temperature sensed into an electrical value. This is an analogue value that is applied to the microcontroller’s ADC pin.
The ATmega8 microcontroller includes six 10 bit resolution multiplexed ADC channels. One of the input ADC pins receives the analogue value. As a result, internal conversion takes place utilising the successive approximation method.
For ADC conversion, internal registers should be declared. The ADC pin outputs a digital value. This is compared with the threshold value by the controller which switches the fan if value is greater than threshold.
- DC motor
The LM35 is a temperature sensor that is built into an integrated circuit. This sensor’s output voltage is proportional to the temperature in degrees Celsius. The LM35’s output voltage varies at a rate of 10mV per degree Celsius.
The LM35 temperature sensor typically has a range of -55 to +150 degrees Celsius. We need to connect an extra resistor between the data pin and a negative supply of Vcc to measure the complete range of temperatures, i.e. from negative to positive.
In any case, the negative temperature range will not be considered in this project. So, under normal operating conditions, we may measure temperatures ranging from +2 degrees Celsius to +40 degrees Celsius.
Nature’s parameters are all analogue, which means that analogue signals characterise the vast majority of data in the real world. For example, suppose the temperature of the room is recorded.
The temperature of the room changes over time. Analog signal refers to a measured signal that changes over time, such as 1 second, 1.1 second, 1.2 second, and so on.
To use a microprocessor or a microcontroller to modify real-world data, we must convert analogue impulses to digital signals so that the processor or controller can read, analyse, and manipulate the data.
Declaring of internal ADC Registers
- The ATmega8 microcontroller internally has three register namely ADMUX , ADCSRA, ADC data registers. Analog to digital converter is of 10 bit resolution.
- Initially, select the reference voltage to the ADC using ADCMUX register.
- Select REFS0 and REFS1 values in ADMUX register to set the reference voltage.
- Now select the ADC channel using MUX0-MUX3 bits in ADMUX register. Below given table shows the binary value to be placed in the MUX0-MUX3 bits to select a channel.
- If the sensor is connected to ADC0 channel with AVCC with external capacitor at AREF pin, then the binary value to be assigned to the ADMUX register is ADMUX=0b01000000.
- Now select the pre scalar value using ADPS0, ADPS1 and ADPS2 bits of ADCSRA register and also enable ADC using ADEN bit in ADSCRA register.
- The following bits decide the division factor between XTAL frequency and input clock of ADC
8. Now enable start conversion bit that is ADCSC in ADCSRA register
9. After the conversion of the value, an interrupt bit is enabled by the hardware
10. Wait until interrupt bit ADIF is set to 1.
The result is stored in two data register of ADC that is ADCL and ADCH. Now read the digital value from these registers
Temperature Controlled DC Fan Circuit Design
The ATmega8 microcontroller, temperature sensor, DC motor, and driver IC are the primary components of the circuit. The temperature sensor is linked to the microcontroller’s ADC0 pin, which is the input of the ADC.
The temperature sensor has three input pins: VCC, ground, and the sensor itself. The output pin is in the middle, while the ground and VCC pins are on the other two pins. The microcontroller’s VREF and AVCC for the ADC are applied externally. AREF and AVCC pins 20 and 21 are coupled to a 5v supply voltage.
The motors are connected to Port B of the microcontroller through a motor driver IC, the L293D. The motor driver’s input pins are connected to the microcontroller. The motor driver’s input 3 and input 4 are coupled to PB0 and PB1.
PB2 and PB3 pins are connected to the input1 and input2 of the motor driver IC. Output pins are connected to the motor. As the motor has two pins, these are connected to the output pins of the driver IC.
Temperature Controlling DC Motor – Circuit Simulation Video
How Temperature Controlled DC Fan Circuit using Microcontroller Works?
- Initially switch the power supply.
- Microcontroller starts reading the temperature of the surroundings.
- The analog value of temperature is given by the temperature sensor.
- This analog value is applied to the analog to digital converter pin of the micro controller.
- This analog value is converted to the digital value by the microcontroller using successive approximation method internally.
- When the temperature is greater than the threshold value, microcontroller sends a command to the controller to switch the motor.
- Thus fan starts rotating.
Temperature Controlled DC Motor Project Output Video
- Temperature Controlled DC Fan can be used to control the temperature of devices, rooms, electronic components etc. by monitoring the temperature.
- Can be extended to PWM based output, where the speed of the fan can be varied according to the duty cycle of the PWM signal.
- The circuit can be used in CPU to reduce the heat.