I need the following sensor as a positional reference for a vertical moving platform:


The encoder has a linear resolution of 0.25 mm, which generates 40.000 pulses/second when using a maximum speed of 10 m/second (the platform is moved by hand, so it should be less than this in average).

Is the raspberry pi fast enough to work with 40000 interrupts/second??? (I think that is what I need to manage if I'm moving with 10m/second, correct me if I'm wrong)

I've done a quick test using the wiringPi library and I did not get back to the initial value, when I moved the platform back to initial position. It worked, when I was moving the platform really slow, but that's not my aim.

My ideas now are to use the pigpio library (I'm writing in c) or to use an arduino board just for reading the encoder (as worst case solution). Are there any other solutions?

I've also read about quadrature decoding ICs. What that be a possible solution?

Thanks in advance :)

Best regards,


  • Linux on the Pi can't handle an interrupt every 25 µs to userland (it takes >50 µs to wake-up a userland process). pigpio samples so will capture the events. Whether the rest of the software can keep up or not is down to you.
    – joan
    May 22, 2016 at 8:34

1 Answer 1


There are some pigpio encoder examples.

  1. Python at abyz.me.uk/rpi/pigpio/examples.html#Python_rotary_encoder_py

  2. C but using the daemon at abyz.me.uk/rpi/pigpio/examples.html#pdif2_RED.

    The C code uses the same interface as Python but can handle far higher rotation rates. Python implementation did it for me , however my encoder has 1000 pulses/revolution

  • Thanks :) I will try that and give some feedback if it works :)
    – Niko
    May 24, 2016 at 5:41
  • Just a short feedback: I have chosen this IC to solve my problem and it works great: mikroe.com/click/counter
    – Niko
    Jun 16, 2016 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.