Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SBUS2 Telemetry support #130

Closed
wants to merge 23 commits into from
Closed

Add SBUS2 Telemetry support #130

wants to merge 23 commits into from

Conversation

mmosca
Copy link
Contributor

@mmosca mmosca commented Jul 22, 2024

This is a port of my INAV code to RotorFlight.

SBUS2 port can be connected to FPORT on rotorflight flight controllers, or on the tx pin of any uart on F7/H7 mcus.

These are the available sensors:

Slot Sensort Type Notes
1 Voltage FC Voltage sensor. Pack and cell voltages
3 Current FC Current sensor.
6 RPM sensor Headspeed
7 Temperature MCU Core temp
8 Kontronic ESC ESC telemetry data

image

src/main/rx/sbus.c Outdated Show resolved Hide resolved
src/main/fc/tasks.c Outdated Show resolved Hide resolved
@rotorflight
Copy link
Owner

The code in sbus2_sensors.c looks iffy in a few places. Is that your code, or copied from somewhere else?

@rotorflight
Copy link
Owner

Is this code always sending all sensors once enebled?
Can you choose what sensors are used?

@mmosca
Copy link
Contributor Author

mmosca commented Jul 23, 2024

The code in sbus2_sensors.c looks iffy in a few places. Is that your code, or copied from somewhere else?

That is a copy from https://github.com/BrushlessPower/SBUS2-Telemetry

Not all sensors are used. That is just the code to pack the info in different sensor types.

@mmosca
Copy link
Contributor Author

mmosca commented Jul 23, 2024

Is this code always sending all sensors once enebled? Can you choose what sensors are used?

Only the sensors used in taskSendSbus2Telemetry in sbus2.c are sent.

The sensors used are currently hard coded. The futaba side is a bit limited as some sensors sensors use more than one slot and can only be used in some positions. (Esc, for example, takes a full 8 slot window and can only be on slot 8, 16 or 24).

Different radios also may support a smaller subset of sensors.

@rotorflight
Copy link
Owner

rotorflight commented Jul 28, 2024

I am not comfortable about the SBUS task running at 8kHz. It's almost certainly interfering with the gyro task.
We had to drop the gyro task to 1k on F411 and G474, because they could not even run that.
I strongly believe we can't run this either at 8k on those platforms. Probably max 1k.

I think there are two optons here:

  1. find another way to guarantee the timing requirements. Increasing the task speed is not the right approach.
  2. if it has to run at 8k, enable this feature only on H7

@mmosca
Copy link
Contributor Author

mmosca commented Jul 28, 2024

I am out of town currently. I will run more tests once I am back with hardware access.

src/main/telemetry/sbus2.c Outdated Show resolved Hide resolved
src/main/telemetry/sbus2.c Outdated Show resolved Hide resolved
src/main/telemetry/sbus2.c Outdated Show resolved Hide resolved
src/main/telemetry/sbus2.c Outdated Show resolved Hide resolved
src/main/telemetry/sbus2.c Outdated Show resolved Hide resolved
src/main/telemetry/sbus2.c Show resolved Hide resolved
Marcelo Bezerra added 5 commits August 6, 2024 21:54
These mcus don't need external inverter circuitry
Unfortunatelly, it still needs to run at 8k as lower rates cause the later telemetry slots to be too late and not work reliably.
@mmosca mmosca requested a review from rotorflight August 6, 2024 21:15
@mmosca
Copy link
Contributor Author

mmosca commented Aug 6, 2024

I believe I addreessed all items. Let me know if you need any more changes.

@mmosca
Copy link
Contributor Author

mmosca commented Aug 7, 2024

Tasks output on flydragonf722_v2 with latest changes and lowest priority.

Realtime load reported at ~26-28% and cpu load ~21-22% on configurator status bar, with all features enabled as well as working sbus2 telemetry, If I switch to crsf, instead of sbus2, realtime load, maybe 1% lower ~25-27%, but really hard to call, as it is a bit all over the place in both scenarios.

# tasks
Task list             rate/hz  max/us  avg/us maxload avgload  total/ms   late    run reqd/us
00 - (         SYSTEM)     10       5       1    0.0%    0.0%         1      0      7       4
01 - (         SYSTEM)    993       4       1    0.3%    0.1%       124      1    629       1
02 - (           GYRO)   3231       5       2    1.6%    0.7%       820      0   2044       0
03 - (         FILTER)   3231       5       1    1.6%    0.6%       663      0   2044       0
04 - (            PID)   3231      58      47   18.7%   15.4%     17429      0   2044       0
05 - (            ACC)    798       8       3    0.6%    0.2%       260      0    504       5
06 - (       ATTITUDE)    497      13       7    0.6%    0.3%       444      0    314      10
07 - (             RX)     66      18      12    0.1%    0.0%       290      0    126      17
08 - (         SERIAL)     98    1070       2   10.4%    0.0%        75      0     61     219
09 - (       DISPATCH)    993       7       0    0.6%    0.0%        83      0    629       5
10 - (BATTERY_VOLTAGE)    200       3       2    0.0%    0.0%        57      0    126       3
11 - (BATTERY_CURRENT)    200       1       0    0.0%    0.0%        19      0    126       1
12 - ( BATTERY_ALERTS)      5       2       2    0.0%    0.0%         0      0      3       3
13 - (         BEEPER)     98       2       1    0.0%    0.0%        14      0     61       1
16 - (           BARO)     43      29       6    0.1%    0.0%       103      0     72       8
17 - (      TELEMETRY)    249       3       0    0.0%    0.0%       133      0    156       2
18 - (       LEDSTRIP)     98      17       5    0.1%    0.0%        46      0     61      33
21 - (    ADCINTERNAL)      1       3       3    0.0%    0.0%         0      0      1       8
23 - (SBUS2_TELEMETRY)   6345       6       0    3.8%    0.3%       451      0   3986       3
RX Check Function                   1       0                        12
Total (excluding SERIAL) 

@rotorflight
Copy link
Owner

Thank you! Merged manually.

@rotorflight rotorflight closed this Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants