George1988
Member
I am writing my code to measure two frequency values to estimate the velocity of two rotary encoders. I am trying to use the FreqMeasureMulti library to get two readings from the encoders, and the example file at
https://github.com/PaulStoffregen/F...ster/examples/Serial_Output/Serial_Output.ino does not work for me.
I tried with the FreqMeasure library on pin 3 and it worked. Below is my code, which worked:
Can you help me please to make it work on Teensy 3.6 with FreqMeasureMulti?
https://github.com/PaulStoffregen/F...ster/examples/Serial_Output/Serial_Output.ino does not work for me.
I tried with the FreqMeasure library on pin 3 and it worked. Below is my code, which worked:
Code:
#include <FreqMeasure.h>
unsigned long rpm1;
void setup() {
Serial.begin(57600);
FreqMeasure.begin();
}
double sum=0;
int count=0;
void loop() {
if (FreqMeasure.available()) {
// average several reading together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
float frequency = FreqMeasure.countToFrequency(sum / count);
rpm1 = (frequency*60)/96; // 96 are the line counts of the encoder http://www.quantumdev.com/finding-the-rpm-of-an-optical-encoder-using-an-oscilloscope/
Serial.print("rpm=");
Serial.print(rpm1);
Serial.print(",freq=");
Serial.println(frequency);
sum = 0;
count = 0;
}
}
}
Can you help me please to make it work on Teensy 3.6 with FreqMeasureMulti?