I just started a project to make a drone without a radio controller. I want to control 4 brushless motors connected to a flight controller KK 2.1.5 using Rpi 3 B+. Obviously, the motors are first connected to the separate ESCs and then to the flight controller. What I am not getting is how can I control each motor separately? I would appreciate any help. Thank you.
-
\$\begingroup\$ "... the motors are first connected to the ESC ..." Are you trying to get independent control of four motors connected to the one ESC? Hit the edit link under your question. Ask a specific question or it will likely be closed as "too broad". \$\endgroup\$– TransistorCommented Feb 17, 2019 at 15:07
-
\$\begingroup\$ No. Motors connected to separate ESCs and those ESCs are connected to a single flight controller. \$\endgroup\$– SkullnewCommented Feb 17, 2019 at 15:42
-
2\$\begingroup\$ Using a pi as a flight controller is a very bad idea. Use a traditional MCU based flight controller to do the flying, either an existing one or something along similar lines. If an embedded Linux system is going to be involved (but still not a pi, which is far too flaky for this) it should decide where to go, but leave the actual flying to a simple, robust, realtime MCU, which means the linux system does not control the motors, the flight controller's MCU does in response to commands of intent (like "we want to go thattaway") from the Linux side. \$\endgroup\$– Chris StrattonCommented Feb 17, 2019 at 15:50
1 Answer
It seems that the KK 2.1.5 flight controller has four separate, "old fashioned" PPM inputs, while most modern controller use a serial link with the receiver, such as DBUS.
Your best bet would be to first implement a way for the raspi to generate the four PPM signals. This can surely be done with a ton of different, already written and proven libraries. Your interface would then just be a file, where you write the value you want the PPM signal to go to, and this can be done with pretty much anything you want on the raspi.
So basically your program on the raspberry would not run the control loop, that stays on the FC, but just some sort of autopilot, high level control loop, that would send just "wanted attitudes" to the FC, pretty much like you would do with a standard TX/RX setup.
disclaimer: bear in mind that the raspberry pi is not a real time system. This can lead to a number of problems, inherent to the system you want to setup, on top of the "normal" problems like software bugs, or hardware failures.
It is your primary responsability to make sure your system is safe for you, for others, and for everything that is around you. Also, make sure to adhere to your local regulations about UAVs.