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

CRSF input for Trainer mode #1607

Open
sk8board opened this issue Feb 19, 2022 · 30 comments · May be fixed by #4102
Open

CRSF input for Trainer mode #1607

sk8board opened this issue Feb 19, 2022 · 30 comments · May be fixed by #4102
Assignees
Labels
enhancement ✨ New feature or request

Comments

@sk8board
Copy link

sk8board commented Feb 19, 2022

Currently, Trainer mode only allows PPM or SBUS input. I am requesting CRSF input for Trainer mode.

Here is why.

I place a receiver in the JR module bay and connect the receiver to the Batt, Ground, and HeartBeat terminals. I then bind the receiver to the student transmitter. If the receiver will output PPM or SBUS, then this allows wireless trainer mode.

The problem is ELRS receivers do not output PPM or SBUS. Therefore, to use student transmitters with internal ELRS, there is a need for trainer mode to support CRSF protocol.

@sk8board sk8board added the enhancement ✨ New feature or request label Feb 19, 2022
@raphaelcoeffic
Copy link
Member

@wimalopaan would you be interested in adding this to your trainer protos?

@rotorman
Copy link
Member

rotorman commented Mar 23, 2022

Luckily the channel data in CRSF is encoded 1-to-1 as with S.BUS. Here as a helper, a short CRSF parsing code by kobata, where he connected a HappyModel EP2 receiver via MCU to USB to act as a joystick: https://qiita.com/kobatan/items/40728fbb625057d9f42b

@wimalopaan
Copy link
Contributor

@wimalopaan would you be interested in adding this to your trainer protos?

Yes, I'll have look at it

@wimalopaan
Copy link
Contributor

Does anyone have a full protocol spec at hand? For this the control-part (no sensor reply) would be sufficient.

What would be the best test-setup for someone not owning CRSF hardware? Are the PC-based generators e.g. to use with some USB/serial converter?

@wimalopaan
Copy link
Contributor

wimalopaan commented Mar 23, 2022

Luckily the channel data in CRSF is encoded 1-to-1 as with S.BUS. Here as a helper, a short CRSF parsing code by kobata, where he connected a HappyModel EP2 receiver via MCU to USB to act as a joystick: https://qiita.com/kobatan/items/40728fbb625057d9f42b

Crossfire is a bidi protocol as oppsed to SBUS oder IBUS-Controlpart.

At a first glance it looks like the Crossfire-RX does not expect anything from the FC (the radio in this case) to be returned for packets of type CRSF_ADDRESS_FLIGHT_CONTROLLER and CRSF_FRAMETYPE_RC_CHANNELS_PACKED. Is this assumption correct?

@rotorman
Copy link
Member

rotorman commented Mar 23, 2022

Correct, you could just wire up the EP2 (CRSF) receiver TX line and leave the RX unconnected. Here a capture from the EP2 TX line (snippet):

C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21 
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21
C8 0C 14 35 00 64 0C 00 07 00 00 00 00 2E
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21 
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21

What you get are CRSF_FRAMETYPE_RC_CHANNELS_PACKED (third byte 0x16) and CRSF_FRAMETYPE_LINK_STATISTICS (third byte 0x14) packets.

@wimalopaan
Copy link
Contributor

Correct, you could just wire up the EP2 (CRSF) receiver TX line and leave the RX unconnected. Here a capture from the EP2 TX line (snippet):

C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21 
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21
C8 0C 14 35 00 64 0C 00 07 00 00 00 00 2E
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21 
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21

Cool, thanks for the data: will use that as replay ...

@wimalopaan
Copy link
Contributor

If I would like to get real HW, what would you suggest as RF-Module and RX? Available, simple and cheap...

@rotorman
Copy link
Member

rotorman commented Mar 23, 2022

Here some more change in data for your experiments:

C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21
C8 0C 14 35 00 64 0C 00 07 00 00 00 00 2E
C8 18 16 EA 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 BB 
C8 18 16 EC 03 9F 4B 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 9D 
C8 18 16 EA 03 9F 4B 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 07 
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 21 
C8 18 16 EC 03 9F 49 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 DC DA 37 
C8 18 16 EA 03 9F 4B 99 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 DC DA 11
C8 18 16 EC 03 9F 49 A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 FF 
C8 18 16 EC 03 9F 49 A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 7C D3 0B 
C8 18 16 EA 03 9F 4B A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 7C D3 2D 
C8 18 16 EA 03 9F 4B A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 D9 
C8 18 16 EC 03 9F 47 A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 61 
C8 18 16 EC 03 9F 47 B9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 7C D3 DF 
C8 18 16 EC 03 9F 47 B9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 2B 
C8 0C 14 35 00 64 0A 00 07 00 00 00 00 FC 
C8 18 16 EC 03 9F 45 B9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 97 
C8 18 16 EC 03 9F 45 A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 DD 
C8 18 16 EC 03 9F 45 A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 7C D3 29 
C8 18 16 EC 03 9F 45 A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 DD
C8 0C 14 35 00 64 0B 00 07 00 00 00 00 68 
C8 18 16 EC 03 9F 45 B9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 97 
C8 18 16 EC 03 9F 47 A9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 7C D3 95 
C8 18 16 EA 03 9F 47 B9 F3 0B F0 81 0F 7C E0 03 1F F8 28 08 00 00 44 1C D7 B1
C8 0C 14 35 00 64 0A 00 07 00 00 00 00 FC 

Have a look at HappyModel ES24TX and EP1 or EP2
Alternatively ES900TX and ES900RX if you want 868 MHz instead (868 MHz units cannot do 500 Hz ELRS, but they have longer range): http://www.happymodel.cn/index.php/2021/02/19/expresslrs-module-es915tx-long-range-915mhz-transmitter-and-es915rx-receiver/

@wimalopaan
Copy link
Contributor

wimalopaan commented Mar 23, 2022

The other protocols like SBUS, IBUS oder SumD/V3 use a fixed known baudrate. As I read CRSF can use different baudrates. But in the hardware-tab there is no more a baudrate selector.

What would be your suggestion how to implement that (at first):

  1. use a fixed baudrate (e.g. 400KBaud (or 420KBaud?))
  2. use a user selectable baudrate (we need again a baudrate chooser)
  3. autobaud (this may be only a try-n-error strategy by simple trying some well known baudrates).

@raphaelcoeffic
Copy link
Member

raphaelcoeffic commented Mar 23, 2022

400k is ok for a start, I think. Autobaud might be doable but it normally requires some bit patterns to be efficient and precise.

@raphaelcoeffic
Copy link
Member

There is also the “brute force method” that just switches between known baud rates and tries to decode some traffic.

@wimalopaan
Copy link
Contributor

There is also the “brute force method” that just switches between known baud rates and tries to decode some traffic.

... that's what I meant above under 3)

@rotorman
Copy link
Member

rotorman commented Mar 23, 2022

Isn't the receiver side always 420k 8N1 irrespective of the update rate?
https://github.com/ExpressLRS/ExpressLRS/blob/2f78e06889f75996a7e7aaa6e63e5bd0f9ffd64d/src/lib/CrsfProtocol/crsf_protocol.h#L30

@wimalopaan
Copy link
Contributor

wimalopaan commented Mar 25, 2022

In #1462 now we have

  • sbus (tested)
  • ibus (tested)
  • crsf (not tested)
  • sumd (not implemented)

This is available on AUX serial ports (AUX1 or AUX2).

@wimalopaan
Copy link
Contributor

wimalopaan commented Mar 25, 2022

For SUMDV3 I intend to do the following:

  • first 16 channels are available as trainer input
  • the binary switches 1-64 are mapped onto a LS iff the LS is of sticky type with no(!) set or reset condition.

So, if one wants to use the binary switches that come in via SUMDV3 trainer, she has to setup the wanted LS as above before.

@pfeerick
Copy link
Member

I'll grab another ELRS RX out later to try the CRSF support...

@pfeerick pfeerick self-assigned this Mar 26, 2022
@pfeerick pfeerick linked a pull request Mar 26, 2022 that will close this issue
@wimalopaan
Copy link
Contributor

I'll grab another ELRS RX out later to try the CRSF support...

I do not guarantee for anything ;-)

@pfeerick
Copy link
Member

It seems to be working fine... only checked with the first four channels so far though :)

@wimalopaan
Copy link
Contributor

It seems to be working fine... only checked with the first four channels so far though :)

Sounds good, thanks for testing.

@sk8board
Copy link
Author

Thank you for working on this. Do you know if this enhancement is targeted for a release?

@pfeerick
Copy link
Member

Should be in 2.8.

@sk8board
Copy link
Author

@pfeerick @raphaelcoeffic

Should be in 2.8.

Is CRSF input for Trainer mode still planned for 2.8? If so, can I test this with 2.8.0-rc3?

@gagarinlg
Copy link
Member

It is not going to be in 2.8.when you check PR #1462, you will see, that it needs to be rebased I clouding a bunch of manual work for translations.

@wimalopaan
Copy link
Contributor

Maybe you want to checkout my
https://github.com/wimalopaan/edgetx/tree/wmibus_telem
branch for this. This is more uptodate.

@pfeerick
Copy link
Member

So #1861 supercedes and includes #1462?

@wimalopaan
Copy link
Contributor

Yes, it does.
It includes SBus/IBus/SumDV1-3 trainer input (up to 32 channels if EXTENDED_TRAINER is set) and FrSky-Telemetry-Input.

@raphaelcoeffic
Copy link
Member

It includes SBus/IBus/SumDV1-3 trainer input (up to 32 channels if EXTENDED_TRAINER is set) and FrSky-Telemetry-Input.

Kind of a "pot pourri", we'll need to sort that out and extract features one by one.

@wimalopaan
Copy link
Contributor

Yes, it is. Actually I don't have time to sort that out by myself ... sorry.
But please don't hesitate to cherry pick the parts.

@pfeerick
Copy link
Member

Lol... have no fear, the skeleton will be picked clean, and credit given where credit is due ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
6 participants