Page 1 of 1

Architecture for phase controlled triac

Posted: Wed Nov 08, 2017 2:05 pm
by snail71
I am designing a lighting controller and I'm having a bit of trouble figuring out how to handle the fast timing needed for phase control.

The circuit has four triacs. The AC signal is also being fed back to an input through an optocoupler that is used to detect zero crossings. I have the zero crossing input configured to generate an interrupt on falling edge. This part is working fine. The way I have designed it is to have a task for each triac. The zero crossing interrupt will give a semaphore to the triac tasks. The next part is where I'm having trouble. The tasks will then need to delay anywhere between 10uS to a full half AC cycle (120 Hz). My original thought was to just do a vTaskDelay of that time but I can't get micro second resolution.

After the phase delay the triac output would be turned on - then a 10uS delay - then back off again. The task would then wait on the next semaphore from the zero crossing input.

Any thoughts?

Re: Architecture for phase controlled triac

Posted: Wed Nov 08, 2017 5:34 pm
by ESP_Sprite
I think your best bet would be to use the MCPWM peripheral. It has a sync input that should do what you want, and would give you a phase control system entirely in hardware.

Re: Architecture for phase controlled triac

Posted: Thu Nov 09, 2017 10:46 pm
by snail71
Any suggestions for configuring this? I haven't seen any examples that do anything similar.

Re: Architecture for phase controlled triac

Posted: Thu Nov 09, 2017 11:20 pm
by ESP_Sprite
Look at the technical reference manual; it describes the peripheral. Also take a look at the documentation for the MCPWM driver in the esp-idf documentation, it should also help a bit. I don't think we have examples around for this specific use case, sorry.