Hi all,

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...

Views: 285683


Reply to This

Replies to This Discussion

I dont think they will do it. They are selling individual S.Port sensors so if they do this they might loose some sales from those sensors. :D. Like in my case if I knew this ahead of time I won't even buy the lipo sensor for X series which now serve just as lipo tester. 

Yap thats what I did. Added variable ap_cell_count. Using the upper ceiling of each Lipo S setup.

On MavLink_FrSkySPort, I added this:

if (ap_voltage_battery > 21000) ap_cell_count = 6;
else if (ap_voltage_battery > 16800 && ap_cell_count != 6) ap_cell_count = 5;
else if (ap_voltage_battery > 12600 && ap_cell_count != 5) ap_cell_count = 4;
else if (ap_voltage_battery > 8400 && ap_cell_count != 4) ap_cell_count = 3;
else if (ap_voltage_battery > 4200 && ap_cell_count != 3) ap_cell_count = 2;
else ap_cell_count = 0;

and on the fryskysport.ino:

case 8: //-- First 2 Cells 

temp=ap_voltage_battery/(ap_cell_count * 2) & 0xFFF;
FrSkySPort_SendPackage(DATA_FRAME,FR_ID_CELLS,(temp 20) | (temp 8));
case 9: //-- Optional 3 and 4 Cells
if (ap_cell_count > 2) {
offset = ap_cell_count > 3 ? 0x02 : 0x01;
temp=ap_voltage_battery/(ap_cell_count * 2) & 0xFFF;
FrSkySPort_SendPackage(DATA_FRAME,FR_ID_CELLS,(temp 20) | (temp 8) | offset);
case 10: //-- Optional 5 and 6 Cells
if (ap_cell_count > 4 ) {
offset = ap_cell_count > 5 ? 0x04 : 0x03;
temp=ap_voltage_battery/(ap_cell_count * 2) & 0xFFF;
FrSkySPort_SendPackage(DATA_FRAME,FR_ID_CELLS,(temp 20) | (temp 8) | offset);

The only downside on my logic is it assumed you started your Lipo around  80% charge else it will detect 1 cell off. It's enough trade-off for me. :D

The Teensy does analog in.  How hard would it be to detect individual cell voltages connecting the balance plug to those inputs?  If you're running the teensy at 3.3v, you'd need to step down the voltage.  But if you're running it at 5v, I think they could go directly in.

Here's a diagram of how the balance plug is wired.  Since the cells are in series, you have to test between the cells to get the voltage of each cell.

Hi Bruce,

You will need to take the voltage down because Teensy can only handle 3,3V max. You can supply Teensy with 3,7V - 5,5V but the analog pins (A0-A20) are 3.3V only. 

The ADC is 16 bit so the resolution is Ok...


 I want to use Teensy++ 2.0  for this rather than Teensy 3.1 which I am not getting at the moment from Sparkfun.

Is your code downward compatible to Teensy++ 2.0 ?

Great work Rolf!

Can you still integrate 2 digital ports for Arming and GPS status?

Background: I have used on my Copters with the APM 2.5 port A7 for an Arming Led and port A6 for an GPS Led.
After switching to the PIXHAWK I miss these leds.

The Toshiba I ² C LED is not available and not bright enough.

regards Peter


I don't think Teensy 2.0 will work with my code because it's an 8bit ATMega32 and don't have the hardware capability to invert Rx/Tx and use single wire mode on the serial ports 


You can rewrite the code to get the Mavlink message for the GPS and Arming status. Then write the status to one of the many out pins on Teensy3.1 , just remember that the output pins are 3,3V... so you need an led-driver to get high Power LED's to work  


#define PORTNR_ARM   11    // pin to use as output for ARMED LED

#define PORTNR_GPS   12    // pin to use as output for GPS  LED


if(ap_base_mode)  // If ARMED

  digitalWrite( PORTNR_ARM , HIGH)

   else                     // Not ARMED

   digitalWrite( PORTNR_ARM , LOW)


if(ap_fixtype==3)  // /if GPS 3Dfix

   digitalWrite( PORTNR_GPS , HIGH)

   else                   // GPS not locked 

   digitalWrite( PORTNR_GPS , LOW)


Maybee it will be possible to also do the SBUS to CPPM conversion on the Teensy....

Many Thanks Rolf.

I inserted your code in the MavLink_FrSkySPort.ino at the end.
It compiles without errors.
If tomorrow my Teensy 3.1 comes, I'll try it.

And yes, i use an 900 mA Leddriver for my High Power LEDs.

regards Peter


One more question.

I use at my PIXHAWK a 3DR radio module.
Could this be a problem?

regards Peter

If you use the radio module remove the TX2 (pin10) from the Teensy, because the radio, not the Teensy, shall be sending the message request to APM. (just use RX2 and GND). This way the Teensy is only receiving from APM and could not interfere with your ground station message..


Also don't forget to set the pins you are using as outputs in the setup function, like this:



Reply to Discussion


© 2017   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service