Hi Folks,
I am using a Teensy 3.6 to time PWM pulses from my RC receiver. I've noticed there is about 1 microsecond of "jitter". Is there any way to reduce this? Here is the ISR code I am using. Thank you very much for any advice!
I am using a Teensy 3.6 to time PWM pulses from my RC receiver. I've noticed there is about 1 microsecond of "jitter". Is there any way to reduce this? Here is the ISR code I am using. Thank you very much for any advice!
Code:
void Receiver::UpdatePWM(uint8_t ch) {
// Current time in microseconds
event_t = micros();
if (digitalReadFast(gc->RX_PIN[ch]) == HIGH)
{
// Rising edge, store the time
ch_time_last[ch] = event_t;
}
else
{
// Falling edge
if (((event_t - ch_time_last[ch]) >= gc->PWM_HARD_MIN_RC) && ((event_t - ch_time_last[ch]) <= gc->PWM_HARD_MAX_RC)) {
ch_pwm[ch] = (event_t - ch_time_last[ch]);
}
}
}