Hello Geeks,
I was wondering whether i can use pwm channels on N78E059A Nuvoton micro-controller as lamp dimmer. I have actually done a pwm code on ESP8266 WiFi module but the problem is that the lamp flickers a lot, so i was wondering whether pwm channels can help me or not. I think i need fading effect in-order to stop flickering of the lamp ?
The hardware with me is N78E059A (8051 core with pwm channels), MOC3041 opto coupler for triac BT12 and an incandescent lamp.
Any help will be helpful.
PWM is normally used when you have a DC-driven device like directly driven LED. Or when you involve some inductive design to create a DC/DC converter or similar.
With incandescent lamps, the traditional way to dim them is to block out parts of each half-period of the sinus. So you implement a delay function to control when to ignite a triac/quadrac that will then stay on for the rest of the half-period until the zero-crossing where it will turn off and wait for a new trig on the gate. This means the half-periods of mains represents the frequency of the PWM - and the delay before igniting the gate represents the pulse quotient. And since the frequency is generated by the mains, you don't really want a PWM device to produce the gate delay. If using a microprocessor, the processor would need to detect the zero-crossing to know when to start counting the delay time. A much easier way is to just use some RC design to slowly charge and reach the trig voltage of the gate of the triac.
Note that a triac can't be turned off on command. The gate can be used to turn it on. But you then need to remove the voltage over the triac to make it turn off - a PWM signal on the gate will be incapable of such a feat.
A significant thing to consider is that having a microcontroller to control mains-driven incandescent lamps is that mains-powered lamps means you have high voltages around your processor. So lots of opportunities to either fry your processor or to get yourself electrocuted. Remember that the processor needs a low-voltage supply and a low-voltage signal to control the light intensity while the zero-crossing signal swings +/- the peak voltage of mains - and the peak voltage of mains is sqrt(2)*Vrms. So with 230V mains, you have peak voltages of +/- 325V. Add to that spikes. Add to that the required safety margins required. So you end up needing kV-class isolation.
Not only needs the used components be certified for this but all isolation distances must also be large enough. Very few people who do have the required knowledge to make safe designs fulfilling UL, CE or similar requirements would show up and ask questions on this kind of forum.
If you throw out that triac and instead use a FET and operate on maybe 12V DC-driven lamps, then you can play around all you like with PWM - a FET can be turned on/off at will so it works well to create a PWM-controlled dimmer as long as you take into account the losses in the FET during switching and protects it from significantly inductive or capacitive loads.
Okies after reading your reply and doing some homework over the internet i came to know that to implement dimmer using micro controller i need to implement zero-crossing detection without which dimming is not possible.
Thanks for your valued reply. It helped me a lot.
"without which dimming is not possible"
Dimming is possible without zero-crossing detection. It's just that not in a design with a triac/quadrac, since when you have a component that you can't turn off on request you instead have to control when it is turned on. So the zero-crossing is important to decide the turn-on time.
If using a component that can be turned both on and off on request, it's possible to ignore the mains frequency and instead turn on/off the power at a much higher frequency. Then it's possible to use PWM and ignore the zero-crossing. The disadvantage is that switch transistors have losses when they turn on/off since the switching isn't instant and in the middle of switching they look like resistors with a significant resistance which means in the middle of the switching they behave like heating elements. Old switch transistors were too inefficient and/or expensive which is why the triac solution was common 20-30 years ago.
The advantage with switching at a much higher frequency is that on average it still produces a sinusoidal load with a bit of low-pass filtering. The triac solution creates very ugly distortion of the sinus wave which affects other customers and the grid - the power company doesn't like consumers who only want to consume the tail part of each half-wave while not loading the network on the leading half of the half-waves. That's not a load the generators are designed to support. And such a load produces huge amounts of overtones that will radiate from the cables.
Okay,
I am not that much into the power theory. I am basically a programmer who like to do embedded programming and do some hardware assembly with the help of people like you. After reading your last reply i think i should go with MOC3021 with zero crossing detection for firing the triac. Actually i have one circuit in that i don't see zero crossing circuit. If i have time i will email you the image of that circuit may be you can have a say on how dimming is implemented on it.