I am on a project which nearly completed. But what remains is balancing. My project is making a quadcopter. All the programing and hardware stuff is completed. But when i fly it, it doesnt goes up, it goes to a side so i just take it down again. I tried different balancing tecniques, using mpu6050. The procedure for balancing i use is; Find the accelerometer values from mpu6050. If lets say ax is less than 0 then speed up one side motor and slow down other motor, and similarly other. But that doesnt work, Please show me how can i balancing it, because that methods are not working for me. And if i am off topic please point me where to ask this question.
-
1You can't use just the accelerometer as the raw value is proportional to the acceleration in a given direction not the position. You have to use both the accelerometer and the gyro to calculate position. Here's an excellent info on that: http://electronics.stackexchange.com/questions/36589/what-are-the-differences-between-a-gyroscope-accelerometer-and-magnetometer – Alexxx Aug 04 '15 at 13:51
-
This question is far too broad to be a fit here. As Alexxx approximately pointed out, you don't do this directly with an accelerometer. Instead, you first build a loop to damp angular rates using the gyros. This can actually get you something flyable by a skilled pilot, aka "acro mode". If you want auto-leveling, you then put a level-seeking loop that looks at the accelerometers *around* the inner rate-damping loop. There are several open source codebases out there that do this, and those and associated discussion are better resources than a first-principles take here could be. – Chris Stratton Apr 10 '18 at 16:23
1 Answers
I suggest you to look at Automatics and PID regulation. Your approach is not wrong, but you're missing a LOT. For instance, how do you know but what amount you should change the speed of your motors to compensate the tilt angle ? How do you make it go to a stable position in a smooth motion ? How do you optimize the time to get to a stable position ? All these questions can be answered by learning about automatics.
If you look at this scheme, consider the Setpoint as your reference-level and Output as your quad-level. Setpoint - Output = Error (ie. the angle between your quad-level and the ref-level).
Now the P gain is going to multiply your error in order to send a correction-command proportional to the error.
The I gain is going to integrate the error. Integral are sums, this terms kicks in when the error is so small that the P gain can't really do anything about it.
The D gain will multiply the derivative of your error, it will basically smooth your output command (DO NOT confuse with Output, the quad-level)
By the way, when you say 'ax' do you mean the raw value you read on the 'x-axis' of your mpu6050 ? Because that's not your reference.
You should find most of your answers by looking at the multiwii code.

- 160
- 2
- 11
-
Yes , by saying ax i mean raw accelerometer value. And will not be able to follow the way u r saying, i have not that much skill, but i am using this tecnique, 1: if ax is less than zero and the change in ax is less than zero then keep increasing speed of one side till change in ax reaches to just positive so that one side start going to stable position. Similarlyy if ax is greater than zero and change is also greater than zero, so increase speed of other motor till change reaches just negative so that side start going to stable position. Similar process is for ay value. Please tell is it fine – Sulaiman Ayub Aug 04 '15 at 09:45
-
It mean that i check the change in acce raw values, and adjust the speed of motors to bring the change to specific value. So going to stable state will reach. – Sulaiman Ayub Aug 04 '15 at 09:49
-
You will observe severe oscillation using this technique. PID are quite easy, it's your call ! – nairyo Aug 04 '15 at 10:37
-
1You can't use just the accelerometer as the raw value is proportional to the acceleration in a given direction not the position. You have to use both the accelerometer and the gyro to calculate the position. MPU6050 lacks a magnetometer which makes position calculation more precise. – Alexxx Aug 04 '15 at 13:30
-
I dont get how to use pid, i googled it, and i have studied it too in my course subjects, control systems. But how to relate it with the motor speed adjustment. What will be kp, ki, kd in my project. Please just point me. – Sulaiman Ayub Aug 04 '15 at 15:13
-
Ok i get it, correct me if i am wrong. The e(t) in my project case is the difference of current ax(lets say) and desired ax(that is zero is desired). I will integrate e and derivate e too, and add integrated and derivated e with e. The coeeficients of the these three will be kp,ki,and kd. After adding them the answer will be added to speed of motor but I am not completely sure about, correct me. – Sulaiman Ayub Aug 04 '15 at 16:01
-
Yes, you're right. however you might have to scale the command before you send it to the ESCs – nairyo Aug 05 '15 at 09:29
-
Ok you mean i will have to scale output of pid to motors scale, and then give it. – Sulaiman Ayub Aug 05 '15 at 11:09