Hi Rob,
Thank you for your answer.
As I understood, this is the basic theory, yes.
In the meantime, I found something on the
Microchip Forum, especially the part "
One approach is to dedicate TWO timers or capture channels to the task:
One grabs the ON time (or OFF time); the other grabs the period of the
entire waveform
"
If I understand correctly, I need a PIC with two timers capable of CCP (used in capture mode), == OR == two timers that can be controlled by a gate (which will be the PWM signal), if I can configure the edge of the control gate, which does not seem be the case on common PIC's....
Then:
- Start to count a Fosc (maybe 2 MHz as you suggested) when rising edge (or falling, not important) at both timers
- When falling edge, stop the count on the first timer
- When rising edge, stop the count on the second timer
- Divide first number by second number, multiply by 100, and display
- repeat
Since the PWM signal has a very low frequency (30 Hz), I will have plenty of time to process the computation in between two periods of the PWM signal.
The display will be based on 74hc595 driven 7-segments. This does not take much time either to update, and I have them laying around.
What do you think of that approach ? Does it sound right to you ?
Thanks again !