Using Motors As Encoders

If you have a brushless motor, you have some magnets, a bunch of coils arranged in a circle, and theoretically, all the parts you need to build a rotary encoder. A lot of people have used brushless or stepper motors as rotary encoders, but they all seem to do it by using the motor as a generator and looking at the phases and voltages. For their Hackaday Prize project, [besenyeim] is doing it differently: they’re using motors as coupled inductors, and it looks like this is a viable way to turn a motor into an encoder.

The experimental setup for this project is a Blue Pill microcontroller based on the STM32F103. This, combined with a set of half-bridges used to drive the motor, are really the only thing needed to both spin the motor and detect where the motor is. The circuit works by using six digital outputs to drive the high and low sided of the half-bridges, and three analog inputs used as feedback. The resulting waveform graph looks like three weird stairsteps that are out of phase with each other, and with the right processing, that’s enough to detect the position of the motor.

Right now, the project is aiming to send a command over serial to a microcontroller and have the motor spin to a specific position. No, it’s not a completely closed-loop control scheme for turning a motor, but it’s actually not that bad. Future work is going to turn these motors into haptic feedback controllers, although we’re sure there are a few Raspberry Pi robots out there that would love odometry in the motor. You can check out a video of this setup in action below.

8 thoughts on “Using Motors As Encoders

    1. I never heard of it before.
      I may be wrong, but it seems that also uses the generated voltage from the motion to detect it. Simultaneously, the motor is also energized to give a cogging effect. Someone on github mentioned that it cannot detect slow motion.
      My method is different, and makes it possible to determine the position even when the rotor is not moving. Actually, my basic implementation doesn’t work at higher speeds, because the generated voltage (EMF) distorts the signal. An advanced algorithm is needed to work in both regions.

      1. It is a long time when I left the school, but similar inductive coupling principle has been used for sensing the position for switched reluctance motors.
        By the way, the crucial detail when inductive coupling principle is used is to use “sensing” pulse, which does not interfere with the “supply” signal needed for keeping the motor in the motion. And it was doable thanks to insensivity of motors for higher-order harmonics (of course, only for some of them).

      2. No, most sensorless field-oriented-control systems use coupled inductance or similar methods to detect position at low speed. They then switch to back-EMF at higher speeds.

        The simpler 6-step PWM-based speed controllers usually use only back-EMF and thus have poor performance at low speeds.

        1. Can you link docs? I’m curious to see how it is done professionally.
          I knew about the back-EMF method and it was obvious that phase current measurements can also be used for this (details are still blurry for me tho).

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.