How to get an output from UNO to communicate with KK2.1 flight controller

Hi all,

I'm working on a quadcopter project. In that project i need autonomous quad. I read most of tutorials about how to make quad but most of them are using remote controller and some of them using arduino to control motors directly, but i need my UNO to communicate with kk2.1 flight controller. Unfortunately, i am in the limit of my budget, so i cannot buy anything more. (I know if i get an accelerometer i can program my own flight controller with the help of UNO, but i don't want to and my project description doesn't let me to do) Here is the list all i have:

4 X motors&propellers
4 X ESC
1 KK2.1 Flight Controller
1 Arduino UNO
1 LİPO battery
1 HMC5883 magnetometer

I can get data from magnetometer, and with PID controller i can try to make my quad stand still in the air (i have enough knowledge to do these), in a certain altitude (in the future i will buy barometer). But the problem is that i don't know how to communicate with that flight controller. In most of tutorials they are connecting reciever to flight controller, so i thought if i create RC-like output, i can connect arduino UNO to my flight controller. How can i create an output that KK2.1 flight controller can understand the signal or how can i create RC-like output signal?

Hi polatbilek,

An RC receiver generates PWM pulses on each of its channels at 50Hz. In general the pulse width is usually between 1ms (1000us) and 2ms (2000us), although in practice many ESCs expect a signal between 1100us and 1900us.

To do this on the Uno, it might be possible to use the servo library.

However, you'll also have to design for ESC calibration, (it goes without saying always remove your propellers during ESC calibration), so that your ESCs know the minimum and maximum signal. There's also the issue of generating the KK2.1 arming and disarming sequence.

Alternatively, the KK2.1 is also able to accept data on its serial port (throttle pin) from a DSM2/DSMX satellite RC receiver, (should be called auxiliary, as it has nothing to do with satellites). If you mimic the satellite receiver's protocol you could transfer control data to the KK2 board this way. Here are some links:

http://www.desertrc.com/spektrum_protocol.htm

...and the protocol from Spektrum:

https://www.spektrumrc.com/ProdInfo/Files/Remote%20Receiver%20Interfacing%20Rev%20A.pdf

MartinL:
Hi polatbilek,

An RC receiver generates PWM pulses on each of its channels at 50Hz. In general the pulse width is usually between 1ms (1000us) and 2ms (2000us), although in practice many ESCs expect a signal between 1100us and 1900us.

To do this on the Uno, it might be possible to use the servo library.

However, you'll also have to design for ESC calibration, (it goes without saying always remove your propellers during ESC calibration), so that your ESCs know the minimum and maximum signal. There's also the issue of generating the KK2.1 arming and disarming sequence.

Alternatively, the KK2.1 is also able to accept data on its serial port (throttle pin) from a DSM2/DSMX satellite RC receiver, (should be called auxiliary, as it has nothing to do with satellites). If you mimic the satellite receiver's protocol you could transfer control data to the KK2 board this way. Here are some links:

Desert RC - Interfacing to Spektrum Remote Receivers

...and the protocol from Spektrum:

https://www.spektrumrc.com/ProdInfo/Files/Remote%20Receiver%20Interfacing%20Rev%20A.pdf

First of all, thanks for helping.

I thought i can manipulate PWM signal to make it look like RC reciever's output, but now i think i don't have enough patience to do it (looks like this method needs lost of corrections for pulse width and frequency). I think, Spektrum is good idea. But how can i mimic the protocol? Is there any library to do this kind of thing? Or will i do that pwm signal adjustments for that method also? If there is no library to help me, complexity of creating DSM2/DSMX signal is as same as creating RC reciever's output i think.

But how can i mimic the protocol? Is there any library to do this kind of thing?

You'll need to create a structure in C, that matches the data packet: Header, Channel 1, Channel 5, Channel 4 etc..., fill it with your data, then create a function that transmits it in bytes using Serial.write().

Whichever way you approach it, it's going to be a tough project.

If you're looking to make your own flight controller with an Arduino Uno, then Joop Brokking has an excellent series of videos on Youtube, (including links to source code). It covers both rate mode and auto-level. It might be easier to go down this route, rather than to attempt to control an existing KK2 board.

There's also "BlueCopter - Arduino Quadcopter" project that uses an Arduino Pro Mini here: BlueCopter - Arduino Quadcopter - Exhibition / Gallery - Arduino Forum

It is very easy to communicate to the KK2 board with an Arduino. All you have to do is give it a PWM signal for throttle, pitch, yaw, and roll. Basically, lookup how to control a servo with the Arduino. Next, remove the servo and connect that to an input to the KK2. The flight controller will now get your PWM signal.

Altitude hold can get tricky. I am using ultra sonic sensor for altitude hold.

I have done it. Check out the video. Source code will be available in a few weeks. I'm still working on position hold.