Time to play "grammar police" and get really meticulous about some terminology for the sake of clarity. I'll add comments / corrections in-place in red.
So... what I should do is to increase a counter (for the velocity) every time that quadrature state changes. No, the count value is for the *position*. And you might increment it or you might decrement it, depending on which specific quadrature state change occurs.
Then, according to that values that I received from this vel_counter (let vel_count be the counter of the velocity) I should divide this value by the dT factor that has passed from the initial position and the current position, right? More or less right, but again, you should think of this count as a *pos_count* value, not a vel_count.
And, guys, I've read about miscount error for encoder measurements, do you think guys that I have some problem about this last one factor with the code in this thread? This "miscount" error is always present and cannot be avoided with changes to the code. It is an inherent quantization effect, representing the resolution limit you can achieve with a digital encoder.
-Kevin P
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.