MT6701 magnetic position encoder support

Anybody has used the MT6701 encoder ?

It is similar to AS5600, supports spi, I2C, ABZ(quadrature), UVW, analog or PWM output but it is 14 bit and a little cheaper than the AS5600.

Just wondering if anyone has any experience with this encoder.

1 Like

Yes, and it works, and we have a dedicated driver for it in our drivers library that you can use!

It uses the SSI interface. I2C isn’t implemented yet.
Because of the SSI protocol, which is implemented using the SPI peripheral of the MCUs but isn’t exactly the same as real SPI, some MCUs only see 13bits instead of 14. Let us know if you have a problem like that.

To use it in ABZ mode you can just use our normal Encoder class.

oh now I find that driver repo… ok great. not seeing why the SSI could not work on an SPI bus but ok. I’ll check the source. thanks !
alright I see why the last bit is not read by a normal SPI transfer, it does not get a falling clock edge to latch according to the datasheet. But that bit is the last bit of the CRC, so the 14 bit of angle data and 4 of magnetic field status should still come through ok…
well debugging this by head I think on an ST micro SPI will get all 14 bit of angle data. Except the data is shifted 2 bits, probably on some micros that allows to make it work. Personally I would try and do a 3 byte transfer to get everything.

It has to do with the timings and SPI modes, and how the MCUs implement them…

This driver lib by Scott Bezek works well with SFOC

1 Like

Thanks for that tip, @Karl_Makes_Music

It looks like an even better driver, since it even implements CRC checks… but it is ESP32-specific code, so it won’t work with other MCUs…

looks like just the spi setup is esp specific.
The most important thing I see is that this code uses 24 bit transfer as I was suggesting, but it uses spi mode 1 instead of SFOC’s mode 2. So data is sampled on rising edge instead of falling. So no missed bits. But that presupposes the data is valid on the clock rising edge, which the datasheet does not say, it shows data valid on falling edge. However, I see some SSI description on wikipedia which tells data is valid on rising clock edge. Interesting.
I think the mt6701 should be changed to 24bit transfer and mode 1
I am definitely going to look at this with the scope once I receive the mt6701…

Did you end up doing any measurements or tests?
Also, I was wondering if you can enable -A/-B/-Z mode, and see what that pin behaviour is.
The datasheet doesn’t really discuss any of this, but I am imagining it is pin held high, with low pulse when it triggers. I think in general for hw interrupts you can specify edge polarity but I need to double check to see if it works.

Following up on this post because it was very helpful for my project. I am using an RP2040 for my project and changing the SPI to mode 1 gave me all 14 bits of resolution. Using the native Pico library:

spi_set_format(SPI_PORT, 8, SPI_CPOL_0, SPI_CPHA_1, SPI_MSB_FIRST);

made it work.

1 Like