RC India

RC Models => Multirotors => Topic started by: Aravind298 on February 13, 2018, 11:19:26 PM



Title: Arduino Quadcopter
Post by: Aravind298 on February 13, 2018, 11:19:26 PM
Hi all!

After building my first assembled drone, which was also my first drone, I wanted to step into making one myself. Right from programming the Flight Controller to fabricating the ESC to 3d-printing the frame.

Fortunately, I was very well helped, and was able to achieve that last year.

And I figure it's time to let everyone who's stuck, to be helped.

Here's an excellent playlist, that I came across while DIYing the Flight Controller.


https://www.youtube.com/playlist?list=PL0K4VDicBzsibZqfa42DVxC8CGCMB7G2G


If anyone happens to develop any doubts or troubles, reach out to me and I'll help you out!



Peace  :hatsoff:


Title: Re: Arduino Quadcopter
Post by: Aravind298 on February 13, 2018, 11:21:27 PM
The arduino code is dead easy. It might look a little complex, but after learning the bitwise operators and extensively using the registers, I believe one can easily understand it.

I suggest reading the 'registers' part of the arduino atmega328 while you're going thru the process.


Title: Re: Arduino Quadcopter
Post by: anilkunchalaece on March 16, 2018, 07:47:35 PM
Hi,

Can you please explain this part of the code ?

    esc_1 = throttle - pid_output_pitch + pid_output_roll - pid_output_yaw; //Calculate the pulse for esc 1 (front-right - CCW)
    esc_2 = throttle + pid_output_pitch + pid_output_roll + pid_output_yaw; //Calculate the pulse for esc 2 (rear-right - CW)
    esc_3 = throttle + pid_output_pitch - pid_output_roll - pid_output_yaw; //Calculate the pulse for esc 3 (rear-left - CCW)
    esc_4 = throttle - pid_output_pitch - pid_output_roll + pid_output_yaw; //Calculate the pulse for esc 4 (front-left - CW)


I didnt get my head around with it.

I didnt understand PID implementation also, but for now iam going with pid library


Title: Re: Arduino Quadcopter
Post by: Aravind298 on March 16, 2018, 07:59:13 PM
That is the final value given to the motor as output, summing up all the factors.

The '+' and '-' signs are assigned according to the position of the motor.

I suggest you learn the PID first and look at the code.


Title: Re: Arduino Quadcopter
Post by: Balakrishna Reddy on March 16, 2018, 10:35:55 PM
Hi,

Can you please explain this part of the code ?

    esc_1 = throttle - pid_output_pitch + pid_output_roll - pid_output_yaw; //Calculate the pulse for esc 1 (front-right - CCW)
    esc_2 = throttle + pid_output_pitch + pid_output_roll + pid_output_yaw; //Calculate the pulse for esc 2 (rear-right - CW)
    esc_3 = throttle + pid_output_pitch - pid_output_roll - pid_output_yaw; //Calculate the pulse for esc 3 (rear-left - CCW)
    esc_4 = throttle - pid_output_pitch - pid_output_roll + pid_output_yaw; //Calculate the pulse for esc 4 (front-left - CW)


I didnt get my head around with it.

I didnt understand PID implementation also, but for now iam going with pid library
Thats a very nice question and its very easy to answer, Below is a brief of it.

1. Assume motor positions and directions initially  https://i.ytimg.com/vi/WNqojyFICZQ/maxresdefault.jpg
   I will take image in link as reference
   a. motor 1 -- bottom right rotating CW
   b. motor 2 -- top right rotating CCW
   c. motor 3 -- bottom left rotating CCW
   d. motor 4 -- top left rotating CW

2. Now I will go step by step.
   a) w.r.t Throttle:
         What is the output of all motors with respect to input? It is proportional output irrespective of position. So throttle is positive i.e
         added to outputs
         Now output is
        m4 = +thr
        m2 = +thr
        m3 = +thr
        m1 = +thr
   b) w.r.t Pitch:
         When you increase the pitch to forward i.e you want your model to move forward. What actually goes?
         motors in front(4,2) will slow a bit and back motors(1,3) will speed up a bit. To increase/decrease add/substract pitch input to/from motor.
         m4 = +thr -pitch
         m2 = +thr -pitch
         m3 = +thr +pitch
         m1 = +thr +pitch
   c) w.r.t Roll:
         When you increase the Roll i.e you want to go right what exactly happens?
         Motor on right i.e (2,1) will slow a bit and motors left(3,4) will speed up a bit. To do this follow above step. Add/substract from output of motor.
         m4 = +thr  -pitch  +Roll
         m2 = +thr  -pitch   -Roll
         m3 = +thr +pitch  +Roll
         m1 = +thr +pitch   -Roll

   d) w.r.t yaw:
         I hope you have already understood the entire logic and you won't really read this. So I skip this. sorry ;D ;D


This is the very basic and you may have to sometimes reverse the inputs depending on how the value changes for direction of stick movement. This is called stick reversing or something similar.




Title: Re: Arduino Quadcopter
Post by: AL HAM SHARI on March 17, 2018, 12:29:45 AM
Bro, You did an awesome job. Even if it's easy for you, You can now proudly say that you technically built a quad rather than assembling.😁


Title: Re: Arduino Quadcopter
Post by: anilkunchalaece on March 17, 2018, 07:14:06 PM
@Balakrishna Reddy
Thankyou so much for clear explanation.

My Build is Faling  to TakeOff - it is Tilting to one side and flipping.
Find the Video https://youtu.be/X5YVZlKIp9o (https://youtu.be/X5YVZlKIp9o)

Things I checked :
            Motor Directions
            Propeller Directions
            MPU 6050 Calibration

Is there any other things i need to check ? :headscratch:

I am able to see modified motor values from PID loop - but dont know are they enough to prevent tilting  :banghead:.

Quad Configuration :
NTM Prop 28-26 1000kv motors
2200mah 3s battery
afro 20A esc's
Arduino Uno
MPU 6050 with i2c dev Library
Pid_V1 library



Title: Re: Arduino Quadcopter
Post by: Aravind298 on March 17, 2018, 07:52:48 PM
Hey! It seems the props are spinning in the wrong direction, actually, it's definite that the props are spinning to the full motor RPM, from the sound captured.

Also, post the size of the propeller that you're using. That might be another reason.


BTW, that's an excellent explanation from Bala. Hats off to that  :hatsoff:


Title: Re: Arduino Quadcopter
Post by: Erpoyo on March 20, 2018, 01:31:27 AM
There is nothing worse than building your first quad and think you have it all right.. and BUMB flipping on take off..  :giggle: :giggle:

That actually happened to me and created a video on 5 different things that could be causing the issue

https://www.youtube.com/watch?v=f-kZgof4YDs



Hope this helps!!