+ All Categories
Home > Documents > AVR Project – Remote Controlled Fan Regulator.

AVR Project – Remote Controlled Fan Regulator.

Date post: 29-Apr-2015
Category:
Upload: nadarat
View: 494 times
Download: 5 times
Share this document with a friend
24
CATEGORIES o 32bit ARM Projects o AVR Development Board o AVR Projects o AVR Tutorials o Chitchat o Code Libraries o Code Snippets o Electronics o Hardwares o Microchip PIC Tutorials o News o PIC Development Board o Programming in 'C' o RF o Robotics o Software o Tools o Uncategorized NAVIGATION Home Forum Shop Links SUBSCRIBE Get New Articles Deliverd To Your Inbox! Email address: Delivered by FeedBurner S ubscribe
Transcript
Page 1: AVR Project – Remote Controlled Fan Regulator.

CATEGORIES

o 32bit ARM Projects

o AVR Development Board

o AVR Projects

o AVR Tutorials

o Chitchat

o Code Libraries

o Code Snippets

o Electronics

o Hardwares

o Microchip PIC Tutorials

o News

o PIC Development Board

o Programming in 'C'

o RF

o Robotics

o Software

o Tools

o Uncategorized

NAVIGATION

Home

Forum

Shop

Links

SUBSCRIBE

Get New Articles Deliverd To Your Inbox!

Email address:

Delivered by FeedBurner

 LATEST DISCUSSIONS

o eXtreme Burner for Atmega88PA Atmega328P

o What is the best IDE for programming of ARM mcu's M.R AVINASH

o 8051 with aubtm-20

o PIC serial communication,Baud rate

o atmega88 interrupt

o atmel atmega 644P

Subscribe

Page 2: AVR Project – Remote Controlled Fan Regulator.

o What is the use of Optimization (O2) in config settings?

o Differentiating between colors

o RF communication query

o Problem with order some products from another country

LATEST ON AVR TUTORIALS

Time Input Dialog for Graphic LCDBY AVINASH - DECEMBER 3 2011 01:27 PM

GUI Frameworks of all modern OS like Windows, Linux (Qt ...

DS1307 I2C RTCC Interface using SoftI2C libBY AVINASH - NOVEMBER 30 2011 06:34 PM

In the last tutorial, I explained you how to use ...

24CXX I2C EEPROM Interface using SoftI2C libBY AVINASH - NOVEMBER 26 2011 07:43 PM

In this tutorial I will show you how to use ...

LATEST ON MICROCHIP PIC TUTORIALS

Thermometer with PIC MicrocontrollerBY AVINASH - JUNE 10 2011 07:26 PM

In the last tutorial we learn about the multiplexing technique ...

Using Multiplexed 7 Segment Displays – PIC Microcontroller TutorialBY AVINASH - MAY 31 2011 12:11 PM

...

Introduction to PIC Interrupts and their Handling in CBY AVINASH - DECEMBER 5 2010 10:51 AM

Interrupts are common features in almost all processor family, be ...

LATEST ON AVR PROJECTS

PC Controlled RobotBY AVINASH - DECEMBER 25 2011 06:06 PM

In this tutorial we will discuss a simple PC controlled ...

Visualize ADC data on PC Screen using USART – AVR Project

Page 3: AVR Project – Remote Controlled Fan Regulator.

BY AVINASH - JUNE 2 2011 08:26 AM

Many times a nice visualization of ADC data is required during learning about new sensors. In this situation this valuable tool will come to your help. The tool I

called is ADCGraph2, it is being with me from a long time but today I thought of sharing it publicly.YOU ARE HERE : EXTREME ELECTRONICS » AVR PROJECTS » VISUALIZE ADC DATA ON PC SCREEN USING USART – AVR PROJECT

AVR Project – Remote Controlled Fan Regulator.Posted By Avinash On July 4th, 2010 12:41 PM. Under AVR Projects  

Share on facebookShare on twitterShare on deliciousShare on diggShare on stumbleuponShare on redditShare on emailMore Sharing Services

This device can be used to remotely control the speed of an AC fan and to switch it on or off. The remote control is a cheap NEC Format remote,

usually supplied with small DVD players. Three buttons are used to command the circuit. The UP key increase the fan's speed while the DOWN key

decrease it. The ENTER key is used to switch on or off the fan. The unit provides 10 way speed control from 0 to 9. The current speed is displayed in

a seven segment display. The yellow LED on the PCB indicates the power status of the load. If the load is switched off using the R/C then the LED

will also be switched off.

In the Video below you can check out the project in action.

The main parts of the circuit is labeled below.

1. The seven segment display used to show the current speed level.

2. The TSOP1738 sensor is used to pick up commands from remote control.

3. The Yellow LED indicates the power status of the load.

4. OUT - Here the AC load is connected in series. Tested on 220v 50Hz AC line.

5. IN - Power supply from a 12-0-12 transformer is applied here.

6. MCU - ATmega8 AVR 8 bit Microcontroller.

7. SWITCH - Manual Switch used to operate the unit without the remote control.

Page 4: AVR Project – Remote Controlled Fan Regulator.

Fig.: Atmel AVR Based Remote Controlled Fan Regulator.

 

Fig.: Remote Controlled Fan Regulator Wiring Diagram.

Construction of Remote Controlled Fan Regulator.

You can make the circuit as per the schematic on any general purpose PCB. To ease your job we are giving the PCB Layouts too, so that you can

make the PCB at your home using the Etching Method. You may also have the PCBs made from any fab house too. To further easy the job and save

your money we have already made the PCBs from a good fab house and they are available for purchase at very low cost.

Start assembly process by first soldering the jumper1. Then you can mount the resistors. After that solder the diodes, remember to properly orient the

diodes. They are polar and don't work if installed other way round. Then solder the IC U4 and U2, this time too take care of the orientation. The small

round circle on the IC package marks the PIN number 1.

Page 5: AVR Project – Remote Controlled Fan Regulator.

Fig.: Proper IC Installation.

After that you can solder the ceramic disk capacitors, the 16MHz crystal, 7805, Triac, TSOP Sensor, Display. Finally Connect the 12-0-12

Transformer and apply power. The display should show '0'. Then you can press the up/down key in remote control to adjust the speed. The display

should change accordingly. This ensures that the circuit is running properly.

Its time to connect a real AC load. Connect a 220V 100W incandescent lamp (NO CFL Please). As shown in the above wiring diagram. Replace the

fan with bulb because its easier to test.

WARNING !!!

Never Touch any part of the circuit when AC load is connected. It can give you a fetal shock !!!

Now you can can use the remote control to increase/decrease the lamp's brightness using the remote control. You can also switch it on and off using

the ENTER key.

Troubleshooting

If the unit does not respond to the remote control signals then look for the following.

1. AVR ATmega8's Fuse BIT is programmed too HIGH=0xC9 LOW=0xFF

2. AVR is clocked with 16MHz crystal (other value won't work)

3. Remote Control is NEC Format Only (Chinese DVD/CD player remote works good, TV Remote Generally do not work as these are RC5

coded)

4. Remote Key codes has been feed to rckey.h file. Build and run this demo and press UP,DOWN and ENTER keys to get their keycode and

put them inrckeys.h file. All remotes available in market has random keycode, so This part is very important. After editing the rckeys.h

file the project must be Rebuild. (I hope you know what does that means).

5. IR sensor is of good quality and must be labeled TSOP1738 (other values won't work).

6. If you get a KIT from us then most of the problem do not arise.

Page 6: AVR Project – Remote Controlled Fan Regulator.

Fig.: This Hobby Remote Control Works Great!

Hobby Remote Control (NEC) is available from our online store.

Part list for Remote Controlled Fan Regulator.

Part List01 330 ohm resistor (8 Nos) R2-R902 4k7 Resistor (2 Nos) R1, ,R1103 1K Resistor R1204 39 ohm Resistor R1305 1K5 Resistor R1506 22pF Ceramic Disk Capacitor (2 Nos) C1,C207 0.1uF Ceramic Disk Capacitor (3 Nos) C3,C5,C608 470uF 50v Electrolytic Capacitor C409 16 MHz Crystal Half Size X110 1N4007 Diode (6 Nos) D2,D3,D4,D5,D6,D711 LED 5mm Any Colour D112 MCT2E Opto Coupler U413 MOC3021 Opto Triac Driver U214 ATmega8-16PU General purpose 8 bit MCU U1

Page 7: AVR Project – Remote Controlled Fan Regulator.

15 Triac BT136 U316 7805 Voltage Regulator U517 Common Anode Display DISP1118 TSOP1738 IR Sensor X2

19220V AC to 12-0-12 Centre Tapped Transformer (NOT Included in KIT)

 

20 Hobby Remote Control (NEC)  

Buy Remote Controlled Fan Regulator Kit.

Schematic

Fig.: Schematic (Click To Enlarge/Print).

PCB For Remote Controlled Fan Regulator.

PCBs can be purchased from PCB section of our online shop.

Page 8: AVR Project – Remote Controlled Fan Regulator.

Fig.: Remote Controlled Fan Regulator PCB.

 

avr-gcc C Source Code.

/*

Remote Controlled Fan Regulator.

********************************

Compiler: avr-gcc (WinAVR-20090313)

Project Manager/IDE: AVR Studio 4.17 Build 666

Other Lib: eXtreme NEC Decoder.

Hardware:

INT0 - IR Receiver

Page 9: AVR Project – Remote Controlled Fan Regulator.

INT1 - Zero Crossing Detector.

PD5 - Triac Control.

PB2 - Manual Switch

For

ATmega8 @ 16MHz

Fuse:

HIGH=0xC9 LOW=0xFF

Copyright (c) 2008-2010

eXtreme Electronics, India

NOTICE

--------

NO PART OF THIS WORK CAN BE COPIED, DISTRIBUTED OR PUBLISHED WITHOUT A

WRITTEN PERMISSION FROM EXTREME ELECTRONICS INDIA. THE LIBRARY, NOR ANY PART

OF IT CAN BE USED IN COMMERCIAL APPLICATIONS. IT IS INTENDED TO BE USED FOR

HOBBY, LEARNING AND EDUCATIONAL PURPOSE ONLY. IF YOU WANT TO USE THEM IN

COMMERCIAL APPLICATION PLEASE WRITE TO THE AUTHOR.

*/

#include <avr/io.h>

#include <util/delay_basic.h>

#include <avr/interrupt.h>

#include "remote.h"

#include "rckeys.h"

#define FAN_POWER_LED_PORT PORTD

Page 10: AVR Project – Remote Controlled Fan Regulator.

#define FAN_POWER_LED_DDR DDRD

#define FAN_POWER_LED_BIT 7

#define POWER_LED_ON() FAN_POWER_LED_PORT&=(~(1<<FAN_POWER_LED_BIT))

#define POWER_LED_OFF() FAN_POWER_LED_PORT|=(1<<FAN_POWER_LED_BIT)

uint8_t table[10]={141,125,109,94,78,62,47,31,16,1};

uint8_t speed=0;

uint8_t fan_on=0;

void Initialize()

{

FAN_POWER_LED_DDR|=0B10000000;

POWER_LED_OFF();

DDRC|=0b00111111; //Seven segment

DDRB|=0b00000010; //Middle segment G

Display(0);

RemoteInit();

//Initialize the zero crossing detector INT(1)

MCUCR|=((1<<ISC11)|(1<<ISC10)); //INT in Rising edge

GICR|=(1<<INT1); //Enable INT1

//Output

DDRD|=(1<<PD5);

PORTD|=(1<<PD5); //High = TRIAC Off

Page 11: AVR Project – Remote Controlled Fan Regulator.

//Set Timer 2

TCCR2|=(1<<WGM21); //CTC

TIMSK|=(1<<OCIE2); //Enable OCI2

sei();

}

/*

Zero Crossing Detect.

*/

ISR(INT1_vect)

{

if(!fan_on)

{

PORTD|=(1<<PD5); //High = TRIAC Off

return;

}

if(speed==9)

{

PORTD&=(~(1<<PD5)); //low = TRIAC ON

return;

}

PORTD|=(1<<PD5); //High = TRIAC Off

OCR2=table[speed];

TCNT2=0x00;

Page 12: AVR Project – Remote Controlled Fan Regulator.

TCCR2|=((1<<CS22)|(1<<CS21)|(1<<CS20)); //Start Timer prescaler =1024

}

/*

Timer2 Compare ISR

*/

ISR(TIMER2_COMP_vect)

{

PORTD&=(~(1<<PD5)); //low = TRIAC ON

TCCR2&=(~((1<<CS22)|(1<<CS21)|(1<<CS20))); //Stop Timer

}

/*

Simple Wait Function

*/

void Wait()

{

char i;

for(i=0;i<100;i++)

_delay_loop_2(0);

}

/*

Displays a number in Seven Seg Display

Page 13: AVR Project – Remote Controlled Fan Regulator.

*/

void Display(uint8_t num)

{

if(num>9)

return;

switch (num)

{

case 0:

PORTC=0B00000000;

PORTB|=0B00000010;

break;

case 1:

// xxfedcba

PORTC=0B00111001;

PORTB|=0B00000010;

break;

case 2:

// xxfedcba

PORTC=0B00100100;

PORTB&=(~(0B00000010));

break;

case 3:

// xxfedcba

PORTC=0B00110000;

PORTB&=(~(0B00000010));

break;

break;

case 4:

// xxfedcba

PORTC=0B00011001;

PORTB&=(~(0B00000010));

Page 14: AVR Project – Remote Controlled Fan Regulator.

break;

case 5:

// xxfedcba

PORTC=0B00010010;

PORTB&=(~(0B00000010));

break;

case 6:

// xxfedcba

PORTC=0B00000010;

PORTB&=(~(0B00000010));

break;

case 7:

// xxfedcba

PORTC=0B00111000;

PORTB|=0B00000010;

break;

case 8:

// xxfedcba

PORTC=0B00000000;

PORTB&=(~(0B00000010));

break;

case 9:

// xxfedcba

PORTC=0B00010000;

PORTB&=(~(0B00000010));

break;

}

}

void main()

{

Page 15: AVR Project – Remote Controlled Fan Regulator.

uint8_t cmd; //Command received from remote

Initialize();

while(1)

{

//Get Command For the Remote Control

cmd=GetRemoteCmd(1);

//Now process the command

//UP Key

if(cmd==RC_UP)

{

if(speed<9)

speed++;

}

//DOWN Key

if(cmd==RC_DOWN)

{

if(speed>0)

speed--;

}

//Enter Key

if(cmd==RC_ENTER)

{

if(fan_on)

{

POWER_LED_OFF();

fan_on=0; //Turn Off

}

Page 16: AVR Project – Remote Controlled Fan Regulator.

else

{

POWER_LED_ON();

fan_on=1; //Turn On

}

}

Display(speed);

}

}

Note: Other files that are part of the eXtreme NEC decoder must also be added to the project. They can be downloaded from links given below.

Downloads

Complete AVR Studio Project .

HEX  File For ATmega8-16PU Chip. A Compatible Remote Control is available from our shop.

PCB Layouts in PDF,Microsoft® Word® and PNG Formats.

Buy Kit

Buy complete kit including PCB, Parts, Programmed MCU and Matching IR Remote Control Unit. You just need to buy a 12-0-12 Transformer of

current rating 500ma or more because it is NOT included in the kit.

Buy Remote Controlled Fan Regulator Kit.

Related Post

Using IR Remote Controls with AVR MCUs

By

Avinash Gupta

www.AvinashGupta.com

[email protected]

Tags: Atmega, Atmega8, Avr Project , Bt136, Ir, Microcontroller, Moc3021, Opto-Coupler,Project, Remote Control, Triac

Share on facebookShare on twitterShare on deliciousShare on diggShare on stumbleuponShare on redditShare on emailMore Sharing Services

45 Responses To “AVR Project – Remote Controlled Fan Regulator.”

Page 17: AVR Project – Remote Controlled Fan Regulator.

1. Arifuddin Sheik Says:

July 6, 2010 at 6:51 pm

Hi Avinash! Nice project. The project file you kept for download is having some problems. When I tried to build the project, i got “no build tools defined” error. When i compiled the same files by creating a new project, there is no problem.

I build a project for controlling home appliances using DVD remote using your files with LCD support and EEPROM options. So, whenever the Main power goes off, the MCU will check the EEPROM data which has the appliances status. After seeing this project, i got an idea of integrating this fan speed control option in my project. Can i connect output to any pin say PC2 ( i bought Xboard MIni from your store, the PD5 pin is already dedicated for LCD connection). I just want to know whether the outputs you specified can be changed to other pins or not. I know we cant change the interrupt pin. I am asking about POWER LEDS and FAN OUTPUT connections.

REPLY

2. Avinash Says:

July 6, 2010 at 7:09 pm

@Arif,

Yes you can change the Triac Output pins. Simply Change the OUTPUT Section in the Initialize() Function.

And some control in the two ISRs

ISR(INT1_vect)ISR(TIMER2_COMP_vect)’

Also Don’t forget to post your project in your blog to share with the World. And give credit to us for the Remote Libraries.

REPLY

3. Avinash Says:

July 6, 2010 at 7:11 pm

As for the AVR Studio Error Please use

Project Manager/IDE: AVR Studio 4.17 Build 666

REPLY

4. Avinash Says:

July 6, 2010 at 7:14 pm

If you post your project on your blog with pictures and code, then I will give you this PCB(Bare) for Free!!!

REPLY

5. Arifuddin Sheik Says:

Page 18: AVR Project – Remote Controlled Fan Regulator.

July 6, 2010 at 11:37 pm

Sure. I will definitely post the project with Pictures and code. After all, I made that using your libraries and tutorials! I had finished the project just today. I am working on integration of speed control. I am thinking of generating pwm using atmega8 feature for speed control. Do you think the pwm logic works for speed control. I will test that tomorrow and post the results. The main reason why I thought this is to reduce the hardware and to avoid the optocouplers. But somewhere in my mind, it is saying me that a person like Avinash could have thought the same and why he implemented this the same thing with more hardware. Is it for educational purpose to cover more topics or there is a need for using the hardware?

REPLY

6. Arifuddin Sheik Says:

July 6, 2010 at 11:39 pm

Sorry its atmega16. not atmega8!

REPLY

7. Arifuddin Sheik Says:

July 7, 2010 at 2:17 pm

http://arif-ece.blogspot.com/2010/07/remote-controlled-home-appliances.html

check out the details of my project in my blog. I am working on improving the code for fan speed control using PWM. I will update it as soon as I finish doing it. Please post your comments and suggestion.

REPLY

8. Avinash Says:

July 7, 2010 at 4:52 pm

@Arifuddin,

The article you submitted is just great !

You won your PCB as I promised!

So should I send it to your registered address?

Khammam, 507001Andhra Pradesh

Also Direct PWM Control as we use with DC Motors Cannot be used with AC Motors Such as a Fan because of following reasons1) The PWM Must be in sync with the AC Waveform for this we use the first MCT2E Opto. By using this we fire INT1 whever the AC Wave reaches zero point.2) Triac Can only be switched on and it remains on even if the driving voltage is removed from the Gate terminal. It can only be Turned off during the AC Zero point!

Because of these the Zero Crossing detection is necessary and simple PWM Cannot be used.

REPLY

9. Avinash Says:

Page 19: AVR Project – Remote Controlled Fan Regulator.

July 7, 2010 at 4:58 pm

Also the bridge rectifier section made from D2,D3,D4,D5 is NOT filtered with capacitor. If capacitor is used it will become PURE DC and we cannot detect Zero point.

Every part of the circuit is well planned and I am NOT an academic guy so I don’t add anything for mere educational purpose.

REPLY

10. Arifuddin Sheik Says:

July 7, 2010 at 6:32 pm

Thank you so much. My address is correct as you stated. But I also need the components that are required in the project. Please mail me the appropriate cost. I will deposit cash in your bank account.

Coming to my blog, I forgot about my blog before a long time. You initiated me for writing the article. So, credit goes to you. I did some research regarding yesterdays comment regarding PWM and found out the same. I will anyhow continue posting my projects. I read your comment in my blog regarding projects today which you sent in may 2010.

Coming to the board modification which I had done, you please check this article and give me suggestions and your feedback regarding powering the XBoardMini with USB Power supply. I think you should consider using Vcc pin in ISP connector.

http://arif-ece.blogspot.com/2010/07/modifying-avr-development-board-and.html

Thanking you,Arifuddin Sheik

REPLY

11. Arifuddin Sheik Says:

July 7, 2010 at 8:11 pm

http://arif-ece.blogspot.com/2010/07/remote-controlled-home-appliances_07.html

This is the new link. I deleted the old link because the post is containing html errors. I haven’t updated the project yet.

REPLY

12. Avinash Says:

July 11, 2010 at 8:39 am

@Arif

Your PCBs have been dispatched. You may get them by Wednesday. Please inform me when you receive them.

REPLY

13. Arifuddin Sheik Says:

July 26, 2010 at 9:37 pm

@Avinash

Page 20: AVR Project – Remote Controlled Fan Regulator.

Thanks for sending me your PCB’s.

Arifuddin Sheik

REPLY

14. Puneet Says:

August 7, 2010 at 3:17 pm

Hello Avinash,

I want to build these remote controllers which can take a load of 1.5 kva. Please advice on what alteration need to be done to the circuit.

Thanks

Puneet

REPLY

15. Fatimah Says:

September 2, 2010 at 3:02 am

do you any supplier in malaysia if i would like to buy the component that used in this project?

REPLY

16. Mahendra Patel Says:

September 12, 2010 at 11:42 pm

remote control fan regulater this products is to good. I want this kit 100 pcs.please sent price and mode of payment

REPLY

o Avinash Says:

September 13, 2010 at 8:43 am

@Mahendra Patel,

For Payment Option seehttp://shop.extremeelectronics.co.in/shipping.php

REPLY

17. Sandeep Says:

Page 21: AVR Project – Remote Controlled Fan Regulator.

October 17, 2010 at 12:49 pm

hello avinash-plz tell me the min ampere rating of the transformer.that’s to be used in this project ,as in shops they ask for that too apart from voltage rating..inform me as asap..

thanks…

REPLY

18. Tandy Says:

November 18, 2010 at 6:37 am

Hi Avinash,

Quick question on the 220V AC to 12-0-12 Centre Tapped Transformer. Is it possible for you to direct me to a place where I could buy them online.

I’m not too sure with what I’ve found so far!

Please help,Tandy

REPLY

19. Tandy Says:

November 18, 2010 at 7:04 am

Hi Avinash,

Sorry for asking another question almost immediately! Basically I have a 240VAC fan to run which runs with 120W of power.

What sort of 12-0-12 Trasformer should I use?

Please help

REPLY

o Avinash Says:

November 18, 2010 at 8:15 am

@Tandy

I can’t get what you mean by

What sort of 12-0-12 Trasformer should I use?

REPLY

20. Tandy Says:

Page 22: AVR Project – Remote Controlled Fan Regulator.

November 18, 2010 at 8:36 am

Hi Avinash,

Sorry I think I worded the post incorrectly.

I’m very new at this and find this project to be very interesting (a bit of a hobbyist).

I noticed that you ran a 100W bulb with your mains being at 220V AC with your transformer.

If i was trying to implement this with the fan I have what sort of transformer would you recommend.

The fan is a 120W fan(that I found lying around) and runs on 240V AC from the mains.

Please help with some knowledge thanks.

REPLY


Recommended