RC India
Welcome Guest, please login or register.
 
Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools Topic Tools 
Read
« on: September 29, 2016, 10:19:42 PM »
ghoshatanu56
Plane Lover
Senior Member
***

Reputation Power: 3 
ghoshatanu56 has no influence.
Offline Offline

City: Kolkata
State: West Bengal
RC Skills: Beginner
Posts: 135
Join Date: Jul, 2011




1.Initialize MPU-6050

2.Read Gyro Values 2000 times and    calculate the offsets for Yaw/Pitch/Roll

3.Read Accelerometer Values for Yaw, Pitch & Roll

4.Read gyro Values for Yaw, Pitch, Roll. Subtract Yaw, Pitch & Roll offsets from Each Reading.

5.Calculate The angles of gyro & accelerometer for Yaw, Pitch & Roll using Atan

6.A) Apply Complimentary Filter Using Angle=0.xx*(Angle+gyro*dt) +                                       (1-0.xx)*Accelerometer for each Yaw ,Pitch & Roll.

b) Read Joystick Yaw, Pitch & Roll

7.Range the Yaw, Pitch & Roll using map/Custom Map function

8.A) Find The error for each Yaw Pitch Roll Error=Present Yaw/Pitch /Roll-Transmitter Yaw/Pitch/Roll

B) Proportional=Kp*Error

C)Integral=Previous Integral + Error*Ki

D)Derivative= (Error-Previous Error) *Kd

9.a)Motor_1=Throttle - PID Output Pitch + PID Output Roll - PID Output Yaw

b)Motor_2=Throttle + PID Output Pitch + PID Output Roll + PID Output Yaw

c)Motor_3=Throttle + PID Output Pitch - PID Output Roll - PID Output Yaw

d)Motor_4=Throttle - PID Output Pitch - PID Output Roll + PID Output Yaw
Logged
 

Read
« Reply #1 on: September 30, 2016, 04:09:45 AM »
Balakrishna Reddy
Plane Lover
Forum Hero
*****

Reputation Power: 8 
Balakrishna Reddy has no influence.
Offline Offline

City: Hyderabad
State: Telangana
RC Skills: Intermediate
Posts: 696
Join Date: Feb, 2015



Even my algorithm looks almost the same but haven't tested it.
2. Dont need to calculate offset everytime you turn on the electronics.
3. Accelerometer cannot determine yaw its purely done by gyro.
5. Do not use atan function as it takes so many clock cycles thus increasing looptime and lowering cycle frequency. You can instead use some linear conversion techniques for converting pitch,roll just by multiplying with some factor.
Rest of the things looks good.
Logged
 

Read
« Reply #2 on: September 30, 2016, 08:34:46 AM »
ghoshatanu56
Plane Lover
Senior Member
***

Reputation Power: 3 
ghoshatanu56 has no influence.
Offline Offline

City: Kolkata
State: West Bengal
RC Skills: Beginner
Posts: 135
Join Date: Jul, 2011


Re:

Thank you Balakrishna Reddy.
If you can just elaborate the point 5 .how to get the angles by using linear conversion.

Sent from my Lenovo P1ma40 using Tapatalk
Logged
 

Read
« Reply #3 on: September 30, 2016, 09:27:09 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Why not use the inbuilt DMP instead? You can achieve a loop rate of 190 to 200 Hz which is great for 250+ sized quads. Also, DMP gives better yaw results than any self implemented algorithm. 

There are errors in your final equations. Are you using the standard motor configuration?
Logged
 

Read
« Reply #4 on: September 30, 2016, 11:14:24 AM »
ghoshatanu56
Plane Lover
Senior Member
***

Reputation Power: 3 
ghoshatanu56 has no influence.
Offline Offline

City: Kolkata
State: West Bengal
RC Skills: Beginner
Posts: 135
Join Date: Jul, 2011



I am not using the DMP as the documentation for it is non-existent .And here is the motor configuration
http://
Is this algorithm accurate for a flight controller of a quadcopter?

imageedit_1_4259326558.jpg
Re: Is this algorithm accurate for a flight controller of a quadcopter?
* imageedit_1_4259326558.jpg (47.12 KB, 800x800 - viewed 158 times.)
Logged
 

Read
« Reply #5 on: September 30, 2016, 11:30:02 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



The documentation is available but needs some patience to understand and implement.

If you don't want to do it from scratch, use Jeff Rowberg's I2C and motionapps libraries. It'll take a little more memory but save you a lot of head banging.
Logged
 

Read
« Reply #6 on: September 30, 2016, 11:51:03 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



The motor outputs are okay.

I use the following formula:
error =  desired position - actual position

That's why the signs appeared wrong to me. My bad.

The PID algorithm needs improvement though. You need to make changes for initialization, derivative kick, reset windup, Ki bumps etc.

Try to use a constant loop time to get better results. My team got much better results with constant time and integer math in the PID.
Logged
 

Read
« Reply #7 on: September 30, 2016, 12:00:30 PM »
ghoshatanu56
Plane Lover
Senior Member
***

Reputation Power: 3 
ghoshatanu56 has no influence.
Offline Offline

City: Kolkata
State: West Bengal
RC Skills: Beginner
Posts: 135
Join Date: Jul, 2011


Re:

Thank you Swapnil for the input.

Sent from my Lenovo P1ma40 using Tapatalk
Logged
 

Pages: [1]   Go Up
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Hobbyking Quadcopter control board or flight controller
For Sale
Mridul 7 2779 Last post April 12, 2014, 12:29:28 AM
by Mridul
quadcopter flight controller for sale
For Sale
Mohammed Naveed 3 1131 Last post March 08, 2017, 04:37:37 PM
by naveenrobo
i Drone i8H RC Quadcopter flight controller
Multirotors
RakeshR 0 785 Last post August 26, 2017, 05:54:41 PM
by RakeshR
Cheap 450 quadcopter frame + APM flight controller + 10 inch props
For Sale - Completed
kn8alpha 5 925 Last post October 25, 2020, 09:42:47 PM
by kn8alpha
Wanted Quadcopter Flight Controller
Wanted
A_Qaiser 7 826 Last post August 13, 2021, 12:06:44 PM
by ujjwaana