For my Control Station project, I also started writing a bunch of decoding function for the FrSky telemetry protocol.

I have now moved those functions into their own library for Arduino. My focus while writing and expanding this library is on ease of use. There is already Arduino code available but I found that a bit complicated to integrate. With the new library, all the user needs to do, is read one char from the serial port and send it to the library via the ::update method. All the decoding is done internally. The ::update method returns 1 when a complete packet was received, otherwise it returns 0. There is (will be) a dedicated method to access every parameter. I'll also try to keep up the detailled documentation.

At the moment, the library decodes only the basic information, RX A1 & A2 ports, uplink and downlink RSSI. Additional sensors will be included as I receive the hardware (which hopefully is soon).

Find the library at GitHub.

Example use (on MEGA 2560):

#include <frsky.h>
FrSky frsky;
void setup() {
Serial.begin(9600);
Serial2.begin(9600);
}
void loop() {
if (Serial2.available()) {
char c = Serial2.read();
if (frsky.update(c)) {
Serial.print("TX RSSI: ");
Serial.println(frsky.getLink_up());
Serial.print("Telemetry RSSI: ");
Serial.println(frsky.getLink_dn());
Serial.print("RX Voltage: ");
Serial.println(frsky.getRX_a1()*0.0517647058824);
Serial.print("A2 Voltage: ");
Serial.println(frsky.getRX_a2()*0.0129411764706);
}
}
}

Views: 1670


Developer
Comment by R_Lefebvre on February 23, 2013 at 1:10pm

Great!  I'll have a look and maybe use it in my project.

Did you have a look at the Open9X code when doing this, and didn't think it was good enough?

Comment by Stefan Gofferje on February 23, 2013 at 1:22pm

No, I didn't :). I had a quick look at a few other sources I found on Google. I decided to write it myself, because I'm really rusty in C++ (learning-by-doing-principle) and I wanted something that I understand because then everybody should be able to understand it :).

Comment by Ellison Chan on February 23, 2013 at 1:59pm

Didn't know you can connect to a frsky module.  What's the link used?

Comment by Stefan Gofferje on February 23, 2013 at 2:04pm

You mean the connection between the TX module and the Arduino? That's a serial link at RS232-levels. So you will need a level-shifter.


Developer
Comment by Andrew Tridgell on February 23, 2013 at 2:09pm

Unfortunately the FrSky telemetry can interfere badly with GPS reception. I use FrSky R/C, but I always disable the FrSky telemetry as I had some bad experiences with losing GPS lock many times per flight when it was enabled.

If you do enable it then make sure your receiver is as far from your GPS as possible.

Cheers, Tridge

Comment by Stefan Gofferje on February 23, 2013 at 2:22pm

Really? With what GPS-module? I have a test setup for development of my ground station project on my desk. Inside, 1.5m from the window and the cockroach-whiskers of the receiver are about 4-5cms from the GPS module (UBlox 5)... I get 3D-fixes with 6-8 satellites.

However, the Hobby King wing camera totally kills the GPS reception when it's within 5-10cm of the antenna, even outside under the sky...

Comment by Ellison Chan on February 23, 2013 at 2:28pm

Which port on the receiver is the serial link?  Do you have a diagram?


Developer
Comment by R_Lefebvre on February 23, 2013 at 2:30pm

Stefan, I have read a post which showed that the FrSky Rx, and probably the Tx, use a 232 chip to do the level shift internally.  So it's actually possible to make the comms link without buying another Max232.  Some creative soldering you can bypass the internal 232 and go direct.

I also haven't seen much problem using FrSky telemetry with GPS.  It's a valid warning, but I haven't seen a problem yet.  Well, I had a problem with APM2.0 All-in-One with the short little wire *directly* over the GPS chip.  But other than that, no.

Comment by Stefan Gofferje on February 23, 2013 at 2:44pm

Ellison: Not the receiver. The transmitter module receives telemetry from the receiver. So if you want to decode telemetry, you connect your Arduino to the serial port of the transmitter module. The serial port is the 4-pin connector and the pinout is printed on the label.

Robert: True on the creative soldering, but I usually prefer not to solder inside RF-components :). A level shifter is very cheap on eBay (e.g. http://www.ebay.com/itm/261070156589) and easy to use. Besides my personal preference, it's also illegal in some countries to modify commercial (and approved/certified) RF-devices if you do not hold either a radio-amateur license or are a certified repair-technician.

Comment by Ellison Chan on February 23, 2013 at 2:48pm

Duh, had my FrSky for a few months, and didn't even notice it.  But, I'm old and need reading glasses, so these things don't pop out at me anymore.  Thanks Stefan! This is very useful.

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service