I couldn’t manage to make the drone fly straight. I couldn’t find the correct PID values. I’ve made 100 tests and still noting. Stay tuned for future updates. You could always use the MultiWii platform. Also, if you consider helping my projects chek my Patreon: www.patreon.com/ELECTRONOOBS I hope that you'll be able to learn sommething new with this video.
The plot twist was awesome :D In the TWO axis file you made a mistake in the pid section. "if(pitch_PID < -4000){pitch_PID=-400;}" I think you want that to be 400 instead of 4000. I know you propably found it, but if somebody uses the code from your site will pull their hair, why is it not working.. :D BTW if you want to improve the quality of your code, make sure that you put every group of functions into a different tab. It's like using separate classes in .h and .cpp files, but simpler. (I have separate tabs for: Setup-Loop, Transmitter, IMU, PID, Motor control, Telemetry, LED signals.) It makes much easier to read the code. I hope that both of us will be able to tune the pid. :D Cheers!
I will never be perfectly symmetric. The idea of the PID is that even with bigger load on one side it should fly streight. On of the PID tests is to hang sommething on one side of the bar and it should always fly horizontal. I'll improve the code... Keep up!
As a tip to anyone trying to build a quad with the mpu6050, calculating the pitch and roll angles the way he did is wrong, you are gonna encounter problems, with rotations around the z- axis. You can test it yourself. 1) Implement his code so that you get an angle that's calculate only with the gyro values. pitch = gyro_x * dt and print the values to the serial port. Now starting at 0° if you rotate around x or y to 45° for example and then rotate around yaw, you'll see that the angle won't change or just a bit. If you now rotate back to the initial orientation the starting angle will be wrong. The correct formula is : phi = prevPhi + dt*(wx + wy*sinPhi*tanTheta + wz*cosPhi*tanTheta); For more information I'd recommend the following book: Rigid Body Dynamics for Beginners by Phil Kim or read this: andrew.gibiansky.com/blog/physics/quadcopter-dynamics/
Well, it is depend on the flight mode he is trying to program. In rate/acro mode you don't need to calculate the angle of the IMU what you need is rate of velocity of the gyro. Only if Angle/Auto-level is programed for the quad you need absolute angle measurement. He is not mention about the flight mode he is trying to do though. One month agos I comment the same as you.
Hello, I think that the main problem resides in the code itself.. Let me explain.. As in the flight controller the PID errors are calculated using the pitch and roll angles, the PID controller is unable to compensate for sudden changes in movement or sudden changes in rate of rotation.. Let's consider an example.. Suppose that the refresh rate is 250Hz giving a loop time of 0.004s or 4ms.. Now let's consider that the drone is flying with zero roll angle, and suddenly due to wind the drone starts to rotate with a rate of rotation of 100 degrees per second.. In this situation the roll angle will change only by 0.0121 ((100/32.8) * 0.004) degrees in one loop, hence the PID error will be +/- 0.0121 which is "very small" to account for a 100 dps movement and hence the PID controller fails to stabilise the drone.. The same can be applied for pitch axis.. According to me, the PID controller should be based on degrees per second movement and not on angles.. Also, do not use the map function as it don't work for floating point numbers and returns long (data type) values.. Divyanshu
I believe (I might be wrong) that the unstable state of the drone was due to the use of Euler Angles which are susceptible to the gimbal lock phenomena. If you opted for a quaternion interpretation of the rotation maybe you would get better results even without extra sensors. To be clear this is not a critique but just an idea. Love your channel and your videos helped me so much through my thesis, so thank you.
Thank you for this information, watching your video and others is helping to put all the pieces of the puzzle together on how to program a diy flight controller.
Man, it was very nice that you built the control algorithm yourself and showed us. I was looking for such video for a long time. I think that you should take the yaw motion into account because when one or two motors try to compensate the disturbance, due to the conservation of angular momentum the yaw orientation of drone also changes. Also anti windup integral may help and probably with that much of code the refresh rate of arduino became insufficient. And you somewhat calibrated the gyro to assume the initial position of the drone to be flat by offsetting the initial reading, I think that should not be done. I also dont know how to control the yaw by the way, if you get it somehow please tell me also)
Oh man you're excellent :) I never undestood the PID in school.But at least now I have an small idea how it works and how to implement it on somethings like multicopter :)
Hey man, your problem isn't in your PID tuning, its in the actual structure of the drone. You see, you have programmed your software to assume symmetry, but your prop-arms are not symmetric about the roll-axis. Meaning, roll and pitch controls are not the same due to the angle of the prop-arms coming out of the center of the body. If you look at Falcon-9 grid fin orientation, they are separated by 90 deg giving identical roll and pitch ability, but if you look at the superheavy grid fins, they are at 120deg and 60 deg orientation, giving more control authority to pitch than roll (since the roll ability of the grid fins is much higher than pitch, I know i was confused at first too). I believe you have the same problem. Just orient your prop positions to be 90 deg apart. PS. even if you look at the other drone footage in your video that shows testing cage, those drones all have their props 90 degs apart.
You need to make integral windup protection. Also calculating rol, pitch, and yaw angle as you made kind a bad idea. Euler angles in 3d rotation sometimes works bad (gimbal lock) = crash. You need to use quaternions instead of euler. read about this things
Sir, i have a doubt... is it possible to use ur program for a drone which is not controlled by remote.... instead we r using GSM to controll the moment of drone.... Please answer fast !!!!
my pwm output from pid calculation is responsive but when it write to esc ,the bldc response is slow(its like have some delay on it) so my quad can't stable in any pid constants that i tune.. Please help how to make my esc reponse to fast with no delay ?( thanks.
Sorry. I am trying to make some sort if uber walter scooter for my son using ovc pipes. Do you gave any suggestiin how to make a warercproof throttke?so novwater will get in the pvc pipes i tgought hall sendors vut they do not seem very good,at sensing range rgs just go on or jf and i would kiks ti avoid using 10 sensers. Or naybe veter use 2 push buttons
This is great you taught me a lot I give a thumbs up 😍😍😍 and I've built mine but how can I add a barometric sensor if I add a barometric sensor do need to code what should I do 🙏
First, I would like to thank you for sharing the knowledge and putting the effort into making educative videos with great illustrations and video editing. I really have something that's bugging me regarding how you calculate the angles using the linear acceleration. the MPU ciruit gives angles from the gyro sensors and linear acceleration from acceleration sensors. a rigid body in space can be fully defined kinematically by 6 DOFs ( 3 dispacements and 3 rotations). in the calculation of angle you seem to include the acceleration which you only account for 2% while 98% comes from gyro angular acceleration. I am also very confused on the formula used to compute angles using acceleration. because the gyro is attached to the body of interest (aircraft) angles should be only coming from gyros and if you want to control translation motion then you can but you will use the linear acceleration data. let me know what you think.
You havent done any coding to choose FS_Select=2 in Register 0x1B, so weren't you using default FS select=0? if so, weren't you suppose to divide gyro raw with 131?
If you go in the final 2 axis code in the setup loop you wil find this lines: Wire.beginTransmission(0x68); //begin, Send the slave adress (in this case 68) Wire.write(0x1B); //We want to write to the GYRO_CONFIG register (1B hex) Wire.write(0x10); //Set the register bits as 00010000 (100dps full scale) Wire.endTransmission(true); //End the transmission with the gyro Wire.beginTransmission(0x68); //Start communication with the address found during search. Wire.write(0x1C); //We want to write to the ACCEL_CONFIG register (1A hex) Wire.write(0x10); //Set the register bits as 00010000 (+/- 8g full scale range) Wire.endTransmission(true); This will setup the gyroand acc data to that range! Keep up!
it's a good work man, i understood the main idea but i need to know why you use a value of pitch angle range as i deal with only one axis (i talk about the pid balance control ) i use that code but i didn't work with me , serial monitor of that code when i use it didn't begin , what do you think ??
Hi, first of all congratulation on your new spanish channel. I want to see you get your flight software to fly. So another comment. I read your code you use the elapsedTime, time, timePrev;. I just want to suggest you to try cycle time like multiwii of 2800us or higher depend on your program run. using while loop to create cycle rate.
how can we make the same receiver using arduino ? in your previous video you made the receiver with arduino but the pwm values were coming out using only 1 pin.. But i want to make the receiver using arduino where it has multiple pins for sending different pwm values of roll, throttle, yall & pitch
That receiver has PPM output not PWM. If you want PWM you should try a servo.writeMicroseconds() for each cahnnel and use a different pin for each one. Keep up!
yaa it is PPM. :) how can we do it using an arduino ? because if we can do that using arduino.. that receiver can be used anywhere like a normal receiver!!
Hey, thanks a lot for sharing. I always love watching your videos! , may I ask what editing softwares you use ? I am guessing adobe premier pro and after effects but still. Cheers!
sir how are you , there is some thing i am working on in pid issue and there is some thing special about not calculating setpoint in an error term , i have perfect results when changing pid rules , more ditles when you respond more thing about using virtual wire instead interrupt routine details
oh i am sorry for misunderstanding my friend i have been working on my cuad and i have always wondering why error = gyrovalue-setpoint why to add an necessary term to the PID equation , what i did simply is that i removed all the setpoint values from pid equations and i added them to the esc final signal drop calculations , the wonder result that i have achieved more stable cuad and when i searched about my way of PID i found that all scientific referances about this subject i found that (error = gyrovalue-setpoint) is a main truth in designing , so how my conclusions are correct!? is what i did a method of PID i dont know? if so why isnt it used in common cuadqopters or balanced systems?
i m making quadcopter using arduino uno mpu6050 and hc05 bluetooth as a transreciever...i tried but there is some mistakes in my code..can u plzz check it and suggest the way to fix it #include #include "I2Cdev.h" #include "MPU6050.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif MPU6050 accelgyro; int16_t ax, ay, az; int16_t gx, gy, gz; #define OUTPUT_READABLE_ACCELGYRO #define LED_PIN 13 bool blinkState = false; //Create the 4 esc objects Servo esc1; Servo esc2; Servo esc3; Servo esc4; //Esc pins int escPin1 = 5; //back int escPin2 = 9; //left int escPin3 = 10; //right int escPin4 = 11; //front //Min and max pulse int minPulseRate = 1000; int maxPulseRate = 2000; int throttleChangeDelay = 50; //SETUP void setup() { #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif Serial.begin(9600); Serial.println("Initializing I2C devices..."); accelgyro.initialize(); // verify connection Serial.println("Testing device connections..."); Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed"); //pinMode(2,OUTPUT); pinMode(3,OUTPUT); Serial.setTimeout(500); //Init escs initEscs(); } //LOOP void loop() { //for led's // digitalWrite(2,HIGH); digitalWrite(3,HIGH); // Wait for some input if (Serial.available() > 0) { // Read the new throttle value int throttle = normalizeThrottle(Serial.parseInt()); // Print it out Serial.print(" Setting throttle to: "); Serial.println(throttle); // Change throttle to the new value changeThrottle(throttle); } } //Change throttle value void changeThrottle(int throttle) { int currentThrottle = readThrottle(); int step = 1; if(throttle < currentThrottle) { step = -1; } // Slowly move to the new throttle value while(currentThrottle != throttle) { writeTo4Escs(currentThrottle + step); currentThrottle = readThrottle(); delay(throttleChangeDelay); } } //Read the throttle value int readThrottle() { int throttle = esc1.read(); Serial.print("Ct th is: "); Serial.print(throttle);
return throttle; } //Change velocity of the 4 escs at the same time void writeTo4Escs(int throttle) {
If you think that is fine to watch, then it's not my problem. I watch videos from atleast 1 meter from my large laptop. I dont watch video's in a typing position where I would clearly be able to read the very left edge of the screen where your code resides. Basically you think its fine because you can read it ?
#separa los valores del universo y de los de pertencia de la matiz # si la funcion de membresia es de tipo trapeziodal def fTra(A,x): # type: (Matrix, universo) -> object #interseccion de la funcion de membresia y singleton """ :rtype: float """ a = A[0] b = A[1] c = A[2] d = A[3] if xa and xb and xc and xd : p=0 return p ################# Triangulo ########################################### #///separa los valores del universo y de los de pertencia de la matiz // #////si la funcion de membresia es de tipo triangular ////////////////// def fTi(A,x): a = A[0] b = A[1] c = A[2] if x a and x b and x 0 and b_t>0 : Or=1 return Or ######## AND difuso############# def t_norma(a_t,b_t,op) : if op==1 : And = min(a_t, b_t) if op==2 : And = a_t * b_t #####Producto drastico if op==3 : if b_t==1 : And=a_t if a_t==1 : And=b_t if a_t
I couldn’t manage to make the drone fly straight. I couldn’t find the correct PID values. I’ve made 100 tests and still noting. Stay tuned for future updates. You could always use the MultiWii platform. Also, if you consider helping my projects chek my Patreon: www.patreon.com/ELECTRONOOBS
I hope that you'll be able to learn sommething new with this video.
The plot twist was awesome :D
In the TWO axis file you made a mistake in the pid section. "if(pitch_PID < -4000){pitch_PID=-400;}" I think you want that to be 400 instead of 4000. I know you propably found it, but if somebody uses the code from your site will pull their hair, why is it not working.. :D
BTW if you want to improve the quality of your code, make sure that you put every group of functions into a different tab. It's like using separate classes in .h and .cpp files, but simpler. (I have separate tabs for: Setup-Loop, Transmitter, IMU, PID, Motor control, Telemetry, LED signals.) It makes much easier to read the code.
I hope that both of us will be able to tune the pid. :D
Cheers!
Ferenczi Csongor thank you very much!!!
Electronoobs You're welcome. :)
Have you check weight on each side? i think it's not symmetric
I will never be perfectly symmetric. The idea of the PID is that even with bigger load on one side it should fly streight. On of the PID tests is to hang sommething on one side of the bar and it should always fly horizontal. I'll improve the code... Keep up!
As a tip to anyone trying to build a quad with the mpu6050, calculating the pitch and roll angles the way he did is wrong, you are gonna encounter problems, with rotations around the z- axis.
You can test it yourself. 1) Implement his code so that you get an angle that's calculate only with the gyro values.
pitch = gyro_x * dt and print the values to the serial port.
Now starting at 0° if you rotate around x or y to 45° for example and then rotate around yaw, you'll see that the angle won't change or just a bit. If you now rotate back to the initial orientation the starting angle will be wrong.
The correct formula is :
phi = prevPhi + dt*(wx + wy*sinPhi*tanTheta + wz*cosPhi*tanTheta);
For more information I'd recommend the following book: Rigid Body Dynamics for Beginners by Phil Kim
or read this:
andrew.gibiansky.com/blog/physics/quadcopter-dynamics/
Well, it is depend on the flight mode he is trying to program. In rate/acro mode you don't need to calculate the angle of the IMU what you need is rate of velocity of the gyro. Only if Angle/Auto-level is programed for the quad you need absolute angle measurement. He is not mention about the flight mode he is trying to do though. One month agos I comment the same as you.
Can you please provide link to the equation above ??
so from the equation you provided above , is it for Roll angle calculation ??
can someone plz say how to implement in his code
Thanks for your hardwork it's because of you we LEARN.
Vishal Mehra thank you. I'm glad to hear that!
Hello,
I think that the main problem resides in the code itself.. Let me explain..
As in the flight controller the PID errors are calculated using the pitch and roll angles, the PID controller is unable to compensate for sudden changes in movement or sudden changes in rate of rotation..
Let's consider an example.. Suppose that the refresh rate is 250Hz giving a loop time of 0.004s or 4ms.. Now let's consider that the drone is flying with zero roll angle, and suddenly due to wind the drone starts to rotate with a rate of rotation of 100 degrees per second.. In this situation the roll angle will change only by 0.0121 ((100/32.8) * 0.004) degrees in one loop, hence the PID error will be +/- 0.0121 which is "very small" to account for a 100 dps movement and hence the PID controller fails to stabilise the drone.. The same can be applied for pitch axis..
According to me, the PID controller should be based on degrees per second movement and not on angles.. Also, do not use the map function as it don't work for floating point numbers and returns long (data type) values..
Divyanshu
Interesting :) thanks but gyro is drifting..
Bro can I use its flight controller code? Will it be worked with my drone?
I believe (I might be wrong) that the unstable state of the drone was due to the use of Euler Angles which are susceptible to the gimbal lock phenomena. If you opted for a quaternion interpretation of the rotation maybe you would get better results even without extra sensors. To be clear this is not a critique but just an idea. Love your channel and your videos helped me so much through my thesis, so thank you.
Thank you for this information, watching your video and others is helping to put all the pieces of the puzzle together on how to program a diy flight controller.
Man, it was very nice that you built the control algorithm yourself and showed us. I was looking for such video for a long time. I think that you should take the yaw motion into account because when one or two motors try to compensate the disturbance, due to the conservation of angular momentum the yaw orientation of drone also changes. Also anti windup integral may help and probably with that much of code the refresh rate of arduino became insufficient. And you somewhat calibrated the gyro to assume the initial position of the drone to be flat by offsetting the initial reading, I think that should not be done. I also dont know how to control the yaw by the way, if you get it somehow please tell me also)
Hello my name is Gift, I love your video to me you are day best I'm learning from you as I'm also trying please keep up the good work
Oh man you're excellent :) I never undestood the PID in school.But at least now I have an small idea how it works and how to implement it on somethings like multicopter :)
Love these video series, great man, really nicely done.
Hey man, your problem isn't in your PID tuning, its in the actual structure of the drone. You see, you have programmed your software to assume symmetry, but your prop-arms are not symmetric about the roll-axis. Meaning, roll and pitch controls are not the same due to the angle of the prop-arms coming out of the center of the body.
If you look at Falcon-9 grid fin orientation, they are separated by 90 deg giving identical roll and pitch ability, but if you look at the superheavy grid fins, they are at 120deg and 60 deg orientation, giving more control authority to pitch than roll (since the roll ability of the grid fins is much higher than pitch, I know i was confused at first too). I believe you have the same problem. Just orient your prop positions to be 90 deg apart.
PS. even if you look at the other drone footage in your video that shows testing cage, those drones all have their props 90 degs apart.
You are a Genius. Love your Videos.
Thank you very much.
My pleasure. Actually was really impressed by your Electronic speed controller project and indeed it was a really complicated one.
Hi electronoobs love you video from India
10:35 you can test with 1 wire atached to load at bottom its more cheaper?
You need to make integral windup protection.
Also calculating rol, pitch, and yaw angle as you made kind a bad idea. Euler angles in 3d rotation sometimes works bad (gimbal lock) = crash.
You need to use quaternions instead of euler.
read about this things
Ave Vovus! Thanks, I'll definitely improve my code.
why are quaternions better ? I'm working on a similar project and i keep seeing this advice without explanation. please could you explain ?
As Ave stated to describe 3D rotations you need to use quaternions, you can search for "gimbal lock" and get a very detailed explanation.
good job! looking forward to ESCs PWM write part!!
Thank You! From Frisco, TX
Dude 😎 u are an absolute legendary legit legend
Question: why is the servo library not used since it is usually used to control ESCs with BLDC motor? Please answer
Thank you so much for sharing. I learned so much from your work. Thanks, heaps. 🤗
You are awesome man u teach so clearly now i am all clear i can make my own drone thanks a lot
Had you built it ??
there is a mistake in line 294 it should be (-400) not -4000 9:46. You probably forgot while typing
ELMO7TARAMQ8 yes, you're the second person that tells me that. Already corrected that in the code on my webpage thanks again
Sir, i have a doubt... is it possible to use ur program for a drone which is not controlled by remote.... instead we r using GSM to controll the moment of drone.... Please answer fast !!!!
Very good and easy explanation,.thanks a lot
What is the metal mechanism you have used to levitate drone with 4 rods in between.
really nice video man ... I tried to make the same but the motors don't turn on ... i don't know why. Maybe the soldering ? or something esle ?
I think you haven't included yaw values that's why it isn't flies perfectly
Hi, thanks. i have a question. how can we make correction on gyro drift to make full imu code the help of magnetometer? i am using mpu9250
Sir , can I use nodemcu instead of transmitter and reciver because it produce pwm output and control pwm using webpage.
my pwm output from pid calculation is responsive but when it write to esc ,the bldc response is slow(its like have some delay on it) so my quad can't stable in any pid constants that i tune..
Please help how to make my esc reponse to fast with no delay ?( thanks.
Sorry. I am trying to make some sort if uber walter scooter for my son using ovc pipes. Do you gave any suggestiin how to make a warercproof throttke?so novwater will get in the pvc pipes i tgought hall sendors vut they do not seem very good,at sensing range rgs just go on or jf and i would kiks ti avoid using 10 sensers. Or naybe veter use 2 push buttons
This is great you taught me a lot I give a thumbs up 😍😍😍 and I've built mine but how can I add a barometric sensor if I add a barometric sensor do need to code what should I do 🙏
First, I would like to thank you for sharing the knowledge and putting the effort into making educative videos with great illustrations and video editing.
I really have something that's bugging me regarding how you calculate the angles using the linear acceleration. the MPU ciruit gives angles from the gyro sensors and linear acceleration from acceleration sensors. a rigid body in space can be fully defined kinematically by 6 DOFs ( 3 dispacements and 3 rotations). in the calculation of angle you seem to include the acceleration which you only account for 2% while 98% comes from gyro angular acceleration. I am also very confused on the formula used to compute angles using acceleration. because the gyro is attached to the body of interest (aircraft) angles should be only coming from gyros and if you want to control translation motion then you can but you will use the linear acceleration data. let me know what you think.
Pregunta brother El control que colocas bajo que función de transferencia lo basas o es de la librería de Arduino?
instead of arudino nano we can use arduino uno...for two axis flight controller.
How are you sir...Can you use the ADXL345 you want the MPU6050 because I don't have the MPU6050 and thank you
Really great . Thanks a lot !
How do you power the arduino without cable from laptop source?
You havent done any coding to choose FS_Select=2 in Register 0x1B, so weren't you using default FS select=0? if so, weren't you suppose to divide gyro raw with 131?
If you go in the final 2 axis code in the setup loop you wil find this lines:
Wire.beginTransmission(0x68); //begin, Send the slave adress (in this case 68)
Wire.write(0x1B); //We want to write to the GYRO_CONFIG register (1B hex)
Wire.write(0x10); //Set the register bits as 00010000 (100dps full scale)
Wire.endTransmission(true); //End the transmission with the gyro
Wire.beginTransmission(0x68); //Start communication with the address found during search.
Wire.write(0x1C); //We want to write to the ACCEL_CONFIG register (1A hex)
Wire.write(0x10); //Set the register bits as 00010000 (+/- 8g full scale range)
Wire.endTransmission(true);
This will setup the gyroand acc data to that range!
Keep up!
Help please
If I want to compute value using a flight controller like Naza M, can I just use analogWrite(pwmPin, pwmInput) to send pwm signal?
pulseOut(pwmPin, pwmInput); works on arduino pins labelled with a "~" next to them like ~3 ~4
sir can i use bluetooth module? and operate by a smartphone...?
thank you very much for this vid!
Really, really nice work, man. :)
Thank you!
it's a good work man, i understood the main idea but i need to know why you use a value of pitch angle range as i deal with only one axis (i talk about the pid balance control ) i use that code but i didn't work with me , serial monitor of that code when i use it didn't begin , what do you think ??
I don't understand your question/problem.
Electronoobs , the code of pid balance control didn’t work for the test and serial monitor gives nothing when when move the gyroscope sensor
is it required only pwm transmitter or not...?
Hi, first of all congratulation on your new spanish channel. I want to see you get your flight software to fly. So another comment. I read your code you use the elapsedTime, time, timePrev;. I just want to suggest you to try cycle time like multiwii of 2800us or higher depend on your program run. using while loop to create cycle rate.
Thank you very much.
Dude you are awsome
can this be used for Beta FPV drone
i am building a bicopter with arduino flight controller, please help me,share some important points you can tell ?
how can we make the same receiver using arduino ?
in your previous video you made the receiver with arduino but the pwm values were coming out using only 1 pin..
But i want to make the receiver using arduino where it has multiple pins for sending different pwm values of roll, throttle, yall & pitch
That receiver has PPM output not PWM. If you want PWM you should try a servo.writeMicroseconds() for each cahnnel and use a different pin for each one. Keep up!
yaa it is PPM. :)
how can we do it using an arduino ?
because if we can do that using arduino.. that receiver can be used anywhere like a normal receiver!!
where in the code we change the value of PID
is possible to get lat lan from Apm2.8 by arduino ?? plz make a video on arduino Mavlink
Bro try with 2212 motor and use Q450 frame and 30am esc it will be stable
Hey, thanks a lot for sharing. I always love watching your videos! , may I ask what editing softwares you use ? I am guessing adobe premier pro and after effects but still.
Cheers!
Just After Effects. I stoped using premiere...
how do I do it for Altitude control
sir how are you ,
there is some thing i am working on in pid issue
and there is some thing special about not calculating setpoint in an error term , i have perfect results when changing pid rules , more ditles when you respond
more thing about using virtual wire instead interrupt routine details
I don't follow you. Thanks !
ok,
, i didnt mean to follow me , but it is just about acknowledge
Thank for everything but what I meant by don't following you is that I didn't fully understood your message. Keep up!
oh i am sorry for misunderstanding
my friend
i have been working on my cuad and i have always wondering why error = gyrovalue-setpoint
why to add an necessary term to the PID equation , what i did simply is that i removed all the setpoint values from pid equations and i added them to the esc final signal drop calculations , the wonder result that i have achieved more stable cuad and when i searched about my way of PID i found that all scientific referances about this subject i found that (error = gyrovalue-setpoint) is a main truth in designing
, so how my conclusions are correct!?
is what i did a method of PID i dont know?
if so why isnt it used in common cuadqopters or balanced systems?
to be more clear , i modfied Joop Brooking code, Brooking from Norway i am sure that you know him
thnks dude, it could minimalize the fee 😁
This only works with ESC's and not Brushed Motors, make one with analogWrite(); pls
hello nice when you build the controller i like that
merci bcp.
👏👏👏👏
good
i m making quadcopter using arduino uno mpu6050 and hc05 bluetooth as a transreciever...i tried but there is some mistakes in my code..can u plzz check it and suggest the way to fix it
#include
#include "I2Cdev.h"
#include "MPU6050.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
#define OUTPUT_READABLE_ACCELGYRO
#define LED_PIN 13
bool blinkState = false;
//Create the 4 esc objects
Servo esc1;
Servo esc2;
Servo esc3;
Servo esc4;
//Esc pins
int escPin1 = 5; //back
int escPin2 = 9; //left
int escPin3 = 10; //right
int escPin4 = 11; //front
//Min and max pulse
int minPulseRate = 1000;
int maxPulseRate = 2000;
int throttleChangeDelay = 50;
//SETUP
void setup()
{
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
Serial.begin(9600);
Serial.println("Initializing I2C devices...");
accelgyro.initialize();
// verify connection
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
//pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
Serial.setTimeout(500);
//Init escs
initEscs();
}
//LOOP
void loop() {
//for led's
// digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
// Wait for some input
if (Serial.available() > 0) {
// Read the new throttle value
int throttle = normalizeThrottle(Serial.parseInt());
// Print it out
Serial.print(" Setting throttle to: ");
Serial.println(throttle);
// Change throttle to the new value
changeThrottle(throttle);
}
}
//Change throttle value
void changeThrottle(int throttle) {
int currentThrottle = readThrottle();
int step = 1;
if(throttle < currentThrottle) {
step = -1;
}
// Slowly move to the new throttle value
while(currentThrottle != throttle) {
writeTo4Escs(currentThrottle + step);
currentThrottle = readThrottle();
delay(throttleChangeDelay);
}
}
//Read the throttle value
int readThrottle() {
int throttle = esc1.read();
Serial.print("Ct th is: ");
Serial.print(throttle);
return throttle;
}
//Change velocity of the 4 escs at the same time
void writeTo4Escs(int throttle) {
//for gyro
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
#ifdef OUTPUT_READABLE_ACCELGYRO
float x,y,z;
x=(ax/131);
y=(ay/131);
z=(az/7072);
Serial.print("a/g:\t");
Serial.print(x); Serial.print("\t");
Serial.print(y); Serial.print("\t");
Serial.print(z); Serial.print("\t");
//Serial.println();
#endif
#ifdef OUTPUT_BINARY_ACCELGYRO
Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF));
Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF));
Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));
#endif
int A,B,C,D;
C=throttle;
A=B=D=C;
//D=B;
int yhigh=7;
int ylow=3;
int xhigh=15;
int xlow=10;
if(y=xhigh)
{
C-=3;
B-=2;
esc1.write(A);
esc2.write(B);
esc3.write(C);
esc4.write(D);
}
else if(y>=yhigh)
{
C-=3;
esc1.write(A);
esc2.write(B);
esc3.write(C);
esc4.write(D);
}
else if(y=xhigh)
{
B-=3;
esc1.write(A);
esc2.write(B);
esc3.write(C);
esc4.write(D);
}
else if(x 80) {
return 80;
}
return value;
}
plz check and help me to fix it
Make the third part bro
maybe hobbyking has a complete unit you can plug in and reverse engineer
your test bar was not always leveling properly...could be due to pinch points
Then just get a betaflight compatible flight controller, and it will fly
Bro.... Where is library link....??
whar library do you need? Codes are in the description!
sorry bro....got it
Any Arduino IDE updated version should have that library.
👌👌good 👏👏🏁🏁🏁🏁
Sir please make a micromouse robot
Bro it name is eletronoob kid
Why even show the IDE with that font size, LOL
If you watch this on a smartphone, well sorry. The video is Full HD and I can perfectly see all the text on my screen. Sorry and keep up!
If you think that is fine to watch, then it's not my problem. I watch videos from atleast 1 meter from my large laptop. I dont watch video's in a typing position where I would clearly be able to read the very left edge of the screen where your code resides.
Basically you think its fine because you can read it ?
good job if your need help to system control algorithm . write in my email i am working in fuzzy neural network , adaptive control
import numpy as np
import matplotlib.pyplot as plt
from module import *
class Neuronal(object):
def __init__(self, inputLayerSize,hiddenLayerSize,output):
self.n1 = hiddenLayerSize
self.n2 = inputLayerSize
self.out=output
def sigmoid(self,x):
return 1 / (1 + np.exp(-x)) # activation function
def tansig(self,n):
y = (np.exp(n) - np.exp(-n)) / (np.exp(n) + np.exp(-n))
return y
def train(self,epochs,x1,y):
ep=1
alfa=0.01
W1 = 2 * ep * np.random.uniform(size=(self.n1, self.out)) - ep
b1 = 2 * ep * np.random.uniform(size=(self.n1, self.out)) - ep
W2 = 2 * ep * np.random.uniform(size=(self.n2, self.n1)) - ep
b2 = 2 * ep * np.random.uniform(size=(self.n2, self.out)) - ep
W3 = 2 * ep * np.random.uniform(size=(self.out, self.n2)) - ep
b3 = 2 * ep * np.random.uniform() - ep;
l = len(x1)
for i in range(epochs):
sum = 0
for q in range(l):
a1 = self.sigmoid(W1 * x1[q] + b1)
a2 = self.sigmoid(W2 * a1 + b2)
a3 = W3 * a2 + b3
e = y[q] - a3
s3 = -2 * 1 * e
s2 = np.diag((1 - a2) * a2) * W3.T * s3
s1 = np.diag((1 - a1) * a1) * W2.T * s2
W3 = W3 - alfa * s3 * a2.T
b3 = b3 - alfa * s3
W2 = W2 - alfa * s2 * a1.T
b2 = b2 - alfa * s2
W1 = W1 - alfa * s1 * x1[q].T
b1 = b1 - alfa * s1
sum = e * e + sum
emedio = sum / l
return a3
def fun(x):
return x*x*x+2*x+1
#x1=np.array([-4,-3,-2,-1,0,1,2,3,4])
#y=fun(x1)
#P = np.array([[0 ,0, 1, 1],[0 ,1 ,0 ,1]])
#T = np.array([-1, 1, 1, -1])
#nn=Neuronal(4,4,1)
#t=nn.train(600,P,T)
#print len(P[1,:]) y
#print t[1,:]
#plt.plot(y,'ro')
#plt.plot(t[1,:])
#x=0
#while True :
# v = circle_trajectory(2, x, 0.1)
# print v
# plt.plot(v[0], v[1], 'ro')
#plt.show()
#x=x+1
#separa los valores del universo y de los de pertencia de la matiz
# si la funcion de membresia es de tipo trapeziodal
def fTra(A,x):
# type: (Matrix, universo) -> object
#interseccion de la funcion de membresia y singleton
"""
:rtype: float
"""
a = A[0]
b = A[1]
c = A[2]
d = A[3]
if xa and xb and xc and xd :
p=0
return p
################# Triangulo ###########################################
#///separa los valores del universo y de los de pertencia de la matiz //
#////si la funcion de membresia es de tipo triangular //////////////////
def fTi(A,x):
a = A[0]
b = A[1]
c = A[2]
if x a and x b and x 0 and b_t>0 :
Or=1
return Or
######## AND difuso#############
def t_norma(a_t,b_t,op) :
if op==1 :
And = min(a_t, b_t)
if op==2 :
And = a_t * b_t
#####Producto drastico
if op==3 :
if b_t==1 :
And=a_t
if a_t==1 :
And=b_t
if a_t
Too complicated to understand