Cleric-K / vJoySerialFeeder

Feed Virtual Joystick driver with data from a serial port
GNU General Public License v3.0
252 stars 55 forks source link

FlySky Fs-ia6 receiver #16

Closed gyoezoe closed 6 years ago

gyoezoe commented 6 years ago

Hi,

It's not an issue, just FYI. You can make another protocol, e.g. Ibus(Ia6)

I have a spare FS-ia6. I wanted to us it for the simulator. I made a mod regarding to this: http://endoflifecycle.blogspot.com/2016/10/flysky-ia6-ibus-setup.html

The iBus protocol of this receiver is a bit different as of the ia6b. The differences are detailed here: https://www.rcgroups.com/forums/showthread.php?2711184-Serial-output-from-FS-IA6-%28Semi-I-BUS%29

I made some modification to IbusReader.cs, and its working now with my FlySky FS-i6.

line 69-70 --- // check length byte --- var len = Buffer[0]; +++ // packet size is 31 +++ var len = 0x1F;

line 76 --- chksum = (UInt16)(0xFFFF - len); +++ chksum = (UInt16)(0x0000);

line 88 --- chksum -= Buffer[idx++]; +++ chksum += (UInt16)(Buffer[idx++] | (Buffer[idx++] << 8)); line 98-99 --- if(Buffer[data_start] == PROTOCOL_COMMAND40) { --- // Execute command - we only know command 0x40

line 101 --- data_start++; // skip command byte

line 109 --- }

Cleric-K commented 6 years ago

Nice, I'll add the protocol these days.

BTW if you're using flyksy stuff you might be interested in something: I'm currently working on a patch for IA6B and X6B receivers. The goal is to inject the RSSI value directly into the IBUS frame.

(with flysky plus this is possible but in roundabout way - the rx sends the telemetry to the tx and tx sends back the rssi as channel with the next frame)

gyoezoe commented 6 years ago

Yes, I'm highly interested. I'm using x6b with stock firmware on my quadcopter, but am not receiving telemetry yet. I think I should upgrade the firmware, but I'm unsure wich version to use..

Cleric-K commented 6 years ago

Hm, I think telemetry should work on x6b no matter what the version.

Currently I'm flashing the rx with a st-link 32 stick. Do you know if there is some other way of upgrading the firmware without additional hardware?

gyoezoe commented 6 years ago

I don't know, I'll be using st-link too, as long as there will be another method

Cleric-K commented 6 years ago

Ok. Already I have located where in memory the firmware stores the rssi and noise measurements (it does some moving averaging over the individual measurements from the A7105 chip).

The rssi integer values are constrained between 600 and 1200 for -60.0dBm and -120.0dBm respectively. Currently I map [1200; 600] -> [1000; 2000] as channel value.

My wondering is whether I have to use also the noise value in the calculation. Do you have any idea?

gyoezoe commented 6 years ago

I'm not an expert in the topic, but for the first round I would make things only with rssi. After that I would calculate some more informative value, e.g. SNR.

Cleric-K commented 6 years ago

Ok, thanks. I'll try to read some more about it too.

I'm writing with qba667 (the author of FlyPlus) if he can tell me what algorithm the FlySky tx itself uses to calculate it's signal quality value (the number from 0-10).

Cleric-K commented 6 years ago

Last night I stumbled upon the code in the rx firmware which seems to calculate the signal strength (the one that is visible on the tx telemetry as SigS ranging from 0 .. 10 )

It turned out that they use entirely SNR. First they truncate the SNR to the [7.8dB; 45dB] range. 45 and above is considered full signal while 7.8 and below is 0.

What was interesting is that the mapping is non linear. They use a lookup table with the precalculated values (obviously to speed things up) and it looks like this: image

There are also some checks for the number of samples that have been averaged in the current SNR value. If the samples are too few they lower the signal quality, probably to reflect the fact that there are drops and the snr value is not very reliable.

I think that I'll simply use this value and inject it in channel 14. Tonight or tomorrow I'll try to publish the patched images.

Cleric-K commented 6 years ago

Hi, the new repo is up FlySkyRxFirmwareRssiMod. So far seems to be doing well. Haven't flown it yet - only with simulators and ground range tests.