×
Important information

To file a bug, find instructions here: Reporting bugs

Please only post images or files to this forum which you either own the copyright to or you are sure can be distributed under an open source license.

Latency Test for deviation vs ersky vs opentx

More
02 Aug 2018 03:42 - 02 Aug 2018 04:09 #70028 by brycej
Hi All,
I recently got a TS2G and added deviation (from the Aug 1, 2018 build) to my frsky latency test.

Test setup:
Using Frsky_X with 8 channels.
Used ARB generate to flip a switch every 1s on taranis, Switch caused 100% throttle
RX gets the signal and transfers it with SPI/SBUS/fport to FC running betaflight
Betaflight increases dshot throttle values
Capture time when over 200 counts (~140 was idle and 1000 was 50%)
Just did one test right now to a matek411RX that has a spi chip on there.

I was hoping that deviation would be the fastest since you have direct access to the TX chips via spi, but it appears it was slightly slower on average then ersky with the same setup (it did couple samples faster 10.94ms vs 11.37ms). Although much faster then opentx. It seems deviation phases in and out the lowest latency over 30s - maybe a timer phasing in and out? Opentx has a similiar issue but that is from not syncing to the heartbeat on the internal xjt module. Compare a couple of the tabs in the data below if your interested!

Link to the data: docs.google.com/spreadsheets/d/1aTRuUzEI...hHw/edit?usp=sharing


So for a quick comparison of the different TX talking to a spi-RX in betaflight (truncating all the numbers)
Deviation 10-26ms
Ersky 11-23ms
Opentx 16-35ms

Let me know if you have any questions!
Attachments:
Last edit: 02 Aug 2018 04:09 by brycej.

Please Log in or Create an account to join the conversation.

More
02 Aug 2018 10:17 - 02 Aug 2018 10:18 #70032 by Fernandez
Replied by Fernandez on topic Latency Test for deviation vs ersky vs opentx
I would expect it is better to setup a 3v3 pulse on the adc input lines, so the pot's itself first 4 control channels?
The 10ms, is probably just low as it gets due to Frsky updates in 8 channel mode? (then depending on timing, theoretically expect 10-20ms)

How are these switches sampled? I there may be some capacitance, rc filtering on the switches ?
Last edit: 02 Aug 2018 10:18 by Fernandez.

Please Log in or Create an account to join the conversation.

More
02 Aug 2018 14:01 #70033 by brycej
Hi Fernandez,
I did a video on my test setup when I was testing opentx/ersky9x on taranis if you wanted to see my test setup.


Quick summary:
I used a square wave ARB generator on 1hz with 0 to 3.3V to trigger one of the switches. In deviation I set the switch to be the throttle output. I used a salae logic analyzer to grab when ARB "switched" the throttle on and then waited to see when the dshot throttle value (betaflight motor output) went up - decoded with salae as well.

Photo of my mixer setup: photos.app.goo.gl/8pRvEV4MjAaQW4UE9

It might be better to use the pulse direct on the ADC for the throttle gimbal, but I didn't do that because I thought other transmitters use PWM gimbals and wanted to have a general test I could use on any transmitter. Also it was much easier to use one of the aux switches. And the way I have it setup, the aux switch should be one of the 4 control channels. I know some protocols prioritize channels 1-4 in the over the air data, so that is why I was sending the data over the throttle channel.

Couple questions on that I could see effect that: Are the switches sampled less frequently then the ADC on the gimbals or are they all sampled at the same rate? Or there some additional processing that happens because it a switch that gets translated into throttle values vs using the throttle gimbal directly? My assumption is the the ADCs are all sampled at the same rate and the same processing happens to all the channels in the mixer.

Please Log in or Create an account to join the conversation.

More
02 Aug 2018 16:57 #70035 by brycej
Looks like from what I can see the ADC and mixer is run on a timer every 5ms?

github.com/DeviationTX/deviation/blob/9b...ca/src/target.h#L121

github.com/DeviationTX/deviation/blob/2c...n/stm32/clock.c#L223

So that would be adding a 0-5ms latency to the signal. Seems like it either could be reduced or called right before the packet is sent out around here: github.com/DeviationTX/deviation/blob/3c...frskyx_cc2500.c#L249

to eliminate it completely.

Please Log in or Create an account to join the conversation.

More
02 Aug 2018 18:06 #70036 by brycej
One other thing:

Is it sending out 16 channels all the time? Maybe I'm missing something on how `chan_offset` works?

github.com/DeviationTX/deviation/blob/3c...frskyx_cc2500.c#L288

Please Log in or Create an account to join the conversation.

More
02 Aug 2018 21:55 - 13 Aug 2018 19:51 #70038 by hexfet
Deviation FrskyX sends the number of channels set in the model file. If that's set to 8 channels or less then all the channels will be updated every radio frame (9ms). If it's greater than 8 then the "doubled" channels are updated every other frame (18ms) while the remaining are still updated every 9ms. For example if the number of channels is set to 12 then channels 1-4 and 9-12 update every 18ms, while 5-8 will update every 9ms.

The ADC is read continuously via DMA. The averaging filter and mixers are run every 5ms. There is some commented-out code that ran them after every DMA update. Not sure why it was changed - maybe cpu load. Switches do not go through the ADC but do go through the mixers. The mixer output is what is transmitted by the protocols.

Makes me curious about the latency just from switch input to devo radio output. Will add it to the list...
Last edit: 13 Aug 2018 19:51 by hexfet.

Please Log in or Create an account to join the conversation.

More
03 Aug 2018 18:27 #70056 by brycej
Hi Hexfet and Fernandez,

I did some additional testing with a hack to add the mixer calc and ADC to happen right at the top of this function:
github.com/DeviationTX/deviation/blob/3c...frskyx_cc2500.c#L249

That definitely helped to reduce the latency, data here:
docs.google.com/spreadsheets/d/1MlGdLWIP...ypg/edit?usp=sharing

I also did a test with the ARB on the ADC of the throttle. That showed it going faster and with less gitter, so my switch method was adding in some additional lag.

Modded code attached to switch to trigger throttle: 6 - 21ms
Modded code attached directly to throttle: 6 - 16ms

I think I remember the actual overtheair time is ~4.5ms (protocol sends every 9ms) So a 6ms minimum is pretty darn good.

All of these is much much better the opentx 16-35ms!

Please Log in or Create an account to join the conversation.

More
03 Aug 2018 19:27 #70058 by Fernandez
Replied by Fernandez on topic Latency Test for deviation vs ersky vs opentx
Indeed Latency of each data sample is something different then just the sampling rate of the signal. (The 9ms from the protocol you can't change anyway.)

Quote hexfet
"For example if the number of channels is set to 12 then channels 1-4 and 8-12 update every 18ms, while 5-7 will update every 9ms"
I do not understand howit works.

By the way I have never understood why we are still sending switches and use full channel bandwith and not just some binary values..….

But with TX and RX modules over SPI, fully firmware controlled, it should be possible make 4 channel high speed data and add some binary encoded/decoded switches ?


All very interesting especially with Betaflight squeezing the best out of the drones…..

Please Log in or Create an account to join the conversation.

More
06 Aug 2018 13:53 #70133 by brycej
Fernadex,
For the greater then 8 channel updating, it looks like it happens here: github.com/DeviationTX/deviation/blob/ma...frskyx_cc2500.c#L209

If you have 12 channels the 8-12 then will go through that function normally, 13-16 will hit that function.


I think the reason they are sending full channels is probably due to planes that don't use flight controllers. I actually have a dual prop plane with 2 motors and 3 servos, so that needed 5 full channels. I could imagine a even more complex plane with more servos. For quads and planes with FCs it probably isn't ever really needed.


It would be nice to bump up the update rate to 2 or 4ms over the air and send much simpler aux channel data. But I only have 2 quads with spi receivers, the rest are using XSR or X4R, I want to keep using those for as well. Might be able to update opensky to support a new protocol: github.com/fishpepper/OpenSky

Please Log in or Create an account to join the conversation.

More
06 Aug 2018 14:11 #70134 by Fernandez
Replied by Fernandez on topic Latency Test for deviation vs ersky vs opentx
Yes my problem, is I am not a good coder, so I can only assist in testing.

But benefit of SPI, both sides, is that you can easily change the protocol, (no need to flash RX) With CC2500 present on both sides, it is no longer needed to use Frsky scheme, so a 4channel "Fast RaceKraft protocol" + binary switches could be possibility for Betaflight and Deviation ?

Same for maybe a longer range protocol using slow updates, or thinking out of the box, maybe even a variable rate, as is done in Crossfire ?

Both are open source who knows someone, catches up on this.
As the trend is that more and more smaller details are being tuned out and optimized to get quads fly as good as possible.

Lowest latency certainly is one of them.

Please Log in or Create an account to join the conversation.

Time to create page: 0.403 seconds
Powered by Kunena Forum