it's been a while ago, but it's nice to be back at avrfreaks.net 8)
I need to measure the duty cycle of a PWM signal. The PWM frequency can vary in the range of 100 Hz to 1kHz. The PWM amplitude can vary in the range of 100mV to 2.5V, too.
The simpliest way to measure the duty cycle is by utilizing the input capture feature of Timer1 (ATtiny24). The PWM signal isn't as simple as a TTL signal, so I want to use the build in analog comparator as input capture trigger source.
With Timer0 I want to generate a PWM which goes through a low pass filter to the positive analog comparator input. This my reference DC voltage.
The PWM signal I need to measure, is connected to the negative analog comparator input.
My question is, how much ripple can I tolerate on my DC reference? I have attached a picture which shows the problem. The PWM input signal must pass a low pass filter before it reaches the analog comparator input. Thus it is possible, that one PWM edge triggers several input capture events.
I looked at the ATtiny24 datasheet but couldn't find any information about the analog comparator hysteresis. The analog comparator output is not connected to an IO pin. So I can't add any hysteresis via a resistor.