This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Measuring of duty cycle

I should implement hysteresis current control on Piccolo TMS32028027 microcontroller. I need a few counters. I will use eCAP as a grid frequency measurement, but I need at least two more counters which should be used for duty cycle measuring and for switching period measuring... 

The results of that counters should be used in further calculation in the algorithm of controller...

Does anyone know how to solve this problem? Are there need for some additional hardware or something else?

Thanks in advance!

  • It depends on your desired timer resolution. If you don't need very high resolution, you can use a hardware timer that updates software timers on every interrupt. You can make many SW timers using this method.

  • Actually, I need a timer/counter which should measure duty cycle where switching frequency is about 40kHz (Tprd=25us, but there is another more problem, when duty cycle is very small, short pulses which are much less than 25us...) So I need high resolution of timer/counter...

     

  • Nikola,

    I can think of three ways (some better than others).  There are likely others, perhaps others on the forum will add ideas.

    1. Using the eCAP module is the best way (however you mentioned that you're already using the only eCAP module which is on the F28027)
    2. The second best way would be if you have some spare ePWM modules.  You could use the ePWM's TZ submodule as a way to accurately stop a timer and measure duty cycle.  You'd start a second PWM when the main PWM is to go high.  You'd then set the second PWM to TRIP on the main PWM's high-to-low transition.  By reading the second PWM timer you can then get an accurate count of PWM cycles.  (the second PWM could also trigger a PRD interrupt if it never receives an high-to-low edge)
    3. Use interrupts.  One potential method is that most GPIO-inputs can be used as a external interrupt source (XINT).  Via an interrupt this could then read a CPU Timer and compare to get a duty cycle.  However, in order to get accurate counts you'd need to make sure all other interrupts are architected or time-sliced to be pretty short.
    4. I'm sure you could do something with external circuitry if you had to.


    Thank you,
    Brett