People would pay to see these videos. Great demos, and explanation to how normal arduino commands slow things down. You should be a teacher. Direct access to ports FTW. GOOD JOB
one of the best tutorial, description i ve ever watched. It applies to all the videos . I admire yor effort and knowledge. EXCELLENT is the least i can say for all the videos so far
Very interesting to see how you estimate the running time of the different code parts. I also like the way you optimize your code, I'll definitely implement that !
very useful and helpful.. thank you for using the o-scope and explaining the methods that you used to validate/verify timing! seeing it first hand helped me very much
This is brilliant. Would love to have my quad copter under my control, and not flying by the magic of someone else's firmware. Just wish I fully understood what you just did there. I need to learn by doing. Thanks for the pin out diagram. Looking forward to the next instalment! :-)
I was thinking to use a function that handles the part of recieving, and returns the values of the 4 channels to the main loop, the transmitter is an arduino too, and sends a string containing the datas relative to the channels (two nunchuks, one for channel1&2 and another for channel 3&4).
could you please explain why would the change in the loop time (4000us) affect the calculation of the IMU? and, is the refresh rate of the ESC same as the wave length of the signal? to make it clear, does it require the pulse(1-2ms) every 4ms or every 20ms ? videos are well structured and vividly clear, you efforts are brilliant.
Joop hi, again me... Im trying this on a nano so Im being very thorough on timing. I measured the calculation time on the signalen () function turning 13 High before and Low at the very end. This gives me 300 us and not 600 us as for you... what did you mean by calculation time? Was this calculated on the same function?
The time that I measured was the complete loop without the I2C calculations. Also, you need to start the quad to have the maximum calculation time. At the end the exact time does not matter because you must prevent the total loop time to exceed the 4000us.
Hi ! Why haven't you used the Servo library with the writeMicroseconds() function ? Moreover is it possible to create a second subroutine for generating outputs ? Thank you, have a great day!
This is helping me a lot, being a computer science student(undergrad) there is a lot of low level mechanical interface that we are never taught, Thank you for the tutorial and I would also like to ask how many parts are there in total to your video series?
aridaman yadav Thanks for the compliments. I hope to finish all the details with 6 video's. In the last video I'll post the final Arduino sketch that you can download.
Hey Joop, great video! I have a question, at one part of your code, the final ESC timing calculation is set as follows: 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 am a bit confused as to how you got this configuration; why are some terms joined by a minus and some by a plus? Is this derived from a physical equation? Thank you!
If the quadcopter needs to tip in the front direction the front motors need to decrease and the rear motors need to increase speed. Same with left and right and yawing.
can u plz eexplain some basic command like digital read, write, analog read, write basics of IIC & SPI communication, conditioning (any faster way than arduino built in ) , loops etc. Plz it would be a loot help for me.
Great Job, we have learned a lot from these videos, i only have a small question. the ESC power cables are connected to the battery, arent they? Its not clear in the schematic. Thank you
sir, al setup program is working properly but esc calibration program is not giving any response. nothing happens when we give r,a. or any other command. your solution from q and a is not helping pls help.
I use simonk esc But I have same problem Two motor work correctly. one motor not start and vibrate. One motor are start after the more than half throttle Please reply fast
I've done all the ESC calibrations according to the instructions for them, but when I have gone to do the calibrations they are starting at different throttle positions, any idea what could be causing this?
Thank you for the work you have put into these videos, they are awesome! I am trying to learn and understand your code, I struggle to understand how you arrived at 16 for the " while(PORTD >= 16)" statement. May I ask how did you derive this value? How does it work?
hi joop you did a good job making this open source flight controller, i was making my own receiver transmitter, i am having a little trouble understanding the receiver code part, we are getting a pulse between thousand to two thousand microsecond at receivers output, how are we reading this pulse in the code to get a value between thousand to two thousand .
Joop Brokking thanks for answer! Do you think that loop time should be kept constant? If it's not constant then this should be considered in PID controller, but what's better?
Hey , Joop I really did learn a lot from you.I want to Know How to do stuff like analyzing a problem and finding a counter measure for it.PLEASE HELP ME I want to have that skill like you.Thank you Once Again.
I have gone through the setup program and I am now a little confused as to what I have to do with the ESC calibration program. I proceeded to upload the Flight controller program just to test it but there is an issue where 2 motors turn on immediately and stay on after I activate the program with the throttle joystick in the bottom left hand corner. I am assuming that this is just a result of me not calibrating the ESCs correctly but I am really not sure. Upon further testing of drone, I have determined that it may be a gyro or prop balancing issue. After I activate the quad copter with throttle down, yaw left, the back left motor begins spinning very fast. I tilted the quad copter around to see if the auto leveling would work and it does, but when the drone is stationary in the same flat position in which I calibrated the gyro and ESC's that back right motor spins. I think the it may be a prop balancing issue, so one question I have is can I connect the flight battery to the drone while it is plugged into the laptop USB? Your explanation on your website implies that, the answer to this question is yes, but I would like to verify so I do not cause damage. Any additional advice on how to troubleshoot this issue would be greatly appreciated.
After uploading the ESC sketch, plug out the USB wire from your pc. Transmitter on, throttle low, then set in the highest position. Attach the Battery to the quadcopter. Wait for the beeps ate gone and led it out. Throttle now to lowest position. The ESC's are calibrated now (always props off for your own safety). De- attach the lipo and connect the USB wire again for uploading the flight sketch.
thanks a lot sir . 1. but why did you use a diode in circuit what is the use of it there ? 2. and i dont have 1.5k register can i use 10k instead of 1.5 k ? thank you sir ;)
Hey Joop, I am using my own gyro (GY-291/ADXL345), and have been able to get data using a separate program so far. Your videos have been very helpful so far, but I am heading in a separate direction now. Is there a way to enable/disable the gyro program using an input from the receiver? I'm guessing that there's probably a code that would disable/enable it in one line. Is there such a code? I'm guessing that i could also use the interrupt code that will interrupt the program whenever you move the sticks. Can a similar code be used from the sticks? I apologize, i'm not too familiar with the Arduino. - Tarik.
i have a question! you said that receiver 's refresh rate is lower than the program loop's , so we have to use interrupt. But I cant understand why this can be the solution. could you help me to understand this?
Pls sir, I tried following your setup code, but can't still understand "channel_1_assign, channel_2_assign... Channel_4_assign". It's really giving me problem. Pls help me out. Especially this code- ((channel_1_assign&0b00000111)+7). I don't understand what it means.
I would like to thank you very much, this series is both interesting and useful. However, you said in part (4) that the refresh rate of the ESC is 250 Hz. My question is: How can I determine the refresh rate of any ESC?
The program loop that is running in the Arduino uses 4us. This makes the refresh rate 250Hz. Most ESC's can handle a 50 till 400Hz refresh rate without problem. But if you want to make sure you need to check the manual of the ESC. However, a 50Hz refresh rate is not suited for multicopters. You really need a fast response to get it stable.
Hello! I'm sorry to say but i've been stuck debugging this program for quite a while. Plenty of things don't make a lick of sense - such as the variables of receiver_input_channel_1, receiver_input_channel_2, receiver_input_channel_3, receiver_input_channel_4; never being assigned any value. Replacing all of them with receiver_input[n] does work. Sadly, while the ESC signals are calculated properly, the ESC signals being sent do not work with the ESCs (even if the previous, "manual" ESC set ups during the program to keep them quiet do send a valid signal).
The receiver_input_channel_1 till 4 are set in the receiver interrupt subroutine. It's the length of the incoming pulse from the receiver. Please use the YMFC-AL: www.brokking.net/ymfc-al_main.html as it is better documented.
Hi I am trying to modify your flight controller code to do some other stuff, but i am having a problem figuring out how you are creating pulses for ESCs..if you can just give a summery of how the flight controller works it would be really helpful. Thank you.
hey Joop, thank you a lot for these videos that are really helpful and we are looking for more :) ... i have a question ... i need to build the same quad copter, but i need also to implement several Range Sensors in it so it can avoid obstacles... but all the Arduino Uno port are occupied. ( only A1 ; A2 ; A3 ; D0 ; D1; D2 ; D3 ; D13 are not used on your schematic)) .. how then could i add like +10 Range sensors to this Arduino Uno? should i add another arduino uno board and make a connection with the first one ? if the solution needs another board to use, please give a schematic for this connection. thank you
Sir, ofcourse, its calliberating ESCs but nothing visible on serial monitor in starting but when I type 'R' serial monitor start showing readings as well as with 'a' also. During calliberation nothing on serial monitor. But ESCs got callieberated ?
Brother, I built an android app and i am trying to use the HC-05 bluetooth module to control the ESC using your code: Here is what my android app briefly does: - when you press the left button on my app --Then --> '1' is send, and when released '0' is sent. - when you press the right button on my app --Then --> '2' is send, and when released '0' is sent. - when you press the up button on my app --Then --> '3' is send, and when released '0' is sent. - when you press the down button on my app --Then --> '4' is send, and when released '0' is sent. I know how to make an led blink using my app via bluetooth. However, i am trying to apply my bluetooth app on your code for the esc. I would really appreciate it if you can give me a hint on how to do this. Thank you. I have read your code and been trying to do this thing the whole past summer, but no luck yet :)
the refresh rate you set in your program is 4000usec, but it don't work for my ESC. the minimum refresh rate in my case is 10,000usec. As you know it should be 20,000usec (by priniciple), but due to our refresh rate resctriction we move towards 4000usec (10,000usec in my case). i have installed TGY hex firmware on my ESC and after installing that ESC's acceptable minimum refresh rate are 10.000usec. i want to decrease that refresh rate to 4000usec kindly give me any solution.
connect the binding cable in the reciever 1st channel & hold the binding button pressing it and turn on the transmitter (the binding button is present on the transmitter)
Hello, why have to abandon the version with the STM32F103C8T6? I find the setup version for the YMFC_all really good. she would have good for the STM32 too!
Good night Joop Brokking, if possible you could add subtitles to the video so you can translate I'm very interested in understanding this video .. thanks !!
Joop Brokking iam trying to build quadcopter so when i put all together one not working but its rotating if connected alone , today i connected red wire from esc to VIN of arduino its working
Your code is fantastic 🙂☺️☺️☺️😍😍. I did on uno. It 's work instantly. But I did on mega2560. It not woking. ESC are not calibrated. I don't know why. I did change DDRD to mega 2560 port but still not working. Finally thank for your Knowledge I learn a lot from you appreciate that.
Invalid library found in C:\Program Files (x86)\Arduino\libraries\PPM-reader-master: no headers files (.h) found in C:\Program Files (x86)\Arduino\libraries\PPM-reader-master
+Joop Brokking yes ...and i used ymfc v2 methods 2 process is completed ....but after uploading final code auto level is not working(no change in motor speed) when i bend or tilt...my quadcopter..i am using mpu-6050 gyro
simraan shaikh You need to check the manual of the esc on how to calibrate them. There are so many brands and types of esc's with all there own calibration method.
Hello Joop Brokking, thank you for this great video. It is so instructive! However, for some reasons any motor that is connected to D5 does not turn on at the same time as the other motors. Would you know how to fix that issue?
Joop Brokking thank you for relying. I'm using the code from your website. However I used MPU 6050, so I had to use a different code for my gyroscope. Would that make any difference?
sir i have some problem . in ESC have 3 pins which is connected in arduino 5 V , GND and Signal Pin. and i try to cennect just Signal Pin and GND then the result the ESC not give respon.
and sir i have problem again 2 motor of my project when throtle reach 30 % motor will turn on and the other 2 motor when throtle reach 5% they turn on.
anyone help plz I need to make the loop at 125hz so if i change these two line do it work probably if(micros() - loop_timer > 8050)digitalWrite(13, HIGH); //Turn on the LED if the loop time exceeds 4050us.
//All the information for controlling the motor's is available. //The refresh rate is 125Hz. That means the esc's need there pulse every 8ms. while(micros() - loop_timer < 8000);{ //We wait until 8000us are passed. loop_timer = micros(); //Set the timer for the next loop. }
Brokking, first of all thanks a lot for the nice videos. I did find out why the refresh rate must be 250 Hz = 4000 micro seconds. How is it determined and to what extend can we change it if we want to impliment an additional sensor like an ultrasonic sensor for altitude hold ? It would be very helpful to give a hints on where in the code to edit the refresh rate. Thank you again
When I run the program of Esc's output all the motors start spinning when led stops blinking. But when I uploaded the final code when Led stops blinking motor does not run. Help me Joop Brokking
simraan shaikh Make sure your transmitter is setup correct with the program of part 2. Starting the motors with the final program requires a special stick sequence. If your transmitter is not setup correct the motors will not start.
dear joop, I am making my science project as i used ur same techinquies for it.. i have done everthing same.. but the issue is that my LED Stays on all the time.. cant understand where the error is and second when i increase the trottle the rpm of the motor increases a bit and then reducing automatically or sometimes it stops so basically its not flying .. i think it can be the voltage drop but still cant get it .. pls help.. thanks ..
Check question 9 on this page about the LED. When you test the quadcopter you need to hold it in your hand as I showed in this video:th-cam.com/video/DYpHB-LfloI/w-d-xo.html Then you can feel if the motors work correct.
dear Joop brother, I found the issue regarding the LED stays on when i just increase the throttle a little bit on this statement : //Turn on the led if battery voltage is to low. if(battery_voltage < 1000 && battery_voltage > 600)digitalWrite(12, HIGH); but when i check the voltage of my battery its not less than 11 but yes my battery drainage fast; btw i'm using li-ion batteries LC 18650 3.7v (3800mah) cell through which I made 3 cell 11.1v 3s battery .. does the battery type effects ? or It only supports the lipo battery ? can u help me or there is any other change in code i can made .. waiting for your great reply ..
Why are you using the wire library in your code? Why can't you just use Servo? It's so much better. myservo.write(180) is full throttle, myservo.write(90) is half throttle and 0 is no throttle... It's pretty straight forward as apposed to calculating pulses.
Thanks you so much Joop, but I don't understand why 4 timer_channel_1 2 3 4 are the same? If it's the same, why don't you let them are unique variable? Secondly, the receiver_input_channel_3 are always positive (1000-2000) right? so how can timer_channel_1
This sketch is just for testing. The motors 'follow' the throttle stick and the pulses are all the same. esc_loop_timer = micros(); And the microsecond timer of the Arduino is incrementing every 4us or so. That is why timer_channel_1 can become smaller than esc_loop_timer.
Thanks a lot Joop. I am a newbie of Arduino as well as microcontroller. And maybe because of my pure English that I spent a lot of time to understand just these 8 code-lines you wrote. My problem begins from zero_timer=micros() , so I think timer_channel 1 (and 2 3 4) are aslo incrementing, am I right?
Example: let's create a 1 hour pulse. 1) The current time is 13:34. This time is stored in the variable zero_timer. ==> zero_timer = micros(); 2) Set the output 4, 5, 6 and 7 high to start the pulse ==> PORTD |= B11110000; 3) Calculate when the output needs to be set to low: 13:34 + 1 hour = 14:34 ==> timer_channel_1 = receiver_input_channel_3 + zero_timer; 4) When the current time is larger than the off-time, set the output to low ==> if(timer_channel_1
HI! It's been a while since I first saw your project and now I am planning serious stuff. First of all, I thought that Gyro readings took almost '1750us', which was calculated in my Arduino uno using a micros(); timer. Well, I wanted to figure out the main problem. So I checked every parts of the I2C request loop. Turns out, Wire.endTransmission(); and Wire.requestFrom(); takes 1683us and the left over was for gyro reading and begin() sign. So.... why do you think this happened??? Is there any problem with using micros(); timer that causes more then 1450us of inaccuracy compared to Oscilloscope??? Looking forward for your experienced answer! Have a great day :)
I am using arduino board atmega 8 so there is problem in compiling sketch, because of difference in micro controller chip can u plz suggest what to do?
ESC caught fire right after calibration process.i gave the motors max throttle and their RPM increased perfectly, but then the rear right ESC caught fire and smoke !! any idea what happned?
First of all i want to thank you for volunteering to give us something that is more important than a ready made code. Because of your tutorial i have been encouraged to buy a 10dof imu with gyro you recommended (i want to add other features in future) and start tinkering with your code . I think that you have an error in the lines 43, 44, 45, 46 . You state the same variable "receiver_input_channel_3" in each line. shouldn't it be : "receiver_input_channel_1", "receiver_input_channel_2" ,"receiver_input_channel_3" and "receiver_input_channel_4" respectively ??? Again thank you for your time and efforts ! :)
First of all it is very helpful to lern programming a microcontroller. what I didn't find out is the "Programm loop @250Hz. I looked Timers 0,1 and 2 in the datasheet of ATMEGA 328P, but still remains unkown for me. Could anyone explain me ?
Hi, i'm having a issue in this part of the video. I have a brushless motor that star's running before all the other 3, and stop's later too. What can be done here in my situation? I'm guessing that it's probably a mismatch of esc controllers.
never expected this to be a batter micro controller lecture than what I had at university.
One of the most clear video about in depth programming atmega328 on arduino one.
My compliments !
People would pay to see these videos. Great demos, and explanation to how normal arduino commands slow things down. You should be a teacher. Direct access to ports FTW. GOOD JOB
one of the best tutorial, description i ve ever watched. It applies to all the videos . I admire yor effort and knowledge. EXCELLENT is the least i can say for all the videos so far
Great way to illustrate the timings with the scope, and interesting method for generating PWM signal :)
Very interesting to see how you estimate the running time of the different code parts. I also like the way you optimize your code, I'll definitely implement that !
very useful and helpful.. thank you for using the o-scope and explaining the methods that you used to validate/verify timing! seeing it first hand helped me very much
The best visual explanation I ever saw! Thank you very much Joop Brokking.
This is brilliant. Would love to have my quad copter under my control, and not flying by the magic of someone else's firmware. Just wish I fully understood what you just did there. I need to learn by doing. Thanks for the pin out diagram. Looking forward to the next instalment! :-)
I was thinking to use a function that handles the part of recieving, and returns the values of the 4 channels to the main loop, the transmitter is an arduino too, and sends a string containing the datas relative to the channels (two nunchuks, one for channel1&2 and another for channel 3&4).
Thx man, your series are extremely professional and very helpful
This was really awesome!
Thanks for sharing such a great methodology, very insightful.
could you please explain why would the change in the loop time (4000us) affect the calculation of the IMU?
and, is the refresh rate of the ESC same as the wave length of the signal? to make it clear, does it require the pulse(1-2ms) every 4ms or every 20ms ?
videos are well structured and vividly clear, you efforts are brilliant.
Joop hi, again me...
Im trying this on a nano so Im being very thorough on timing. I measured the calculation time on the signalen () function turning 13 High before and Low at the very end. This gives me 300 us and not 600 us as for you... what did you mean by calculation time? Was this calculated on the same function?
Where (time) was this in my video?
+Joop Brokking 1:45
The time that I measured was the complete loop without the I2C calculations. Also, you need to start the quad to have the maximum calculation time.
At the end the exact time does not matter because you must prevent the total loop time to exceed the 4000us.
This is pure cybernetics, I'm jealous right now...
Cannot wait for part 5. Please hurry! :-)
Torsten Persson I just uploaded part 5 :-)
Joop Brokking
That was quick! And I thought that I couldn't be more impressed! :-) Thanks a lot!
I've never felt more stupid after watching this video.
Never feel stupid. I also started at the bottom and worked my way up. And so can you!
same same xD
Fantastic! Absolute stellar video.
Just use HW PWM... This is very time consuming and tedious. I applaud you for you patience
Hi !
Why haven't you used the Servo library with the writeMicroseconds() function ?
Moreover is it possible to create a second subroutine for generating outputs ?
Thank you, have a great day!
This is helping me a lot, being a computer science student(undergrad) there is a lot of low level mechanical interface that we are never taught, Thank you for the tutorial and I would also like to ask how many parts are there in total to your video series?
aridaman yadav Thanks for the compliments. I hope to finish all the details with 6 video's. In the last video I'll post the final Arduino sketch that you can download.
So good. Thank you Joop Brokking.
Im using FS-T6 transmitter all the code is uploaded but transmitter is not working.....
can you show pictures of how ESC's are connected to the arduino.
hi is it possible to make a voice controlled quadcopter please answer quickly. Please
Hey Joop, great video!
I have a question, at one part of your code, the final ESC timing calculation is set as follows:
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 am a bit confused as to how you got this configuration; why are some terms joined by a minus and some by a plus? Is this derived from a physical equation?
Thank you!
If the quadcopter needs to tip in the front direction the front motors need to decrease and the rear motors need to increase speed. Same with left and right and yawing.
Ah I see, thank you so much! +1 sub :)
Does the final code on @11:00 actually works ? can i get this version of code ? im not seeing on the website anymore
can u plz eexplain some basic command like digital read, write, analog read, write basics of IIC & SPI communication, conditioning (any faster way than arduino built in ) , loops etc. Plz it would be a loot help for me.
Can you provide list of parts which is available also in india?
Sir why didnt u used servo library n use write.Microseconds for escs
can u pls instruct me how to controll aesc with rc tx interfacing with arduino .....reading the signal and then delivering them to the esc.
Great Job, we have learned a lot from these videos, i only have a small question. the ESC power cables are connected to the battery, arent they? Its not clear in the schematic. Thank you
Yes they are. You can read more here: www.brokking.net/ymfc-al_main.html
sir, al setup program is working properly but esc calibration program is not giving any response. nothing happens when we give r,a. or any other command. your solution from q and a is not helping pls help.
I use simonk esc
But I have same problem
Two motor work correctly. one motor not start and vibrate.
One motor are start after the more than half throttle
Please reply fast
I've done all the ESC calibrations according to the instructions for them, but when I have gone to do the calibrations they are starting at different throttle positions, any idea what could be causing this?
Thank you for the work you have put into these videos, they are awesome!
I am trying to learn and understand your code, I struggle to understand how you arrived at 16 for the " while(PORTD >= 16)" statement.
May I ask how did you derive this value? How does it work?
why didn't you use delayMicroseconds with timer0 disabled instead of micro? it was perfect without jitter.
How can we adapt for tricopter?
how can i tell the fastest batteru to get depending on esc?
hi joop you did a good job making this open source flight controller, i was making my own receiver transmitter, i am having a little trouble understanding the receiver code part, we are getting a pulse between thousand to two thousand microsecond at receivers output, how are we reading this pulse in the code to get a value between thousand to two thousand .
Maybe this video will help: th-cam.com/video/bENjl1KQbvo/w-d-xo.html
Do i need to study electronic engineering for this because there so many thing I do not understand.
I tried this code but nothing appears on the serial monitor
why you dont put codes of the videos in website?
Is this oneshot125?
How can you know what's the loop frequency? Doesn't it change if there is a new sensor reading or not? Loop on my software is from 15us to 1000us..
I used a wait loop in the code. So the next loop will always start 4000us after the previous start.
Joop Brokking thanks for answer! Do you think that loop time should be kept constant? If it's not constant then this should be considered in PID controller, but what's better?
Hey , Joop I really did learn a lot from you.I want to Know How to do stuff like analyzing a problem and finding a counter measure for it.PLEASE HELP ME I want to have that skill like you.Thank you Once Again.
I have gone through the setup program and I am now a little confused as to what I have to do with the ESC calibration program. I proceeded to upload the Flight controller program just to test it but there is an issue where 2 motors turn on immediately and stay on after I activate the program with the throttle joystick in the bottom left hand corner. I am assuming that this is just a result of me not calibrating the ESCs correctly but I am really not sure.
Upon further testing of drone, I have determined that it may be a gyro or prop balancing issue. After I activate the quad copter with throttle down, yaw left, the back left motor begins spinning very fast. I tilted the quad copter around to see if the auto leveling would work and it does, but when the drone is stationary in the same flat position in which I calibrated the gyro and ESC's that back right motor spins. I think the it may be a prop balancing issue, so one question I have is can I connect the flight battery to the drone while it is plugged into the laptop USB? Your explanation on your website implies that, the answer to this question is yes, but I would like to verify so I do not cause damage. Any additional advice on how to troubleshoot this issue would be greatly appreciated.
After uploading the ESC sketch, plug out the USB wire from your pc. Transmitter on, throttle low, then set in the highest position. Attach the Battery to the quadcopter. Wait for the beeps ate gone and led it out. Throttle now to lowest position. The ESC's are calibrated now (always props off for your own safety). De- attach the lipo and connect the USB wire again for uploading the flight sketch.
first of all thank you sir for the video series.
my question is why didn't you use Servo library and motor.writeMicroseconds (pwm).
please sir .
It's bloated and not accurate enough.
thanks a lot sir .
1. but why did you use a diode in circuit what is the use of it there ?
2. and i dont have 1.5k register can i use 10k instead of 1.5 k ?
thank you sir ;)
The diode is used to protect the USB port of your computer. Used the exact same components as on the schematic.
My throttle stick is giving common inputs to all 4 channels. I am using Fy Sky FS-CT6B transceiver. Please help.
Hey Joop,
I am using my own gyro (GY-291/ADXL345), and have been able to get data using a separate program so far. Your videos have been very helpful so far, but I am heading in a separate direction now. Is there a way to enable/disable the gyro program using an input from the receiver? I'm guessing that there's probably a code that would disable/enable it in one line. Is there such a code? I'm guessing that i could also use the interrupt code that will interrupt the program whenever you move the sticks. Can a similar code be used from the sticks?
I apologize, i'm not too familiar with the Arduino.
- Tarik.
my brushless motor just on 3, 1 motor cannot on.. help
i have a question! you said that receiver 's refresh rate is lower than the program loop's , so we have to use interrupt. But I cant understand why this can be the solution. could you help me to understand this?
there is a error saying "No valid receiver signals found!!! (ERROR 1)" how can i clear it pls anyone help
Pls sir, I tried following your setup code, but can't still understand "channel_1_assign, channel_2_assign... Channel_4_assign". It's really giving me problem. Pls help me out. Especially this code- ((channel_1_assign&0b00000111)+7). I don't understand what it means.
I would like to thank you very much, this series is both interesting and useful. However, you said in part (4) that the refresh rate of the ESC is 250 Hz. My question is: How can I determine the refresh rate of any ESC?
The program loop that is running in the Arduino uses 4us. This makes the refresh rate 250Hz. Most ESC's can handle a 50 till 400Hz refresh rate without problem. But if you want to make sure you need to check the manual of the ESC.
However, a 50Hz refresh rate is not suited for multicopters. You really need a fast response to get it stable.
Ouh ... Now I got it! Thanks a lot for your detailed clarification and quick reply
Hello! I'm sorry to say but i've been stuck debugging this program for quite a while. Plenty of things don't make a lick of sense - such as the variables of receiver_input_channel_1, receiver_input_channel_2, receiver_input_channel_3, receiver_input_channel_4; never being assigned any value. Replacing all of them with receiver_input[n] does work. Sadly, while the ESC signals are calculated properly, the ESC signals being sent do not work with the ESCs (even if the previous, "manual" ESC set ups during the program to keep them quiet do send a valid signal).
The receiver_input_channel_1 till 4 are set in the receiver interrupt subroutine. It's the length of the incoming pulse from the receiver. Please use the YMFC-AL: www.brokking.net/ymfc-al_main.html as it is better documented.
where is connection diagram of arduino + esc + rc receiver ?
i have not get it :(
There is a link in the description of part 1 (hardware). And don't forget to visit my page for more information: www.brokking.net
Hi
I am trying to modify your flight controller code to do some other stuff, but i am having a problem figuring out how you are creating pulses for ESCs..if you can just give a summery of how the flight controller works it would be really helpful.
Thank you.
hey Joop, thank you a lot for these videos that are really helpful and we are looking for more :) ... i have a question ... i need to build the same quad copter, but i need also to implement several Range Sensors in it so it can avoid obstacles... but all the Arduino Uno port are occupied. ( only A1 ; A2 ; A3 ; D0 ; D1; D2 ; D3 ; D13 are not used on your schematic)) .. how then could i add like +10 Range sensors to this Arduino Uno? should i add another arduino uno board and make a connection with the first one ? if the solution needs another board to use, please give a schematic for this connection. thank you
Why don't just use writeMicrosecond? Is delay microsecond has any benefit?
Sir, ofcourse, its calliberating ESCs but nothing visible on serial monitor in starting but when I type 'R' serial monitor start showing readings as well as with 'a' also. During calliberation nothing on serial monitor. But ESCs got callieberated ?
Please help when I download YMFC-AL_Flight_controller to the Arduino engine does not work when I download YMFC-AL_esc_calibrate
send me the link from where I can buy these ESEs .
witch part of the code comes the calibration?
+Noam Koren You need to perform the calibration yourself. Check the manual of your specific esc on how to do that.
heey
please the download sketch for the stm32
hey plz tell me the flight control configuration code
hello +Joop Brokking
can you explain what does esc_loop_timer and esc_timer does?
Brother, I built an android app and i am trying to use the HC-05 bluetooth module to control the ESC using your code:
Here is what my android app briefly does:
- when you press the left button on my app --Then --> '1' is send, and when released '0' is sent.
- when you press the right button on my app --Then --> '2' is send, and when released '0' is sent.
- when you press the up button on my app --Then --> '3' is send, and when released '0' is sent.
- when you press the down button on my app --Then --> '4' is send, and when released '0' is sent.
I know how to make an led blink using my app via bluetooth. However, i am trying to apply my bluetooth app on your code for the esc. I would really appreciate it if you can give me a hint on how to do this. Thank you.
I have read your code and been trying to do this thing the whole past summer, but no luck yet :)
hi all !!!
when i turn on the transmitter , the led don't off
why???
please help me !!!!!
thanks a lot !!!!!!!!!!!!!!!!!
Hi sir i ask u why multiple (angle_pitch Or angle_roll) by 15 to find level_adjust. why this number (15)?
please help
the refresh rate you set in your program is 4000usec, but it don't work for my ESC. the minimum refresh rate in my case is 10,000usec.
As you know it should be 20,000usec (by priniciple), but due to our refresh rate resctriction we move towards 4000usec (10,000usec in my case).
i have installed TGY hex firmware on my ESC and after installing that ESC's acceptable minimum refresh rate are 10.000usec.
i want to decrease that refresh rate to 4000usec kindly give me any solution.
hi joop how to read the gyro angular rate data?
That can be seen in the datasheet?
Watch YMFC-3D part 3 - gyro.
th-cam.com/video/nCPEJTUYch8/w-d-xo.html
my transmitter and receiver are not connecting what should i do please please reply i also saw your seconds part also what can i do
connect the binding cable in the reciever 1st channel & hold the binding button pressing it and turn on the transmitter (the binding button is present on the transmitter)
Hello,
why have to abandon the version with the STM32F103C8T6?
I find the setup version for the YMFC_all really good.
she would have good for the STM32 too!
Thanks a lot. I am trying to make a RC plane with this technique. I wonder if I can use the UBEC in an ESC to power the arduino. Do you know?
Good night Joop Brokking, if possible you could add subtitles to the video so you can translate I'm very interested in understanding this video .. thanks !!
sir one ESC - motor rotating when its connected alone but not rotatin when connected with other motor why
Did you mean that you want to connect two motors o one ESC or did you mean that you used another motor?
Joop Brokking iam trying to build quadcopter so when i put all together one not working but its rotating if connected alone , today i connected red wire from esc to VIN of arduino its working
Make sure that you calibrate the ESC's with the calibration sketch as described in the manual of the ESC's.
Joop Brokking s i did sir its working when battery connected seperately but not working with others, its contineously beeping and motor vibrating
Your code is fantastic 🙂☺️☺️☺️😍😍. I did on uno. It 's work instantly. But I did on mega2560. It not woking. ESC are not calibrated. I don't know why. I did change DDRD to mega 2560 port but still not working. Finally thank for your Knowledge I learn a lot from you appreciate that.
Invalid library found in C:\Program Files (x86)\Arduino\libraries\PPM-reader-master: no headers files (.h) found in C:\Program Files (x86)\Arduino\libraries\PPM-reader-master
my motor has high initial RPM which code is used to control rpm of motor ..plz help
You mean after starting the quadcopter?
+Joop Brokking yes ...and i used ymfc v2 methods 2 process is completed ....but after uploading final code auto level is not working(no change in motor speed) when i bend or tilt...my quadcopter..i am using mpu-6050 gyro
The YMFC-3D does not have an auto level feature. This is something you can program yourself ;-)
Can i use smartphone battery of 2200 mAh of 3.7V i dont need to fly it for long time
No, a smart phone battery can't produce the needed +12A when flying.
Thank you Joop Brokking ... but is there any cheap options for li-po battery ??
Hobbyking is a good alternative.
the programming code is not in the Link help please
+miguel san Check the description, it's there.
The led stops blinking but the motors just keep on beeping !!!PLEASE HELP!!!
My motor are not arming I think helpme
saattvik thourwal Try to calibrate your esc's, they don't recognize the 1000us pulse as 0. This will probably fix your problem.
Joop Brokking Even I am getting the same problem , Led stops blinking but motors do not spin. How to calibrate esc's. Please help
simraan shaikh You need to check the manual of the esc on how to calibrate them. There are so many brands and types of esc's with all there own calibration method.
Joop Brokking Thank you for your response :) I have calibrated my Esc's. Thankyou for making such a wonderful series of YMFC
Hello Joop Brokking, thank you for this great video. It is so instructive!
However, for some reasons any motor that is connected to D5 does not turn on at the same time as the other motors.
Would you know how to fix that issue?
What code are you using? And did you calibrate the ESC's with the same pulse?
Joop Brokking thank you for relying.
I'm using the code from your website. However I used MPU 6050, so I had to use a different code for my gyroscope.
Would that make any difference?
If you add your own code it will make a lot of difference. Please use the YMFC-AL code that supports the MPU-6050.
www.brokking.net/ymfc-al_main.html
Joop Brokking Alright, thank you very much!
sir i have some problem . in ESC have 3 pins which is connected in arduino 5 V , GND and Signal Pin. and i try to cennect just Signal Pin and GND then the result the ESC not give respon.
and sir i have problem again 2 motor of my project when throtle reach 30 % motor will turn on and the other 2 motor when throtle reach 5% they turn on.
Make sure to calibrate the ESC's as shown in this video: th-cam.com/video/DYpHB-LfloI/w-d-xo.html
anyone help plz
I need to make the loop at 125hz so if i change these two line do it work probably
if(micros() - loop_timer > 8050)digitalWrite(13, HIGH); //Turn on the LED if the loop time exceeds 4050us.
//All the information for controlling the motor's is available.
//The refresh rate is 125Hz. That means the esc's need there pulse every 8ms.
while(micros() - loop_timer < 8000);{ //We wait until 8000us are passed.
loop_timer = micros(); //Set the timer for the next loop.
}
Is there any problem using the Servo.h library?
The servo library is to slow. You need a refresh rate of 250Hz.
I Think you can change the refresh rate of it editing the library, so it would be possible to use it.
At least in theory.
Brokking, first of all thanks a lot for the nice videos. I did find out why the refresh rate must be 250 Hz = 4000 micro seconds. How is it determined and to what extend can we change it if we want to impliment an additional sensor like an ultrasonic sensor for altitude hold ? It would be very helpful to give a hints on where in the code to edit the refresh rate. Thank you again
And put a delay(1000) after digitalWrite(12, HIGH);...
What are the connections in gyroscope to know that the frequencies are 300us and 600us? I read the datasheet of the gyro and I can not understand
The times (300us and 600us) are shown on the oscilloscope. The data transfer time can be calculated but reading the oscilloscope is much easier.
+Joop Brokking thanks very much : >
+Joop Brokking you put a pin in gnd and the other pin in clock (scl) of L3dg4200? and other signal SDA?
Check the schematic that you can download here: www.brokking.net/ymfc-3d_downloads.html
You can see all the connections of the gyro.
When I run the program of Esc's output all the motors start spinning when led stops blinking.
But when I uploaded the final code when Led stops blinking motor does not run. Help me Joop Brokking
simraan shaikh Make sure your transmitter is setup correct with the program of part 2. Starting the motors with the final program requires a special stick sequence. If your transmitter is not setup correct the motors will not start.
dear joop,
I am making my science project as i used ur same techinquies for it.. i have done everthing same.. but the issue is that my LED Stays on all the time.. cant understand where the error is and second when i increase the trottle the rpm of the motor increases a bit and then reducing automatically or sometimes it stops so basically its not flying .. i think it can be the voltage drop but still cant get it .. pls help.. thanks ..
Check question 9 on this page about the LED.
When you test the quadcopter you need to hold it in your hand as I showed in this video:th-cam.com/video/DYpHB-LfloI/w-d-xo.html
Then you can feel if the motors work correct.
dear Joop brother,
I found the issue regarding the LED stays on when i just increase the throttle a little bit on this statement :
//Turn on the led if battery voltage is to low.
if(battery_voltage < 1000 && battery_voltage > 600)digitalWrite(12, HIGH);
but when i check the voltage of my battery its not less than 11 but yes my battery drainage fast; btw i'm using li-ion batteries LC 18650 3.7v (3800mah) cell through which I made 3 cell 11.1v 3s battery .. does the battery type effects ? or It only supports the lipo battery ? can u help me or there is any other change in code i can made .. waiting for your great reply ..
Why are you using the wire library in your code? Why can't you just use Servo? It's so much better. myservo.write(180) is full throttle, myservo.write(90) is half throttle and 0 is no throttle... It's pretty straight forward as apposed to calculating pulses.
Thanks you so much Joop, but I don't understand why 4 timer_channel_1 2 3 4 are the same? If it's the same, why don't you let them are unique variable? Secondly, the receiver_input_channel_3 are always positive (1000-2000) right? so how can timer_channel_1
This sketch is just for testing. The motors 'follow' the throttle stick and the pulses are all the same.
esc_loop_timer = micros(); And the microsecond timer of the Arduino is incrementing every 4us or so. That is why timer_channel_1 can become smaller than esc_loop_timer.
Thanks a lot Joop. I am a newbie of Arduino as well as microcontroller. And maybe because of my pure English that I spent a lot of time to understand just these 8 code-lines you wrote. My problem begins from zero_timer=micros() , so I think timer_channel 1 (and 2 3 4) are aslo incrementing, am I right?
Example: let's create a 1 hour pulse.
1) The current time is 13:34. This time is stored in the variable zero_timer. ==> zero_timer = micros();
2) Set the output 4, 5, 6 and 7 high to start the pulse ==> PORTD |= B11110000;
3) Calculate when the output needs to be set to low: 13:34 + 1 hour = 14:34 ==> timer_channel_1 = receiver_input_channel_3 + zero_timer;
4) When the current time is larger than the off-time, set the output to low ==> if(timer_channel_1
+Joop Brokking Thank you Joop, now I understand what you mean. There are a lot of new things I have studied from your project. Thanks again :)
I have seen you before, I read about some of your thesis in CS, can´t remember. Hopefully I get to know your goals by achievement.
HI! It's been a while since I first saw your project and now I am planning serious stuff. First of all, I thought that Gyro readings took almost '1750us', which was calculated in my Arduino uno using a micros(); timer. Well, I wanted to figure out the main problem. So I checked every parts of the I2C request loop. Turns out, Wire.endTransmission(); and Wire.requestFrom(); takes 1683us and the left over was for gyro reading and begin() sign. So.... why do you think this happened??? Is there any problem with using micros(); timer that causes more then 1450us of inaccuracy compared to Oscilloscope??? Looking forward for your experienced answer! Have a great day :)
Is your TWI/I2C speed set to 400kHz?
I found an easier way on code instead of getting into twi.h file, after Wire.begin(), write Wire.setClock(400000L) and that should do it.
J. Enrique Cerda Zertuche Thanks!
I had the same problem. Thank for the tip.
I am using arduino board atmega 8 so there is problem in compiling sketch, because of difference in micro controller chip can u plz suggest what to do?
Buy a Arduino Uno (cloon). There pretty cheap.
ESC caught fire right after calibration process.i gave the motors max throttle and their RPM increased perfectly, but then the rear right ESC caught fire and smoke !! any idea what happned?
What battery, motor and props are you using?
I had no props on the motors while calibrating. Im using a 3S 35C 2200mAh lipo battery, and a A2212 13T 1000kv brushless motor.
First of all i want to thank you for volunteering to give us something that is more important than a ready made code. Because of your tutorial i have been encouraged to buy a 10dof imu with gyro you recommended (i want to add other features in future) and start tinkering with your code . I think that you have an error in the lines 43, 44, 45, 46 . You state the same variable "receiver_input_channel_3" in each line. shouldn't it be : "receiver_input_channel_1", "receiver_input_channel_2" ,"receiver_input_channel_3" and "receiver_input_channel_4" respectively ???
Again thank you for your time and efforts ! :)
Ahhh.. !!! you want to control the esc's from the same channel i was so clumsy to comment something like that !!!
Thanks for the compliments. Indeed, the sketch can be used for programming the esc's.
First of all it is very helpful to lern programming a microcontroller. what I didn't find out is the "Programm loop @250Hz. I looked Timers 0,1 and 2 in the datasheet of ATMEGA 328P, but still remains unkown for me. Could anyone explain me ?
The main loop that I used for the YMFC quadcopter runs on 250Hz. Meaning that every loop takes 4 microseconds.
www.brokking.net/ymfc-al_main.html
The Esc doesn't work at
"While(receiver_input_channel_31020 || receiver_input_channel4
www.brokking.net/ymfc-3d_qanda.html
Check question 5.
Hi, i'm having a issue in this part of the video. I have a brushless motor that star's running before all the other 3, and stop's later too. What can be done here in my situation? I'm guessing that it's probably a mismatch of esc controllers.
Make sure that all the ESC's are calibrated. Watch this video for more information: th-cam.com/video/DYpHB-LfloI/w-d-xo.html
i have the same Pblm. Do you have the solution?