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.

problem in controlling LIGHT INTENSITY OF AC BULB through 2051uc using zero detector

Status
Not open for further replies.

lucky6772

Junior Member level 2
Joined
Sep 4, 2010
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,441
Hey guys M controlling light intensity using zero detector through microcontroller 2051 using moc3041 and traic 136

what m doing is as there will zero detecting pulse after every 10ms. so m doing is m jst making moc off for 8ms and on for 2ms by this i m achieving 20% brightness BUT
THE PROBLEM IS BULB IS ACHIEVING 20%BRIGHTNESS BUT ITS KEEP ON FLICKER HERE'S THE SIMPLE CODE FOR TESTING M POSTING KINDLY HELP


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <REG2051.H>
int i,j,a;
sbit moc=P3^7;
void delay();
void delay(int x)
{
for(i=0;i<100;i++)
for(j=0;j<x;j++)
;   
}
 
void isr(void) interrupt 0
{
 
moc=1; ///bulb off for 8ms
delay(8);
moc=0; /// bulb on for 2ms
delay(2);
moc=1;
delay(8);
moc=0;
delay(2);
 
}
void main()
{
EX0 = 1; // Enable EX0 Interrupt
EA = 1; // Enable Global Interrupt Flag
while(1)
{
;
}
 
}



NOTE= i am using moc3041 and connect in such a way that wen i give low pulse i.e '0' it fires..bulb on..
 
Last edited by a moderator:

Your ISR has a total delay time of 20 ms. How can you expect that it's triggered each period?

At the very least, you'll want to comment the last delay(2), to get a chance that the ISR is triggered periodically. If the interrupt is triggered every 10 ms, as you mention, the ISR can be finished after the first moc=0, isn't it?
 

Your ISR has a total delay time of 20 ms. How can you expect that it's triggered each period?

At the very least, you'll want to comment the last delay(2), to get a chance that the ISR is triggered periodically. If the interrupt is triggered every 10 ms, as you mention, the ISR can be finished after the first moc=0, isn't it?

hey buddy..
i even tried this..but still it flicker

Code:
void isr(void) interrupt 0
{
 
moc=1; ///bulb off for 8ms
delay(8);
moc=0; /// bulb on for 2ms
delay(2);
}

the above produce exact 10ms total delay..
 
Last edited by a moderator:

There are actually two problems remaining:
- the ISR code must be finished before the next zero crossing. So delay(2) is definitely wrong, as previously mentioned.
- the triac control must be switched off before the zero crossing. The triac only needs a short trigger pulse.

Try something like this:
Code:
void isr(void) interrupt 0
{
delay(8);
moc=0; // bulb on
delay_100us():
moc=1; // triac is on now, switch off control
}
 

There are actually two problems remaining:
- the ISR code must be finished before the next zero crossing. So delay(2) is definitely wrong, as previously mentioned.
- the triac control must be switched off before the zero crossing. The triac only needs a short trigger pulse.

Try something like this:
Code:
void isr(void) interrupt 0
{
delay(8);
moc=0; // bulb on
delay_100us():
moc=1; // triac is on now, switch off control
}

sowie i didnt get u delay_100us(): wat will dis function do..? y 100microsecond delay..? how sholud i make that function.
 

Actually - there is a far more fundamental problem.
The MOC3041 is a zero crossing opto-triac so it isn't suitable for phase control anyway.

Brian.
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
betwixt is right of course, you need a non-zerocrossing detector optotriac like MOC3021 to implement phase angle control.
sowie i didnt get u delay_100us(): wat will dis function do..? y 100microsecond delay..? how sholud i make that function.
I don't believe, that there will be much doubts what delay_100us() means. It's just a placeholder for a short delay that's long enough to trigger the opto triac, below 20 µs according to the datasheet. Most embedded compilers have microsecond delay functions, if not, it's easy to create.
 

Code:
void isr(void) interrupt 0
{
delay(8);
moc=0; // bulb on
delay_100us():
moc=1; // triac is on now, switch off control
}

not working at all...ow the bulb remain off not even glowing...
 

Code:
#include <REG2051.H>
int i,j,a;
sbit up=P3^4;
sbit down=P3^5;
sbit moc=P3^7;
void delay();
/*void delay(int x)
{
	for(i=0;i<100;i++)
	for(j=0;j<x;j++)
		;							 
} */
void delay1(int d) 
	{
		int k;
		TL0=0x17;
	    TH0=0xFC;
		TR0=1;
		for(k=0;k<d;k++)			  //will produce dx1ms of delay
		  {
			while(TF0==0)
			TF0=0;
			TL0=0x17;
			TH0=0xfc;
		  }
		  TR0=0;
		  
	}

void isr(void) interrupt 0
{
	delay1(8);
	moc=0; // bulb on
	delay1(2);
	moc=1; // triac is on now, switch off control
}
void main()
{
TMOD=0x01;
//P3=0xff;
//IT0 = 1;   // Configure interrupt 0 for falling edge on /INT0 (P3.2)
EX0 = 1;   // Enable EX0 Interrupt
EA = 1;    // Enable Global Interrupt Flag
while(1)
{
 P1=0xA5;
}

}

- - - Updated - - -

HTML:
void delay1(int d) 
	{
		int k;
		TL0=0x17;
	    TH0=0xFC;
		TR0=1;
		for(k=0;k<d;k++)			  //will produce dx1ms of delay
		  {
			while(TF0==0)
			TF0=0;
			TL0=0x17;
			TH0=0xfc;
		  }
		  TR0=0;
		  
	}



as per my calculation the value "fc17" should produce 1milisecond of delay but it is not generating while i checked on keil debugger its producing around 66ms when i call delay1(8) where as it should produce 8ms delay . now tell me where i am wrong.
 
Last edited:

Please read my previous post. you CANNOT use the MOC3041 in this application becasue it has it's own built in trigger supression circuit that will not allow you to 'fire' it between zero crossing points. The best you can achieve is flickering and that's exactly what you saw. No amount of adjusting delays will help until you change to a different "non-zero crossing" type such as the MOC3021 suggested by FvM.

Brian.
 
  • Like
Reactions: FvM

    FvM

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top