jonidohc16v
Member
Hello everyone,
I'm working on a project with the Teensy 4.1 and I'm using the FreqMeasureMulti library, to get the PWM value from a Servo. But I'm having a little problem, the values it prints in the Serial are not consistant. They are always "glithcing" at least 1 value and I don't even move the servo, like this:
663.45
657.40
661.48
657.40
657.40
655.36
661.48
661.48
653.31
669.65
651.31
The situation is, I used the same code with a Teensy 3.2 and 3.6 and it worked perfectly like I wanted, but with the 4.1 not. So, my question is, is there a bug with the 4.1 or am I doing something wrong.
Here's the code by the way:
Thank you and I hope that someone can help
I'm working on a project with the Teensy 4.1 and I'm using the FreqMeasureMulti library, to get the PWM value from a Servo. But I'm having a little problem, the values it prints in the Serial are not consistant. They are always "glithcing" at least 1 value and I don't even move the servo, like this:
663.45
657.40
661.48
657.40
657.40
655.36
661.48
661.48
653.31
669.65
651.31
The situation is, I used the same code with a Teensy 3.2 and 3.6 and it worked perfectly like I wanted, but with the 4.1 not. So, my question is, is there a bug with the 4.1 or am I doing something wrong.
Here's the code by the way:
Code:
#include <FreqMeasureMulti.h>
FreqMeasureMulti Servo1;
void setup()
{
Serial.begin(115200);
while (!Serial);
Servo1.begin(22,FREQMEASUREMULTI_MARK_ONLY);
}
float sumServo1 = 0;
int countServo1 = 0;
elapsedMicros timeout;
void loop()
{
if(Servo1.available())
{
sumServo1 = sumServo1 + Servo1.read();
countServo1 = countServo1 + 1;
}
if(timeout > 100000)
{
if(countServo1 > 0)
{
Serial.print((Servo1.countToNanoseconds(sumServo1/countServo1))*0.001);
//Serial.print ((((R5ER.countToNanoseconds(sumServo1 / countServo1))-752650)/ 2294.7))
}
else
{
Serial.print("(no pulse)");
}
Serial.println();
sumServo1 = 0;
countServo1 = 0;
timeout = 0;
}
}
Thank you and I hope that someone can help