PLEASE USE THE YMFC-AL (AUTO-LEVEL) SOFTWARE: https://youtu.be/DYpHB-LfloI
These videos are just for reference. The new software is much easier to setup and supports almost all transmitters.
You can download the Arduino sketch here:
http://www.brokking.net/ymfc-al_main.html
ATmega328 pinout diagram:
http://www.brokking.net/YMFC-3D/YMFC-3D_ATmega328_pinout_diagram.png
Great series of videos. How can I balance the props and motors Can you
please help!
– via YTPak(.com)
Hey +Joop Brokking I have a question 🙂
Can you tell me if this programm works with SimonK ESCs? My Motors don’t
spin. I also tried to set the time in the while loop (the waiting for the
250hz to 2040 microseconds (490hz), but nothing works…
hi joop, I need another hint.
As I’m using an arduino due, and an xbee as a reciever, should i worry
about data receiving interrupts? I have also struggles, from findin how
program directly the ports on arduino due.
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).
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
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?
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 <= esc_loop_timer?
Can i use smartphone battery of 2200 mAh of 3.7V i dont need to fly it for
long time
where is connection diagram of arduino + esc + rc receiver ?
i have not get it :(
One of the most clear video about in depth programming atmega328 on arduino
one.
My compliments !
Would it not be possible to use the hardware PWM registers on the arduino
to create the pulses? Can’t we simply set the PWM frequencies to 250Hz and
adjust the duty cycles registers? If this is possible, what is your
reasoning for not using the hardware PWM?
hi,I’m doing this own project of mine,I have a doubt. can I control
individual motor using the arduino and ESC?
hi joop how to read the gyro angular rate data?
That can be seen in the datasheet?
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
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.
my motor has high initial RPM which code is used to control rpm of motor
..plz help
can you show pictures of how ESC’s are connected to the arduino.
I tried this code but nothing appears on the serial monitor
hello joop i am building my quadcopter with a different method that auto
balances it. i am not sure if i can use the servo library to control the
ESCs
egs.
m1.writeMicroseconds(1000);
can you please help me.
hi joop… I m trying to control the quadcopter using android(wifi module
esp8266-01) … can you please help me with esc calibration?
The Esc doesn’t work at
“While(receiver_input_channel_31020 ||
receiver_input_channel4<1400)"
Than what should I do??
Reply fast
how can i tell the fastest batteru to get depending on esc?
Hello again.Some of us,don’t have an oscilloscope at home.How is it
possible to figure all this out,especially with the timings?Is there a
methodology i can follow about the calibration? Or again, i can figure out
these things by reading datasheets ?Can you provide me with a guide online
,if you have something in mind?
Is a gyro sufficient along with a arduino for building the flight control
or do we need an accelerometer also to connect to the arduino or some other
card? Please reply
i just bought four new ESCs…when i tested for the first time, the minimum
esc.writeMicroseconds(1200) worked as the minimum PWM for rotation…but
subsequently the minimum PWM value is going on increasing…the next time i
tested, 1200 pulse didnt work..1300 us pulse became the minimum PWM for
rotation…any idea whats the problm ? please help
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 .
Can you explain the PORTD >= 16? When the ESC ports are all low, PORTD will
be less than 16. Does this mean 16 base 10? 00001111 in binary is 15 in
base 10 so as long as PORTD is 16 or higher it means one of the escs are
high. Is this correct?
13:41 COOL!
Do we need a BEC if we are using OPTO ESC’s?
never expected this to be a batter micro controller lecture than what I had
at university.
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?
Hello,
Please, can you tell me why when i send 1000 microseconds to the esc, they
keeps beeping?
Why don’t just use writeMicrosecond? Is delay microsecond has any benefit?
What is the difference between an esc and a motor controller board (like
the adafruit motor controller)? They seem like they do the same thing…but
in different ways?
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 :)
Thanks Brokking for this amazing series, very educational, i learned a lot
thanks for all the good explanation details and good code comments!
I was trying to use this software pwm generation method to control some
servos, and the gitter that you showed in the oscilloscope was quite
evident in the servos. (I also had to change the refresh rate to even get
them working to 20000 instead of 4000) I was wondering if there was a
better way of generating stable pwm signals rather than manually through
the code. How hard do you think it would be to make a dedicated pwm
hardware generator? I am trying to relate this to existing FCs like the
Naze32, i wouldn’t think that code is set up to generate the signals like
that. I know aidafruit has a 16 channel pwm generator shield i suppose that
is pretty much what i am referencing when i ask this question as well (
)
Hello Joop once again. Finally i built my quadcopter.But…, when i do the
starting sequence the motors are spinning way too fast for a start. I am
using the YMFC-3D code ( i want to use this code and not the v2) and i
think that the esc’s need calibration.Can you suggest a way of calibrating
them but not using the code of YMFC-3D v2 ?? I thought of connecting the
esc’s one by one on the throttle pin of the receiver and follow the
manual’s calibrating procedure.Is that correct? What do you say?
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?
one comment 🙂
@ 4:53 I see
PORTB |= B00110000;
PORTB &= B11001111;
if you type a ! for a byte it inverts it so than you get
PORTB &= !B00110000;
this is the same as
PORTB &= B11001111;
like this you can work with the exact same byte value and that will reduce
typos and bugs and headaches etc.
PORTB |= B00110000;
PORTB &= B11001111;
=
PORTB |= B00110000;
PORTB &= !B00110000;
I know it is it bit grammar nazi like ;-)
hey plz tell me the flight control configuration code
is there no way to just flash with other setting.
Something that can programme it to work with quadcopter? or you think best
to just get a naze32?
I can get uni cheap but this looks long. watched a guy do the naze32 threw
a chrome app and flashed and calibrated it.
Is there no way to do that with this? or is there any cheap nano size that
can do it?
want a cheap solution for flight control for myself thats all. but plug n
play be nice.
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
Hi
I am using a flysky ct6b transmitter
in your receiver program its displaying 1180 and 1308 for channel 3 and 4
respectively.
but when i am using your esc- program the motors won’t move at all though
they wont beep
can you pls help
the setup program in either of the 2 programs the AL version or the other … they both keep hanging sporadically on the “move joystick….”
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.
Its badly explained but I found that the Arduino Uno is happy with the 3D V2 version of the software…. Just remember to move the joystick slooowly to center until the program catches that …Otherwise the program will look like it froze! It took me days to discover that until I read his code!
BTW I contributed $5.00 to Arduino just because, I believe electronics is the only or one of the only things remaining to save this planet!
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
hello again.. +Joop Brokking
when you said
[1] PORTD |= B11110000; //Set digital poort 4, 5, 6 and 7 high.
delayMicroseconds(1000); //Wait 1000us (We can use delayMicroseconds because the receiver interrupt routine is not used).
[2] PORTD &= B00001111; //Set digital poort 4, 5, 6 and 7 low.
———————————————————————————-
for [1] you activate B11110000 which mean digital pin 4,5,6 and 7 using PORTD which a got it from the manual ATmega328 and the Pinout digram.
for [2] you activate B00001111 which mean digital pin 0,1,2 and 3 by using PORTD which i did not got it !!!!!
Set digital poort 4, 5, 6 and 7 high. !!!
Set digital poort 4, 5, 6 and 7 low. !!! the manual show me that you activate 0,1,2,3!!!
sorry but i did not understand it!!!
It’s the |= and &= that make the difference. It’s bitwise and and or. You can read about it here:
got it thanks 🙂
hello +Joop Brokking
can you explain what does esc_loop_timer and esc_timer does?
Can I a Question for that Refresh rate always 250 Hz on arduino uno ? If not, Should I adjust?
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 someone help me? Do i need an “electronic speed controler”. or can I build a drone/quadcopter without it?
No, you cannot, BLDC motors need the specific output signal that these controllers generate to rotate the propellers
is there any difference between BLDC motors and DC motors?
oh boy there is, DC motors use brushes to connect the rotor coil of the machine to the stator coil and voltage source BLDC motor consist of 3 coils in the stator that are connected in a star shape. The rotor consist of a permanent magnet, so there are no needs for brushes, therefor the name BrushLess DC motors. To run these motors you need 3pwm modulated voltages that can only be generated via an ESC.
If you have any questions feel free to ask 🙂
my brushless motor just on 3, 1 motor cannot on.. help
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?
I love this community man I can’t wait to make my own board
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!
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
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!
Do i need to study electronic engineering for this because there so many thing I do not understand.
Please help when I download YMFC-AL_Flight_controller to the Arduino engine does not work when I download YMFC-AL_esc_calibrate
When I upload the ESC calibration program and send an ‘r’ over the serial, I get the message ‘Reading receiver signals’ but no values. I`ve tried using arduino IDE for mac and windows version 1.8.1 and 1.0.6. two times it worked but when repeating the process no values again. It seems to be something with the loop_counter iteration, if i change the if(data == ‘r’) statement to a while(data == ‘r’) it prints the values, but then I can not return to user input again. I`ve looked in the Q and A on your site, but no luck. Any Idea what this could be?
First, many thanks for replaying it is much appreciated. yes the values were in this interval and the ESC`s beep . When i upload the YMFC-AL_Flight_controller it works as it should, but since i can not view the values in the ESC calibration program I `m not able to balance the props, so i dont dare to try flying it as I`m not sure how it will react. I have been going through the code and changing the endpoints trying to force it to start but no luck there either, it seems like the loop_counter does not start to iterate. And i`m not able to figure out why. Have anybody reported problems with respect to library versions?
Could you add the following lined under void loop(){
Serial.print(data);
Serial.print(” : “);
Serial.println(loop_counter);
This will print the data and loop_counter value on the serial monitor. Send an ‘a’ and please tell me what the data and loop_counter are showing.
Ok, serial monitor is showing a running 0:0 until i send an ‘a’ then ‘calibrating gyro’ 97:0, 13:0 and into running 10:0, so loop_counter = 0 all the time
I found that some Arduino IDE’s send a ‘new line’ after the a. This results in a frozen screen. In the esc calibration code you need to find the line:
data = Serial.read(); //Read the incomming byte.
And change it to:
data = Serial.read(); //Read the incomming byte.
delay(100);
while(Serial.available() > 0)loop_counter = Serial.read();
This should solve your problem. Please let me know if it worked.
That did the trick, now it works perfectly. Thank you so much for all your help, cant wait to try flying it.
What about pausing interrupts with cei() command then send a pulse, and resume interrupts with sei(), so that there is no jitter. would this work you think?
You will miss valuable timer steps. The timer micros() will not be accurate anymore.
hi joop, would you tell me the script part who described esc_1, esc_2, esc_3 or esc_4 is will be output digital pin 4,5,6,7? i’m not expert in arduino code, so i still learning this script 😀
thanks a lot 😀
It’s this part:
PORTD |= B11110000; //Set digital outputs 4,5,6 and 7 high.
timer_channel_1 = esc_1 + loop_timer; //Calculate the time of the faling edge of the esc-1 pulse.
timer_channel_2 = esc_2 + loop_timer; //Calculate the time of the faling edge of the esc-2 pulse.
timer_channel_3 = esc_3 + loop_timer; //Calculate the time of the faling edge of the esc-3 pulse.
timer_channel_4 = esc_4 + loop_timer; //Calculate the time of the faling edge of the esc-4 pulse.
while(PORTD >= 16){ //Stay in this loop until output 4,5,6 and 7 are low.
esc_loop_timer = micros(); //Read the current time.
if(timer_channel_1 <= esc_loop_timer)PORTD &= B11101111; //Set digital output 4 to low if the time is expired. if(timer_channel_2 <= esc_loop_timer)PORTD &= B11011111; //Set digital output 5 to low if the time is expired. if(timer_channel_3 <= esc_loop_timer)PORTD &= B10111111; //Set digital output 6 to low if the time is expired. if(timer_channel_4 <= esc_loop_timer)PORTD &= B01111111; //Set digital output 7 to low if the time is expired. }
I assembled all the hardware, I am using MPU-6050. Setup went correctly, but then I start drone, only one motor starts spinning(ESC 4). I have no idea why, when I increase throttle other two start spinning and it flips. With full throttle only all four start. Does anybody know why it could be?
Thanks for quick response! I uploaded ESC calibration sketch, but it does not react to serial input as stated in Q&A, Enter ‘1’ and you will see test motor 1. Can i download that sketch somewhere?
Oh, I found scetch in tutorial you just mentioned. I will try that.
I calibrated ESC with scetch, now they are all starting at the same time! Thank you very much! But as soon as I try to take off, it rolls over. What could be the problem here?
Test the quadcopter in you hand as I showed in the video to make sure everything is working correct. If it’s not, don’t try to fly it and work the problem first.
Joop Brokking also one more thing: is it okay what I have my frame sideways? motor directions are okay. i have same type frame as yours, but extended plate parts are on side. I guess this is not a problem?
what is the code for sending pulse to pin, like
{
esc.attach(9);
Serial.begin(9600);
esc.writeMicroseconds(1000);
}
which line of your program addressing the signal of esc to the pin,
pls help me
PORTD |= B11110000; //Set digital outputs 4,5,6 and 7 high.
timer_channel_1 = esc_1 + loop_timer; //Calculate the time of the faling edge of the esc-1 pulse.
timer_channel_2 = esc_2 + loop_timer; //Calculate the time of the faling edge of the esc-2 pulse.
timer_channel_3 = esc_3 + loop_timer; //Calculate the time of the faling edge of the esc-3 pulse.
timer_channel_4 = esc_4 + loop_timer; //Calculate the time of the faling edge of the esc-4 pulse.
//There is always 1000us of spare time. So let’s do something usefull that is very time consuming.
//Get the current gyro and receiver data and scale it to degrees per second for the pid calculations.
gyro_signalen();
while(PORTD >= 16){ //Stay in this loop until output 4,5,6 and 7 are low.
esc_loop_timer = micros(); //Read the current time.
if(timer_channel_1 <= esc_loop_timer)PORTD &= B11101111; //Set digital output 4 to low if the time is expired. if(timer_channel_2 <= esc_loop_timer)PORTD &= B11011111; //Set digital output 5 to low if the time is expired. if(timer_channel_3 <= esc_loop_timer)PORTD &= B10111111; //Set digital output 6 to low if the time is expired. if(timer_channel_4 <= esc_loop_timer)PORTD &= B01111111; //Set digital output 7 to low if the time is expired. }
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.
Thank you for this great tutorial, i want to ask something about micros function, when it overflows ( about 70 minutes for uno) there will be a timer miscalculation in loop most probably for only one cycle. Do you think any serious problem occurs from this ?
One cycle does not cause any problems as long as the program keeps running. But most quadcopters don’t fly for 70 minutes.
thanks for reply mr. Brokking, actually i want to modify this code for my diy underwater ROV project if it is okay for you ?, it will have same stabilisation and motor driving algorithm with some vector and axis adjustments. Thanks for the video tutorial again!
Is there any problem using the Servo.h library?
The servo library is to slow. You need a refresh rate of 250Hz.
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:
Then you can feel if the motors work correct.
Joop , i know this has been asked before but i am not satisfied with the answer.
You said that you are not using the arduino pwm capabilities because the 500 hz pwm from it is too much for some esc . What do you mean by that,the esc is made up of 6 transistors …also , couldn’t you have just used the arduino pwm and lower the frequency ?
The Arduino PWM is running at a fixed frequency of +/- 500Hz. You can change it but you need to modify the Arduino core code. To keep it as simple as possible and that it will work with most hardware I used this method.
hello joop, I am attempting to control my quadcopter setup (consist of arduino & mpu6050) through nrf24l01 transceivers…..I’ve got one arduino and PS2 breakout sensors setup as the controller, it transmits throttle, yaw, roll and pitch values to the second receiver nrf24l01 hooked up to my quadcopter setup. Could you please guide me on how to use these values once I receive them on my Quad to control the ESCs?
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 ..
Hi Joop, I have a problem with calibrating the ESC’s with your sketch, when I try the motors alone, they all do great, but when i want to try all together, only 2, 3 of them spins. I have a lipo 30C 2200mAh and I think that somehow the motors don’t get enough current. Any idea?
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.
If the motors don’t start at the same moment you need to calibrate the ESC’s first. This can be done with the ESC calibration sketch as shown in this video:
Ah I see, thank you so much! +1 sub 🙂
Hey Joop! First of all thank you very very much for these incredible videos!
I have a question regarding the pin manipulation method you used for your Arduino Uno. I bought an Arduino Mega 2560 and tried to run the code and who would have guessed it…it didn’t work. 😀 I feel that the issue has to do with the pin manipulation method you used. On the Arduino Mega the pins 4,5,6 and 7 use different port registers (In this case DIGITAL PIN 4 equals PORTG 5, DIGITAL PIN 5 -> PORTE 3 and DIGITAL PIN 6 and 7 equal PORTH 3 and 4). I was wondering if you could add some code for the support of Arduino mega 2560.
Thanks for your time !
Alex
The YMFC is not made for the MEGA. So I’m afraid you are on your own. Try it first with an Arduino Uno and work your way through the datasheets. This way you learn something and you will be able to adapt the code for the MEGA.
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.
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:
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?
hey hai!!! brooking firstly thanks for the videos . well brooking can you help me i have uploaded the esc calibration code and then checked by disconnecting the usb and connected it to battery they are spining but only when when i increase throttle from centre position only when i start increasing it from lower position its not spinning but after centre position its starts spinning with high speed can you help me how to fix this
What code are you using? And did you calibrate the ESC’s with the same pulse?
All the steps are explained in detail on this page:
If you follow the it should work fine. Make sure to build it exactly the same as the schematic. Otherwise it will not work.
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?
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.
If you add your own code it will make a lot of difference. Please use the YMFC-AL code that supports the MPU-6050.
Joop Brokking Alright, thank you very much!
hey brooking thanks for that i have successfully done the esc calibration i have connected the battery checked they they are spinning correctly but the problem is when i uploaded the flight controller program and then connected the battery then i started by throttle down and yaw left only 2 of them spin if i increase then 3 one ill start spin and four one is will starting some some moments I don’t know what to do can you help me please this the final step and got stuck please help me fast brooking thanks for the reply from start i have error with helpof you i came this far i am most to finish can you please help me what to do now
i have no knowledge and it’s all so confusing, should I learn the basics of anything before coming here?
i have no knowledge and it’s all so confusing, should I learn the basics of anything before coming here?
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 🙂
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
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:
send me the link from where I can buy these ESEs .
i have the same Pblm. Do you have the solution?
The best visual explanation I ever saw! Thank you very much Joop Brokking.
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?
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?
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.
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.
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
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
Can you provide list of parts which is available also in india?
Can you provide list of parts which is available also in india?
Can you provide list of parts which is available also in india?
Mr Joop Brokking I have one serious question. Once ESCs are calibrated, dont we have to calibrate again and after calibration, do we just can give esc the signals and esc starts working? and also, is there any condition that ESC enters the calibration mode? (the way i see it, i think that when throttle signal is Full_Throttle, ESC immediatly enters into the cali mode. Am i correct ?)
The ESC’s are only calibrated once. With the YMFC flight controller code it’s not possible to start with a high pulse so the calibration values are stored and cannot be changed. Only the setup program can enter the calibration mode.
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?
why didn’t you use delayMicroseconds with timer0 disabled instead of micro? it was perfect without jitter.
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)
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)
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.
same same xD
Hello brother can i use other low cost transmitter????
Hello brother can i use other low cost transmitter????
Hello brother can i use other low cost transmitter????
Hello brother can i use other low cost transmitter????
Hello brother can i use other low cost transmitter????
I connect two different pairs of Escs
2 run the motors when thrttol in the lowest position(say 1000) ,but the others takes delay about (1200).
Sir why didnt u used servo library n use write.Microseconds for escs
@Joop Brokking (or anyone else)
Does using bit masks defined at the top cause performance drop? For example, if I use:
#define BIT0HI B00000001
Will there be any difference between the following lines of code:
PINB |= B00000001
PINB |= BIT0HI
I don’t think so, because the compiler will handle it, but I’m not sure. Thanks for any help!
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.
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.
Im using FS-T6 transmitter all the code is uploaded but transmitter is not working…..
Im using FS-T6 transmitter all the code is uploaded but transmitter is not working…..
Im using FS-T6 transmitter all the code is uploaded but transmitter is not working…..
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. Any advice you can provide me with here will be greatly appreciated.
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.
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.
Hello Joop, My question is in the loop function: Why dont you just use delay? Set PortD as high, then delayus(receiver_input_channel_3), PortD as low, then you can control the motor ady. Am i missing out something in the video?
Why go through all the hassle( So many lines of codes in the loop function?
I guess that method can use to control 4 motor all together. I guess so. Nice
Hi Joop. First of all thank you very much for your instructional videos and project page as they helped me to a great extent in learning about Arduino, drones and electronics. I wanted to ask for your input as I am having a problem with the motors turning off mid-flight. It only happens Serial.print(F”…”) is used to print a long telemetry string at once/ per loop. The drone functions as expected when I don’t move the sticks but the moment I send a throttle value > 1500, the following happens:
– Motors turn off and start beeping
– The LED lights up
– Impossible to start the motors again (have to unplug the battery)
I understand that this may be a cause of the loop time increasing above 4050us which causes the led to light up, but I don’t understand why the motors are stopping.
I fixed the Serial.print to print a short string per loop and then wait for several loops by following one of your other examples but can you please help me understand the cause that made the motos stop?
Another question I’d like to ask is regarding PWM. You mentioned that using PWM doesn’t make it possible to send 2000us pulse. Does that mean that analogWrite(255, pin) when is at the default 500Hz, won’t send a continuous 2ms pulse?
Thank you for your time.
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.
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
Hey i have gone through this tutorial and when i connect only one motor it works very well and gets its maximum speed at maximum throttle position bt when the 4 motors are connected, speed of a motor cannot be put to the maximum value which i got at first when the throttle stick at max.The value is lower than that.can someone give me a solution for this?
Make sure to calibrate the ESC’s to the length of the used pulse.
they were calibrated back then sir and i found the error.And its a silly error.i used a wire which goes around the ESC’s and and connected the ESC plus sides to it at random places and same did for the negative ones.Actually thats wrong becuz at first first connecting point there will be 2 paths with 2 different loads of 1 : 3.And i corrected it and itworks now.
Your videos were a super help and plzz accept my sincere thanks sir
Hi joop! Really appreciate your good work! love all your projects. I have a problem with YMFC32. First when I test the voltage with your code it show that only 4.7V. what is cause that make it drop 0.3V and with 4.7V it make quadcopter what difference? I try to take off my quadcopter and I feel it hard to take off because of the thrust is a bit weak. is it the problem of 4.7V or propeller or something else? Do you have any ideas with that? can you share email so I can show the problem in video. Thank you!
If you follow the instructions in the video 4.7V is normal as you have some voltage drop in the USB cable. If you have 4.7V with a connected battery you battery is empty. Double check by measuring the voltage with a multimeter.
Thank you very much Joop! I’m working on it. Hope to see more new projects from you soon 🙂
Hello Joop,
Im new to Quadcopters and Arduinos. After finishing setup and esc calibrations, i uploaded the flight controller but now when i want the quadcopter to take of it seems that the front two motors are taking more power so the quadcopter keeps on flipping over. Can you please provide a solution or tell me what might be wrong?
Thank You.
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?
Figured it out 🙂
Ok.
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:
This is pure cybernetics, I’m jealous right now…
This is pure cybernetics, I’m jealous right now…
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.
how do you calibrate the esc’s the first time you connect them to the arduino ? By norms we are to start with the max pwm value (2000ms) to start calibration, then how would these program react to non-calibrated ESCs ?
How can we adapt for tricopter?
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. }
if I use porth instead of portd do it still >=16 ??
Could you fix the problem? I have same problem..
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!
Thank you! I’m learning from you so many things.
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: as it is better documented.
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?
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.
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.
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 !!
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.
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.
Thank you for the informative video! I’m trying to use an orientation breakout to have an autonomous rc plane. (Just flying in a circle for starter). Interfacing the Arduino with a spectrum rx is so much easier than creating your own rc rx/tx
My throttle stick is giving common inputs to all 4 channels. I am using Fy Sky FS-CT6B transceiver. Please help.
Hi, I have a doubt, most of the ESC takes a 50 Hz signal, right? That means 20 mS timing the ESC is updating. So if we run the PID, at 250Hz how its gonna update? Am I correct? Or the esc update PWM frequency to be increased to theoretical value 500 Hz ( mostly 400 Hz). Thanks. Hope you can help me.
Is this oneshot125?
Hello Sir, I am very new to arduino. Your explanation was so clear, but I have a doubt on a portion of your code..
1 while(micros() – loop_timer < 4000); 2 loop_timer = micros(); 3 4 PORTD |= B11110000; 5 timer_channel_1 = esc_1 + loop_timer; 6 timer_channel_2 = esc_2 + loop_timer; 7 timer_channel_3 = esc_3 + loop_timer; 8 timer_channel_4 = esc_4 + loop_timer; 9 10 while(PORTD >= 16){
11 esc_loop_timer = micros();
12 if(timer_channel_1 <= esc_loop_timer)PORTD &= B11101111; 13 if(timer_channel_2 <= esc_loop_timer)PORTD &= B11011111; 14 if(timer_channel_3 <= esc_loop_timer)PORTD &= B10111111; 15 if(timer_channel_4 <= esc_loop_timer)PORTD &= B01111111; 16 } my doubt is after the execution of 4th line every ESCs pulse will be high and if an interrupt occurs at the that time then this code execution will be stopped for 2000us for receiver input (if I am not wrong) and every pulse of ESCs will remain high for 2000us. And this will continue for the next loop also..and keeps the ESCs in highest Throttle.. I know that there is something that am not getting, Can you Please clear the doubt for me..
When I saw angular rate when I rotate drone along x axis at 90+ code give me none results, I think because of asin function is my result expected?
heey
please the download sketch for the stm32