EdgeTX / edgetx

EdgeTX is the cutting edge open source firmware for your R/C radio
https://edgetx.org
GNU General Public License v2.0
1.59k stars 338 forks source link

Kingtech (and Jetcat) Telemetry Sensors from Spektrum Rx #5576

Open crwardlaw opened 3 weeks ago

crwardlaw commented 3 weeks ago

Is there an existing issue for this feature request?

Is your feature request related to a problem?

When using a Spektrum Rx, Kingtech turbine telemetry kiddy-backs on the Spektrum built-in Jetcat Telemetry structs. However, EdgeTx does not import the STATUS field which is based upon enums. Kingtech and Jetcat use different enums. My Radio master TX16s Max with Spectrum Rx detects the majority of the Jetcat/Kingtech Telemetry data but not status. I have linked useful documents in the additional context section. N.B.: the status enum for Kingtech seems to use two enums depending on whether the first enum is a specific value.

The status enums may also be applicable to other Rx protocols, this may not only benefit Spektrum users.

Describe the solution you'd like

Preferably option 2 below so that all telemetry and sensor information is held on the one page on the UI.

Describe alternatives you've considered

  1. Just populate the status with its numeric value, and have a specialized "value" widget to display the equivalent text for that numeric status.. like a "valueKTEnum" widget or "valueJCEnum" widget.
  2. Create separate sensors for the KT and JC status, populating them with the proper translation. So you pick wich one to use on the screen.
  3. Use a specialize widget to display a telemetry screen with all the tubine info together (similar to the spektrum telemetry screen).. the translation of the numeric status is done there.. so one wiget for KT, and one widget for JC.

Additional context

Spektrum's X-Bus file showing Jetcat enum and Jetcat struct: https://github.com/SpektrumRC/SpektrumDocumentation/blob/2a8a5f9d6f85eff0d2458b9ac2b05e9dcf7ddcab/Telemetry/spektrumTelemetrySensors.h#L739

EdgeTx Spektrum telemetry file showing a TODO for adding status telemetry: https://github.com/EdgeTX/edgetx/blob/149e1a2df00f680404691dadbb59de62abecc3bf/radio/src/telemetry/spektrum.cpp#L193

Document showing the differences between enums for Jetcat and Kingtech - page 41 section 2.9.4: https://drive.google.com/file/d/1TfaMCA3zpDcdGQMnRq5MnjJexTBp-VZD/view

frankiearzu commented 3 weeks ago

COPIED from the previous conversation on an older issue: We could aproach it in three ways:

  1. Just populate the status with its numeric value, and have a specialized "value" widget to display the equivalent text for that numeric status.. like a "valueKTEnum" widget or "valueJCEnum" widget.
  2. create separate sensors for the KT and JC status, populating them with the proper translation. So you pick wich one to use on the screen.
  3. Use a specialize widget to display a telemetry screen with all the tubine info together (similar to the spektrum telemetry screen).. the translation of the numeric status is done there.. so one wiget for KT, and one widget for JC.

Options 1,2 will allow you to log the value into telemetry logs... Option 3 don't log, but probably looks nicer, and can be done without touching the firmware code.

I see in the Google Drive document that there is already an OpenTX telemetry page.. will research that.. could be a quick way to start.

frankiearzu commented 3 weeks ago

Wirdget/Script like this could be the fastest: image

found their LUA source code, will port it to EdgeTX. Will work on it this comming weekend.

crwardlaw commented 3 weeks ago

Thank you so much!

frankiearzu commented 2 weeks ago

@crwardlaw Here is the zip file for the Widget ported to EdgeTX.

Copy the VSpeak_ECU folder into your WIDGET folder: image

Then on the telemety page, create a new page (full screen, only 1 big cell) and add the VSpeak widget.. and select the ECU (5=JetCat, 6=KingTech). There is a read_me.pdf with instructions for OpenTX, but is very similar on EdgeTX.

This is how it looks: image

The data comes from telemetry values: Tmp2 is the Status, not a temperature (need new firmware.. will attach it soon).. should be a small value (0-11). image

frankiearzu commented 2 weeks ago

Here is the firmware for Radiomaster TX16S, where status comes as sensor Tmp2.
Is based on the 2.10.x branch (2.10.4 + some other fixes that will become 2.10.5).

Have no way to test it, so let me know if it works, and will check in the code changes to be added to a future EdgeTX release.

crwardlaw commented 2 weeks ago

That's amazing - thank you for putting this test together so quick! I'll be back with the jet this weekend so will try it out and bring feedback on Monday at the latest.

Did you have to take in consideration the two status enums that kingtech uses where you refer to one when the other is a specific value? I believe that's how it's meant to work.

frankiearzu commented 2 weeks ago

I only ported the LUA that they provided, and change the firmware to send the status on sensor Tmp2… so is the same logic that the did provide on their original lua.On Oct 8, 2024, at 3:36 PM, crwardlaw @.***> wrote: That's amazing - thank you for putting this test together so quick! I'll be back with the jet this weekend so will try it out and bring feedback on Monday at the latest. Did you have to take in consideration the two status enums that kingtech uses where you refer to one when the other is a specific value? I believe that's how it's meant to work.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

crwardlaw commented 2 weeks ago

Their LUA script is for use with their proprietry VSpeak telemetry unit which I think may pass the status data differently from the official kingtech and jetcat units, I'll give it a go this weekend and see how it goes but I think the following will also need taken into consideration:

  1. The VSpeak unit seems to be treated as a signed int enum (https://github.com/thomasekdahlN/jeti/blob/fbf69aa66e8651a4ddddf9da2f5e5ec90dd9ad4a/ecu/converter/vspeak/kingtech/config.jsn#L15)
  2. Whereas the kingtech and jetcat units use 2 unsigned int enums, status and offCondition which are at lines 611 and 617 in the spektrum telemetry file linked below. When, line 611, status == 0x00 then the reported status should instead be taken from the offCondition enum, line 617. https://github.com/SpektrumRC/SpektrumDocumentation/blob/2a8a5f9d6f85eff0d2458b9ac2b05e9dcf7ddcab/Telemetry/spektrumTelemetrySensors.h#L611
  3. status enum can be found at https://github.com/SpektrumRC/SpektrumDocumentation/blob/2a8a5f9d6f85eff0d2458b9ac2b05e9dcf7ddcab/Telemetry/spektrumTelemetrySensors.h#L621
  4. offCondition enum, applicable when status == 0x00, can be found at the link below. It also states when to use this enum further along the line in a comment. https://github.com/SpektrumRC/SpektrumDocumentation/blob/2a8a5f9d6f85eff0d2458b9ac2b05e9dcf7ddcab/Telemetry/spektrumTelemetrySensors.h#L739

In summary, depending on which variable in the struct in the spektrum .h below, is now coming in as Tmp2, I may get one of the status infos coming through https://github.com/SpektrumRC/SpektrumDocumentation/blob/2a8a5f9d6f85eff0d2458b9ac2b05e9dcf7ddcab/Telemetry/spektrumTelemetrySensors.h#L607

I think EGT will be coming in as Tmp1, therefore, if Tmp2 is coming in as the next variable in the struct, I reckon I will get the offCondition enum coming through to the WIDGET.

frankiearzu commented 2 weeks ago

I see, i was thinking that you have the VSpeak Translator. Im not processing the offStatus code right now, i think what they are doing is passing the OFFstatus as negative. I can do something similar in the EdgeTX firmware. Another thing that im not sure is if the value is BCD encoding or not... every other field is documented as BCD, but the statuses don't have any documentation that say BCD encoding.

Lets see what telemetry sensor values you get from your ECU. What are you using to send the data from the ECU to the RX?? any translator (Like VSpeak)?? just want to make sure it can send the Spektrum JetCap ECU messages,

If the sesors are not OK, I have a small LUA script to capture the RAW data comming from Spektrum telemetry data. we can try that after the first attempt.

frankiearzu commented 2 weeks ago

This is how the code in the firmware is now: image

The status comes as Tmp2

crwardlaw commented 2 weeks ago

The kingtech telemetry unit which I have can be found here https://kingtechturbine.lu/KingTech-T-Modul-5-in-1-Telemetry_1 The kingtech telemetry unit connects to the kingtech ecu and the spektrum Rx. I've been able to see it working as have had it hooked up to my Dad's spektrum which was able to receive the temps etc. and seemed to be receiving the status when set to jetcat, but might not have been using the offCondition as that might only be a kingtech thing - it's difficult to tell. I have been in touch with Kingtech and they were not able to provide documentation, so I have had to piece it all together myself.

I think the recording LUA script would be useful to see both the status and offCondition enums changing.

frankiearzu commented 1 week ago

Did a bit more work on both the LUA and Firmware. Is combining the Status and offStatus in the way that the LUA widget needed.. (status positive, offStatus negative). Moved the status to Tmp4 to avoid conflicts.

Sensors: Tmp3 Turbine Temperature Tmp4 Status A3 ECU voltage A4 pump votage RPM RPM

VSpeak_ECU_and_Firmware.zip

crwardlaw commented 1 week ago

So I have good news and some not so suprising news - firstly thanks for your efforts so far - I can't believe how well this has went!

  1. To the best of my knowledge the telemetry comms are working and numbers are matching up where I expect for at least the Rx and Turbine voltages and Temperatures (room temperature), I haven't been able to check the other scalars yet (rpm etc.).
  2. Status and offCondition seem to be being detected correctly.
  3. However, the enum which the VSpeak widget uses is not a 1:1 mapping to Kingtech nor Jetcat's enums when passing through a Spektrum Rx. Therefore, we're needing to add another enum for Kingtech [and in theory Jetcat if doing the full job] somehow. I'm happy to build that enum as a trial within the Lua Script to make sure I am confident in my thoughts; but, it'll be next weekend before I can again test it. This does lead us to a bit of a hurdle: this would be adding functionality to the borrowed lua script that wasn't for the technology that the original lua script exists for. If I do create the enum for the Lua Script, it will also need to be written to be compatible with the Lua Script's expectations of negative values, rather than the true Kingtech/Spektrum status enums. Like I say, I am happy to change the Lua script to make sure I see the info coming through as I expect, but this now seems like it's moving towards a kludge between the firmware importing the status data to suit a widget's enum which isn't correct for the manufacturer's enums. Do you have a recommended path forward?
  4. A tad separate, regarding the firmware you gave me for trialing this: is it expected to be stable or am I best going back to the released firmware I was using for flying in the meantime? I never saw any issues with it, just thought it's better to be safe before having the risk of losing a plane.

Thanks again, Chris

frankiearzu commented 1 week ago

Hi Chris, Good that the firmware seems OK, thats the most dificult part.. the LUA is easier to change later. The firmware was build using the 2.10 branch, that is a pre-release of 2.10.5. So once we are OK with the firmware, I can create a Merge Request to be added offcially to the next version of EdgeTX.. maybe 2.10.6. I can build a 2.10.5 + this change only later once 2.10.5 is released in the meantime.. but yes, use it only one the ground for now.

I modified to LUA to add ECU type 26, that will be Kingtech with the Kingtech telemetry module. The name shows as "Kingtech KT Tel". You can edit the messages on the "msg_table_Kingtech_2" that currently is a copy of the Kingtech ones. I want to leave the script backward compatible with the VSpeak instead of replacing the current Kingtech.

image image

New Widget attached below, you can edit main.lua with your favorite editor. Negatives are the OffStatus, and Positives are the Status. OffStatus is only used if the main Status is Zero. If this logic changes fror different turbines, we can change the firmware to report both Status and OffStatus separate (Tmp4, Tmp5), and the script join them depensing of the value of Status. VSpeak_ECU.zip

But looks like we are on the right path.

frankiearzu commented 1 week ago

Firmware 2.10.5 was released, no more changes compared to the branch i had, so seems like the Firmware that i gave you is safe.

crwardlaw commented 4 days ago

I tried the widget and telemetry again over the weekend and I am unfortunately stumped at the order of the enum texts that are required. As there is no clear mapping between the Jetcat status enum : Kingtech status enum : what a spektrum Tx shows for the Jetcat enum : the Kingtech ECU screen status display : vspeak's enum, it is making it difficult to work out what the correct enum should be for the vspeak widget. However, I plan on running the turbine next weekend and that will let me match up more of the status enums between the Kingtech ECU screen and the vspeak widget which will hopefully guide me to get more of them right. I'm also going to get in touch with Kingtech again to see if they can assist by providing the enum that the Kingtech screen uses as that is really what I need.

Anything else you are looking for at the moment?

frankiearzu commented 3 days ago

Not much that i can do on my side.. the only thing that i was looking is at the Jetti Script. Looking at the status messages on Digitech and vspeak converters for Kingtech. Digitech all positive, and vspeak has negative ones and positive ones. Not sure what the Kingtech converter sends as status on the Spektrum Telemetry Frame.

On the spektrum Radio, it it was made for Jetcat, it will be showing you probably the wrong status message.

Looked at a few of the configurations of the Jetti Widget: image https://github.com/thomasekdahlN/jeti/tree/fbf69aa66e8651a4ddddf9da2f5e5ec90dd9ad4a/ecu/converter

The statuses for VSpeak are more richer than the digitech ones..