In this post, we will control the speed of dc fan based on the temperature.
List of components:
1. Arduino Uno
2. LM 35 temperature sensor
3. LCD 16*2
4. 10k potentiometer
5. ULN 2003
6. DC motor
7. Breadboard/ perfboard
First of all, we will monitor the temperature by using lm35 i.e. temperature sensor. It's scale factor is +10mV/°C which means with increment in temperature by 1° Celsius, the voltage is rise by 10 mV.
We can read adc count by analogRead(A0); // we are using channel A0
This will give us a digital count of adc which varies from 0 to 1023, we have to convert these count into voltage and then into temperature. First of all, we will convert into voltage:
In arduino uno, adc is of 10-bit.
Resolution = Vref/(2^n-1), where n is bit (in our case it's 10)
Resolution = 5000 / 1023, ( Verf = 5000 mV and 2^10 is 1024 minus 1 is 1023)
Resolution = 4.887 mV
Now, we have to convert voltage into temperature:
Temperature (in °C) = Voltage (in mV) / 10.0
With this temperature monitoring is over.
LCD interfacing is simple since we have library for the same with proper documentation.
Now coming to pwm part. In arduino, we can control output voltage by pulse width modulation (pwm).
Duty Cycle = Ton / (Ton + Toff)
Duty Cycle = Ton / T
Duty Cycle (in %age) = (Ton / T)*100
In arduino, for pwm we have analogWrite function :
In arduino uno, we have six pwm channels viz, pin no. 3, 5, 6, 9, 10 and 11.
analogWrite(pin no, value)
Pin no may be 3, 5, 6, 9, 10 and 11
Value varies from 0 to 255 since pwm resolution is of 8-bit (2^8-1)
0 for 0% duty cycle 0 volts
64 for 25% duty cycle 1.25 volts if(val<=40.0)
127 for 50% duty cycle 2.50 volts if(val>40.0 && val<=50.0)
192 for 75% duty cycle 3.75 volts if(val>50.0 && val<=60.0)
255 for 100% duty cycle 5.00 volts if(val>60.0)
where val is temperature in °C
Vavg = Duty Cycle * 5.0 volts
|
Schematic of temperature controlled fan |
Download the source code from the link below:
Stay tuned for more updates !!