nilton61:
That sounds pretty complicated but still doable if you got your math right.
I have been using these 1024p/r encoder a lot If you act on every edge you can get 4096 counts/rev. With a 50mm dia masuring wheel that will give you a linear resolution of 0.03835mm
Here is some example code:
const char encTable[16] ={0, 1, -1, -0, -1, 0, -0, 1, 1, -0, 0, -1, -0, -1, 1, 0};//gives -1, 0 or 1 depending on encoder movement
volatile long actPos;
volatile byte encState;
void setup(){
Serial.begin(115200);
attachInterrupt(0, readEnc, CHANGE);
attachInterrupt(1, readEnc, CHANGE);
}//setup()
void loop(){
Serial.println(actPos);
delay(500);
}//loop()
void readEnc(){
encState = ((encState<<2)|((PIND>>2)&3))&15;//use encoder bits and last state to form index
actPos += encTable[encState];//update actual position on encoder movement
}//readEnc()
Thank you very much
this us exactly what i need but... I See too much wires :o is there a Hardware usage example (or a sketch up diagram ;'D )
And another question, sequentially i get YPR data from IMU (i said sequentially because is impossibile to use multithreading in Arduino) and Shaft, will i have problems with clock ( latency or delay on the read of one of two sensors)?
Thaaaaaaanks, have a nice day 