Beginnings of more flexible encoder and I/O support

The moteus controller, being a brushless servo drive, needs to use encoders to measure things like how the rotor is positioned relative the stator, and possibly output shafts that have passed through a reducing stage. The support for this has gradually expanded over time, but is still relatively limited as far as those things go. The available options are:

  • Primary encoder (used for commutation)
    • The onboard AS5047P
    • An external AS5047P
  • Auxiliary encoder (optional, for measuring the output shaft)

However, the moteus hardware has always been capable of more, both because the processor is a very capable one, and the exposed IO pins are relatively flexible. While looking at some future designs that incorporate even more IO options, I decided it was time to update the firmware to finally start taking advantage of that flexibility.

My goals can be broken down into two parts. First, what types of IO (input/output) to support, and second, how those inputs and outputs can be used.

I/O Support

For the types of encoders, there are first a number of “primitive” types that are somewhat like common interchange formats for encoders:

  • Quadrature – This uses two signal lines which cycle through a fixed pattern to indicate motion and direction.
  • Index – Here a single digital line is used to indicate when the rotating device is at a fixed position.
  • Sine / cosine – Two analog values report the sine and cosine of the angular position.
  • Hall effect sensors – Many brushless motors have 3 hall effect sensors permanently mounted inside which, while it cannot determine the position of the rotor relative to the stator fully, can determine the electrical phase configuration.

Second, there are a number of digital sensors which are relatively common in servo applications that are moderately convenient to interface.

  • iC-PZ – This is an absolute optical reflective encoder from iC-Haus which has relatively loose mechanical tolerances and very high resolution. It supports a number of protocols, multiple of which could work with moteus. Many diameter code rings are supported for hollow shaft applications.
  • RLS AksIM-2 – This is an absolute magnetic encoder with similar performance properties to the iC-PZ and also supports a variety of code ring diameters.

Third, the exposed pins of moteus could be used for application specific purposes:

  • Digital input – Some of the STM32 pins support 5V tolerant inputs, and all support 3.3V
  • Digital output
  • Analog input
  • Step/direction control
  • RC PWM/PPM input

How they can be used

There are a number of ways that encoders can be used, and it would be nice to be able to use some or all of them in different applications:

  • Electrical commutation – Determine the electrical phase for performing field oriented control.
  • Output position control – Provide feedback to the servo position and velocity control loop.
  • Disambiguate gear reducers – When an absolute sensor is present before a gear reducer, a separate sensor of lower quality can be used to determine in which sector of the output the reducer is currently in.
  • Application monitoring – In some cases, moteus may not need to use the value at all, but the application would like to monitor the position or rate of an encoder that happens to be colocated with a moteus.

Next steps

In the next post, I’ll take a look at the configuration model I implemented to support these goals in moteus!

2 thoughts on “Beginnings of more flexible encoder and I/O support

  1. Josh .. Do you plan to design a new hardware ? Or the R4.11 will be always OK ?
    Louis F.


    1. The features described here will work on all of the released moteus boards to date, although r4.5 and older did not have a connector for an external primary encoder. You can try out beta versions (and read the documentation), in the #encoder-mk2 channel in the mjbots Discord:


Comments are closed.