I just bought an FrSky Taranis for my quad copter and needed to get the Mavlink data up on the Taranis LCD telemetry display. So here is my solution using a Teensy3.1 as a converter between MavLink and the S.Port on FrSky X8R.
See attached file below...
Come on guys !!!
This also works with a ATmega 328P
There is absolutely no need to waste a MK20DX256VLH7 !!!
push ! Where is the GPS issue ???
static float osd_lat = 0; // latidude
static float osd_lon = 0; // longitude
Here goes the version 0.1 of my telemetry script for Taranis X9D for APM/PixHawk Flight Controllers.
The interface between the APM/PixHawk and the FrSky X series receiver is a small Teensy 3.1 board running a custom protocol translator from Mavlink to SPort telemetry.
Almost all the parameters on the normal telemetry screens of the Taranis X9D are correct, with some exceptions (RPM and T2), that combine multiple values on a single field.
Cell ( Voltage of Cell=Cells/(Number of cells). [V])
Cells ( Voltage from LiPo [V] )
A2 ( HDOP value * 25 - 8 bit resolution)
A3 ( Roll angle from -Pi to +Pi radians, converted to a value between 0 and 1024)
A4 ( Pitch angle from -Pi/2 to +Pi/2 radians, converted to a value between 0 and 1024)
Alt ( Altitude from baro. [m] )
GAlt ( Altitude from GPS [m])
HDG ( Compass heading [deg]) v
Rpm ( Throttle when ARMED [%] *100 + % battery remaining as reported by Mavlink)
VSpd ( Vertical speed [m/s] )
Speed ( Ground speed from GPS, [km/h] )
T1 ( GPS status = ap_sat_visible*10) + ap_fixtype )
T2 ( Armed Status and Mavlink Messages :- 16 bit value: bit 1: armed - bit 2-5: severity +1 (0 means no message - bit 6-15: number representing a specific text)
Vfas ( same as Cells )
Longitud ( Longitud )
Latitud ( Latitud )
Dist ( Will be calculated by FrSky Taranis as the distance from first received lat/long = Home Position )
Fuel ( Current Flight Mode reported by Mavlink )
AccX ( X Axis average vibration m/s?)
AccY ( Y Axis average vibration m/s?)
AccZ ( Z Axis average vibration m/s?)
This telemetry screen tries to report the data received in a easy way.
Due to the restricted screen space I didn't make descriptive labels on the values but tried to group them on a logical (to me) way.
Also, this script relies heavily on voice alerts and prompts.
I use a two switch combination (SWE and SWF) to change flight modes, that gives me the 6 flight modes. The combination of the 2 switches activate six Logical Switches on the Taranis - The Logical Switches MUST be L1 to L6.
I could not find a way to have the Flight Controller report the settings for some parameters, like which 6 Flight Modes are defined so the script must be updated with the Flight Mode Numbers that correspond to each Logical Switch.
But the screen deserves some explanation, so here goes:
A-Current Flight Mode Active as reported by the Flight Controller. If blinking the vehicle is not Armed.
B-Current Flight Mode Timer. Each Flight Mode has its own timer. The timer stops if the vehicle is not Armed.
C-Radio Transmitter Battery Voltage.
E-Estimated Flight Time.
F-Available Vehicle battery capacity.
E and F are inter related. When the vehicle is armed, the script checks the voltage and calculates the number of cells and estimates the status of the vehicle battery. This is then combined with the available capacity reported by the flight controller.
E is calculated based on the rate of decay of reported capacity.
These are highly experimental and not to be considered real, but simple estimates.
G-Actual consumed power in mAh
H-Actual power output in Watts (VxA)
I-Reported Flight Battery Voltage
J-Reported Flight Battery Current
K-Vertical Gauge that shows the actual Throttle output (not the Throttle stick position but the actual output reported by the Flight Controller)
O-Vertical Speed Indicator (up or down)
R-Armed Time Timer - Starts and stops when the Vehicle is armed/disarmed
T-Pitch Indicator. When over 45 degrees the indicator is replaced by 3 up or 3 down indicators
U-GPS Indicator. Three different graphics dependent on GPS status, 3D, 2D or no status
V-HDop indicator. Blinks when over 2
W-Number of reported satellites
X-Distance to home (Distance to the point the Taranis received a good satellite fix)
Y-Heading to home (Heading to the point the Taranis received a good satellite fix)
When changing flight modes the radio says Flight Mode X engaged when the switch is moved and Flight Mode X active when the Flight Controller reports it. If there is a mismatch or the Flight Controller doesn't not report the Flight Mode as set by the switches you'll be notified.
Any questions, please feel free to ask.
There are some minor issues that I must check.
It will be available later on my github
and the entire project:
Thanks to all that are involved in this project, specially Rolf that started it and Christian that picked up and got things rolling :)
first off all: AWESOME work.
I have the Teensy running now and your LUA script shows up nicely.
My flight modes are configured with SG for the 3 positions and SD to toggle between the 2 sets.
SD UP is set 1, !SD UP is set 2
The mix is setup so that it goes through all the modes in sequence of the PPM signal which I mixed to be linear (Stabilize, AltHold, Loiter, Drift, Circle, Auto).
The first 3 work perfectly with voice feedback. The 2nd set is a bit of a problem.
Stabilize -> Drift (SD from UP to !UP) I hear: Stabilize engaged, Drift active and after that a male voice: "Check flight switch missmatch" a few times
Move from Drift to Circle mode and I get: Position hold engaged, Circle mode active and after that a male voice: "Check flight switch missmatch" a few times
Stupid of me.... fixed it myself after I found that the modes have to be defined in the lua script manually to match. So with this the 6 flight modes are working and the above can be ignored :-)
Any suggestion on how I can get this to work?
In addition to that I have RTH on CH7 separately. Once this is pulled I get return to launch followed by the guy again (quite a nag) with "check flight switch mismatch" a few times.
The male guy voice nagging ends after a while :) I also have CH7 set to RTH :)
What happens is this: Return to Home can be set as a flight mode. So if there's a mismatch between what we ask the PixHawk to do (one of the 6 positions set by SD and SG in your case) and what the PixHawk reports the voice warns us of the mismatch between what is set by the switches and the real flight mode.
I created this scheme because if you ask for a GPS assisted mode (say Loiter) and there's no GPS then the PixHawk continues at the previous mode, and I wanted to be warned of this.
Also imagine that for some weird reason you are flying in some mode and there's a glitch on the controller and it switches to RTH or Land although you were flying in other mode.
So whenever there's a mismatch between what we ask the PixHawk to do and what it really does the male voice comes up.
That's the reason it's a male voice, and it nags you. I bet you really pay attention :)
Initially I had it repeating forever :) but then changed the behavior for it to shut up after a few times (the interval gets smaller between warnings)
You can control its behavior at the Flight_switches() function modifying either of these 2 lines:
where the 300 is interval to the first repetition and 5 the number of times the nagging repeats :)
Now it makes a lot of sense. Well thought through and good to know.
Yes, now i will definitely pay attention if he talks :-)
I was almost ready to order a Teensy but seeing this way of displaying the information on the Taranis screen pushed me over the edge, great work. Is this for OpenTX 1.? or will this work with the newer Opentx 2.0 or does it not really matter?
When i use the Telem1.lua on my Taranis i get only a blank screen.
Within the Companion Simulator everything looks fine.
Any ideas how i can working it on Taranis too ?
Do i have to remove the Scripts from the original Mavlink 2 FrSky Projekt APMTelem.lua and ApmSounds.lua from the Scripts/Mixes Folder ?