Dear Paul and the other contributors of this fabulous platform!
Just to introduce my self because its the first time:
I have shifted from Arduino to the Teensy 4 because in need of a microcontroller capable of real time task execution for a high performance PID controller.
At the moment I am really satisfied, and i think i will only work with teensy in the future, so really thank you Paul and the other contributors!
Substantially the problem I have encontered is that i must elaborate as fast as possibile and with the highest resolution possible the frequency output of an encoder.
I am happly using the library Freqmeasure ported for the T4 but now it became a limit because I cannot let the encoder "work" in quadrature.
I am using such library beacause i needed to use the clock cycle as the smaller time unit possible to enhnche the resolution and i did not know another method on the T4 beacause I am a newbie with it.
I thougt that freqmeasuremulti could let me address such situation but i think the library could have a bug for the T4 unless I am using it in the wrong way.
I wrote few line of code to the test it out side of my program and it manifest the same problem.
I have downloaded the latest version of this library and I am using the latest version of the Arduino IDE with teensyarduino
Only pin 22 and 3 have channel A and B of the encoder connected in this test. (IT IS A 600cpr encoder)
The Serial print output is as follow, you will see that the readings don't updates as they should:
chA: 3038 1 327680.00 457.76 22.89
chA: 3039 2 393216.00 381.47 19.07
chA: 3040 1 393216.00 381.47 19.07
chA: 3041 2 393216.00 381.47 19.07
chA: 3042 1 196608.00 762.94 38.15
chA: 3043 1 196608.00 762.94 38.15
chA: 3044 2 393216.00 381.47 19.07
chA: 3045 1 393216.00 381.47 19.07
chA: 3046 2 458752.00 326.97 16.35
chA: 3047 1 458752.00 326.97 16.35
chA: 3048 2 458752.00 326.97 16.35
chA: 3049 1 458752.00 326.97 16.35
chA: 3050 2 458752.00 326.97 16.35
chA: 3051 1 458752.00 326.97 16.35
chA: 3052 2 458752.00 326.97 16.35
chA: 3053 1 524288.00 286.10 14.31
chA: 3054 2 524288.00 286.10 14.31
chA: 3055 1 524288.00 286.10 14.31
chA: 3056 2 524288.00 286.10 14.31
chA: 3057 1 458752.00 326.97 16.35
chA: 3058 2 524288.00 286.10 14.31
chA: 3059 1 524288.00 286.10 14.31
chA: 3060 2 458752.00 326.97 16.35
chA: 3061 1 524288.00 286.10 14.31
chA: 3062 2 524288.00 286.10 14.31
chA: 3063 1 524288.00 286.10 14.31
chA: 3064 2 589824.00 254.31 12.72
Also, if I use such library inside mine final program, it gives only readings value like 65555 or 0....
But i should test it more in such environment.
It would be kind if someone could help me to address such problem because i cannot do more by myself because I am still in a learning process.
Thank you again!
ps: for very slow rotation of the encoder the readings update correctly every time
Just to introduce my self because its the first time:
I have shifted from Arduino to the Teensy 4 because in need of a microcontroller capable of real time task execution for a high performance PID controller.
At the moment I am really satisfied, and i think i will only work with teensy in the future, so really thank you Paul and the other contributors!
Substantially the problem I have encontered is that i must elaborate as fast as possibile and with the highest resolution possible the frequency output of an encoder.
I am happly using the library Freqmeasure ported for the T4 but now it became a limit because I cannot let the encoder "work" in quadrature.
I am using such library beacause i needed to use the clock cycle as the smaller time unit possible to enhnche the resolution and i did not know another method on the T4 beacause I am a newbie with it.
I thougt that freqmeasuremulti could let me address such situation but i think the library could have a bug for the T4 unless I am using it in the wrong way.
I wrote few line of code to the test it out side of my program and it manifest the same problem.
I have downloaded the latest version of this library and I am using the latest version of the Arduino IDE with teensyarduino
Code:
#include <FreqMeasureMulti.h>
FreqMeasureMulti chA;
FreqMeasureMulti chB;
float frq_rd=0, frq=0, rpm=0;
int indx=0, enc_res=1200, levels=0;
void setup()
{
chA.begin(22);
chB.begin(3);
}
void loop()
{
if( chA.available() )
{
frq_rd = chA.read();
levels = chA.readLevel();
frq = chA.countToFrequency(frq_rd);
rpm = frq / enc_res * 60;
indx ++;
Serial.print("chA: "); Serial.print(indx); Serial.print(" "); Serial.print(levels); Serial.print(" ");
Serial.print(frq_rd); Serial.print(" "); Serial.print(frq); Serial.print(" "); Serial.print(rpm); Serial.println(" ");
}
}
Only pin 22 and 3 have channel A and B of the encoder connected in this test. (IT IS A 600cpr encoder)
The Serial print output is as follow, you will see that the readings don't updates as they should:
chA: 3038 1 327680.00 457.76 22.89
chA: 3039 2 393216.00 381.47 19.07
chA: 3040 1 393216.00 381.47 19.07
chA: 3041 2 393216.00 381.47 19.07
chA: 3042 1 196608.00 762.94 38.15
chA: 3043 1 196608.00 762.94 38.15
chA: 3044 2 393216.00 381.47 19.07
chA: 3045 1 393216.00 381.47 19.07
chA: 3046 2 458752.00 326.97 16.35
chA: 3047 1 458752.00 326.97 16.35
chA: 3048 2 458752.00 326.97 16.35
chA: 3049 1 458752.00 326.97 16.35
chA: 3050 2 458752.00 326.97 16.35
chA: 3051 1 458752.00 326.97 16.35
chA: 3052 2 458752.00 326.97 16.35
chA: 3053 1 524288.00 286.10 14.31
chA: 3054 2 524288.00 286.10 14.31
chA: 3055 1 524288.00 286.10 14.31
chA: 3056 2 524288.00 286.10 14.31
chA: 3057 1 458752.00 326.97 16.35
chA: 3058 2 524288.00 286.10 14.31
chA: 3059 1 524288.00 286.10 14.31
chA: 3060 2 458752.00 326.97 16.35
chA: 3061 1 524288.00 286.10 14.31
chA: 3062 2 524288.00 286.10 14.31
chA: 3063 1 524288.00 286.10 14.31
chA: 3064 2 589824.00 254.31 12.72
Also, if I use such library inside mine final program, it gives only readings value like 65555 or 0....
But i should test it more in such environment.
It would be kind if someone could help me to address such problem because i cannot do more by myself because I am still in a learning process.
Thank you again!
ps: for very slow rotation of the encoder the readings update correctly every time