Go Down

Topic: BlueCopter - Arduino Quadcopter (Read 376982 times)previous topic - next topic

GoussLegend

#30
Oct 04, 2013, 11:07 pm
Thanks for the nice explanation!

Still one question though:
Quote
You have to tune the rate-PID before the angle-PID

I agree with this but how do you practically tune it? I mean with the angle-PID, it's easy to tune,  you can look at the angles values or even look at your quad to see if it's stable but with the rate-PID, I have no idea how to tune it.

baselsw

#31
Oct 05, 2013, 12:16 amLast Edit: Oct 05, 2013, 12:18 am by baselsw Reason: 1

Thanks for the nice explanation!

Still one question though:
Quote
You have to tune the rate-PID before the angle-PID

I agree with this but how do you practically tune it? I mean with the angle-PID, it's easy to tune,  you can look at the angles values or even look at your quad to see if it's stable but with the rate-PID, I have no idea how to tune it.

ya, I get what you're saying.. The method I'm using today is pretty advanced and requires some expensive software.. I basically made a Matlab script that sends data back and forth to the quadcopter and optimize the PID values..  Before that I did it by hand, this is my old method:

1 ) Put the quadcopter in rate mode
2 ) Increase the throttle until the quadcopter starts to hover on its own..
3 ) Increase the P-term until you observe oscillations..  Now subtract 10% of the value and set it as your P-term ..
4 ) Increase the D-term until you observe oscillations..  Now subtract 10-20% of the value (this is your D-term now)..
5 ) Now go back and increase the P-term with small steps until you observe oscillations.. Then subtract a couple of steps..
6 ) Increase the I-term until you observe oscillations.. These oscillations will have a lower frequency, so step up the I-term slowly.. And be careful when it starts to oscillate.. Because the P- and D-term will kick in, and increase the frequency of the oscillations.. So be careful! After that, substract approx. 10-15% of the value...
7 ) If you are satisfied with the results, then go out and take it for a spin, and observe how it flies and reacts to the wind etc.. Then go back and fine tune your copter if you observed any types of oscillations/control problems..
8 ) Buy me a beer!!!!!

//Basel

GoussLegend

#32
Oct 05, 2013, 10:15 am
What is your speed setpoint/reference ? I guess 0 deg/s and before your have manually put your quad at 0 deg for roll and pitch angle?

Quote
The method I'm using today is pretty advanced and requires some expensive software.. I basically made a Matlab script that sends data back and forth to the quadcopter and optimize the PID values

I know well Matlab and I have got it on my laptop. (My dream would have been to use Simulink  . Anyway what do you do with your Matlab script? Transfer function?

Quote

8 ) Buy me a beer!!!!!  smiley

I will send you one to Sweden once my quad is flying

baselsw

#33
Oct 05, 2013, 11:00 am

What is your speed setpoint/reference ? I guess 0 deg/s and before your have manually put your quad at 0 deg for roll and pitch angle?

I have trouble understanding what you mean.. But I'll give it a shot.. When the quadcopter is in rate-mode, the set-point is determined by the RC-reciever.. Meaning you change the setpoint directly with the transmitter/Remote control.. For example, if you roll left then the setpoint will be something <0deg/s (negative angular rate), and the opposite if you roll right, >0deg/s (positive angular rate)..

If you're in angle mode, the reciever controls the setpoint of the angle-PID, and the angle-PID will in turn decide the setpoint for the rate-PID...

I know well Matlab and I have got it on my laptop. (My dream would have been to use Simulink  . Anyway what do you do with your Matlab script? Transfer function?

Simulink is slow and not optimal for something you run and optimize in real time.. Sure, you got the Real-Time toolbox, but if you ask me it sucks!

No it's not transfer functions, that would be optimal in-case i modeled the system.. But instead I did the following:

Arduino side: Wrote a whole new sketch that only handles inputs, outputs and gyro, acc calculations.. Meaning all the PID calculations are done in matlab..

Matlab side: I implemented some known PID tuning methods, like Ziegler-Nichols, SIMC, IMC etc.. They are easy to calculate.. It was just a matter of iterating and testing the results I got from the different methods..  The method that gave the best result for my quad. was the SIMC.. Still the results were not perfect, but it got me pretty close to something acceptable.. I know your going to ask why it didn't give me the optimal magical numbers =P! The reason is lag/delay in the system.. Matlab runs fast, a little too fast for the Serial-communication on the arduino.. So by the time arduino sends the data, the quadcopter would have changed its state drastically (not for the human eye maybe, but you can see it if you look at the data).. This kind of lag/delay can lead to early oscillations in the PID-tuning..

The optimal way to run this type of tuning is on the arduino itself.. So maybe write a PID optimizer for the arduino??

//Basel

sk8amazing

#34
Oct 14, 2013, 07:33 pm
hi again.
i have some question i fixed my receiver and now i have some question .
how we can change pid values?  is it compatible with multiwii gui ?

baselsw

#35
Oct 14, 2013, 07:45 pm

hi again.
i have some question i fixed my receiver and now i have some question .
how we can change pid values?  is it compatible with multiwii gui ?

Hmm, if you're talking about my code then no.. To change the PID values you'll have to go to the Config.h file and change them there... You'll find these lines inside the file:

Code: [Select]
`#define ROLL_PID_KP  0.250#define ROLL_PID_KI  0.950#define ROLL_PID_KD  0.011#define ROLL_PID_MIN  -50.0#define ROLL_PID_MAX  50.0#define PITCH_PID_KP  0.250#define PITCH_PID_KI  0.950#define PITCH_PID_KD  0.011#define PITCH_PID_MIN  -50.0#define PITCH_PID_MAX  50.0#define YAW_PID_KP  0.680#define YAW_PID_KI  0.500#define YAW_PID_KD  0.0001#define YAW_PID_MIN  -50.0#define YAW_PID_MAX  50.0#define ANGLEX_KP 5.0#define ANGLEX_KI 0.02#define ANGLEX_KD -0.015#define ANGLEX_MIN -100.0#define ANGLEX_MAX 100.0#define ANGLEY_KP 5.0#define ANGLEY_KI 0.02#define ANGLEY_KD -0.015#define ANGLEY_MIN -100.0#define ANGLEY_MAX 100.0`

The first three sections is for the rate mode PID.. And the last two are for the angle mode PID..

sk8amazing

#36
Oct 14, 2013, 08:28 pm
sorry bro how arm the quad ? i tried all the ways but quadcopter didnot armed and motors didint start anyway

baselsw

#37
Oct 14, 2013, 10:05 pm

sorry bro how arm the quad ? i tried all the ways but quadcopter didnot armed and motors didint start anyway

The copter will arm when the throttle is higher than 1100ms.. Just increase the throttle slowly until it arms..

sk8amazing

#38
Oct 14, 2013, 10:31 pm
i changed pins because i use arduino uno and i think problem caused bcuz of that .....

baselsw

#39
Oct 14, 2013, 10:46 pm

i changed pins because i use arduino uno and i think problem caused bcuz of that .....

Hmm, then what pins did you change to?? You can find the pins definition in the Config.h file..  The throttle is on pin 7.. And it's a interrupt pin on the leonardo.. Did you come around the receiver code, and in that case did you implement it in the firmware???

If you need further help then please provide me with everything you have, so I know how to formulate my answers..

//Basel

sk8amazing

#40
Oct 15, 2013, 08:03 am
i changed the motors to 3 9 10 11 pins
and throttle to pin 2 and other 3channel to 4 5 6
i think the interupt of arduino is pins 3 isnt it ?

baselsw

#41
Oct 15, 2013, 10:14 amLast Edit: Oct 15, 2013, 06:14 pm by baselsw Reason: 1

i changed the motors to 3 9 10 11 pins
and throttle to pin 2 and other 3channel to 4 5 6
i think the interupt of arduino is pins 3 isnt it ?

I'm currently at work.. But i'll look at it as soon as I get home.. Will you be so kind and post all your code changes so I can take a look at them??? Just zip the whole project and post it here...

Edit: Just got back from work.. i looked over your pin choices.. Well yes the interrupts are on pin 2 and 3.. So that also means that you can't use pin 3 for one of the motors.. Why not leave the motor pins as is??? Did you write a new interrupt routine for the receiver? Because the current one won't work on the UNO..

//Basel

sk8amazing

#42
Oct 15, 2013, 09:43 pm
i can unchange the pins but the uno dont have more than 13 pins ...

baselsw

#43
Oct 15, 2013, 10:02 pm

i can unchange the pins but the uno dont have more than 13 pins ...

4 pins for the motors, 4 for the receiver, and 2 for the I2C.. that's 10 pins.. how many do you need??

//Basel

sk8amazing

#44
Oct 15, 2013, 11:11 pm
that looks enough but i told that bcuz you said leave the pins as their default ..  ]

Go Up