Terms of service
Brokking
 
 
.net
Let's keep it simple
 

 
   Home
   Projects
 

   Articles
 

   Donation
         
 
 
 
 

 
Brokking.net - Video: YMFC-32 | Part 4 | a DIY 32-bit STM32 and Arduino based quadcopter flight controller

YMFC-32 | Part 4 | a DIY 32-bit STM32 and Arduino based quadcopter flight controller

This page contains the full script that I used for making this video.

This is the YMFC-32 quadcopter that I have developed during my last videos.

In the previous video I explained how to build the hardware and how to setup the transmitter. In this video I will explain how to balance the propellers by using the setup program and how to prepare and test the quadcopter for the first flight.

If this is the first YMFC-32 video that you are watching I recommend to check out the YMFC-32 playlist that you can find in the description. This will help you to better understand the workings of the YMFC-32.

Please note that you can find a detailed build tutorial on my website. The link is also in the description.

So let's start by balancing the propellers.

Balancing the propellers is very important because vibrations will make the gyro produce unnecessary noise. Small movements are not registered correctly and the quadcopter performance is poor. So please take your time to balance the propellers correctly.

With the setup program loaded into the STM32 and the USB cable connected you can open the serial monitor at 57.6kbps. Switch on the transmitter with the throttle stick in the lowest position and make sure it binds to the receiver.

Depending on the ESC's that you are using you might hear a weak beeping from the motors. This is the 5V from the USB cable powering the ESC's.

Please be aware that after connecting the flight battery the motors are active. This is because the setup program can be used for calibrating the ESC's. So don't move the throttle stick when the flight battery is connected.

And after this warning it's time to connect the flight battery and press the reset button with the boot jumper in the zero position.

This menu should now appear on the screen. And as you can see there is a warning that the motors are active.

When you send a 1 via the serial monitor the first motor, that is the right front motor, can be controlled with the throttle stick on the transmitter. The rest of the motors are disarmed.

Hold the motor mount firmly in your hand and increase the throttle to half way. This should be the hover throttle point.

Remember the numbers on the screen that indicate the amount of vibrations. Also feel the vibrations with your hand and stop the motor.

Now place a small piece of tape on one of the propeller blades. I use insulation tape for this as it is heavier than normal tape and it can easily be removed.

Repeat the vibration test and check if the vibrations are getting worse. If the vibrations are getting worse you should try the other propeller blade. If the vibrations are getting less you might try to add extra tape.

Keep repeating this process until you get minimal vibrations. As already mentioned this is a very important step so please take your time to get it right.

Ok, after all the props are balanced you can disconnect the flight battery.

Next thing on the to-do list is calibrating the accelerometer so the IMU knows when the quadcopter is level.

Before calibration I disconnected the ESC that provides power to the board. This way I don't have the soft beeping sound from the motors.

For calibration you need to place the quadcopter on a spirit level surface. This will be the level position that the quadcopter will try to maintain when the sticks are released.

Run the setup program and send an h. After this the gyro and accelerometer are calibrated. Please don't move the quadcopter during calibration.

When finished the calibration values are printed on the serial monitor as you can see here. These values are just an examples and will be different for your own MPU-6050.

Next step is to copy these values from the serial monitor into these lines that you can find in the setup program and in the flight controller program.

And basically that's it. Except for this line: use_manual_calibration. This variable is set to false by default. Meaning that these manual gyro calibration values are not used and the gyro is calibrated automatically at startup.

This true or false variable is only used for the gyro calibration. The accelerometer calibration values are always used.

So, on startup and with the use_manual_calibration variable set to false the red LED will flash for 5 seconds as a delay indication. After that the gyro is calibrated. This is indicated by a fast flashing of the red LED. During this calibration the quadcopter should not be moved.

When the calibration is done the green LED turns on indicating that the quadcopter is ready to fly.

When I change the use_manual_calibration variable to true the manual gyro calibration values are used and the automatic gyro calibration is skipped. When the flight battery is connected the green LED turns on immediately and the quadcopter is ready to fly.

Ok, here's the catch. The gyro calibration values will change with temperature as you can see in this diagram.

In short when I calibrate the gyro indoors these values are given by the setup program. When I fly the YMFC-32 outdoors in winter time these values should be used. And as you can see there is a different of 45 points on the roll axis.

When we have a look in the datasheet we can see that an output of 65.5 represents 1 degree per second. This is because the YMFC-32 uses a full-scale range of 500 degree per second.

With the output difference of 45 between 19.6 and 2.6 degrees Celsius the gyro outputs a constant .7 degree per second drift. Most of this drift will be compensated by the accelerometer. However, the quadcopter is drifting more than necessary.

So, please keep in mind that, when you use the manual calibration values you need to make sure that the temperature changes between flight and calibration are not too large. Other than that it should work fine.

My personal choice is to set the use_manual_calibration to false and use the automated gyro calibration before every flight.

Now, re-upload the setup program with the correct calibration values and send an e to check the IMU angles.

Nose up should give a positive pitch angle and nose down must result in a negative pitch angle.

Left wing up should give a positive roll angle and left wing down results in a negative roll angle.

The yaw value is gyro based only. So no movement should result in a zero. Nose right will give a positive value and nose left a negative value.

And now it's time to upload the YMFC-32 flight controller program. And make sure to set the calibration values. When the flight controller program is loaded into the STM32 make sure that the boot jumper is in the off position again.

This will be the first time that the quadcopter is tested. So please be careful and never try to fly it without proper testing.

First step is to test the starting and stopping of the motors. Switch on the transmitter and connect the battery. Leave the battery next to the quadcopter so you can disconnect it when something is wrong. Push the quadcopter to the ground and wait for the calibration sequence to finish.

If the red LED starts to flash during startup or during flight you can check the LED codes on my website. As you can see, every flash sequence represents a different error.

Start the motors by yawing left with the throttle is in the lowest position. The motors should now start at the same speed. Immediately after start stop the motors by yawing right with the throttle in the lowest position. The motors should now stop. Repeat this process a couple of times so you get familiar with the start and stop procedure.

When you keep the motors running for a longer period some motors will start increase their rpm. This is normal because the flight controller tries to level the quadcopter.

When this is working fine it's time for the next step. Hold the quadcopter firmly in your hand and start the motors. increase the throttle slowly up to the point it feels weightless. During this process the quadcopter should try to level itself. If this is not the case you need to recheck the setup procedure. Also make sure that all the connections are soldered reliable.

With the quadcopter still firmly in your hand you can now start to test the controls. The quadcopter should follow the stick movements without any glitches.

After this test it's time to carefully test the quadcopter. If you have never flown a quadcopter before I highly recommend this little fella. It has the same control principle as the YMFC-32 but without the destructive energy. So you can safely fly this thing indoors and practice your skills before flying the YMFC-32. You can find the link in the description where I bought it.

Please, don't fly the YMFC-32 quadcopter indoor. Always test your quadcopter above grass and keep it as low as possible during the first couple of test flights.

When you use the same hardware as shown on my website the quadcopter should fly with the stock settings. If you use other hardware is might be necessary to adjust the PID values. These values can be found in the top section of the flight controller program.

For more information about quadcopter PID settings I recommend you to watch this video that I made earlier for the Arduino based YMFC-3D and AL quadcopter.

And that brings us to the end of this video. I hope that this project will help others to build their own 32-bit quadcopter flight controller. If you have any questions please visit my website where you can find detailed information about the YMFC-32.

Thank you for watching and see you next time.