• Soooo many encoders! (and more to come...)

    Josh Pieper10 minutes ago 0 comments

    All the released versions of moteus have had an ABS port, and since r4.8 it has had an ENC port.  To date, the only supported things for the ABS port was to attach a low rate I2C device as a disambiguator, and the only use for the ENC port was to connect an external primary encoder.

    No more!

    Now, the ports can be used for a host of encoders and other accessories, including:

    • Quadrature / Index
    • Sine / Cosine
    • I2C - AS5048, AS5600
    • SPI - AS5047, iC-PZ
    • UART - AksIM-2
    • GPIO

    Additionally, you can flexibly set up which encoder(s) are used for commutation, output, and disambiguation, in addition to monitoring the values of everything over CAN.  All of these features are available now in the 2022-06-28 release on github and work with every released moteus board (with the caveat that r4.5 and earlier have no ENC port).

    Here's a big video showing a bunch of different possible configurations:

    The details of how to set things up can be found in a series of blog posts:

    And all the worked examples can be found at:

  • Acceleration and velocity limited trajectory following

    Josh Pieper04/18/2022 at 10:47 0 comments

    To date, the only onboard trajectory following that moteus implemented was a limited form of constant velocity tracking.  This was the minimum viable setup, as it allowed an external controller to command piecewise linear trajectories in nearly any form.  However, it isn't all that convenient for simple systems, where you don't necessarily want to implement a complex controller.

    So, now, one of the most requested features for moteus is now a reality: acceleration and velocity limited trajectories!

    Using it can be pretty simple, just configure `servo.default_velocity_limit` and `servo.default_accel_limit` to values that are not `nan`.  Then all position mode commands will obey the desired velocity and acceleration limit.  See the results in the video below:

    For more advanced cases there are more options... you can only limit acceleration or velocity, and you can override the limits on a per-command basis.  Finally, if you leave the limits as `nan`, then you get the same legacy behavior, which can be useful if you want jerk limited trajectories for instance, which the onboard controller can't do.

  • Configurable PWM rate

    Josh Pieper03/28/2022 at 16:35 0 comments

    moteus is a switch mode motor driver.  That means it alternately switches the phase terminals of the motor between ground and the positive input to either decrease or increase the current through the winding inductance.  Like most switch mode motor drivers, it performs that switching at a fixed frequency.  To date, that has been a fixed 40kHz frequency.

    As of firmware release 2022-03-12, this frequency can now be configured to anywhere between 15kHz and 60kHz to give you more flexibility at optimizing various parameters.

    There are a few performance measurements that fall out from the switching rate, otherwise know as the PWM rate, short for pulse width modulation.

    Efficiency: Lower PWM rates results in higher efficiency for the driver.  That means less power will be used, and the motor driver will generate less heat for a given load.

    Peak power: Higher PWM rates result in higher peak power.  moteus is limited in peak power by its bulk capacitance.  Higher PWM rates result in less ripple, so that more instantaneous power can be applied.

    Motor speed and control bandwidth: These usually aren't a problem, but the moteus control loop runs at the PWM rate as well.  That means that a lower PWM rate will result in reduced control bandwidth, and a reduced maximum electrical frequency.  The effective control bandwidth and motor speed are not usually limited in this way for most applications though, so it isn't as likely to affect the PWM rate selection.

    To get a feel for what you could expect for peak power and efficiency at different control bandwidths, I ran some experiments with an mj5208 motor.

    FrequencyPeak Power24V Eff / Idle Thermal36V Eff / Idle Thermal
    15kHz190W94% / 0.20W92% / 0.25 W
    40kHz500W88% / 0.25W85% / 0.30W
    50kHz625W84% / 0.30W84% / 0.35 W

  • Improved calibration mechanism

    Josh Pieper11/23/2021 at 14:50 0 comments

    TLDR: The default calibration approach used by moteus_tool as of version 0.3.30 now works on a much wider variety of motors, including gimbal style high resistance motors, and smaller high Kv motors.

    pip3 install --upgrade moteus

    Long form

    During the calibration process, moteus_tool measures a few different motor parameters.  Those are the relationship between the electrical phases and the magnetic encoder, the phase resistance, the phase inductance, and the Kv rating.  Each of these operations has to assume something about the motor in order to operate correctly.  While those assumptions are configurable, there are many things that have to be set for any given motor and the names are non-obvious.

    With the newer version, there are two primary tunables.  The first is how much power to dissipate in the windings during the encoder, resistance, and inductance calibration phases.  The second is the maximum mechanical speed to try to spin at during Kv calibration.

    Given those values, moteus_tool gradually ramps up the voltage to find an appropriate value that roughly matches the desired power consumption and the desired speed.  That makes it work on motors with very low or high resistance, and very low or very high Kv with no modifications.

    All the old parameters are still there, albeit with rationalized names.  If you want the details of what those names are, you can check out the more detailed write-up at: https://jpieper.com/2021/11/23/improved-moteus_tool-calibration/

  • moteus r4.8

    Josh Pieper09/13/2021 at 14:53 0 comments

    There's a new version of moteus out!  For now, the biggest win is that it uses components which I was able to actually purchase, and thus it is in stock!


    It does finally support external primary encoders, which I'll write up more about soon!

  • Auxiliary encoders

    Josh Pieper04/28/2021 at 15:32 0 comments

    moteus has always had a port intended for use as an extra absolute encoder, and now it finally works!  This is for the case where you have a gear reduction, and want to be able to monitor the output of the reducer in addition to the rotor position.  The moteus firmware doesn't use the value for much, but does allow you to initialize the number of full revolutions of the rotor from it.  It also reports the value over CAN so that your application can use it.

    Currently, just the AS5048B is supported, although other I2C based encoders should be pretty easy to make work.

  • Anti-windup (pure velocity control mode)

    Josh Pieper04/18/2021 at 16:58 0 comments

    I recently added an optional "anti-windup" term to the position control loop in moteus.  This lets it operate in a pure velocity mode with behavior that is more familiar to a 3 stage control law, as opposed to the integrated position/velocity controller that moteus uses.

    You can configure it by setting the "servo.max_position_slip" option to the number of revolutions the control position is allowed to deviate from the actual position.

    I've got a video showing how to use it here: