“Encoder: Processes quadrature encoder inputs of 588 counts per wheel turn from the” but the number of the encoder is no lineal, I cant do: (current_input-start_input)%588 = 1 cycle more
Alsi, if I observe the wheel, is not 588 per cycle, more or less 1000.
Do you have the second block of code inside your main loop() function? The serial protocol might be become unsynched, and that can be cause of the gibberish…
I would recommend trying something like this:
while (Serial.available()) {
Serial.read(); // empty the input buffer
}
Serial.write(CMD);
Serial.write(GET_ENC1); // Recieve encoder 1 value
while (Serial.available() < 3) {
// wait for all 4 bytes
}
enc1a = Serial.read();
enc1b = Serial.read();
enc1c = Serial.read();
enc1d = Serial.read();
result = enc1a << 24ul;
result += enc1b << 16ul;
result += enc1c << 8ul;
result += enc1d;
The number should indeed be pulses. We checked the specs, and the EMG49 motors actually have 980 pulses per rotation, not 588, so your observations are correct and we’ve updated our product page. The pulses should however be observed increasing linearly, but this might be a side effect of the serial communication problem. Please try the code above and let us know if it improves.