Another excellent instructional video from Joop! You are an excellent teacher. Thanks for just the right amount of details, the working code, and for taking the time to share your work for our benefit. Super job!
Hello sir! Could you please make videos on other peripherals of stm32 like adc, dac etc please. Your explanations along with scope waveforms are perfect!
Comparing timestamps directly will/can yield undefined results since it has a fixed number range (4294967296us in this case). This means about every 1.2 hours your loop will continue immediately after doing the flight controller section for a period of 4ms. To fix this use "while(time_now - time_start < 4000);" which will give you the correct result even after rolling over the 32bit range.
just how you switch to Atmel Studio instead of Arduino IDE i suggest you dump Arduino IDE for stm32 and go for Keil which is free (with code size limit) or System Work Bench for Stm32 also free , because debugging and seeing the register values as you program is priceless!!!
thanks alot i am waiting the time that you may explain the feature of hold position of the quad and how to connect to GPS module to the stm to get a professional flight controller
Hi Joop. Here a big fan of all yoru videos asking a dumb question. Why do you do it this way instead of simply using the setPWM function? What's the advantage of this? Thanks
Please look at the comment from Lighttec regarding handling timer maths properly. Otherwise, unexpected things can happen when rollover occurs. In this use case timer rollover occurs every 4000 seconds. For the main loop timer, worst case seems to be that the loop won't wait out the rest of the 4mS. That's fairly benign in this case, but in other situations tragedy could possibly result.
This is a great project. Thank you very much for your great contribution. These video contents are precious to us beginners.I will always follow your video to learn from you sir i have done everything accordingly what u have explained in all the videos...............when i uploded the YMFC-32 - SETUP programme ,it appears “'HardWire' does not name a type”,an This causes the program to fail to compile,Can you help me? Thank you very much.
Hello sir,my quadcopter can fly normaly,Thank you very much for your reply.,You are too great!the program works fine. Today I successfully passed the test program and flight control program. I can let the drone take off。 But i have a question ?the first time the motor is turned on and off is normal. The second time, the motor can be turned on, but it cannot be turned off. Fly mode is normal, just can not turn off the motor,Can you help me? Thank you very much.
I scour these videos just for the programming tips. How to write directly to registers in the STM32 micro yet using higher level Arduino code when appropriate. You could do a video on this topic alone. Great stuff! BTW, cannot download your s/w from your website for some reason??
Hello Sir, I already completed the hardware and all setup but during the calibration of ESC to synchronize the speed of the motors my front right ESC burned out (throttle in full upward position). Last time, my right rear ESC also burned out. Kindly help what are the solution on that issues. I used and follow according to your recommended hardware and during setup all are correct. Thanks.
Hello Joop.Can you recommend a starting point for an absolute beginner in embedded programming and in programming in general?.What i don't know is whether to start studying assembly language for a specific microcontroller or to start with general purpose C/C++ and then to make the transition to the microcontroller world.Please give me an advice on where to start and on which particular aspects of programming i should insist on.Thank you!!
I too preferred the bit-banging method because then I can do that on ANY pin I want, however, if you produce the signals using the timer, the major advantage that you get is that you can do stuff(communications with sensors, math etc) for the entire duration of the cycle instead of wasting at least 1000 us of time(the time after the first 1000us). This is a huuuuge advantage if you're trying to make something fully autonomous(think GPS+IMU+optical flow+obstacle avoidance + telemetry ) ;) . Also, Joop, I would love it if you could check out my code for a quadcopter (stabilize+altitude hold) , it runs at 400Hz - github.com/naughtyStark/Altitude-Hold-Drone-Simple
If we wanted to run this code at higher rates or lower rates. Which part of the code has to be modified? Is this the part I need to change? //Gyro angle calculations //0.0000611 = 1 / (250Hz / 65.5) Say if I added more code and I am able to get 200hz loop rate. Should I use 0.00007634(1/200/65.5) instead of 0.0000611? Is there any other place I need to change the code?
I can't imagine how much time it took to figure out these details. I've read through the STM32 datasheet and reference manual and it gets a bit overwhelming. And then how do you figure out that setting a pin to PWM mode links it to the alternate function??? You've saved me so much time and frustration. Thanks. I am proceeding with my plan to send telemetry data using DMA, and receive the GPS data also using DMA. I'll keep you posted. Just wondering...Have you ever tried experimenting with longer loop times? Is it really noticeable if you would double the loop time to 8ms?
Great to hear that my videos help. I always try to keep the loop time as short as possible. With the YMFC-32 it's possible to get even shorter loop times. However, it's always a good idea to have some extra room for your own extra's :-)
hi sir i bought FLIP 32 and i tried to load your program to the filp 32 but in the Arduino message it is saying device not initiated could u please help me sir
Hi Joop, I am working on a physics project for school on the topic of electric motors and efficiency. I can’t find a clear answer to this anywhere on the internet : Is the pulse given to the ESC directly proportional to the RPM of the motor? Meaning does the ESC give the motor more current under load than when under no load with the same pulse?
Can you give me some advice about ESC, i’m planing to built quadcopter with these things: 1. Brotherhobby R2 2207 2400 KV motor 2. ESC 40 A ZTW 3. HRB 4S 14,8 V 5000 mAh, 50C battery Do they match? And if not what should i change?
thank you for this amazing project. this will be my first drone project, can I use STM-Nucleo F446RE? would the code work with this nucleo board?. thanks for the time.
I want to know if these kind of budget oscilloscopes are any good. Most sources (review videos and forums) are 'forcing' people to buy a expensive oscilloscope. Not many have that kind of budget. That is why I bought one so my viewers can see for them self that it works fine for my projects.
Hi joop, would you told me how data can share or exchange between ArduPilot and mission planner ground station, or packet format of exchange data. so i can display my flight controller data by using mission planner ,such as altitude, location on map etc.
Hello Joop. Great educational videos! Can I send you a Teensy 3.6. ? My gift to you. I would love to see you build your quadcopter with this powerful little board.
Dan, thank you for the gesture. But I simply don't have the time to start working on another microcontroller. It's already a time-challenge to get it to work on the STM32.
I have done some work with a futaba and got sbus to work using the arm chip. Compared to pwm it is much faster. I posted the code here: github.com/Chasedog98/SBUS_explore Try it out and see if any changes need to be made.
You provide a goldmine of information, thank you very much. Keep it up! :)
Another excellent instructional video from Joop! You are an excellent teacher. Thanks for just the right amount of details, the working code, and for taking the time to share your work for our benefit. Super job!
Many Thanks so much for the detailed explanation on how the hardware and software works together. hope to see more.
Hello sir!
Could you please make videos on other peripherals of stm32 like adc, dac etc please. Your explanations along with scope waveforms are perfect!
I think you developed this channel for me dude 😊 You absolutely talk about the things I want to learn about 👍
Comparing timestamps directly will/can yield undefined results since it has a fixed number range (4294967296us in this case). This means about every 1.2 hours your loop will continue immediately after doing the flight controller section for a period of 4ms.
To fix this use "while(time_now - time_start < 4000);" which will give you the correct result even after rolling over the 32bit range.
This is spot on. You must do unsigned subtract, then look at the result, to properly handle the rollover of the timer without a glitch.
just how you switch to Atmel Studio instead of Arduino IDE i suggest you dump Arduino IDE for stm32 and go for Keil which is free (with code size limit) or System Work Bench for Stm32 also free , because debugging and seeing the register values as you program is priceless!!!
Thanks for the vídeo and oscilloscope suggestion. I bought it from express! :)
thanks alot
i am waiting the time that you may explain the feature of hold position of the quad
and how to connect to GPS module to the stm to get a professional flight controller
Hi Joop. Here a big fan of all yoru videos asking a dumb question. Why do you do it this way instead of simply using the setPWM function? What's the advantage of this? Thanks
Please look at the comment from Lighttec regarding handling timer maths properly. Otherwise, unexpected things can happen when rollover occurs. In this use case timer rollover occurs every 4000 seconds. For the main loop timer, worst case seems to be that the loop won't wait out the rest of the 4mS. That's fairly benign in this case, but in other situations tragedy could possibly result.
Thank you very much :)
Joop, Did you ever try to load your FC code into the Flip 32? I didn't see any video's on that.
Thanks Joop for the videos. waiting for Flip 32 version...............
This is a great project. Thank you very much for your great contribution. These video contents are precious to us beginners.I will always follow your video to learn from you
sir i have done everything accordingly what u have explained in all the videos...............when i uploded the YMFC-32 - SETUP programme ,it appears “'HardWire' does not name a type”,an This causes the program to fail to compile,Can you help me? Thank you very much.
Use:
TwoWire HWire (2, I2C_FAST_MODE);
instead of:
HardWire HWire (2, I2C_FAST_MODE);
Hello sir,my quadcopter can fly normaly,Thank you very much for your reply.,You are too great!the program works fine. Today I successfully passed the test program and flight control program. I can let the drone take off。
But i have a question ?the first time the motor is turned on and off is normal. The second time, the motor can be turned on, but it cannot be turned off. Fly mode is normal, just can not turn off the motor,Can you help me? Thank you very much.
Geweldig
what if I want to change the Pin to pb6 to pb5 then what we have to do?
Very good.
Do some tiny projects like diy for begining learners
Why is it not supported to generate subtitles
hi sir....
can I use arduino nano instead of stm 32?
I scour these videos just for the programming tips. How to write directly to registers in the STM32 micro yet using higher level Arduino code when appropriate. You could do a video on this topic alone. Great stuff! BTW, cannot download your s/w from your website for some reason??
My server is down for the moment. And it will take a while to get it running again. Very inconvenient :-(
Hello Sir, I already completed the hardware and all setup but during the calibration of ESC to synchronize the speed of the motors my front right ESC burned out (throttle in full upward position). Last time, my right rear ESC also burned out. Kindly help what are the solution on that issues. I used and follow according to your recommended hardware and during setup all are correct. Thanks.
Hi, I get a square wave, but only get
Hello Joop.Can you recommend a starting point for an absolute beginner in embedded programming and in programming in general?.What i don't know is whether to start studying assembly language for a specific microcontroller or to start with general purpose C/C++ and then to make the transition to the microcontroller world.Please give me an advice on where to start and on which particular aspects of programming i should insist on.Thank you!!
The Arduino environment and the datasheet of the ATmega328P are very good starting points.
Hey Joop why not use the old way for controlling a brushless motor? like your YMFC, I tried it with the STM32 and it wokred fine.
With the STM32 it's possible to control the duty frequency. This way I'm sure that all ESC's for multicopters can handle this pulse.
I too preferred the bit-banging method because then I can do that on ANY pin I want, however, if you produce the signals using the timer, the major advantage that you get is that you can do stuff(communications with sensors, math etc) for the entire duration of the cycle instead of wasting at least 1000 us of time(the time after the first 1000us). This is a huuuuge advantage if you're trying to make something fully autonomous(think GPS+IMU+optical flow+obstacle avoidance + telemetry ) ;) . Also, Joop, I would love it if you could check out my code for a quadcopter (stabilize+altitude hold) , it runs at 400Hz - github.com/naughtyStark/Altitude-Hold-Drone-Simple
If we wanted to run this code at higher rates or lower rates. Which part of the code has to be modified?
Is this the part I need to change?
//Gyro angle calculations
//0.0000611 = 1 / (250Hz / 65.5)
Say if I added more code and I am able to get 200hz loop rate. Should I use 0.00007634(1/200/65.5) instead of 0.0000611? Is there any other place I need to change the code?
I can't imagine how much time it took to figure out these details. I've read through the STM32 datasheet and reference manual and it gets a bit overwhelming. And then how do you figure out that setting a pin to PWM mode links it to the alternate function??? You've saved me so much time and frustration. Thanks.
I am proceeding with my plan to send telemetry data using DMA, and receive the GPS data also using DMA. I'll keep you posted. Just wondering...Have you ever tried experimenting with longer loop times? Is it really noticeable if you would double the loop time to 8ms?
Great to hear that my videos help. I always try to keep the loop time as short as possible. With the YMFC-32 it's possible to get even shorter loop times. However, it's always a good idea to have some extra room for your own extra's :-)
Hi joop nice work, can you explain me why do you set 5000 ARR value ?. Thank you.
hi sir i bought FLIP 32 and i tried to load your program to the filp 32 but in the Arduino message it is saying device not initiated could u please help me sir
Cool
I clicked on your video faster than _Flash_ .
Hello again,
How will you connect GPS to that Flip32 board..?
why 250hz,since stm32 is faster why not reduce the frequency and get better control over the motor.
Because the refresh rate of electronic speed controller (ESC) is 250Hz..!
I want to give people enough room (time) to create their own code in the main loop.
Hi Joop,
I am working on a physics project for school on the topic of electric motors and efficiency. I can’t find a clear answer to this anywhere on the internet : Is the pulse given to the ESC directly proportional to the RPM of the motor? Meaning does the ESC give the motor more current under load than when under no load with the same pulse?
Electronoobs made a video about how an ESC works. You will find your answer there: ua-cam.com/video/8LXPcJD6hEA/v-deo.html
can you make it with attny13 too?
Calibração esc opto??
Can you give me some advice about ESC, i’m planing to built quadcopter with these things:
1. Brotherhobby R2 2207 2400 KV motor
2. ESC 40 A ZTW
3. HRB 4S 14,8 V 5000 mAh, 50C battery
Do they match? And if not what should i change?
20A should be enough
My ESC is racerstar rs30A blheli_s opto can it will work with the 1000kv motor because i am making quardcopter F450 frame
This should work fine.
thank you for this amazing project. this will be my first drone project, can I use STM-Nucleo F446RE? would the code work with this nucleo board?. thanks for the time.
Did it work for F446RE? Just looking for an update :-)
But you allready used an osziloskop....what was the reason to change it?
I want to know if these kind of budget oscilloscopes are any good. Most sources (review videos and forums) are 'forcing' people to buy a expensive oscilloscope. Not many have that kind of budget. That is why I bought one so my viewers can see for them self that it works fine for my projects.
Hi joop,
would you told me how data can share or exchange between ArduPilot and mission planner ground station, or packet format of exchange data. so i can display my flight controller data by using mission planner ,such as altitude, location on map etc.
Check the ArduPilot forum for information about ArduPilot.
Hi... Joop Thanks, will you update some video about how to make ground telemetry Box that you are using.
Hello Joop. Great educational videos! Can I send you a Teensy 3.6. ? My gift to you. I would love to see you build your quadcopter with this powerful little board.
Dan Archuleta I’ve got it ported over and running on a Teensy 3.2. Works great. I did my interrupts different, but things run fast!
Dan, thank you for the gesture. But I simply don't have the time to start working on another microcontroller. It's already a time-challenge to get it to work on the STM32.
void setup() {
pinMode(PB6, PWM); //output
TIMER4_BASE->CR1 = TIMER_CR1_CEN | TIMER_CR1_ARPE; //channel 1
TIMER4_BASE->CR2 = 0;
TIMER4_BASE->SMCR = 0;
TIMER4_BASE->DIER = 0;
TIMER4_BASE->EGR = 0;
TIMER4_BASE->CCMR1 = (0b110 CCMR2 = 0;
TIMER4_BASE->CCER = TIMER_CCER_CC1E;
TIMER4_BASE->PSC = 71;
TIMER4_BASE->ARR = 5000; // auto reload register value
TIMER4_BASE->DCR = 0;
TIMER4_BASE->CCR1 = 1000;
}
void loop() {
delay(4);
loop_timer = micros() + 4000;
TIMER4_NASE ->CNT = 5000;
//flight controller code ehere
TIMEr_BASE->CCR1 = channel_1
// end flight controller code
while (loop_timer > mirco())
}
I have done some work with a futaba and got sbus to work using the arm chip. Compared to pwm it is much faster. I posted the code here: github.com/Chasedog98/SBUS_explore Try it out and see if any changes need to be made.