EmbDev.net

Forum: µC & Digital Electronics Programming a Quadrocopter with Arduino and using Transistors as hardware


von Sinan Civelek (Guest)


Attached files:

Rate this post
useful
not useful
Hello together,

We (3 students) bought a quadrocopter and now we changed its hardware so 
we can program it with the Arduino Mega 2560. Furthermore we used 
transistors for supplying the DC motors. We also implemented a gyroscope 
and it works with the so called Kalman filter.

We have the following problem when we let the quadrocopter fly: it 
doesn't fly stable. We change the PWM (pulse width modulation) values to 
let the quadrocopter fly in balance but it doesn't work. It is always 
swinging.

At this point we don't know where the problem is? We tried to optimize 
the source code for controlling the motors with the help of the 
gyroscope. But it didn't help.

However we have seen a lot of tutorials and tips supplying the motors 
with ESC's (electronic speed control).

So would you prefer ESC's rather than transistors?
Would the ESC's let our quadrocopter fly stable?

We are very thankful for all tips and recommandations.

Best greedings!

von Sina A. (sinapse)


Rate this post
useful
not useful
ok, you have the kalman filtered signal of the gyro and a motor 
controller. how are these two parts connected? do you use some kind of 
feedback control loop?

what do you mean by swinging? the quad keeps on flying while swinging or 
crashes right away?

von Sinan Civelek (Guest)


Attached files:

Rate this post
useful
not useful
Hi Sina,

thank you for your remarks.

1st answer:
The measured values from the gyro are evaluated in the endless
"loop()". There are a lot of cases implemented with "if{} else{}" 
instructions. In one of the cases there aren't any changes because the 
gyro values assume that the quadrocopter is in balance. In the other 
cases the motor speed gets changed with reducing the PWM value.

So we don't know if this kind of implementation is a "feedback control 
loop" as you mentioned?

2nd answer:
Swinging means that the quadrocopter doesn't fly in balance and it 
crashes after a few seconds. We tried a lot of PWM values for each motor 
to reach the required speed for each motor for a balanced flight.

1st question:
At this point we have another question: we haven't implemented any speed 
control algorithm in our source code. So do we need such kind of an 
algorithm (like the PID algorithm)?

2nd question:
There are two kinds of values of the gyroscope: the gyroscope and the 
acceleration values. We only have used the acceleration values so far. 
So maybe this is our problem. We couldn't understand the gyroscope 
values and for that reason we analyzed the accelaration values to 
determine the position of the x- and y-coordinates. We also ignored the 
z-coordinate.

Pictures:
hardware: here you can see our hardware.
axes: difference between the gyroscope and acceleration values
(https://developer.apple.com/library/iad/documentation/UserExperience/Conceptual/DesigningExpandedAdUnits/Art/axes.png)
x-axis: the blue (red) graph shows the acceleration values of the x-axis 
as the quadrocopter lied on the desk (was moved in the x direction).
x-axis: the blue (red) graph shows the acceleration values of the y-axis 
as the quadrocopter lied on the desk (was moved in the y direction).

von Sina A. (sinapse)


Rate this post
useful
not useful
Sinan Civelek wrote:
> So we don't know if this kind of implementation is a "feedback control
> loop" as you mentioned?

this sounds like a bang-bang controller. could work... but:

Sinan Civelek wrote:
> 1st question:
> At this point we have another question: we haven't implemented any speed
> control algorithm in our source code. So do we need such kind of an
> algorithm (like the PID algorithm)?

a PID controller would help a lot more.

Sinan Civelek wrote:
> We couldn't understand the gyroscope
> values and for that reason we analyzed the accelaration values to
> determine the position of the x- and y-coordinates. We also ignored the
> z-coordinate.

best would be to utilize both... the gyro and accel values. but it 
sounds like you are missing some theory here. to achieve fast results i 
recommend:

- implement a PI controller for each axis (use the accel values as 
feedback)
- implement an offset correction (especially z must be 0 when the quad 
is not moving)
- play aroumd with the P and I values until your quad flies (hold it in 
mid air before you start the software and slowly let it go when it 
feels stable)

you can find source code for PID controllers in the iNet. just download 
it, integrate it into your project and understand the PID controller 
just so much, that you know, what you have to feed into the controller 
and how to adjust the P,I and D parameters (for a PI controller D must 
be 0)


(and just to make sure: the gyro and acc sensors are sitting on the 
quad? the iphone pics just suggest that you are holding the sensors in 
your hand. they of course must be mounted on the quad)

von Albert Janik (Guest)


Rate this post
useful
not useful
Hi,
i am a friend of Sinan who is working with him on this project.

We actually utilize both gyro and accel values. This was some 
misunderstanding.

Yes, the gyrocsope is sitting on the copter. We just put the picture of 
the iphone to show what we mean.

I understand that you know how pid works.
We are reading the whole day and even more about PID, but there are so 
many sites and explanations and code examples, that we are a little bit 
lost. Maybe you could recommend some good source, where we can learn how 
PID works, with a good example. We would really appreciate it.

Greetings
Albert

von Sinan Civelek (Guest)


Rate this post
useful
not useful
Hi Sina,

Thank you a lot for your remarks.
We will try to find a PID regulation code.
And in case of success we will post our solution.

Best Greetings,
Sinan

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.