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.

Triac based light dimming using 8051 microcontroller

Status
Not open for further replies.

raghurocks

Member level 1
Member level 1
Joined
Jul 3, 2012
Messages
33
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Location
India,Gujarat
Activity points
1,568
Hai every one,

I have been working under varying the brightness of the ac loads using the triac and a microcontroller.
I have written code for it and I tried for the output on the simulator as we cannot see the dimming on the simulator I have seen the output voltage which is varying for different levels but practically I am not getting the output which I am getting on the simulator

Here is the schematics I have done......

final_tahmid.jpg

and the code I have written is........

Code:
 org 00h
 MOV P2,#00H
 MOV P1,#00H
 MOV TMOD,#01H
 MOV SCON,#50H
 MAIN:
 	MOV A,P1;// to take data from the switches into the accumulator
LOOP1:
CJNE A,#01H,LOOP2
	S1:JNB P2.1,S1
SETB P2.0
MOV TL0,#0A4H//0.1MSEC  ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#3DH//9.1MSEC  OFF
MOV TH0,#0DFH
CALL DELAY
LJMP MAIN


LOOP2:
CJNE A,#02H,LOOP3
	S2:JNB P2.1,S2
CLR P2.0
MOV TL0,#07BH//0.7mSEC	 OFF to set delay angle for 0.7msec
MOV TH0,#0FDH
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON trigger for 100us
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#0E1H//9.2MSEC OFF
MOV TH0,#0DEH
CALL DELAY
LJMP MAIN

LOOP3:
CJNE A,#03H,LOOP4
	S3:JNB P2.1,S3
CLR P2.0
MOV TL0,#0F6H//1.4MSEC	 OFF to set delay angle for 1.4msec
MOV TH0,#0FAH
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON trigger for 100us and so on
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#066H//8.5MSEC OFF
MOV TH0,#0E1H
CALL DELAY
LJMP MAIN

LOOP4:
CJNE A,#04H,LOOP5
	S4:JNB P2.1,S4
CLR P2.0
MOV TL0,#71H//2.1MSEC	 OFF
MOV TH0,#0F8H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#0ECH//7.8MSEC OFF
MOV TH0,#0E3H
CALL DELAY
LJMP MAIN

LOOP5:
CJNE A,#05H,LOOP6
	S5:JNB P2.1,S5
CLR P2.0
MOV TL0,#0ECH//2.8MSEC	 OFF
MOV TH0,#0F5H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#71H//7.1MSEC OFF
MOV TH0,#0E6H
CALL DELAY
LJMP MAIN


LOOP6:
CJNE A,#06H,LOOP7
	S6:JNB P2.1,S6
CLR P2.0
MOV TL0,#66H//3.5MSEC	 OFF
MOV TH0,#0F3H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#0F6H//6.4MSEC OFF
MOV TH0,#0E8H
CALL DELAY
LJMP MAIN

LOOP7:
CJNE A,#07H,LOOP8
	S7:JNB P2.1,S7
CLR P2.0
MOV TL0,#0E1H//4.2MSEC	 OFF
MOV TH0,#0F0H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#7BH//5.7MSEC OFF
MOV TH0,#0EBH
CALL DELAY
LJMP MAIN

LOOP8:
CJNE A,#08H,LOOP9
	S8:JNB P2.1,S8
CLR P2.0
MOV TL0,#5CH//4.9MSEC	 OFF
MOV TH0,#0EEH
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#00H//5.0MSEC OFF
MOV TH0,#0EEH
CALL DELAY
LJMP MAIN

LOOP9:
CJNE A,#09H,LOOP10
	S9:JNB P2.1,S9
CLR P2.0
MOV TL0,#7BH//5.7MSEC	 OFF
MOV TH0,#0EBH
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#0E1H//4.2MSEC OFF
MOV TH0,#0F0H
CALL DELAY
LJMP MAIN

LOOP10:
CJNE A,#0AH,LOOP11
	S10:JNB P2.1,S10
CLR P2.0
MOV TL0,#0F6H//6.4MSEC	 OFF
MOV TH0,#0E8H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#066H//3.5MSEC OFF
MOV TH0,#0F3H
CALL DELAY
LJMP MAIN

LOOP11:
CJNE A,#0BH,LOOP12
	S11:JNB P2.1,S11
CLR P2.0
MOV TL0,#71H//7.1MSEC	 OFF
MOV TH0,#0E6H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#0ECH//2.8MSEC OFF
MOV TH0,#0F5H
CALL DELAY
LJMP MAIN

LOOP12:
CJNE A,#0CH,LOOP13
	S12:JNB P2.1,S12
CLR P2.0
MOV TL0,#0ECH//7.8MSEC	 OFF
MOV TH0,#0E3H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#71H//2.1MSEC OFF
MOV TH0,#0F8H
CALL DELAY
LJMP MAIN

LOOP13:
CJNE A,#0DH,LOOP14
	S13:JNB P2.1,S13
CLR P2.0
MOV TL0,#66H//8.5MSEC	 OFF
MOV TH0,#0E1H
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#0F6H//1.4MSEC OFF
MOV TH0,#0FAH
CALL DELAY
LJMP MAIN

LOOP14:
CJNE A,#0EH,LOOP15
	S14:JNB P2.1,S14
CLR P2.0
MOV TL0,#0E1H//9.2MSEC	 OFF
MOV TH0,#0DEH
CALL DELAY
SETB P2.0
MOV TL0,#0A4H//0.1MSEC ON
MOV TH0,#0FFH
CALL DELAY
CLR P2.0
MOV TL0,#7BH//0.7MSEC OFF
MOV TH0,#0FDH
CALL DELAY
LJMP MAIN


LOOP15:
CJNE A,#0FH,LOOPE
	S16:JNB P2.1,S16
CLR P2.0
MOV TL0,#00H//10MSEC OFF
MOV TH0,#0DCH
CALL DELAY
LJMP MAIN

LOOPE:
	LJMP MAIN

DELAY:
SETB TR0
L1:JNB TF0,L1
CLR TF0
RET

END

Concept:

The concept I have used is that if I want a less brightness the I will increase the delay time for the triac to trigger where we are increasing the delay angle and decrease the conduction there by decreasing the rms output so like wise I for example if I want 20% brightness I will give zero pulse for 8 ms and will give high pulse for 100us(0.1 ms) and then off for the remaining time like wise I have divided into 16 levels where the input I give from the switches(based on the basic concept of the TRIAC) which you can see on the above code

Problems:

The problems I am facing in the hardware are the

1.In the schematic I am grounding the ac neutral and the T1 of the triac to the circuit ground so if I do that on the bread board the lamp is lighting at only one level and the 220 ohm resistor is burning

2.If I don't do the grounding like that the lamp is not at lighting on

I am unable to know where the problem persist
1.whether am I going wrong in detecting zero or
2.producing pwm which indeed depend on the zero crossing

Queries:

1. I don't have the CRO so how to check whether my zerocrossing detector is producing the zero crossing or not
2. And how to check whether my microcontroller is producing the desired pwm wave or not

Any help is very much valuable for me.......
Thanks in advance
 
Last edited:

I don't know different errors are coming when I am dealing with the hardware as I stated earlier I got the desired output on the simulator but when I am doing it on the bread board it is showing different errors like I am using the port 1 for input but as per my code it should become zero first and when I give input its value should as of my input but my port values are not changing the entire port1 is high irrespective of input I give so I think this might be the reason for no dimming can anyone help me out
 

    V

    Points: 2
    Helpful Answer Positive Rating
I have a doubt regarding the zero detection for the microcontroller..
can we give the zerodetection output to one of the port pin and use that for further purpose or use some interrupt routine for giving the zero detection output to the microcontroller
 

    V

    Points: 2
    Helpful Answer Positive Rating
I'm facing a problem to make the zero crossing detection circuit. could you discuss the zero crossing part details.
 

hey bro, dealing with triacs simply means u hav to hav a first hand info as regards the firing scheme employed so that u dnt end up messing up with ur precious semionductors

1. your triac should be fired at the zero crossing point of ur ac power line else your aim will be distorted
2. u can make a simple zero crossing detector circuit with your conventional full wave bridge rectifire via the power line and a limiting resistor. u can use the retified source which wud be off course twice the mains frequency to fire a small signal transistor or better still an optocoupler if total isolation is of prime importance.
3. use this signal from the bjt or optoisolator to trigger an interupt routine which shud occur at the zero crosiing mark
4. from here u can call your interupt service routine which is infact your firing time.
hope this helps...
 

Hello!

Your schematic includes triac, optocoupler, transistor, trans, etc...
You may consider using a 0 detection capable phototriac which would do most of what you want.
You would need:
1 phototriac
1 resistor for the internal LED
And of course your MCU and push buttons.
Then you enter a PWM signal to the LED anode, and you get what you want.
And the buttons will be used to change the duty of the PWM.

Dora.
 
Thank you for your replay. This is the circuit which I used. In the code I wrote, when a interrupt in the INT0 pin, where zero crossing detector is connected, PORTB.0 become High that mean it trigger the TRIAC. after 1000uS later it become turn off. In this case light become less brightly, around 45voltage AC can be found across the light. But if the turning ON time is more then 1500uS then the light become fully bright that mean found full AC voltage across the light. So I found two state, fully dimmed (Around 45 Voltage) or fully bright (Full voltage across the light). In between the I want some more steps like 180V, 190V, 200V, 210V etc. Please instruct me what should I do?

https://obrazki.elektroda.pl/5560202300_1351402992.gif

regards,
Ripon
 

increasing the firing time of the triac simply means fewer steps for looking at the AC power line. see it as an analog to a digital converter scheme where we deal with step size!
also am not seeing any interupt service routine in ur code except my eyes are failing me.

u can use a simple sheme instead of u goin for the timer overflow mode.
1. u hav to configure ur SFR for an interupt function say: mov ie,#10000001B. this will setup ur INT0.
2. add up your vectors that will be called upon an interupt say ; ORG 003H ; Interrupt routine address for INT0
3. u hav to AJMP to the service routine in other to execute your funtion. but i'll advice u disable futher interupt once u are in your routine and enable it one u are out.
4. u can simply clr ur firing bit then call the neccesri delay then setb the bit after ur delay. with this sheme it will be very easier for you to generate diferent firing angles.
since one half cycle is abt 10mS @ 50Hz, u can run a lil manipulation there by dividing thru with the number of firing angles u want thus convertin it time time....:grin:
 

    V

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top