Overview
While consulting on a large multidisciplinary project in the early proof-of-concept phase, we offered support to another team beyond our initial remit.
Here, we investigated a misbehaving multi-axis motion control system, delivering a working solution despite harsh constraints.
Situation
ODrive S1 controllers were employed, and would frequently disengage with the MISSING_ESTIMATE error.
We established that the ODrive was connected to a remote encoder via SPI and approximately 1.5 metres of individual thin wires.
Approach
Environmental EMI was the prime suspect, with long motor phase wires running in parallel to the encoder lines as the main aggressor.
Due to the tight design and extreme time constraints, we proposed moving to an RS-485 communication link, emulating the supported AMT21 series encoders, and reducing the SPI link to tens of millimetres.
We ordered sets of ATmega4809 boards and RS-485 transceivers on next-morning delivery, and began firmware implementation.
Hidden Requirement
With the parts assembled and initial firmware loaded, we discovered that the ODrive was throwing an immediate MISSING_ESTIMATE error.
Unfortunately, we had overlooked the very tight 3 µs turnaround time listed in the AMT21 datasheet - had we spotted it earlier, we might have selected a different MCU with a faster core clock.
Solution
The ATmega4809 running at 20 MHz has no chance of calculating and sending the response in time, let alone querying the SPI encoder too (3 µs is just 60 CPU cycles).
To resolve this, we rewrote the firmware, with a sample delay timer, pre-calculated response, and very tight UART interrupt handler.
Result
The result was a very robust AMT21 emulator that fully resolved the issues experienced by our colleagues, meeting the deadline without requiring new wiring or integration of a different encoder.
The time elapsed from agreeing a plan of action to delivering a solution was under 24 hours.