Recently I wanted to have sensors values from ArduPilot back into FrSky Taranis radio,
mostly to be able to see my quadcopter's current altitude and GPS ground speed.
The goal is to have a nice real time display of telemetry sensors on Taranis LCD screen.
My quadcopter current setup is:
- Flight Controller: HobbyKing APM 2.7
- Running ArduCopter 3.2
- Radio Tx: FrSky Taranis X9D
- Running OpenTx 2.1.8
- Receiver: FrSky X8R (S-Port)
As explained in ArduPilot documentation here, a couple of solution already exists. Basically 2 possibilities:
- Use the native support for FrSky S-Port telemetry built-in ArduCopter.
- Use a hardware converter cable to connect APM with X8R receiver.
Example of converter cables:
- All-in-one cable from Craft and Theory here.
- DIY solution using a TTL-RS232 converter coupled with a SPC cable as explained here.
- DIY solution using an inverting circuit, see here.
- Keep default MavLink ArduCopter telemetry output.
- Use a MavLink to FrSky S-Port converter to connect APM with X8R receiver. Such converter can be made using a Teensy board.
I chose to implement solution 2 because Teensy board is small yet quite powerful and can be extended to support battery voltage and/or current telemetry, or to control on-board LEDs without having to mess up with ArduCopter code running on APM.
This is how the final result looks like on Taranis screen:
And on the quadcopter (top and bottom views):
Step 1: Teensy setup
- configure mavlink stream request for attitude sensors (roll / pitch)
- configure sketch for voltage monitoring
- add a new lua hud (see below)
- fix space bug / bad indentation
Teensy board after soldering (with cable for voltage monitoring, see below):
Step 2: Voltage monitoring
implementation has support for battery cells voltage monitoring up to 12S,
so more than enough for my 3S quadcopter.
As the Teensy board only support 3.3V max on its analog input pins a voltage divider is required to reduce the 12.6V of 3S Lipo battery down to less than 3.3V.
I used the following resistor network to do that (1x 47k, 2x 10k, 2x 4.7k, 1x 1k Ohm):
Where S1, S2, S3 are the pins from LiPo battery balancer plug, and A0, A1, A2 are analog input pins from Teensy board.
Which garanties the following max values for voltage and current:
- A0 Vmax < 0.73 V
- A1 Vmax < 2.68 V
- A2 Vmax < 2.20 V
- S1 Imax < 0.73 mA
- S2 Imax < 0.57 mA
- S3 Imax < 0.22 mA
This is under Teensy voltage limits and generates an acceptable power loss in resistor network.
Voltage divider after soldering and heat-shrink tubing:
Step 3: Taranis HUD
The telemetry display screen on OpenTx can be scripted using Lua5.1.
The Lua script basically calls OpenTx API to get sensor values and
then calls drawing primitives to show values on screen.
For documentation on OpenTx Lua scripting, check documentation here.
I tried some of the existing huds but was not satistied with the result. Default hud from MavLink_FrSkySPort is quite bad looking and has no artificial horizon, and also takes too much space displaying current/amps related telemetry data which is not relevant for me as I do not have any current sensor on-board.
Probably the best hud is the one from Craft and Theory here but costs around $15.
I ended up coding my own hud for OpenTx to get a custom display.
One problem, memory is quite limited on Taranis so I had to reduce the size of my Lua script.
I did a first pass with a custom python script to remove Lua local variables used as constants.
And a second pass with LuaSrcDiet.
(git s-c-l-v-rc-opentx2.1)$ cd scripts/luastrip/ (git s-c-l-v-rc-opentx2.1)$ make [...]
After that my script shrinks from 24K to 11K which now fits into Taranis memory.
(git s-c-l-v-rc-opentx2.1)$ ls -alh hud.lua -rw-r----- 1 po po 24K Jul 7 23:50 hud.lua (git s-c-l-v-rc-opentx2.1)$ ls -alh hudsml.lua -rw-r----- 1 po po 11K Jul 11 01:18 hudsml.lua
Final result for Taranis telemetry screen: