Encoder loosing steps


I have the following setup:

When I am using the normal programm the encoder status is only uptaded on the serial monitor about every half second. And even though the counter is refreshed when the count is eather +2048 or -2048 the value in the serial monitor can get higher. (example: 2155)

When I deleted the following coder, the serial monitor is updated way quicker and the value doesn’t get anymore over 2048.

//#if 1
// // Wait one second with interrupts disabled
// noInterrupts();
// // We can’t call delay() since it uses interrupts, so use busy loops
// for (int i = 0; i < F_CPU / 10; i++) {
// asm (“nop”);
// }
// interrupts();
// //delay(1);

But when the part is turning a couple hundret times my zero-point of the shaft is drifting away, which means that the encoder is skipping some signals.

Does anyone has experience with the Vidor and using an encoder?

Thank you :slight_smile:


Lucky enough it's not the fpga missing steps but rather the issue is that since API calls are a bit slow between the time you read and the time you write encoder is incrementing and result is that zero is not where it should be anymore. For example, you read 2040 and do nothing then at next round you read 2050 and reset to 0 and you just lost two steps.
If you want to avoid this you should rather avoid zeroing at runtime and eventually use modulo to check where you are.. basically you need a number between 0 and 4096 so if you use value%4096 you will still have a number in that range without the need to reset


thank you very much for your advice. This works perfect :slight_smile:

Do you know if there is any posibility to set outputs based on the encoder value in the FPGA?

For example:

if encoder value is 2022 then set output HIGH

Thank you :slight_smile:

Hi Michael,
no, there is no such possibility right now but if you explain me how you plan to use it and if it's something more generally useful we can implement it.


Thank you for your reply.

I want to trigger a camera based on the encoder position.
It would be very nice to set outputs based on the position :slight_smile: