Because I’ve had so much trouble with various sensors, I wanted to try an optical quadrature encode as I badly need a “gold standard” for motor performance, which currently eludes me…
But I just noticed the optical encoder interface seems to be interrupt based?
Does my 1000 line encoder have any chance of working at a reasonable RPM (at 10K RPM this would be interrupting the CPU at a rate of 330 Khz, can an STM even handle this?
Why use interrupts when most CPUs have HW quadrature decoders?
Because not all MCUs have this… and in terms of Arduino, there is no support for timer based encoders, but there is support for interrupts. So the basic Encoder solution can be considered as a “basic” cross platform compatible solution.
But no, I don’t think that it will work at 10kRPM…
But you’re in luck, our drivers repository contains a driver for STM32 MCUs to use their hardware encoder features. It needs specific pins to be used, but if you can set it up then it won’t use interrupts, and in fact it is an entirely overhead-free solution.
That’s great news Runger thanks so much, I’ll first get my encoder working with the interupt-based interface first then I’ll give the overhead-free one a go!