I am working with a magnetic encoder that outputs a PWM waveform with the duty cycle proportional to the position for one rotation. The PWM frequency is 1khz and the minimum "ON" period before rolling over to a new rotation is 1.8us (the minimum "OFF" period is about 2x longer). Initially, I intended to pass the PWM through a low pass filter and read the result via ADC, but I am having an issue with noise on the output of the low pass due to noise in the amplitude of the output from the encoder (but not noise in the duty cycle).
Which brings me to where I am currently at, needing to measure a short period between rising and falling edges that ranges from 1.8us to 1ms with at least 10bit resolution. Any solution cannot impede the main loop for more than 100 microseconds, as the same controller monitors other functions that are time dependent (BLDC motor control, current sense, etc).
Searching and reading over the last day has led me to believe that FTM timers may be exactly what I need for this purpose, but I am having trouble grasping my mind around the lower level functions of the Teensy. This leads me to a few questions:
1. Does anyone know of a library that can already do what I need (calculate the length of a pulse without impeding the main program for the duration of each measurement)?
2. Is there a tutorial on accessing the FTM? My degree and background is in mechanical, so my experience with low level programming is limited.
3. Is there a list of variables for low level functions of the K66 family somewhere? I am looking through FreqCountTimers.h to try to understand FTM and am seeing variables accessed that seem to exist due to the core programming without indication of what their purpose is. I would like to know where these come from, or at least how they are determined using the K66 manual. For example, in FreqCountTimers.h, line 120, 121, variables TCCR1A and TCCR1B are accessed.
Thank you for reading.
Which brings me to where I am currently at, needing to measure a short period between rising and falling edges that ranges from 1.8us to 1ms with at least 10bit resolution. Any solution cannot impede the main loop for more than 100 microseconds, as the same controller monitors other functions that are time dependent (BLDC motor control, current sense, etc).
Searching and reading over the last day has led me to believe that FTM timers may be exactly what I need for this purpose, but I am having trouble grasping my mind around the lower level functions of the Teensy. This leads me to a few questions:
1. Does anyone know of a library that can already do what I need (calculate the length of a pulse without impeding the main program for the duration of each measurement)?
2. Is there a tutorial on accessing the FTM? My degree and background is in mechanical, so my experience with low level programming is limited.
3. Is there a list of variables for low level functions of the K66 family somewhere? I am looking through FreqCountTimers.h to try to understand FTM and am seeing variables accessed that seem to exist due to the core programming without indication of what their purpose is. I would like to know where these come from, or at least how they are determined using the K66 manual. For example, in FreqCountTimers.h, line 120, 121, variables TCCR1A and TCCR1B are accessed.
Thank you for reading.