Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

is it possible to control the speed of the ac fan through AT89s52

Status
Not open for further replies.

saurabh pant

Newbie level 4
Joined
Dec 19, 2011
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,335
i am trying to control the speed of a ceiling fan with at89s52 on pin p0.0 but not able to do it.
i am writing the code in assembly. please tell me how it can be done.
i tried it but instead of control on speed, the fan gives zerks. plz help......
 

Re: is it pssible to control the speed of the ac fan through AT89s52

yes it is possible , you can control the speed of ac fan , for this you first have to detect the Zero cross of AC and the after the zero cross achived waite for a certain delay and then ON the triac gate and to the triac connect the AC fan ,
this is quite simple
 

Re: is it pssible to control the speed of the ac fan through AT89s52

thanks for replying...
i did that but it doesnt work out. i have taken the zero crossing at INT1. i am testing it on a bulb. now the intensity of the bulb should change but wat happns is that
the bulb blinks. here is my code:
ORG 00H //start
LJMP MAIN_1

ORG 0013H //timer subroutine for INT1
MOV TMOD,#01H //timer for to wait
MOV TL0,#67H
MOV TH0,#0FEH
SETB TR0 // start timer
JNB TF0,$
CLR TR0
CLR TF0
CLR P0.1 //this is trigger to triac
LCALL DELAY
SETB P0.1
RETI

MAIN_1:
MOV IE,#84H //initialize interrupt
SJMP MAIN_1

DELAY:MOV R0,#1
H1:MOV R1,#10
H:MOV R2,#2
DJNZ R2,$
DJNZ R1,H
DJNZ R0,H1
RET

END

now if i change the value of the TL0 TH0 like EE00, 8888 etc,then the bulb blinks with more delay..
plz tel me where i am going wrong....
 

Re: is it pssible to control the speed of the ac fan through AT89s52

Sory dear if i did not read your code care fully , but i go through it
as far as i am able to find , i did not find any EXtarnal interrupt routeen in you code,
You mentioned the timer up ISR , but in fact you should detect zero cross detecting on external interrupt and in EXTERNAL INTERRUPT SERVICE ROUTEEN you should waite for a certian period delay , then on the traic

And as far as you have told about you BULB BLINK problem , that also can b a hardware level problem , cant say any thing without diagram :(

But i think you should take care of code, you are using assembly , i have done it in C but not a big difference in shuch level problem
 

Re: is it pssible to control the speed of the ac fan through AT89s52

yes its quite easy.......our ac supply is at frequency 50Hz...

means 0.02sec per cycle now you need to develop a code which will generate pulses with at most frequency 50Hz.... when this is done you are to interface 8052 with IGBT or thrystor who's switching frequency is much much greator than 50Hz ... once this is done you have controlled your ac at any angle from 0 to 180 (sine/cosine wave)....

see the diagram for reference

please correct me if i am wrong

 

Re: is it pssible to control the speed of the ac fan through AT89s52

yes its quite easy.......our ac supply is at frequency 50Hz...

means 0.02sec per cycle now you need to develop a code which will generate pulses with at most frequency 50Hz.... when this is done you are to interface 8052 with IGBT or thrystor who's switching frequency is much much greator than 50Hz ... once this is done you have controlled your ac at any angle from 0 to 180 (sine/cosine wave)....

see the diagram for reference

please correct me if i am wrong



Yes this is correct, but the diagram i think should include some capacitive protection too at AC[in my openion , as i have used it :p]
 

Re: is it pssible to control the speed of the ac fan through AT89s52

thanks for replying..
as u said that i havnt defined the external interrupt routine but i did it..see in main...its MOV IE,#84H... which is enabling interrupt on INT1 i.e. P3.2.
plz correct if i m wrong.

---------- Post added at 21:31 ---------- Previous post was at 21:26 ----------

@mrarslanahmed...thanks for replying..
as u said about frequency i calculated the cycle time which is 20 ms. that means i have to trigger the triac in b\w every 10ms.
i have calculated values for 1ms to 9ms that i load in timer and then trigger triac but it doesnt work.. i am not able to detect where i m going wrong.
i have posted my assembly code..plz go through it n correct me..
 

Re: is it pssible to control the speed of the ac fan through AT89s52

plz help guyzzzzz...
 

Re: is it pssible to control the speed of the ac fan through AT89s52

can anybody help ?
 

Dear @saurabh pant i have done this but unfortunately i dont have a piece of work required for you as seperate code,
i am writing a seudo code i dont know whether it will help you or not , i just hope that it works to you ....
;======================================================

0rg 00h
ljmp main

out_triac bit P2.0

main :
initalize the timer0 to generate one milli second delay
initialize external interrupt
stop timer 0
setb out_traic ; assumed that clearing the bit will anable triac to conduct
sjmp $


timer_interrupt_service:
; this service routteen sould occure after one milli second or any unit that you like to sample , like you can do this for ;10usec which will cause 10ms/10usec times firing angle


if(is_delay_reached_enough)
{
stop timer0 ;
clr out_traic ;

}


iret


;=============================================

external_interrupt0_serivce_routeen:
start_timer0;

iret
;============================================

Please modify your code according to this algorithm , i hope it will definatly helps you

---------- Post added at 12:00 ---------- Previous post was at 11:48 ----------

ORG 00H //start
LJMP MAIN_1

ORG 0013H //timer subroutine for INT1
MOV TMOD,#01H //timer for to wait
MOV TL0,#67H
MOV TH0,#0FEH
SETB TR0 // start timer
JNB TF0,$
CLR TR0
CLR TF0
CLR P0.1 //this is trigger to triac
LCALL DELAY
SETB P0.1
RETI


now if i change the value of the TL0 TH0 like EE00, 8888 etc,then the bulb blinks with more delay..
plz tel me where i am going wrong....

;=================================================

this time i read your code more attentioally unlike i did before,

You are doing somthing like this


timer_interrupt_serivce:
initialize_timer;
start_timer;
waite_for_timer_to_fire_up;
enable_triac;
calling_a_delay;
disable_triac;
iret

;=============================================
You should start timer in External interrupt service routteen, so that it only starts when a zero cross occures,
and in timer service routeen you should only waite for a certain time delay , and then on the traic, and then [you can optionaly of the after a short delay, but i think its not necessory , as the reverse cycle will automatically off the triac, ]

and after that disable timer so that not further delay is possible unless the zero cross occure again
 

thanks for replying...i did as u said..but no improvement...
ORG 00H //start
LJMP MAIN_1

ORG 0013H //timer subroutine for INT1
SETB TR0 // start timer
JNB TF0,$
CLR TR0
CLR TF0
CLR P0.1 //this is trigger to triac
LCALL DELAY
SETB P0.1
RETI

MAIN_1:MOV TMOD,#01H
MOV TL0,#67H
MOV TH0,#0FEH

MOV IE,#84H //initialize interrupt
SJMP MAIN_1

DELAY:MOV R0,#1
H1:MOV R1,#10
H:MOV R2,#2
DJNZ R2,$
DJNZ R1,H
DJNZ R0,H1
RET

END
 

It should work , you should first chk it on LIGHT bulb , and also add some buttons or should try to change the delay so that you can visualize if delay increment and decrement make effect on the output or not ,
and if your code is working on the light bulb then you should add a LC filter for inductive load , my be induction load interfacing is being problem for you , you should take some time on hardware too,
 

if your problem is only that the bulb blinks then your problem is simple :smile:. Look my friend the problem is not in the code, the problem is with the timing. you mentioned that you work with 50HZ AC source so the external interrupt comes every 10 millisec. Now to control the speed of the fan or the intensity of the light you can use a PWM technique in other words turn the bulb on for percentage of time and off for the rest of the total time. Now if you used the external interrupt as 1% of your whole cycle the 100% or the total time will be 1 second (since the external interrupt is 10 millisec). for example if you want to run the fan or the bulb for 50% you will turn the fan on for 50 external interrupts and turn it off for the other 50 external interrupts, in this case you will see the bulb blinks or you will feel unstable speed of the fan as your case because multiples of 10milliseconds is obvious for the human eye. the solution is to use a timer with 0.1msec as your 1% of the cycle and in this case the external interrupt (10 msec) is your 100%. for example when the first external interrupt comes it should trigger a timer which will generate interrupt every 0.1msec (this is the step of synchronization of the timer with the external interrupt) and then you will count 50 OFF interrupts of the timer (50 * 0.1 msec = 5msec) and 50 ON (50 * 0.1msec = 5msec). The total will be the 10 msec (total cycle 100%). In this case you will feel a full control of speed on the fan and a full control of light intensity on the bulb. I had this problem before so hope this is the solution feed me back with the results. If you have a problem in the Hardware this is another issue specially when you add the fan I could help you with this also if you face any problem.
 

@mohamed.elsabagh: thanks man..this might help me.

this is something i didnt take care of. so i'll try n let u knw.. thanks alot..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top