I’ve implemented something similar using an STM32, I was taking 20 point averages of a value, after some analysis I realised a 1D Kalman Filter was more responsive, used less processing power and gave a smoother output. Estimate(new) = Estimate(old) + gain(0.15)*(measurement - estimate(old) ). Gains around the 0.1-0.3 mark have good smoothing ability without too much lag. Hope that’s useful.
Nice to see you are further developing the project! I myself got into multicopter because of your DIY projects, both YMFC-AL and -32. My first iteration was with atmega328p using your code, and then, again from you, I discovered stm32 and got me some boards. I was having some flight stability issues, I guess because of the unstable power from the ESCs. But now with a dedicated mosfet I had laying around things are improving! I keep a log of my build on rcgroups if you want to have a giggle at my progress so far.
I never giggle as I always respect others who are building their own quadcopter flight controller. If it was easy everybody could do it :-) Please share the link to your project.
Well I hope this at least puts a slight smile on your face, because it sure does on mine. I very much enjoy this project :D www.rcgroups.com/forums/showthread.php?3086792-Building-my-first-quad-copter-Using-YMFC-AL
Few points: 1. Both the I2C ports of stm32f103 are 5V tolerant, then why to worry about I2C signal levels? 2. Try gy-86 breakout board. It contains mpu6050, ms5611 and hmc5883l all on a single board! Here's what I do: 1. I request temperature with 1024 osr and pressure with 4096 osr as follows: -> Setup() - request temperature with 1024 osr -> loop 0 - read and calculate temperature, request pressure with 4096 osr -> loop 1 - idle -> loop 2 - idle -> loop 3 - read and calculate pressure, request temperature for next loop After calculating altitude I take average of 16 altitude readings and update baro_updated flag so that pid outputs are calculated only when new averaged data is available. This gives accurate altitude with 62.5Hz refresh rate and 7cm precision. 2. When my throttle reaches hover point, I activate the altitude hold algo. When the throttle is raised I increase the setpoint of altitude hold algo and vice versa so that altitude hold algo is always running and the flight is more stable. Great video as always :)
Great to read that you found your own method and algorithm. I tried changing the setpoint with the throttle stick but it was lagging as the PID controller needs time to react. And you always want to have the ability to react very fast (for example obstacles). That is why I have chosen this method. You should try my method and you might see some improvement in altitude precision and response time. As it runs on +/-80Hz. I kept the I2C signals at 3.3V because I could not find any level shifters in the GPS/Compass module that I use. By using this module you get the compass away from you main wiring. That is why I don't use an all-in-one and you need a GPS anyway.
Joop Brokking Thank you for your reply sir. All I want to ask was that stm32 has 5V tolerant I2C interface and we can connect ms5611 or any other sensor directly without any problem (just like you did with npu6050 in this video: ua-cam.com/video/ImctYI8hgq4/v-deo.html) so why to worry about I2C signal levels when connecting ms5611..? Yes, it's better to use magnetometer with a gps since it will be away from other electronics. That's why I use only mpu6050 and ms5611 on the gy-86 module and leave the magnetometer on it unused so that I don't have to use separate modules of mpu6050 and ms5611. And yeah, your algorithm is a lot more better and precise than mine :)
The STM32 might have 5V tolerant inputs, but the HMC5883L in the GPS module might not have 5V tolerant inputs. As explained I could not find a level shifter so I want to be sure that the HMC5883L stays within it limits.
@@Joop_Brokking Then why using mpu 6050 i2c lines directly..? Also, can we use simple resistor voltage dividers on the scl and sda lines for level shifting?
As far as I know the i2c lines are specified open drain. So by switching off the internal pullup resistors at the i2c pins and using external resistors to pull up the i2c lines to 3,3 volts everything should be fine.
What fantastic attention to detail of the sort hopefully turns this project from ‘it worked for me’ to one that should work when people build their own with different motors/ rotors/ ESCs/batteries/bregulators/arometer mounting etc. etcI built a YMFC-AL & modified the code a little. Rock solid stable in flight, but the hardest thing to do when flying was to keep it level. Although changing the throttle response on the RC transmitter helped a lot, I figured adding a barometer to YMFC-AL was doable. It didn’t work & I never worked out why - but there are at least 3 ‘gotchas’ explained in this upload.
My dear Joop, thank you so so much for you passion and inspiration of drone and embedded programing. I was one of your big fan when I studied in university. Now I am working on software field in Japan but I can not forget the time I was in love with Arduino and AVR MCU. I think that I will comeback to my truly passion in the future. Thanks so much for your inspiration :)
To get rid of the 5V level shifting you can also just desolder the two 5V pull-ups on the clock and data lines (and - if you don't have pull-ups elsewhere - add some new pull-ups to 3.3V). This is a lot easier than trying to solder wires to the 3.3V side.
The MS5611 breakout board has two pull-up resistors to 5V on the board. So you have to remove them. As they are 0603 size it might be easier to just solder the wires.
Good tutorial! Unfortunately averaging 20 measurements seems like a lot of time with this output data rate. Ive tried median filter with 3 measurements and it gets rid of those annoying spikes aswell. Then Ive used "simple" kalman filter and complementary filter at the end (like you did). Ive noticed very fast response with smooth signal :). Its recommended to have very smooth and responsive signal for altitude hold. D term of altitude hold algorithm put a lot of stress on battery esc and engines.
Kamil, Do you have an example of your code with kalman and complementary filter? I also feel that averaging 20 pressure readings puts a large lag in the pressure data, so am looking for a different signal filtering method. I've found that by alternating temperature and pressure readings from the 5611, the pressure values are more stable, and you don't get the "repeating spike pattern" Joop talks about in the video. With the averaging method it takes 20 * (3 * 0.004)= 240 msec for the signal to fully respond to a step change. By alternating temp/pressure readings I get a new pressure value every 2 * (3 * 0.004)= 24 msec, and I can apply a filter to that signal and likely still have faster response than 240 msec.
You could use lidar sensor with accelerometer (which you already have onboard) to get altitude when you're in horizontal position in x and y and use altimeter for getting altitudes beyond the lidar range.
Hello, Why did you use a pressure sensor instead of using the altitude value from the gps when implememting altitude hold? Is it because the gps altitude value is not too accurate or there is another reason? Thanks in advance.
Ill go ahead and reply for him as this video is quite old. GPS height is very very inaccurate and slow compared to GPS position or the barometer altitude.
excellent contribution, I have been following your projects for a while now and I have decided to replicate your YMFC autonomus project. One question, is there any way to get the PCB that appears in the videos? Is there a way to buy it? Sincerely jose
@Joop Brokking I dont know if you still read the comments, but I am building the YMFC-32 at the moment. In one of yor videos you showed the telemetry of the copter on a notebook an there was a max altitude set. I dont have found this in the code you have published. Is there any way to limit the height it can fly? In my country a restriction of 100m is given and I want to add this in the software.
I use arduino ONU and I make a quad like your ymsc-AL (see your video) how can I add attitude hold to my ymsc-Al.. Ymsc3d is very costly for me... Please tell?
Dear Joop, thanks again for this informative video. Doesn't the MS5611 have a read out of "uncompensated" pressure data? Because your FC is merely interested in changes of pressure and temperature is considered mostly stable, one probably can neglect the temperature reading and calculation. Just using the raw values ...
Hello Mr .Brokking . i have seen u r video on ms5611 , in the video u are explain 25 ms to acquire the ms5611 data . i had developed ms5611 code where i use my one loop as count each loop is 2ms , once it reaches 10 i acquire the data and it works well .I just want to know why this extra 5 ms u had used in u r code . i have seen u had made a black container to over come the light sensitivity of ms5611 , i have used a black tape ( not touching the sensor) but i see a drift in the altitude over a period of time . do the black tape cause the drift ? or drifting the air pressure is normal for me i( the diff is around 2 meter in 30 minuts ). can you share ur experience. thanks in advance .
Hello sir. You wrote about getting the temperature of Barometer. "After that we can poll the pressure data and immediately request the temperature. And again we need to wait for 2 loops before the temperature data becomes available." Why not using the temperature value from gyro, which created in every loop.
Awesome! I have one notice: Why not to activate altitude-hold when throttle became stabilized? I mean when difference in throttle is about some value of error? In your case I have to remember to center stick every time. In my case it'll calculate altitude for any value of throttle
The throttle stick has a small dead band when altitude hold is activated. So you don't have to exactly remember the center position. As explained at startup the hover throttle is registered with the accelerometers and the stick is automatically centered as hover throttle.
Hey Joop, as a hobbyist, recently I have been following your videos, instructions and have successfully flown auto leveling drone. Your simple and yet effective way of explaining fundamentals is amazing! After auto level, I am now trying out the altitude control. Here I have trouble working with MS5611. To experiment, I have taken snippet of your code to play with MS5611. My code reads very high raw temperature & pressure values, almost like full scale. Any suggestion what could be the issue? Could the daylight be interfering with MS5611 (i did putting the breakout in a closed box). Or could the light from LED on the GY-63 breakout interfere with pressure reading?
Thanks for the quick reply Joop. I seem to have narrowed down the problem. I get better temperature value when i make the following change to my code this instruction results in absolutely wrong reading --> program #1 raw_temperature = Wire.read()
Hello, and thanks again for this wonderful fun and educational project. I am however confused regarding the need to power the MS5611 breakout board with 3.3 V. As far as I understand, the I2C pins used on the STM32 (B10/B11 - RX3.TX3) are tolerant to 5V. And indeed both the HMC5883L and the MPU6050 are power with 5V and connected to the same I2C line. Since both the MS5611 board and the STM32 pins accept 5V, why should we power the MS5611 board with 3.3V ? Thanks for any information.
B10/B11 are not 5V tolerant when they are used for I2C. Both HMC5883L and MPU6050 output 3.3V even with 5V input. They do not have a step up converter for the SCL and SDA lines. Hence they can directly to connected to 5V input and SDA SCL pins directly to B10 and B11. MS5611 has a step up converter which steps up the 3.3V to 5V on SDA/SCL. This will kill the I2C bus on STM32 (know this by experience :) ).
Nice project and excellent explanation of how works this system for hold altitud, i want suggest in the future if possible can you explaint how works a code of ESC controller without sensors, i see many tries in UA-cam but not work good, thanks for share.
Hello. I really like your project. Does the Quadcopter have enough lift to get for example a camera / gopro in the air? Which ways can you mount a camera like a gopro or a camera for fpv funcionality? Whats the flight time you can get with the battery? And the last question: Whats the weight of the drone? Thank you very much in advance.
Joop Brokking okay thank you a lot. So you are basically saying that it can't lift a GoPro and a gimbal? Stronger motors will fix the problem, won't they?
Is there any difference your altitude holding technique and beta flight ? I am just asking, I don't know what are the techniques used by the other stable drones and commercial versions, like DJI. Please can you enlighten me Mr. Brokking.
I have no idea what altitude hold techniques other flight controllers are using. I started from scratch and never felt the need to have a "peek" at other software. I just wanted to know if I could make it work for myself so I could share it.
can you please provide 3d design of that which you build in cnc machine. you are doing great work. but please help me. and also can provide the detail connection of how to connect STM and barometer.
I noticed that it was a little windy in the very last video. How did you keep the copter from drifting away in any direction? Some new copters use a downward facing camera to keep them from drifting.
Hi. I have a project. In my project, I designed a four-engine drone. My teacher made it a condition for me to graduate. This condition is that the drone will go down at the desired speed, it will go down at 6 m/s by increasing the pwm according to the height, and I am thinking of doing this task with a pixhawk, which will fix the altitude at 100 meters. Can I change the descent speed continuously by adjusting the pwm according to the altitude? (It will be a fully autonomous system). I would be very happy if you have any suggestions.
Hi....May I know if you have some lessons about the openCV and image processing....I like your codes...They are easy to understand and can be readily implemented without using libraries as you explained them very well......Thank You :)
hi where is the schematic of this case ? i would like to do it with 3d printer can i have measure i will design a .stl file and there s no other way to welded wire on CMS components ?
Hello sir Joop Brokking, really thank you for your wonderful work, I learned a lot from YMFC-AL, which I am currently mastering. I recently developed the YMFC-32 with GPS, normal flight works fine, but I am having difficulty maintaining altitude and position, I have already traveled a wide range of PID values for GPS and altitude. The altitude still works but is not always stable, my real concern is position hold, when I activate it the drone lands on its own, then the propellers stop after 5s. Please answer items.
Hello brooking sir!! I am trying to develop a flight controller by stm32f4 (according to our future requirement)..i have already spent 9 months on it, to only fail..so could we use the same stm32f1 code for stm32f4 (by changing the timer configurations accordinh to stm32f4 add on and necessary pin outs)..and yes how much do i need to change the timer configuration..
Yes, you could use the YMFC-32 code for the F4 as a base. Just make sure that the main program loop is running at 250Hz. But you might want to build it with the F1 first to get familiar with the code and after that transfer it to the F4.
why not use an IR sensor/camera/ultrasonic module instead of this? IR and ultrasonic is unaffected by light changes, you could have ultrasonic for low altitude and IR for above.
I made a quadcopter with P I D method. But even at the best p i d values, it doesnt balance well its position. 2-4 degree vibration. 2-3 vibration per second. What can i do to fix this? ;(
The bmp 180 has a resolution of 30 cm. I dont know, what will happen, but imagine your sensor doesnt recognize, if the Quad dropped 30 cm. It would drop to -30 cm overcompensate to +30 cm and your Quad behaves like a bunny on drugs. (I dont know, if it would really happen, but no, you cant. I had to upgrade my bmp180 for this reason)
Florian Ehrhardt thanks for replying n thanks for sharing your hard amazing hard work step by step with ❤ Actually it's my final year project to design " stable altitude automatic control of a quadcopter" they asked for 1 m altitude with ultrasonic sensor And they said I have to put the pic for roll and pitch as zero is it possible ?
Hi Joop, thanks for the reply. But I meant Altitude Tuning systematically like the one you did with "roll pitch yaw tuning", but I think I will try tickle around for my PID altitude parameters to get the best Alt Hold.
I think he's still developing the flight control system which is lower level essential stuff first. Once that's stable, he could introduce image recognition which would be incredibly awesome. This guy is next-level smart.
I’ve implemented something similar using an STM32, I was taking 20 point averages of a value, after some analysis I realised a 1D Kalman Filter was more responsive, used less processing power and gave a smoother output.
Estimate(new) = Estimate(old) + gain(0.15)*(measurement - estimate(old) ).
Gains around the 0.1-0.3 mark have good smoothing ability without too much lag. Hope that’s useful.
Hello sir, did you take Error band +/-2.5mbar of MS5611 as the measurement uncertainty and around 0.7 as the noise variance for calculating gain?
@@kybousong no error band, I just put the raw pressure data into the formula above with the gain I mentioned and got a smooth response.
@@jamesaddison81 thanks you for your fast response and information, sir.
Nice to see you are further developing the project! I myself got into multicopter because of your DIY projects, both YMFC-AL and -32. My first iteration was with atmega328p using your code, and then, again from you, I discovered stm32 and got me some boards. I was having some flight stability issues, I guess because of the unstable power from the ESCs. But now with a dedicated mosfet I had laying around things are improving! I keep a log of my build on rcgroups if you want to have a giggle at my progress so far.
I never giggle as I always respect others who are building their own quadcopter flight controller. If it was easy everybody could do it :-) Please share the link to your project.
Well I hope this at least puts a slight smile on your face, because it sure does on mine. I very much enjoy this project :D www.rcgroups.com/forums/showthread.php?3086792-Building-my-first-quad-copter-Using-YMFC-AL
Few points:
1. Both the I2C ports of stm32f103 are 5V tolerant, then why to worry about I2C signal levels?
2. Try gy-86 breakout board. It contains mpu6050, ms5611 and hmc5883l all on a single board!
Here's what I do:
1. I request temperature with 1024 osr and pressure with 4096 osr as follows:
-> Setup() - request temperature with 1024 osr
-> loop 0 - read and calculate temperature, request pressure with 4096 osr
-> loop 1 - idle
-> loop 2 - idle
-> loop 3 - read and calculate pressure, request temperature for next loop
After calculating altitude I take average of 16 altitude readings and update baro_updated flag so that pid outputs are calculated only when new averaged data is available. This gives accurate altitude with 62.5Hz refresh rate and 7cm precision.
2. When my throttle reaches hover point, I activate the altitude hold algo. When the throttle is raised I increase the setpoint of altitude hold algo and vice versa so that altitude hold algo is always running and the flight is more stable.
Great video as always :)
Great to read that you found your own method and algorithm. I tried changing the setpoint with the throttle stick but it was lagging as the PID controller needs time to react. And you always want to have the ability to react very fast (for example obstacles). That is why I have chosen this method.
You should try my method and you might see some improvement in altitude precision and response time. As it runs on +/-80Hz.
I kept the I2C signals at 3.3V because I could not find any level shifters in the GPS/Compass module that I use. By using this module you get the compass away from you main wiring. That is why I don't use an all-in-one and you need a GPS anyway.
Joop Brokking
Thank you for your reply sir. All I want to ask was that stm32 has 5V tolerant I2C interface and we can connect ms5611 or any other sensor directly without any problem (just like you did with npu6050 in this video: ua-cam.com/video/ImctYI8hgq4/v-deo.html) so why to worry about I2C signal levels when connecting ms5611..?
Yes, it's better to use magnetometer with a gps since it will be away from other electronics. That's why I use only mpu6050 and ms5611 on the gy-86 module and leave the magnetometer on it unused so that I don't have to use separate modules of mpu6050 and ms5611.
And yeah, your algorithm is a lot more better and precise than mine :)
The STM32 might have 5V tolerant inputs, but the HMC5883L in the GPS module might not have 5V tolerant inputs. As explained I could not find a level shifter so I want to be sure that the HMC5883L stays within it limits.
@@Joop_Brokking
Then why using mpu 6050 i2c lines directly..?
Also, can we use simple resistor voltage dividers on the scl and sda lines for level shifting?
As far as I know the i2c lines are specified open drain. So by switching off the internal pullup resistors at the i2c pins and using external resistors to pull up the i2c lines to 3,3 volts everything should be fine.
What fantastic attention to detail of the sort hopefully turns this project from ‘it worked for me’ to one that should work when people build their own with different motors/ rotors/ ESCs/batteries/bregulators/arometer mounting etc. etcI built a YMFC-AL & modified the code a little. Rock solid stable in flight, but the hardest thing to do when flying was to keep it level. Although changing the throttle response on the RC transmitter helped a lot, I figured adding a barometer to YMFC-AL was doable. It didn’t work & I never worked out why - but there are at least 3 ‘gotchas’ explained in this upload.
I am very excited about this serie.
My dear Joop, thank you so so much for you passion and inspiration of drone and embedded programing. I was one of your big fan when I studied in university. Now I am working on software field in Japan but I can not forget the time I was in love with Arduino and AVR MCU. I think that I will comeback to my truly passion in the future. Thanks so much for your inspiration :)
You are amazing!
There is so much practical info in your videos. Not just theory that only works on paper.
Hey joop...I am a big fan of your project and your knowledge and the way you described the project it just awesome..
This is a great failsafe function. Definitely getting an FC that has an baro on my next built. Those F7 boards are looking mighty-nice 👌
I am happy to see your new video Mr. Joop :)
Excellent video. Thanks a lot for the dedication you put in this project.
Thanks,Mister I study a lot of it from you ,say Thanks from Taiwan.
It s a pleasure to see your videos, thank you for sharing your passion :)
To get rid of the 5V level shifting you can also just desolder the two 5V pull-ups on the clock and data lines (and - if you don't have pull-ups elsewhere - add some new pull-ups to 3.3V). This is a lot easier than trying to solder wires to the 3.3V side.
The MS5611 breakout board has two pull-up resistors to 5V on the board. So you have to remove them. As they are 0603 size it might be easier to just solder the wires.
Great project Joop. Really good ideas n developments there.
Good tutorial! Unfortunately averaging 20 measurements seems like a lot of time with this output data rate. Ive tried median filter with 3 measurements and it gets rid of those annoying spikes aswell. Then Ive used "simple" kalman filter and complementary filter at the end (like you did). Ive noticed very fast response with smooth signal :).
Its recommended to have very smooth and responsive signal for altitude hold. D term of altitude hold algorithm put a lot of stress on battery esc and engines.
Kamil, Do you have an example of your code with kalman and complementary filter? I also feel that averaging 20 pressure readings puts a large lag in the pressure data, so am looking for a different signal filtering method. I've found that by alternating temperature and pressure readings from the 5611, the pressure values are more stable, and you don't get the "repeating spike pattern" Joop talks about in the video. With the averaging method it takes 20 * (3 * 0.004)= 240 msec for the signal to fully respond to a step change. By alternating temp/pressure readings I get a new pressure value every 2 * (3 * 0.004)= 24 msec, and I can apply a filter to that signal and likely still have faster response than 240 msec.
Wow finally you decided to share it with us. Thanks for all your efforts
Great job, and easy to follow. Thank you again
You could use lidar sensor with accelerometer (which you already have onboard) to get altitude when you're in horizontal position in x and y and use altimeter for getting altitudes beyond the lidar range.
In the future GPS data will be more and more accurate. With a really good GPS receiver you only need a barometer and a GPS.
nice job bro. i always new videos from you. thanks
Thank you! It's very interesting, can't wait to repeat it by myself.
Hi Mr. Brokking
why when I enable alt hold quad fly up?
hover throttle about +/- 1500 and I guarantee barometer reading is good
Nice job! Very clear explanation!
Joop, In this video @ 2:12 you use a PCB. Any plans to publish the scheme and design? Or did I miss it?
Great work, I would like to know more on that telemetry system. Looks interesting.
That will be the subject of the next video.
Thanks joob, excellent work, I really appreciate the effort that you put on, GREAT
Dude you are awesome. I will use your technique in share market also. For scalping
Hello, Why did you use a pressure sensor instead of using the altitude value from the gps when implememting altitude hold? Is it because the gps altitude value is not too accurate or there is another reason? Thanks in advance.
Ill go ahead and reply for him as this video is quite old. GPS height is very very inaccurate and slow compared to GPS position or the barometer altitude.
excellent contribution, I have been following your projects for a while now and I have decided to replicate your YMFC autonomus project. One question, is there any way to get the PCB that appears in the videos?
Is there a way to buy it?
Sincerely
jose
@Joop Brokking I dont know if you still read the comments, but I am building the YMFC-32 at the moment. In one of yor videos you showed the telemetry of the copter on a notebook an there was a max altitude set. I dont have found this in the code you have published. Is there any way to limit the height it can fly? In my country a restriction of 100m is given and I want to add this in the software.
I use arduino ONU and I make a quad like your ymsc-AL (see your video) how can I add attitude hold to my ymsc-Al..
Ymsc3d is very costly for me...
Please tell?
interesting, thanks. just curious, at the end when you are flying, on the right, is that the highest mountain in Holland?
Thanks my frinds, so good work fantastic arduino profec man.
Dear Joop, thanks again for this informative video. Doesn't the MS5611 have a read out of "uncompensated" pressure data? Because your FC is merely interested in changes of pressure and temperature is considered mostly stable, one probably can neglect the temperature reading and calculation. Just using the raw values ...
Hello,
In the complementary filter, does the coefficient value should always add up to 1?
Hello Mr .Brokking .
i have seen u r video on ms5611 , in the video u are explain 25 ms to acquire the ms5611 data . i had developed ms5611 code where i use my one loop as count each loop is 2ms , once it reaches 10 i acquire the data and it works well .I just want to know why this extra 5 ms u had used in u r code . i have seen u had made a black container to over come the light sensitivity of ms5611 , i have used a black tape ( not touching the sensor) but i see a drift in the altitude over a period of time . do the black tape cause the drift ? or drifting the air pressure is normal for me i( the diff is around 2 meter in 30 minuts ). can you share ur experience. thanks in advance .
Hi, can I use the MS5611 barometer on the stm32 the controller board (PCB) and by covering all the flight controller with a special case?
Hello sir.
You wrote about getting the temperature of Barometer.
"After that we can poll the pressure data and immediately request the temperature. And again we need to wait for 2 loops before the temperature data becomes available."
Why not using the temperature value from gyro, which created in every loop.
Awesome!
I have one notice:
Why not to activate altitude-hold when throttle became stabilized? I mean when difference in throttle is about some value of error?
In your case I have to remember to center stick every time.
In my case it'll calculate altitude for any value of throttle
The throttle stick has a small dead band when altitude hold is activated. So you don't have to exactly remember the center position. As explained at startup the hover throttle is registered with the accelerometers and the stick is automatically centered as hover throttle.
Hey Joop, as a hobbyist, recently I have been following your videos, instructions and have successfully flown auto leveling drone. Your simple and yet effective way of explaining fundamentals is amazing! After auto level, I am now trying out the altitude control. Here I have trouble working with MS5611. To experiment, I have taken snippet of your code to play with MS5611. My code reads very high raw temperature & pressure values, almost like full scale. Any suggestion what could be the issue? Could the daylight be interfering with MS5611 (i did putting the breakout in a closed box). Or could the light from LED on the GY-63 breakout interfere with pressure reading?
my code
#include
//-----------global variables
byteMS5611_address = 0x77;
byte start, error;
uint16_t C[7];
int64_t OFF, OFF_C2, SENS, SENS_C1;
int32_t dT;
uint32_t raw_pressure, raw_temperature;
float actual_pressure;
int32_t P, actual_temperature;
//----------setup()
void setup() {
Wire.begin();
Serial.begin(57600);
delay(350);
Serial.println(F("testing barometer"));
error = 0; // reset all
raw_temperature = 0;
raw_pressure = 0;
actual_pressure = 0;
actual_temperature = 0;
Wire.beginTransmission(MS5611_address);
Wire.write(0x1E); // reset 5611
delay(350);
//Check if the MS5611 is responding.
Wire.beginTransmission(MS5611_address);
error = Wire.endTransmission();
if (error != 0) {
Serial.print("MS5611 is not responding on address: ");
while(1); // just freeze here
}
// get the 6 calibration values from the MS5611
for (start = 1; start
in the datasheet you can find normal/example values. You can check them with your own values. The led will not influence the pressure sensor.
Thanks for the quick reply Joop. I seem to have narrowed down the problem. I get better temperature value when i make the following change to my code
this instruction results in absolutely wrong reading -->
program #1
raw_temperature = Wire.read()
Thanks for sharing this filtering method, I may just try something like that myself. Out of interest, would 2048 not have been sufficient resolution?
Probably not. You need at least one loop after the request as the maximum conversion time is 4.54ms.
Hello, and thanks again for this wonderful fun and educational project.
I am however confused regarding the need to power the MS5611 breakout board with 3.3 V.
As far as I understand, the I2C pins used on the STM32 (B10/B11 - RX3.TX3) are tolerant to 5V. And indeed both the HMC5883L and the MPU6050 are power with 5V and connected to the same I2C line.
Since both the MS5611 board and the STM32 pins accept 5V, why should we power the MS5611 board with 3.3V ?
Thanks for any information.
B10/B11 are not 5V tolerant when they are used for I2C. Both HMC5883L and MPU6050 output 3.3V even with 5V input. They do not have a step up converter for the SCL and SDA lines. Hence they can directly to connected to 5V input and SDA SCL pins directly to B10 and B11. MS5611 has a step up converter which steps up the 3.3V to 5V on SDA/SCL. This will kill the I2C bus on STM32 (know this by experience :) ).
@@askant101 bro, acturally, acouding to the datasheet, B10/B11 both are 5V tolerant.
Nice project and excellent explanation of how works this system for hold altitud, i want suggest in the future if possible can you explaint how works a code of ESC controller without sensors, i see many tries in UA-cam but not work good, thanks for share.
Building my own ESC is not my priority. Maybe in the future, but no guaranty.
Thanks you
Hey Joop, I always wondered how you graph the data with the arduino software(not excel) because I want to see a live feed of sensor data.
You can use the Serial Plotter. It is like the serial Monitor, only output graphs. Open it with strg + shift + l or Sketch -> tools -> Serial Plotter
Hello. I really like your project. Does the Quadcopter have enough lift to get for example a camera / gopro in the air? Which ways can you mount a camera like a gopro or a camera for fpv funcionality? Whats the flight time you can get with the battery?
And the last question: Whats the weight of the drone?
Thank you very much in advance.
Weight of the drone that I use is around 770gram without battery. It can lift a Gopro without gimbal.
Battery depends on how aggressive you fly, the wind etc.
Joop Brokking okay thank you a lot. So you are basically saying that it can't lift a GoPro and a gimbal? Stronger motors will fix the problem, won't they?
Is there any difference your altitude holding technique and beta flight ? I am just asking, I don't know what are the techniques used by the other stable drones and commercial versions, like DJI. Please can you enlighten me Mr. Brokking.
I have no idea what altitude hold techniques other flight controllers are using. I started from scratch and never felt the need to have a "peek" at other software. I just wanted to know if I could make it work for myself so I could share it.
can you please provide 3d design of that which you build in cnc machine.
you are doing great work. but please help me.
and also can provide the detail connection of how to connect STM and barometer.
I noticed that it was a little windy in the very last video. How did you keep the copter from drifting away in any direction? Some new copters use a downward facing camera to keep them from drifting.
Isidro Murillo GPS if I’m not mistaken
In this video I corrected it manually for wind drift.
How can I add servos or a 12v moter to this ?
have you thought about trying your codes on a Multiwii flight controller, your videos are very inspirational.
May I ask a question? ! Do you calculate PID altitude in every loop ( 4 microseconds ), or every time the actual_pressure is updated?
you update date PID when barometer_counter == 3, don't u ?
The PID is calculated when new pressure data is available.
Can ultrasonic module be used for the purpose of altitude hold
Only for the first few meters. Above that you need the pressure sensor.
Another great work Thanks
Can we connect resistors to the pins of the MS-5611 to step down 5v to 3.3v
Hi. I have a project. In my project, I designed a four-engine drone. My teacher made it a condition for me to graduate. This condition is that the drone will go down at the desired speed, it will go down at 6 m/s by increasing the pwm according to the height, and I am thinking of doing this task with a pixhawk, which will fix the altitude at 100 meters. Can I change the descent speed continuously by adjusting the pwm according to the altitude? (It will be a fully autonomous system). I would be very happy if you have any suggestions.
Great work Joop !!!
Can I modify and use this code on YMFC-AL (with. Arduino Mega) + GY-BMP280 Sensor ?
Yes, it might be possible for the Arduino Mega to handle this code.
Dear Sir, Brokking. What about Arduino Uno? Can it be handle the code when I modify on YMFC-AL with Arduino UNO? Regards.
Hi....May I know if you have some lessons about the openCV and image processing....I like your codes...They are easy to understand and can be readily implemented without using libraries as you explained them very well......Thank You :)
Is the VCC of the ms5611 connected to 5V or to 3.3V?
hi where is the schematic of this case ? i would like to do it with 3d printer can i have measure i will design a .stl file and there s no other way to welded wire on CMS components ?
Hello sir
Joop Brokking, really thank you for your wonderful work, I learned a lot from YMFC-AL, which I am currently mastering. I recently developed the YMFC-32 with GPS, normal flight works fine, but I am having difficulty maintaining altitude and position, I have already traveled a wide range of PID values for GPS and altitude. The altitude still works but is not always stable, my real concern is position hold, when I activate it the drone lands on its own, then the propellers stop after 5s. Please answer items.
You need to check sensors (pressure) and GPS signals values. The PID algorithm of Joop is very good but need some tolerance in some cases.
@@guywatcho1641 How exactly please? Currently I have been able to perform altitude hold, but position hold is really catastrophic.
Only this code can be used with any flight controller?
Sir, is it possible to use brush motor with same code in arduino ??
Sir can i use chaper version of barometric pressure sensor
Great !!! I want to be like you. Thanks!
Hello brooking sir!! I am trying to develop a flight controller by stm32f4 (according to our future requirement)..i have already spent 9 months on it, to only fail..so could we use the same stm32f1 code for stm32f4 (by changing the timer configurations accordinh to stm32f4 add on and necessary pin outs)..and yes how much do i need to change the timer configuration..
Yes, you could use the YMFC-32 code for the F4 as a base. Just make sure that the main program loop is running at 250Hz. But you might want to build it with the F1 first to get familiar with the code and after that transfer it to the F4.
Thank you sir ,I had already started with the F1,
I face problems on getting a Wire.h library for the F4 board.
Sir I am not able to access the content in the website sir.
It says 404 ERROR
what to be done
Please reply
I am having the same problem. Could you fix this and reupload your schematics and code?
@@yourileenman8403 What is the problem? I cannot recreate, check it now.
We have to come together and help each other , we are on our one the matrix don't want us to have this intelligence...
i really enjoy watching your video's ! but i would really like you to explain this to a flat erather :))
very good work , thanksfor the share
nice complicated job !
great effort, good representatio brother.
please make RC control with LoRa sx1276/1278 Module with arduino.
Thank you. Appreciate it very much
Finally come!
why not use an IR sensor/camera/ultrasonic module instead of this? IR and ultrasonic is unaffected by light changes, you could have ultrasonic for low altitude and IR for above.
Even I have the same doubt. Do let me know if you got the answer.
Why can't you use timer interrupt to get data from pressure sensor ? Or does the sensor itself offers some interrupt??
It has a fixed maximum time that I used. Using an interrupt is possible but not necessary in this case.
Can I purchase the MS5611 case from you?
Unfortunately not.
@@Joop_Brokking Nae bother, ill have something along the same lines printed. Thanks anyway.
MS5611 - How many meter can hold altitude?. It can hold in the 30 or 40 to 100 meter?.
The air pressure changes almost linear the first few km or so. This means that it will work up to 1km without any problem.
@@Joop_Brokking thank you.
Amazing job
I made a quadcopter with P I D method. But even at the best p i d values, it doesnt balance well its position. 2-4 degree vibration. 2-3 vibration per second. What can i do to fix this? ;(
Make sure you calibrate the gyro before you use the gyro values.
can you calculate average time of 1 mesure of altitude ?
Can I use an bmp180 or BMP 280 instead of 5611
The bmp 180 has a resolution of 30 cm. I dont know, what will happen, but imagine your sensor doesnt recognize, if the Quad dropped 30 cm. It would drop to -30 cm overcompensate to +30 cm and your Quad behaves like a bunny on drugs. (I dont know, if it would really happen, but no, you cant. I had to upgrade my bmp180 for this reason)
Hello sir I am Sourav. Sir can I use arduino uno or mini instead of Stm32
No
Check: ua-cam.com/video/dWnF3sAvONM/v-deo.htmlm52s
so smart, fantastic
can i use one battery only for arduino and the other only for motors?
Yes but you need to ground them together
if im using ultrasonic sensor instead of the barometer how do i change the code ?
what im usuing for this
Arduino uno
Ultrasonic sensor HC-SR04
Gyro MPU 6050
and blutooth model
still facing issues in writing the code
Florian Ehrhardt thanks for replying n thanks for sharing your hard amazing hard work step by step with ❤
Actually it's my final year project to design " stable altitude automatic control of a quadcopter" they asked for 1 m altitude with ultrasonic sensor
And they said I have to put the pic for roll and pitch as zero is it possible ?
did you make any progress in altitude hold with ultrasonic? I'm also doing the same thing.
Error 2 - Program loop exceeded what should i do?
Me too. I have same problem.
@@aldiriswandi4655 my problem was the gps model with the same model number
@@shehabmansoor4693 Is your drone operating normally now?
@@aldiriswandi4655 it did a long time ago, it's not with me anymore
@@shehabmansoor4693 how to make sure that problem is caused by gps module ...?
Sir i want to know when yiu will release code
End of September is my goal.
Good job.
Thank you.
How about PID Altitude Tuning?
You can easily test various settings with the setup method:
ua-cam.com/video/ys-YpOaA2ME/v-deo.html
Hi Joop, thanks for the reply. But I meant Altitude Tuning systematically like the one you did with "roll pitch yaw tuning", but I think I will try tickle around for my PID altitude parameters to get the best Alt Hold.
Thumbs up.
GREAT!
👍👍👍👍
uint8_t max numbers of likes
Make a ai for camera to detect people and use it in drone
I think he's still developing the flight control system which is lower level essential stuff first. Once that's stable, he could introduce image recognition which would be incredibly awesome. This guy is next-level smart.
now just one more to go gps hold
Don't forget the compass ;-)