0
\$\begingroup\$

I'm using an STM32 for AC dimming, for which I use a GPIO output (or timer channel out) to drive a triac, whenever I get a zero crossing detection (rising edge). Is there a way to solve this only using timers architecture and without firmware overhead?i.e not using interrupt handlers.

  • Toff -> configurable.
  • Tonn -> remains the same.

enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ "I output PWM signal to triac ..." You can't use PWM on a triac. Once a triac turns on it remains on until the next zero-cross. I think you need to edit your question to explain it better. \$\endgroup\$ – Transistor Dec 24 '19 at 10:10
  • \$\begingroup\$ Yes, after each zero crossing I wait for Toff time and the triac is turned on later triac is switched off at zerocross. \$\endgroup\$ – Rohitsam Dec 24 '19 at 10:20
  • \$\begingroup\$ Mains frequency is low (100 or 120 zero-crosses per second). Why not have your code check the zero-cross in the main program loop? \$\endgroup\$ – Transistor Dec 24 '19 at 10:51
  • \$\begingroup\$ It shouldnt be problem , just wanted to know if the stm32 timer architecture is self-sufficient. \$\endgroup\$ – Rohitsam Dec 24 '19 at 13:09
0
\$\begingroup\$

You can put a timer (A) in single shot triggered from an external pin.
This external pin is your zero crossing detector.

You also may need a timer (B) to measure the frequency.

Software still needs to calculate the duty cycle percentage based on the frequency. And set timer A reload to the measured value in timer B.

However, you could use a DMA operation triggered by timer A to copy the capture time of B to the reload register of A. But, you're calculating with those numbers anyway.


Having an ISR called at 50Hz isn't a problem when it doesn't take a lot of time to process it.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It shouldnt be problem , just wanted to know if the stm32 timer architecture is self-sufficient \$\endgroup\$ – Rohitsam Dec 24 '19 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.