YMFC-3D part 4 - Arduino quadcopter - Electronic Speed Controller (ESC)

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 มิ.ย. 2024
  • PLEASE USE THE YMFC-AL (AUTO-LEVEL) SOFTWARE: • YMFC-AL - Build your o...
    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:
    www.brokking.net/ymfc-al_main....
    ATmega328 pinout diagram:
    www.brokking.net/YMFC-3D/YMFC-...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 320

  • @kuyanatnatdkrx7
    @kuyanatnatdkrx7 8 ปีที่แล้ว +23

    never expected this to be a batter micro controller lecture than what I had at university.

  • @giaras64
    @giaras64 8 ปีที่แล้ว +5

    One of the most clear video about in depth programming atmega328 on arduino one.
    My compliments !

  • @rchotel
    @rchotel 6 ปีที่แล้ว +6

    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

  • @victorpkstrength
    @victorpkstrength 7 ปีที่แล้ว +1

    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 !

  • @happyhippr
    @happyhippr 7 ปีที่แล้ว +1

    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

  • @billybbob18
    @billybbob18 9 ปีที่แล้ว +2

    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

  • @iforce2d
    @iforce2d 9 ปีที่แล้ว +10

    Great way to illustrate the timings with the scope, and interesting method for generating PWM signal :)

  • @novoster
    @novoster 6 ปีที่แล้ว +1

    The best visual explanation I ever saw! Thank you very much Joop Brokking.

  • @tetradb_
    @tetradb_ 9 ปีที่แล้ว +1

    This was really awesome!
    Thanks for sharing such a great methodology, very insightful.

  • @engzoz1412
    @engzoz1412 9 ปีที่แล้ว +1

    Thx man, your series are extremely professional and very helpful

  • @PhilipStubbs
    @PhilipStubbs 9 ปีที่แล้ว +7

    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! :-)

  • @ohitstarik
    @ohitstarik 8 ปีที่แล้ว +3

    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.

    • @turgutmalkoc3773
      @turgutmalkoc3773 5 ปีที่แล้ว +1

      kardeşim ne dediğini anlayamadım :D Halen uğraşıyorsan belki yardımcı olabilirim

  • @topanglera5695
    @topanglera5695 5 ปีที่แล้ว +1

    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?

  • @chocolatelover7396
    @chocolatelover7396 4 ปีที่แล้ว +3

    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.

  • @flavb83music
    @flavb83music 7 ปีที่แล้ว +2

    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!

  • @kevinsi5194
    @kevinsi5194 8 ปีที่แล้ว +1

    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).

  • @torstenpersson5629
    @torstenpersson5629 9 ปีที่แล้ว +1

    Fantastic! Absolute stellar video.

  • @teodorcali
    @teodorcali 7 ปีที่แล้ว +1

    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?

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      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: th-cam.com/video/DYpHB-LfloI/w-d-xo.html

  • @rooster443
    @rooster443 5 ปีที่แล้ว +1

    This is pure cybernetics, I'm jealous right now...

  • @tobiasveselsky6796
    @tobiasveselsky6796 8 ปีที่แล้ว +1

    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...

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว +1

      +Tobias Veselsky Yes it will work with 99% of the esc's. You might need to calibrate your esc's. Setup the transmitter with the program of part 2 and make sure you get the same results as I did. After that you can calibrate the esc's with the throttle output of your receiver.

  • @torstenpersson5629
    @torstenpersson5629 9 ปีที่แล้ว +1

    Cannot wait for part 5. Please hurry! :-)

    • @Joop_Brokking
      @Joop_Brokking  9 ปีที่แล้ว +2

      Torsten Persson I just uploaded part 5 :-)

    • @torstenpersson5629
      @torstenpersson5629 9 ปีที่แล้ว +1

      Joop Brokking
      That was quick! And I thought that I couldn't be more impressed! :-) Thanks a lot!

  • @Stiyx
    @Stiyx 4 ปีที่แล้ว +1

    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?

  • @robotcanfly4864
    @robotcanfly4864 9 ปีที่แล้ว +1

    So good. Thank you Joop Brokking.

  • @johncollins3450
    @johncollins3450 6 ปีที่แล้ว +1

    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?

  • @THEVENGENCEGURU
    @THEVENGENCEGURU 9 ปีที่แล้ว +1

    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?

    • @Joop_Brokking
      @Joop_Brokking  9 ปีที่แล้ว +3

      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.

  • @dhruvajayray3538
    @dhruvajayray3538 2 ปีที่แล้ว

    Hi. I am making a small-sized, lightweight drone and am mostly thinking of using an arduino nano and small coreless motors. In that case, do I really need to use an ESC?

  • @yelectric1893
    @yelectric1893 6 ปีที่แล้ว

    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?

  • @raedamine2886
    @raedamine2886 7 ปีที่แล้ว +1

    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

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      Yes they are. You can read more here: www.brokking.net/ymfc-al_main.html

  • @pascalou95pascal52
    @pascalou95pascal52 5 ปีที่แล้ว

    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!

  • @eliemachaalany6793
    @eliemachaalany6793 8 ปีที่แล้ว

    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

  • @haniomar3743
    @haniomar3743 8 ปีที่แล้ว +1

    hi is it possible to make a voice controlled quadcopter please answer quickly. Please

  • @MultiTechEducation4U
    @MultiTechEducation4U ปีที่แล้ว

    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 ?

  • @stevenlee1726
    @stevenlee1726 6 ปีที่แล้ว

    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?

    • @stevenlee1726
      @stevenlee1726 6 ปีที่แล้ว

      I guess that method can use to control 4 motor all together. I guess so. Nice

  • @TexProjects
    @TexProjects 7 ปีที่แล้ว +3

    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..

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว +3

      I used a wait loop in the code. So the next loop will always start 4000us after the previous start.

    • @TexProjects
      @TexProjects 7 ปีที่แล้ว +2

      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?

  • @4Dipayan
    @4Dipayan 5 ปีที่แล้ว

    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 ?

  • @vishnukartha47
    @vishnukartha47 4 ปีที่แล้ว

    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.

  • @sriramk2900
    @sriramk2900 8 ปีที่แล้ว

    can you show pictures of how ESC's are connected to the arduino.

  • @zaferseis7842
    @zaferseis7842 7 ปีที่แล้ว

    Can I a Question for that Refresh rate always 250 Hz on arduino uno ? If not, Should I adjust?

  • @khalidMohsin
    @khalidMohsin 2 ปีที่แล้ว

    Hi sir i ask u why multiple (angle_pitch Or angle_roll) by 15 to find level_adjust. why this number (15)?
    please help

  • @Joel-rf7bf
    @Joel-rf7bf 7 ปีที่แล้ว

    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.

  • @durvesularevanth1797
    @durvesularevanth1797 6 ปีที่แล้ว

    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.

  • @mrarmymanful
    @mrarmymanful 8 ปีที่แล้ว +1

    Just use HW PWM... This is very time consuming and tedious. I applaud you for you patience

  • @imrulhaque961
    @imrulhaque961 7 ปีที่แล้ว

    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.

  • @dhruvthakkar7485
    @dhruvthakkar7485 7 ปีที่แล้ว

    hello +Joop Brokking
    can you explain what does esc_loop_timer and esc_timer does?

  • @jimitjaishwal
    @jimitjaishwal 3 ปีที่แล้ว

    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?

  • @kaustyagi
    @kaustyagi 5 ปีที่แล้ว

    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
      @Joop_Brokking  5 ปีที่แล้ว

      Maybe this video will help: th-cam.com/video/bENjl1KQbvo/w-d-xo.html

  • @eviandrianto4786
    @eviandrianto4786 6 ปีที่แล้ว

    why didn't you use delayMicroseconds with timer0 disabled instead of micro? it was perfect without jitter.

  • @jorch778
    @jorch778 6 ปีที่แล้ว

    Sir why didnt u used servo library n use write.Microseconds for escs

  • @evic262
    @evic262 7 ปีที่แล้ว

    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 ?

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      One cycle does not cause any problems as long as the program keeps running. But most quadcopters don't fly for 70 minutes.

    • @evic262
      @evic262 7 ปีที่แล้ว

      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!

  • @krtinshet9295
    @krtinshet9295 4 ปีที่แล้ว

    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.

  • @aaryan2512
    @aaryan2512 4 ปีที่แล้ว

    My throttle stick is giving common inputs to all 4 channels. I am using Fy Sky FS-CT6B transceiver. Please help.

  • @kaustubhpatil103
    @kaustubhpatil103 7 ปีที่แล้ว

    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?

  • @enriquecerda1
    @enriquecerda1 7 ปีที่แล้ว +1

    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?

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว +1

      Where (time) was this in my video?

    • @enriquecerda1
      @enriquecerda1 7 ปีที่แล้ว +1

      +Joop Brokking 1:45

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว +1

      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.

  • @joh1ish
    @joh1ish 7 ปีที่แล้ว +1

    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!

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      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.

    • @joh1ish
      @joh1ish 7 ปีที่แล้ว

      Ah I see, thank you so much! +1 sub :)

  • @dretekin2794
    @dretekin2794 7 ปีที่แล้ว

    Do i need to study electronic engineering for this because there so many thing I do not understand.

  • @othmandiab4471
    @othmandiab4471 7 ปีที่แล้ว

    Please help when I download YMFC-AL_Flight_controller to the Arduino engine does not work when I download YMFC-AL_esc_calibrate

  • @REN-fr2sm
    @REN-fr2sm 8 ปีที่แล้ว

    Why don't just use writeMicrosecond? Is delay microsecond has any benefit?

  • @2394ravi
    @2394ravi 6 ปีที่แล้ว

    Can you provide list of parts which is available also in india?

  • @SetFreeByTheTruth2024
    @SetFreeByTheTruth2024 8 ปีที่แล้ว

    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?

    • @SetFreeByTheTruth2024
      @SetFreeByTheTruth2024 8 ปีที่แล้ว

      I think I figured it out. ESC is needed for brushless motors to determine when to reverse the voltage, whereas a motor shield is for brushed motors and handled pwm and external power.

  • @qudizzle1
    @qudizzle1 8 ปีที่แล้ว

    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?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      It is possible to use hardware PWM. But I like to keep the code as simple as possible so everybody can understand what is going on.

  • @Jukalihaha123
    @Jukalihaha123 7 ปีที่แล้ว +1

    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.

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว +1

      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

    • @saifulsk8653
      @saifulsk8653 6 ปีที่แล้ว

      i have the same Pblm. Do you have the solution?

  • @SanchayGupta23
    @SanchayGupta23 8 ปีที่แล้ว

    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

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      A gyro is enough for flying. An accelerometer is needed for auto level.

    • @SanchayGupta23
      @SanchayGupta23 8 ปีที่แล้ว

      Ok..thanku..thumbs up to your videos..very helpful

  • @muhammadrizwanchughtai4311
    @muhammadrizwanchughtai4311 4 ปีที่แล้ว

    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.

  • @projectdrone3281
    @projectdrone3281 7 ปีที่แล้ว

    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 :D
    thanks a lot :D

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      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

  • @iforce2d
    @iforce2d 8 ปีที่แล้ว +1

    If the ESCs are using 'oneshot125' (pulse lengths 125-250us) all we need to do is scale all the values that are based on 1000-2000us range to 125-250us range..... right?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว +2

      +iforce2d That is correct. The only problem is the 20us jitter (10:40). For a 1000 to 2000us pulse this is 2% and will work fine. For a 125 to 250us pulse it becomes 16%. So this will not work.
      If you want to use the oneshot125 you might consider to use the pwm outputs of the ATmega328. These are supposed to be jitter free.

    • @iforce2d
      @iforce2d 8 ปีที่แล้ว

      +Joop Brokking ah of course, that would not work out well.
      Here's a crazy idea then...
      1. With nRF24 as receiver I would not need the pin-change interrupts, so no micros() used there.
      2. With oneshot125 the longest ESC pulse will be 250us, so four ESCs could be done sequentially using delayMicroseconds and still take less than 2000us, again no micros() used.
      3. Use delayMicroseconds again to wait out the remaining time (250-pulse for each ESC) so that total time for ESC pulses is constant.
      4. Remove the micros() call which ensures 4000us has passed before starting the next loop.
      5. Now we can disable timer0 because it is not needed, and the delayMicroseconds calls will be jitter free.
      The remaining issues that I can see:
      1. main loop may now run too fast for ESC to keep up
      2. potentially small jitter from reading nRF24 packets (there may or may not be a packet waiting)
      3. adding more features to the loop is tricky unless those features can also be kept constant-time
      Issue 1 could be worked around by adding another constant delayMicroseconds. I don't know how bad issue 2 would be, but the jitter would affect the PID result, which I'm pretty sure would not cause as much trouble as jitter in the ESC signals. It might also be possible in the case where there is no packet to read, to use delayMicroseconds to wait out the time that would otherwise be spent reading the packet from the nRF24 module.
      I'm itching to try this stuff out but I've just moved countries and all my stuff is not here yet. So I'm pondering ideas and making long comments on TH-cam instead :)

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว +1

      +iforce2d Ok, so you are on the move... where to? Getting closer to Europe?
      You run into the same problems as I did haha. My problem was creating 10 servo outputs without jitter. But the basic is still the same.
      Using the software options of the Arduino IDE slows everything down and eats tons of memory bytes. To get around this I wrote my own I2C and UART send / receive software. Just a fraction of the original Arduino library's and so much faster. I can almost make the jump to Atmel Studio :-)
      Euhm, sorry, just got carried away by my own frustrations haha.
      1) If you don't call any Serial.*** functions the interrupt routine that handles the serial data is not created by the Arduino IDE. This way you can create your own (faster, smaller and less jitter) UART reception interrupt routine with:
      ISR (USART_RX_vect){
      serial_input[USART_buffer_counter] = UDR0;
      ..........
      ..........
      }
      You only need to receive your predefined transmitter data so there is no need for a complex ring buffer. The only downside is that you cannot user Serial.print for testing. Softserial might be an option to overcome this during testing.
      2) Creating the esc pulses sequentially is a winner! (Faster and less jitter)
      3) Is not needed (read on).
      4) Yes
      5) Yes, disable the Timer0 interrupt. Timer0 will always run ;-) And I'm not making fun of you here because it might hold a key....
      All hardware timers run in the background. You can't disable them unless you go low power. That said, you might consider the use of timer1. This is a 16 bit timer and can run without overflow (interrupt) for 4us.
      Set it to 0 at the beginning of the loop (TCNT1 = 0;) and call it when you need it (while (TCNT1

    • @iforce2d
      @iforce2d 8 ปีที่แล้ว

      +Joop Brokking No, further from Europe - I moved back to NZ.
      Yes the nRF24 holds a buffer that can be polled, and it is accessed via SPI interface. It handles all of the packet assembly and buffering, along with acknowledgements and resending if using auto-ack connection. From the arduino point of view in the main loop, all we do is:
      while ( radio.available() ) {
      radio.read( &mybuffer, howmanybytes ); // max 32 bytes, this will also shift the packet out of the nRF24 buffer
      }
      The nRF24 will buffer up to 3 packets, and for use as radio control the packet length will most likely be constant. We only care about the most recent control state so it's ok to make this a 'while' loop and overwrite the previous packet without ever using it. There may be more than one packet ready, or zero packets ready, which could cause some jitter here.
      Yes, I meant disable the interrupt, not the timer itself :)
      I thought about timer1 but saw your other comment here saying it might not help. But I guess if I'm not using it to trigger an interrupt, then it's not a problem.
      Of course I would start with standard YMFC first though. I don't actually have any oneshot125 ESCs anyway, it just seems like something interesting to try. It's quite amazing what you can get done with these simple cheap micro-controllers with some careful thought and determination!

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว +1

      *****
      If you can poll the data there is no need for interrupts. Just poll the data when you need it.... very nice!
      Yes, if you disable the interrupt of timer1 you can use it without problems. I just learned this a couple of weeks ago when I needed 10 outputs for my octocopter :-) And there is so much more to learn.
      Like you said, you can do amazing things with the ATmega328 if you can work your way around the Arduino library's and software ;-)
      Wow, you can at least say that you traveled the world. I hope the move goes well. More flying space around your new location?

  • @johnstech6437
    @johnstech6437 6 ปีที่แล้ว

    Im using FS-T6 transmitter all the code is uploaded but transmitter is not working.....

  • @omarelnaggar5841
    @omarelnaggar5841 8 ปีที่แล้ว

    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?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว +3

      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.

    • @omarelnaggar5841
      @omarelnaggar5841 8 ปีที่แล้ว

      Ouh ... Now I got it! Thanks a lot for your detailed clarification and quick reply

  • @offensivebias3965
    @offensivebias3965 ปีที่แล้ว

    Does the final code on @11:00 actually works ? can i get this version of code ? im not seeing on the website anymore

  • @pranjultanwar7394
    @pranjultanwar7394 6 ปีที่แล้ว

    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.

  • @watchingin3d549
    @watchingin3d549 7 ปีที่แล้ว

    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.

    • @watchingin3d549
      @watchingin3d549 7 ปีที่แล้ว

      i want to build a qav250 asap. as cheap as possibles.

    • @ShaunHusain
      @ShaunHusain 7 ปีที่แล้ว

      FindmeKicksUK just get a naze32 or cc3d libre pilot based flight controller this is more for the sake of learning and learning to debug using an arduino as the flight controller. If you wanted to do autonomous flight something like this is more beneficial so you can debug and modify any part of the system but for regular hobby flying the actual flight controllers and corresponding software make the whole thing simple.

  • @rezahr9066
    @rezahr9066 7 ปีที่แล้ว

    sir i'm very curious of your YMFC-AL project and i try it by the steps you shown on your website
    but then my motors wont spinning after i uploaded the esc program at step 7, what could possibly wrong?
    thank you

    • @rezahr9066
      @rezahr9066 7 ปีที่แล้ว

      i already done that at the set up phase, but at the next step when i test it, my motors wont spinning

  • @TrootsD2
    @TrootsD2 4 ปีที่แล้ว

    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).

    • @Joop_Brokking
      @Joop_Brokking  4 ปีที่แล้ว

      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.

  • @sanstar9338
    @sanstar9338 ปีที่แล้ว

    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.

  • @computerman4321
    @computerman4321 7 ปีที่แล้ว

    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?

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      You will miss valuable timer steps. The timer micros() will not be accurate anymore.

  • @samrejijoseph
    @samrejijoseph 8 ปีที่แล้ว

    hi,I'm doing this own project of mine,I have a doubt. can I control individual motor using the arduino and ESC?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      Yes, as I described in the video the ESC's just need a 1000 till 2000 microsecond pulse every 50 milliseconds.

  • @kubergupta3869
    @kubergupta3869 8 ปีที่แล้ว

    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?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      Buy a Arduino Uno (cloon). There pretty cheap.

  • @hoangphamduc3928
    @hoangphamduc3928 8 ปีที่แล้ว +2

    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

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว +2

      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.

    • @Sulerhy
      @Sulerhy 8 ปีที่แล้ว +1

      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?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว +4

      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

    • @hoangphamduc3928
      @hoangphamduc3928 8 ปีที่แล้ว +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 :)

    • @rooster443
      @rooster443 5 ปีที่แล้ว +1

      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.

  • @salamalbaradie5946
    @salamalbaradie5946 5 ปีที่แล้ว

    if I use porth instead of portd do it still >=16 ??

  • @CarlosMontalvo251
    @CarlosMontalvo251 8 ปีที่แล้ว

    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?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      Yes, that is correct. If any ESC port is high the value of PORTD is equal or higher than 16.

    • @CarlosMontalvo251
      @CarlosMontalvo251 8 ปีที่แล้ว

      Awesome thanks.

  • @ELMO7TARAMQ8
    @ELMO7TARAMQ8 6 ปีที่แล้ว

    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 :)

  • @piratekingraiderbrad2075
    @piratekingraiderbrad2075 8 ปีที่แล้ว

    how can i tell the fastest batteru to get depending on esc?

  • @kschethankumar7111
    @kschethankumar7111 7 ปีที่แล้ว

    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

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว +1

      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

  • @obichekwubechukwu4402
    @obichekwubechukwu4402 5 ปีที่แล้ว

    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.

  • @RajeevKumar-pi7en
    @RajeevKumar-pi7en 6 ปีที่แล้ว

    send me the link from where I can buy these ESEs .

  • @ehsanhoseini5641
    @ehsanhoseini5641 11 หลายเดือนก่อน

    why you dont put codes of the videos in website?

  • @zmn88sw
    @zmn88sw 6 ปีที่แล้ว

    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 ?

    • @Joop_Brokking
      @Joop_Brokking  6 ปีที่แล้ว

      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

  • @bogdannica79
    @bogdannica79 7 ปีที่แล้ว

    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 ?

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว +1

      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.

  • @thangpham5806
    @thangpham5806 9 ปีที่แล้ว

    hi all !!!
    when i turn on the transmitter , the led don't off
    why???
    please help me !!!!!
    thanks a lot !!!!!!!!!!!!!!!!!

  • @freddiesnijman
    @freddiesnijman 9 ปีที่แล้ว

    Thank you. Excellent!

  • @mohansangroula6633
    @mohansangroula6633 6 ปีที่แล้ว

    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

    • @adityaanandiitb5302
      @adityaanandiitb5302 6 ปีที่แล้ว

      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)

  • @etiamlawson930
    @etiamlawson930 6 ปีที่แล้ว

    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
      @Joop_Brokking  6 ปีที่แล้ว +1

      What code are you using? And did you calibrate the ESC's with the same pulse?

    • @etiamlawson930
      @etiamlawson930 6 ปีที่แล้ว

      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?

    • @Joop_Brokking
      @Joop_Brokking  6 ปีที่แล้ว +1

      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

    • @etiamlawson930
      @etiamlawson930 6 ปีที่แล้ว

      Joop Brokking Alright, thank you very much!

  • @nombreapellido5125
    @nombreapellido5125 8 ปีที่แล้ว

    hi joop how to read the gyro angular rate data?
    That can be seen in the datasheet?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      Watch YMFC-3D part 3 - gyro.
      th-cam.com/video/nCPEJTUYch8/w-d-xo.html

  • @fagouma
    @fagouma 7 ปีที่แล้ว

    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_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      If you use the YMFC-3D version 1 code you have the transmitter pulses / sticks set to 1000 till 2000us. So you can calibrate the ESC's with the throttle channel of the receiver.

    • @fagouma
      @fagouma 7 ปีที่แล้ว

      Calibrated them.And set p_gain to 1.Again they start too aggressive.I am suspecting the IMU. I will check it.Thank you for your answer.

    • @Joop_Brokking
      @Joop_Brokking  7 ปีที่แล้ว

      When you start the motors they will run at a minimum of 1200us. You can lower this value to 1100 in the code.

  • @kevinpinheiro2485
    @kevinpinheiro2485 8 ปีที่แล้ว

    I tried this code but nothing appears on the serial monitor

  • @noamkoren1839
    @noamkoren1839 8 ปีที่แล้ว

    witch part of the code comes the calibration?

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      +Noam Koren You need to perform the calibration yourself. Check the manual of your specific esc on how to do that.

  • @manoharsingh1920
    @manoharsingh1920 8 ปีที่แล้ว

    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 .

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      It's bloated and not accurate enough.

    • @manoharsingh1920
      @manoharsingh1920 8 ปีที่แล้ว

      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 ;)

    • @Joop_Brokking
      @Joop_Brokking  8 ปีที่แล้ว

      The diode is used to protect the USB port of your computer. Used the exact same components as on the schematic.

  • @elmehdimahfoud954
    @elmehdimahfoud954 3 ปีที่แล้ว

    heey
    please the download sketch for the stm32

  • @prajwalr174
    @prajwalr174 ปีที่แล้ว

    there is a error saying "No valid receiver signals found!!! (ERROR 1)" how can i clear it pls anyone help

  • @jonhattan.beatbox
    @jonhattan.beatbox 3 ปีที่แล้ว

    Is this oneshot125?

  • @ryanharysufrianto3638
    @ryanharysufrianto3638 7 ปีที่แล้ว

    my brushless motor just on 3, 1 motor cannot on.. help