S Port Protocol

General Help and support for the Taranis Radio.
Gandalf
Posts: 20
Joined: Fri Apr 25, 2014 3:45 pm
Country: -

Re: S Port Protocol

Post by Gandalf »

Hmmm,

Maybe my receiver needs a software upgrade? Any ideas?

User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: S Port Protocol

Post by MikeB »

I assume you have your 'scope on the SPort at the receiver. You could check on the transmitter. The SPort signal is on pin 5 (bottom pin) of the 5-pin external module connector. Pin 4 is Gnd.
You could look for data arriving from the receiver.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Gandalf
Posts: 20
Joined: Fri Apr 25, 2014 3:45 pm
Country: -

Re: S Port Protocol

Post by Gandalf »

Mike,

I won't be able to check that data arrives at the TX for a couple of days but thanks for the suggestion.

Am I right in saying that I must have the latest software build on these boards because my analog sensor boards give the second output after I've shorted pin 2 to ground?

Thanks,
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: S Port Protocol

Post by MikeB »

Yes, you have the latest firmware.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Gandalf
Posts: 20
Joined: Fri Apr 25, 2014 3:45 pm
Country: -

Re: S Port Protocol

Post by Gandalf »

OK, I eventually got round to doing the tests; I was not getting 7E-1B data out of the back of the Taranis (but I was getting 7E-98 data).

After much reading, I realized that you only get S.Port data down-linked to the Taranis when you're in D16 mode, I was in D8 mode because the receiver instruction sheet seemed to indicate that you get Telemetry in D16 and D8 mode - clearly you do get Telemetry in D8 mode in the form of receiver battery voltage but you don't get any S.Port data - serves me right for reading too much!

Anyway, after re-binding in D16 mode (changed in the TX model menu and then binding the X8R with no pins shorted), I now get 7E-1B data coming out of the back of the Taranis and when I enable the second A2D port on Mike's board, I do see the data coming through on the Taranis display as T2.

Now to tweak my PIC code to send my own data :D

Erni
Posts: 27
Joined: Wed Jun 04, 2014 3:41 pm
Country: -

Re: S Port Protocol

Post by Erni »

A big thanks to MikeB

I just flashed an ATtiny13 with the hex file found in the above link, connected to my X6R and without any errors I get the analog value on my Taranis.
I used PB3 as analog input and PB1 as Sport conection.
Next I will try on a X8R, but it is deeply burried in a glider at the moment
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

MikeB wrote:There is quick way to get bi-directional data transfers. Get two of these:
http://www.t9hobbysport.com/frsky-s.por ... -adc-ports
one host and one remote. (I'm not sure why Aloft haven't got them).

Just plug the remote into the receiver SPort and the host into the Tx SPort, and you have a, RS232 compatible, serial link working.

Regarding latency, it partly depends on how many devices are on the SPort. Yes, the Rx polls all IDs, but when it finds a responding device, it polls that more often. If you only have 1 device, then it polls that, then polls one other ID, then goes back to the existing device, then on to the next 'empty' ID and so on. Each poll takes 12mS. So, with just 1 device, it should get polled every 24mS.

Minor note, SPort and SBUS are not the same thing. The SPort is for telemetry, the SBUS is for servo control.

Mike.
Mike, I know you created something similar... but I was wondering if this configuration is okay to use with ER9x and this adapter?

Image

I did connect it according to this diagram and set the A1 to 28.8V in order to see the voltage correctly... its a 6:1 Ratio for 3S

Have you or anyone does this before?

http://www.elektromodelle.ch/FBVS-X8R.j ... VS-X8R.jpg[/img]
Custom 9x with M64/Telemetry Mod
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: S Port Protocol

Post by MikeB »

I don't think I've added that sensor in to er9x. I've got a couple of these sensors, but only tested the UART function.
Give me a day or so and I'll have a look.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

Sounds great thanks...
at this point.. I get the 11.5V on at battery set to storage mode.. just charged my batt.. and see if I get 12.6V displayed on my Radio A1=
But that didn't work, it still shows 11.5V.

I have this on my CC3D FC and I would like to get voltage sent to my Radio via Telemetry with my X8R / XJT setup running on ER9x.

Here is the post from FrSky
Re: 【New Product】S.PORT TO UART Converter, w/ two ADC Ports
Postby FlyingAllen » 2013-12-04 5:38

Obtain AD analog input via X8R & SP2UART adapter:

Many customer contact us how to connect Frsky battery voltage sensor with X8R receiver, because the X8R receiver is not built-in the AD port, which is not support connection FBVS with X8R directly.

Now, you can, through this adapter:
5.jpg
The SP2UART have two ADC port, supporting link with external analog devices.

It is very simple, just need enable the ADC function by SHORT CIRCUIT S1/S2 & GND is ok, and now you can connect /solder the FBVS to SP2UART as connect with D8R-II plus rx.
You do not have the required permissions to view the files attached to this post.
FlyingAllen
Mahon
Mahon

Posts: 197
Joined: 2013-08-05 7:18
Custom 9x with M64/Telemetry Mod
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

So, I guess I could just buy a SPort Sensor... but I had a few of these lying around.. and was wondering if I could get use out of them... If not, I can use them with my OSD and try to get that data sent to my SCREEEN instead of my Radio. I like the Audible Alerts... ;-)

Thanks again
Custom 9x with M64/Telemetry Mod
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: S Port Protocol

Post by MikeB »

OK, I have already got processing in for these, but I haven't tested it. The confusion is they are sent as A3 and A4, not A1 and A2. A1 and A2 are still used by the X6R and the 'D' series receivers.
A3 and A4 may be selected as telemetry values for the custom display and comparison in logical switches. They are near the end of the list, just before the scalers.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

okay.. thanks.. will test now..
Custom 9x with M64/Telemetry Mod
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

alright.. fully charged battery shows A3=208 (@12.6V) and at 11.54V shows A3=192
So is there some magic formula to convert to Voltage?
Custom 9x with M64/Telemetry Mod
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

So if the ratio is 6:1 but...
208 Reading Raw at battery level for 12.46V
and
195 Reading Raw at Battery level for 11.54V

So what i did was Multiple of 6 and Divisor of 10.
Does that sound right?
It gives me 12.4V or 11.5V depending on the battery level I know to be true with Volt meter?
Custom 9x with M64/Telemetry Mod
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

p.s. Mike, I have to say this functionality is amazing... truly pleased with this feature, I have never made it to this page before... ;-)
Custom 9x with M64/Telemetry Mod
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: S Port Protocol

Post by MikeB »

My understanding is the value is in units of 1/100 volts, so 208 is 2.08 volts and 192 is 1.92 volts. If you have a 6:1 ratio then these need to be multiplied by 6.
2.08 * 6 = 12.48.
1.92 * 6 = 11.52.

Probably the 'best' way to get the reading you want is to use a Scaler.
Set the source to A3 (or A4)
set the multiplier to 6.
Set the number of decimal places to 2.
Set the units to "volts".
Set the name to something useful (say "Pack" for pack voltage).
Then use the scaler for display and/or voice output.

If the resulting reported voltage is not quite right, you could use a multiplier of 60 and a divisor of 10, then adjust the multiplier to 61 or 59 (or so) to get the correct reading. For greater resolution, use a multiplier of 240 and a divisor of 40, then adjust the multiplier as needed.

Or, as you have done, a multiplier of 6 and a divisor of 10 with 1 decimal place. You could use a multiplier of 120 and a divisor of 200, then adjust the multiplier, to allow a more accurate calculation to cope with measurement and conversion errors.

Mike.

Edit: I always knew scalers were useful!
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: S Port Protocol

Post by LTMNO »

Ha, awesome.. thanks for the OOTB thinking... I will put in effect your recommendations...
Thanks again! Awesome platform!
Custom 9x with M64/Telemetry Mod
marcmerlin
Posts: 2
Joined: Mon Apr 11, 2016 4:02 pm
Country: -

Plugging Sport sensors directly in arduino?

Post by marcmerlin »

I have a couple of Sport sensors that work when connected to an X8R and show values on my FrSky Taranis:
one is a lipo sensor with per cell voltage, the other is an RPM sensor with 2 temperature sensors.

My problem is that I use openlrs now, so I can't send that telemetry data, and either way I'd like to send the data directly to my OSD board (minimOSD) and/or my pixhawk autopilot.

Everything I've found so far seems to talk about getting telemetry data back from a Taranis after it's gone through an X8R or equivalent.
I haven't found a good explanation on how to talk to the sensors directly.
If I convert my Sport connection to UART with the diode or SPC, and then a FUL-1, what's the way for my microcontroller to talk to the Sport sensors directly?
Do I need to send them special frames with their ID number in them, and they reply on the bus?

Thanks, Marc
marcmerlin
Posts: 2
Joined: Mon Apr 11, 2016 4:02 pm
Country: -

Re: S Port Protocol

Post by marcmerlin »

Howdy,

Can someone help me find existing code to decode sport telemetry sensor data when connected directly to the sensors?
I currently use a TTL to 3V converter and an SPC (the diode) to connect frsky telemetry sensors directly to my PC's serial port.
I'm seeing the frames that look like
4S 15.21V 3.80 3.80 3.81 3.80
2 messages for 4S lipo sensor
Message: a1:10:0:3 40:6f:d7:76
Message: a1:10:0:3 42:75:07:77
(all messages have the trailing 7e which I stripped and I believe the last byte left above is a checksum)
I can see that telemetry device a1 sends 10:0:2:40 for the first data frame and 10:0:3:42 for the second data frame and then 2x2 bytes encode the level of the 4 cell lipos.
But basically it's painful to reverse engineer the protocol when there must be already decoded somewhere.
I had a loop in the opentx code, frsky_sport.cpp, but didn't really find much yet (still looking).
For some reason, also, when I send data from my PC, it doesn't get on the sport bus. Somehow it doesn't get past the diode, so for now, I'm using an X8R plugged into the bus simply to have it send the query to all the sport devices on the bus.

To be clear again, I will not be connected to the X8R or to the Taranis X9D, I'm going to be connected directly to the telemetry sensors so that I can read them from an arduino board (pixhawk and/or minimOSD).
Could someone help me a bit with this, especially the decoding part?
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: S Port Protocol

Post by Kilrah »

https://github.com/opentx/opentx/blob/m ... t.cpp#L197

The 7E is a lead (frame start), not a trail.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: S Port Protocol

Post by MikeB »

This might be useful: https://github.com/MikeBland/SportToHub.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
bobbdobbs
Posts: 1
Joined: Sun Apr 14, 2019 5:46 pm
Country: -

Re: S Port Protocol

Post by bobbdobbs »

Sorry to revive a many years old topic, but this page was useful to me so I though I would add more about the S.Port checksum.

Ignoring any bytes before the starting 0x10, add all the bytes together. It is easiest to do this by adding 8 bit values to a 16 bit accumulator. On the final sum before the message checksum, add the upper 8 bits of the accumulator to the lower 8 bits (add the carries.) Then add the 8 bit message checksum. The final accumulator value should end up as 0xFF which is a good checksum. Anything else is a failed checksum and the message should be ignored. Keep in mind that if a 0x7D 0x5D or 0x7D 0x5E combination is encounter, they should not be added directly to the accumulator, but rather 0x7D or 0x7E respectively.
ProfManeuver
Posts: 1
Joined: Sat Nov 19, 2022 7:34 am
Country: -

Re: S Port Protocol

Post by ProfManeuver »

Hi all-

Hate to be a "demanding newbie" but I'm trying to create a non-Arduino based device to create legit Frsky telemetry data. We've sniffed actual Frsky sensors using a logic analyzer, figured out the serial baud rate and inverting business, found and figured out Data IDs and sensor IDs, the polling 0X7E and the 0X10 preamble response and able to duplicate observed (static) data from a Frsky sensor on our device and have it appear on the TX. However, creating real data is a lot tougher.

Is there some comprehensive document that fully describes the S. Port protocol in words (vs a link to some JAVA or Python or Arduino Code with 27 #includes that professes to be "all there")? If nothing else, can the Checksum algorithm described in the post above (copied below) be further explained? I don't see how adding (7) 8-bit values is going to give an 8-bit checksum.

"Ignoring any bytes before the starting 0x10, add all the bytes together. It is easiest to do this by adding 8 bit values to a 16 bit accumulator. On the final sum before the message checksum, add the upper 8 bits of the accumulator to the lower 8 bits (add the carries.) Then add the 8 bit message checksum. The final accumulator value should end up as 0xFF which is a good checksum. Anything else is a failed checksum and the message should be ignored. Keep in mind that if a 0x7D 0x5D or 0x7D 0x5E combination is encounter, they should not be added directly to the accumulator, but rather 0x7D or 0x7E respectively."

Cheers/Thanks,

Steve Manganelli aka ProfManeuver
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: S Port Protocol

Post by MikeB »

The SPort protocol document is released by FrSky under a NDA, so we cannot publish it.

You do (probably) need to look at the c/cpp code available on Github for erskyTx, openTx, edgeTx or the multiprotocol module to pick out the data scaling for individual sensors, and the specific checksum calculation.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

Post Reply

Return to “General help (FrSky Taranis radio)”