This is my first time posting so please be gentle. Until now I’ve successfully managed to solve my hardware and coding issues with google searches and good old fashioned troubleshooting, but I’ve hit a roadblock.
First some background on my project:
I’m building a custom controller for one of those generic 17 DOF robot kits. The servos it came with were garbage so I upgraded to nice(er) brushless servos. My robot controller takes input from a PS3 controller through a USB host setup. This is handled by an ATMega328P. The 328P is also taking input from a 6 DOF IMU and kalman filtering the input to give me nice clean orientation data. With all of that processing handled the filtered IMU data and PS3 button info is transferred, through I2C, using the wire library, to an ATMega2560 for joint choreography and servo control. Both MCUs have FTDI setups for serial programming and monitoring (debugging).
The power is supplied by a 2S lipo capable of outputting more amps continuously than all my servos can pull and there is a nice clean, regulated 5V going to all the sensitive logic things.
I am proud to say that everything works (with the exception of the glitch that has brought me here). The PS3 commands are read, the AMU is filtered, all that is sent over I2C to the 2560 that happily runs through it’s code and outputs to the servos.
The issue I’m having is twitching servos. After a lot of frustration and troubleshooting it looks like the I2C transmission is the cause of the twitch. Killing that section of code makes the servos behave nicely again. From what I’ve read the wire library locks up the MCU while receiving. It seems to be well known that the wire library is less than ideal and there are other versions floating around with various modifications.
My question is, does anyone know of a good I2C library to use that won’t screw with my servo outputs?
I found and attempted to understand this, which indicates that the functionality is there but the standard library doesn’t take advantage of it:
I’ve tried reading through the libraries and most of the code flies right over my head. If there isn’t a prepackaged library that will do what I need, can someone help me code up a fix for this.
Sorry for the long post, and thanks in advance for any help!