Good catch!
ESP32 with Triac
Re: ESP32 with Triac
Oh.. why ? The circuits I am finding around point toward 3063.. I am a new in this stuff, so please explain it to me if possible.
Re: ESP32 with Triac
There's of course tons of in-depth information on the internet, so let's keep it simple:
I would say the default way of light-dimming is leading edge trimming.
If we would e.g. dim at 50%, we cut-off the first half of the half-sine.
In other words, we ignite the triac half way the (half)sine wave.
At 50Hz, the whole sinewave duration is 1/50 = 20 milliseconds.
A half sinewave (positive or negative) duration is 10 mseconds.
Igniting half way means: ignite at 5 mseconds after zero crossing.
That's why you need a random-phase triac driver (like moc3023): we don't want to ignite at zero crossing (like moc3063), but (in this example) 5 ms later.
summarizing: led in 4N25 start emitting light just after zero crossing, generating an interrupt at the ESP32.
This interrupt starts a counter, and after 5 ms the ESP generates an ignite pulse for the moc-triac.
Hope this explains.
I would say the default way of light-dimming is leading edge trimming.
If we would e.g. dim at 50%, we cut-off the first half of the half-sine.
In other words, we ignite the triac half way the (half)sine wave.
At 50Hz, the whole sinewave duration is 1/50 = 20 milliseconds.
A half sinewave (positive or negative) duration is 10 mseconds.
Igniting half way means: ignite at 5 mseconds after zero crossing.
That's why you need a random-phase triac driver (like moc3023): we don't want to ignite at zero crossing (like moc3063), but (in this example) 5 ms later.
summarizing: led in 4N25 start emitting light just after zero crossing, generating an interrupt at the ESP32.
This interrupt starts a counter, and after 5 ms the ESP generates an ignite pulse for the moc-triac.
Hope this explains.
Re: ESP32 with Triac
Good lords. I haven't event think about this. So my design is generally flawed. Thank You very much !
Re: ESP32 with Triac
Yep. Will report in a week or two how it went.
-
- Posts: 1
- Joined: Fri Apr 05, 2019 4:47 am
Re: ESP32 with Triac
Dear All,
Look at the below code, it is Phase controlled. But it does not work.
//============================================================================================================
// setup code snippet
//============================================================================================================
attachInterrupt(digitalPinToInterrupt(ZCD_INT), zero_cross_detect, FALLING);
timer = timerBegin(0, 80, true); // Timer pre-scaled to 1usec
timerAttachInterrupt(timer, &dim_check, true);
timerAlarmWrite(timer, 1000, true); // 1ms; timer for testing purpose
timerAlarmEnable(timer);
----------------------------------------------------------------------------------------------
//============================================================================================================
// INTERRUPT FUNCTIONS - TIMER AND ZCD
//============================================================================================================
///*Timer Interrupt Function used to trigger the triac for Dimming*/
void IRAM_ATTR dim_check()
{
/*For Dimmer */
if (zero_cross == true)
{
if (dim_value >= dimming) // 'dimming' is controlled by USER: 0 to 9
{
portENTER_CRITICAL_ISR(&timerMux);
digitalWrite(DIMMABLE_TRIAC1, LOW); // turn on Triac
dim_value = 0; // reset time step counter
zero_cross = false; // reset zero cross detection
portEXIT_CRITICAL_ISR(&timerMux);
}
else
{
dim_value++; // increment time step counter
}
}
}
//--------------------------------------------------------------------------------------------------------------
/*ZCD Interrupt Function*/
void IRAM_ATTR zero_cross_detect()
{
portENTER_CRITICAL_ISR(&timerMux);
digitalWrite(DIMMABLE_TRIAC1, HIGH); // turn on Triac
dim_value = 0; // reset time step counter
zero_cross = true; // reset zero cross detection
portEXIT_CRITICAL_ISR(&timerMux);
}
---------------------------------------------------------------------------------------------------------
HARDWARE : ESP-WROOM32
OPTO BASED BASED ZCD HARDWARE (see attached diagram)
AC Frequency : 50HZ, 230V
FOLLOWING ARE THE ISSUES:
-------------------------
1. Zero Cross Detector Interrupts are generated for multiple times : 33usecs, 1.3ms and 8.7ms. How to avoid such extra interrupts ? I need interrupt only for 8.7ms
(see attached diagram)
Any Input in this direction would be great...I am using ESP32-Arduino for programming.
Look at the below code, it is Phase controlled. But it does not work.
//============================================================================================================
// setup code snippet
//============================================================================================================
attachInterrupt(digitalPinToInterrupt(ZCD_INT), zero_cross_detect, FALLING);
timer = timerBegin(0, 80, true); // Timer pre-scaled to 1usec
timerAttachInterrupt(timer, &dim_check, true);
timerAlarmWrite(timer, 1000, true); // 1ms; timer for testing purpose
timerAlarmEnable(timer);
----------------------------------------------------------------------------------------------
//============================================================================================================
// INTERRUPT FUNCTIONS - TIMER AND ZCD
//============================================================================================================
///*Timer Interrupt Function used to trigger the triac for Dimming*/
void IRAM_ATTR dim_check()
{
/*For Dimmer */
if (zero_cross == true)
{
if (dim_value >= dimming) // 'dimming' is controlled by USER: 0 to 9
{
portENTER_CRITICAL_ISR(&timerMux);
digitalWrite(DIMMABLE_TRIAC1, LOW); // turn on Triac
dim_value = 0; // reset time step counter
zero_cross = false; // reset zero cross detection
portEXIT_CRITICAL_ISR(&timerMux);
}
else
{
dim_value++; // increment time step counter
}
}
}
//--------------------------------------------------------------------------------------------------------------
/*ZCD Interrupt Function*/
void IRAM_ATTR zero_cross_detect()
{
portENTER_CRITICAL_ISR(&timerMux);
digitalWrite(DIMMABLE_TRIAC1, HIGH); // turn on Triac
dim_value = 0; // reset time step counter
zero_cross = true; // reset zero cross detection
portEXIT_CRITICAL_ISR(&timerMux);
}
---------------------------------------------------------------------------------------------------------
HARDWARE : ESP-WROOM32
OPTO BASED BASED ZCD HARDWARE (see attached diagram)
AC Frequency : 50HZ, 230V
FOLLOWING ARE THE ISSUES:
-------------------------
1. Zero Cross Detector Interrupts are generated for multiple times : 33usecs, 1.3ms and 8.7ms. How to avoid such extra interrupts ? I need interrupt only for 8.7ms
(see attached diagram)
Any Input in this direction would be great...I am using ESP32-Arduino for programming.
- Attachments
-
- ESP32-ZCD-details.png (369.22 KiB) Viewed 12680 times
-
- Posts: 10
- Joined: Fri Nov 01, 2019 6:52 pm
- Location: Italy
- Contact:
Re: ESP32 with Triac
Hi all,
Finally I can say that this library is working also for ESP32 rev0, (thanks -rudy-). Also thanks to mention an alternative way to control a electrical heating appliance through full lenght sinusoidal semi-period , avoiding that annoying buzzy sound.https://github.com/fabiuz7/Dimmable-Light-Arduino is the library I first tried (but couldn't get to work on the rev. 0 part). I didn't use it in the end, but it is worth looking at.
Find me on GitHub
-
- Posts: 1
- Joined: Thu Sep 01, 2022 2:09 pm
Re: ESP32 with Triac
Hi Ristridin, hi all other also knowledgable in trailing edge phase controllers,Ristridin wrote: ↑Mon May 20, 2019 6:06 pmThere's of course tons of in-depth information on the internet, so let's keep it simple:
I would say the default way of light-dimming is leading edge trimming.
If we would e.g. dim at 50%, we cut-off the first half of the half-sine.
In other words, we ignite the triac half way the (half)sine wave.
At 50Hz, the whole sinewave duration is 1/50 = 20 milliseconds.
A half sinewave (positive or negative) duration is 10 mseconds.
Igniting half way means: ignite at 5 mseconds after zero crossing.
That's why you need a random-phase triac driver (like moc3023): we don't want to ignite at zero crossing (like moc3063), but (in this example) 5 ms later.
summarizing: led in 4N25 start emitting light just after zero crossing, generating an interrupt at the ESP32.
This interrupt starts a counter, and after 5 ms the ESP generates an ignite pulse for the moc-triac.
Hope this explains.
sorry for derailing this old thread, but as an interested newcomer with a lot of half knowledge, I couldn't resist to try to get your attention. You seem to be knowledgable in the area of phase control circuits and I want to dive a bit deeper into this topic, but I might need a nudge in the right direction.
To keep it short, I want to dimm a LED filament light, which isn't meant for dimming. After reading through a ton of material (blog posts, introduction articles, the very valuable german wiki page and some some stuff more...) I came to the conclusion I would need a trailing edge phase control to not to mess around with the capacitor power supply integrated in the light bulb. I hope I am not completely wrong here.
As you gave recommendations for triacs I hoped you could point me to an explanation, a schematic and BOM for a trailing edge phase controller I could utilize with an ESP32.
Your advice is really appreciated.
Thanks in advance!
-----------------------------------------------------------------------------
Whatever it takes, let's dig down this rabbit hole.
Whatever it takes, let's dig down this rabbit hole.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32 with Triac
You might not be able to dim it at all, dependent on the power supply inside the lamp. If it's a capacitive dropper combined with some sort of current regulator IC, the current regulator IC will try to keep the current down the LEDs the same as you attempt to dim them down. This happens up to the point there's not enough voltage in the dropper cap, at which point regulation fails and the brightness will go down fast. As you only have a small range of voltage where you get proper dimming, a difference of a few volt in your 230V supply will get a lot of light difference, meaning the lamp will flicker.
Who is online
Users browsing this forum: No registered users and 52 guests