0
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ You 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: electronics.stackexchange.com/questions/36589/… \$\endgroup\$ – Alexxx Aug 4 '15 at 13:51
  • \$\begingroup\$ 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. \$\endgroup\$ – Chris Stratton Apr 10 '18 at 16:23
3
\$\begingroup\$

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.

PID loop

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.

\$\endgroup\$
  • \$\begingroup\$ 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 \$\endgroup\$ – Sulaiman Ayub Aug 4 '15 at 9:45
  • \$\begingroup\$ 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. \$\endgroup\$ – Sulaiman Ayub Aug 4 '15 at 9:49
  • \$\begingroup\$ You will observe severe oscillation using this technique. PID are quite easy, it's your call ! \$\endgroup\$ – nairyo Aug 4 '15 at 10:37
  • 1
    \$\begingroup\$ You 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. \$\endgroup\$ – Alexxx Aug 4 '15 at 13:30
  • \$\begingroup\$ 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. \$\endgroup\$ – Sulaiman Ayub Aug 4 '15 at 15:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.