Hi,
I have just done some digging into the theory behind brushless gimbals and I spend a few evenings getting to know the problems. I fired up my arduino and a brushless motor. Interesting stuff!
Let me just start by saying that my objectives is not to build something finished - but rather to understand the inner workings in the strategy behind the control system. I hope that there might be somebody willing to share their approaches. Sadly I am not skilled enough to decipher the inner workings on the BruGi project, just by looking at the code. Which is, in my defense, quite comprehensive On to the fun stuff:
To start with, I got my arduino out, and hooked up some experiments:
Powered up the arduino and coupled it with an L6234 H-bridge motor driver. Which seems to be the basic strategy for a number of projects out there.
I quickly got the phases right and was able to turn the motor slowly and precisely. I used a PWM frequency of 34KHz and an 8 bit resolution. So far so good. I noticed some irregular movement, which I learned is a common problem called cogging. This arises from the inner workings of the motor stators and magnets, which tends to "want" to be in specific places rather than others. I didn't dive to deep in this since it seems to be a unavoidable issue. I used a T-Motor GB-2208-80 for testing.
Okay, so I got the motor turning and moved on to implementing an IMU. I had an invensense MPU-6050 lying around so I hooked this up. This thing has some serious DMP capability which I immediately fond way too complex. Invensense documentation is also not the must friendly I have seen... Anyway, thanks to Jeff Rowberg and his work on the DMP I pretty quickly got it running, and supplying me with friendly 3-axis degree angles every 10ms. Great! Now to the first control experiment:
I made a very simple PID control loop that adjusted the motor speed towards the target. To my surprise this actually worked well... but not too well. I thought that with some PID tuning and some code optimization things could work out good. Boy, was I wrong. I hit a wall of problems, and started looking at the whole system again. These was my initial observations:
8 bit PWM resolution is fine. (thought it might not be)
Any PWM frequency above 8 KHz seems to be good
The 6050 IMU gives me readings at 100 Hz. Gyro only might be faster?
The response time for my motor was minimum 15ms with some rippling after
I fond that with almost plain vanilla arduino coding I could do a half decent job with processor-time to spare (should probably make me question my strategy )
So my control strategy is this:
I get my current error in rotation every 10ms and run it through a basic PID.
Adjust the motor speed every 1ms, so linear motion for 10 ms until next IMU reading. This works fine at low speeds.
Now things got tricky (for me at least), since I quickly saw some oscillations at relatively high constant speed. I traced this back to the fact that I make the motor compensate for an error but the motor dosn't start doing this for another 15 ms. Before the 15 ms has passed the error might have gotten greater and the previous correction hasn't kicked in.. bummer. Now the PID control event (in between) thinks that things are worse than it is, and over compensates which gives my nasty 10-20 Hz shakes.
I am mainly experimenting with only the proportional of the PID active. So I don't make any (very easy to make) derivative screw-ups. PID tuning for gimbals can be extremely tricky...
This is pretty much where I am now.
I am considering if the speed should be the center of my control strategy or maybe a position target, which might be easier.
I seem to be stuck with how to handle the motor reaction delay. I tried to account for motor-compensation not yet "seen" by the IMU, but none the less known. Not much success, since the motor reaction curve is rather complex. It starts moving at 15ms and then overshoots the target and then wiggles in place for the next 40-50 ms. Annoying to describe in math...
The 100Hz update rate for the IMU also makes me think if this is fast enough. Could this be done with gyro reading only, which I think could be done a lot faster. But then again the motor reaction time seems to be the bottleneck time-wise.
I hope that some of you have dived into similar projects or perhaps thinks that is could be fun to experiment along Any feedback is much appreciated.
Looking forward to your insights
Best
Esben