1
\$\begingroup\$

I am trying to implement a phase control circuit for driving a TRIAC/SCR. I plan to use an xmegaA4U series microcontroller.

I already know that I can route the AC signal through a voltage divider and into the analog comparator, and route the output of the DAC to the other input of the analog comparator. From there I can select rising edge or falling edge triggering and that will allow me to control firing angle by programming the DAC (and the trigger edge).

The last bit of the puzzle is the firing pulse to the gate of the TRIAC/SCR. I figure I can route the output of the analog comparator to a timer channel via the event system, however, I am not sure that I can configure the timer to operate as a one-shot that can elicit a change on an output pin. Does anyone know if this is possible?

P.S. I know this could very easily be done in software with interrupt handlers, however I am trying to "kick the tires" on the xmega and event system, so I want to have minimal CPU intervention besides setting the pulse width once, and the DAC output when the firing angle needs to change. Beyond that, the hardware should take care of it.

\$\endgroup\$
1
\$\begingroup\$

I am not sure that I can configure the timer to operate as a one-shot that can elicit a change on an output pin. Does anyone know if this is possible?

It is possible to generate a true fixed-length one-shot on AVR8 Timer hardware, but it is not straight forward.

The basic idea is to set the match value higher than the top value. If you then set the count to a value higher than the top, it will count up and hig the match exactly once before overflowing back to zero and then getting trapped down below match.

Using this technique it is actually possible to trigger a one-shot pulse as short as a single cycle. Additionaly, once started these one-shots will run deterministically to completion without any intervention whatsoever from the processor.

enter image description here

A full explanation and working code available here...

https://wp.josh.com/2015/03/12/avr-timer-based-one-shot-explained/

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Definitely a cool concept, but I'm specifically looking for a hardware only solution. I may have found a way with the xmegaE and XCL, as the XCL natively supports a one-shot PWM that can be triggered by events. I will need to check on some of the configuration for it, and if it works I will answer my own question. \$\endgroup\$ – Brendan Simpson Jun 7 '16 at 19:09
  • \$\begingroup\$ You might be able to trigger the one-shot timer using and event from the comparitor. You might also be able to use the timer's input capture mode, but set it up so that it creates the pulse as a side effect. \$\endgroup\$ – bigjosh Jun 7 '16 at 19:22

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.