Configuring an off-axis MA600 encoder with moteus

This is the final post (hah! for now at least) in my series about implementing support for off-axis encoders in moteus (see previous iterations here: 1, 2, 3, 4, 5). In this one, I’ll share the recipe for how to set up an off-axis MA600 encoder using a ring magnet as the only encoder source.

Hardware

Parts list:

Magnet mounting: The ring magnet needs to be rigidly affixed to the rotor of the motor being driven. It may be necessary to construct a bracket to mount the magnet, or a fixture to position the magnet before using an adhesive.

Encoder mounting: The MA600 breakout should be mounted so that the MA600 chip is centered vertically on the 4mm thickness of the sense magnet, and as close as possible to the magnet as your tolerances allow. Ideally the gap between the magnet and the edge of the breakout board would be no larger than 0.5mm.

Wiring: The JST GH7 to JST GH6 cable included with the MA600 breakout will be used to connect the breakout board to the moteus-n1 AUX2 port.

Configuration

The following configuration changes can be made interactively in tview, or using moteus_tool --restore-config / moteus_tool --write-config

AUX2 configuration:

aux2.pins.0 1             # spiaux2.pins.1 1             # spiaux2.pins.2 1             # spiaux2.pins.3 2             # spi_csaux2.spi.rate_hz 6000000aux2.spi.mode 5           # ma600

motor_position configuration:

motor_position.sources.0.aux_number 2motor_position.sources.0.type 1        # spimotor_position.sources.0.cpr 65536

Provisioning

To start, run select the appropriate bias current trimming value for the MA600:

moteus$ ./util/measure_ma732_bct.py

Next, calibration is required.

moteus$ python -m moteus.moteus_tool -t 1 --calibrate

Finally, you can repeat the following procedure as many times as is helpful to improve the non-linear compensation of the encoder:

moteus$ ./util/compensate_encoder.pymoteus$ python -m moteus.moteus_tool -t 1 --calibrate

Alternative options

The above procedure will work with the MA732 as well, albeit with reduced performance. The only difference is that the correct encoder type needs to be configured for aux2:

aux2.spi.mode 4  # ma732

A moteus-c1 can be substituted for a moteus-n1 with no change in wiring or process.