MG996Rs Finally Working
The servos finally work. I don’t even think this amount of hours logged is equal to how long this took, because I just got tired of it.
I think I printed like 20 new revisions of the case and servo mount. It was just so so annoying. While the general case worked, getting a reliable magnet output shaft was impossible. From tolerances, to my own errors to binding to hot glue getting everywhere, or superglue binding random gears, or my getting my fingers stuck to the actual case from superglue (was not fun and hurt)
The case finally works.
And the prototype code somewhat works too. It basically rotates until the sensor hits zero, it resets the “ticks”. A tick is a raw output from the AS5600. Because this magnet shaft spins faster than the output shaft, like 10x faster, the MCU needs to poll the sensor super quickly, which also needed some optimizations to clear the blocking bus communication wait that would let the magnet skip multiple full turns. The sensor doesn’t internally count turns so we just need to count manually and detect when it jumps from 4096-0 or the other way around.
It then spins around until the sensor is hit AGAIN to calculate tick to degrees, assuming the sensor was zeroed before, and then the current ticks would equal 360 degrees.
Another problem was the servo needs a PWM signal to move. The threshold from stop to go is pretty garbage on these cheap servos, leading it to spin quite fast already when at the lowest PWM value. Instead when far from the value it increases the PWM signal, closer it brings to minimum and starts linearly flickering the PWM signal from 0 to the speed, with the closer it is the more ratio of time stopped to inch it closer to the target.
It actually surprisingly works. It’s very fragile though, any skipped reads, from potentially slow bus transfers would completely throw it off, so all the code running locally on the weak 8 bit MCU needs to be extremely lightweight.
Yeah this was super super painful. I’ve been sitting here redoing superglue and code for hours.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.