pascallanger / DIY-Multiprotocol-TX-Module

Multiprotocol TX Module (or MULTI-Module) is a 2.4GHz transmitter module which controls many different receivers and models.
https://www.rcgroups.com/forums/showthread.php?t=2165676&goto=newpost
GNU General Public License v3.0
1.61k stars 434 forks source link

Add support for SX127X chips (TBS CrossFire, FrSky R9) #303

Open UnTraDe opened 4 years ago

UnTraDe commented 4 years ago

Is there a plan to add support for the long range systems (TBS CrossFire/FrSky R9)? By taking apart the R9M and the R9 I own, I found they are based on the SX1276 LoRa chip from Semtech (https://www.semtech.com/products/wireless-rf/lora-transceivers/sx1276).

Some pictures I took from the R9 receiver with a microscope:

2015_0606_000453_002

And the front-end ~looks like it has an amplifier~ has a switch (probably for antenna diversity):

2015_0606_000509_003

Googling around about TBS Crossfire, it looks like they use an RFM95-something chip, which appears to be the same silicon as the SX1276 chip just with different markings. Is there any work currently being done on reverse-engineering those protocols?

As far as hardware goes, I think this module could be used easily along side the current 4-in-1 2.4GHz module, with a different antenna of course. This module is available from a lot of places really cheap (3~8$). I've ordered a few and I'm currently designing a simple PCB that connects them to an STM32F103 and expose the antenna pad to an SMA connector. I will try to write some initial code to try to talk to a receiver.

I can capture some SPI communications with a logic analyzer between the stm32f103 and the SX1276 chip on the R9M and R9 I have. Which procedures are usually the most useful to start with? (binding/regular use/telemtry?) I can also try to capture on-air data with SDR, but that would probably take longer to decode.

UnTraDe commented 4 years ago

@pascallanger

the code is set to minimum power output with 2dBm on the PA_BOOST pin: SX1276_SetPaConfig(true, 7, 0); -> the 0 sets it to 2dBm incrementing it up to 0xF would only increase the power output up to 20dBm. => the PA Absolute Maximum Rating input is 10dBm so the value must be limited to a max of 8

Correct, but 20dBm requires special operation, settings SX1276_SetPaConfig(true, 7, 15) alone would give +17 dBm.

the PA can't be turned off/changed -> the gain is fixed Therefore I don't see a way to decrease the power of this module. You can increase the output but I'm not sure if the radio is designed to handle more current so I'm a little hesitant to try it out... I don't have a power meter to see how much it outputs currently but I've measured an input power of 1.55W. Usually there is a factor of 3-5 from input to output, so the output of the module is probably between 300mW and 500mW.

According to the schematics, you can bypass the external amplifier (SKY65111) by operating the SX1276 through the RFO_HF pin and set the switch (SKY13330) to use RF2 as input. That way we can go from -4dBm to the max of what the external amplifier can do, in steps of 1 dBm.

image

We can go up to 15 dBm on the RFO_HF pin, and then switch to 10dBm over PA_BOOST with the external amplifier.

pascallanger commented 4 years ago

@UnTraDe

According to the schematics, you can bypass the external amplifier (SKY65111) by operating the SX1276 through the RFO_HF pin and set the switch (SKY13330) to use RF2 as input. That way we can go from -4dBm to the max of what the external amplifier can do, in steps of 1 dBm.

Sorry but no... On the schematic the RFO_HF pin is unconnected. The RF switch is between RFI_HF and PA_BOOST. Therefore with the current implementation there is no way to lower the output power but just increase it as said previously.

UnTraDe commented 4 years ago

@pascallanger

Sorry but no... On the schematic the RFO_HF pin is unconnected. The RF switch is between RFI_HF and PA_BOOST. Therefore with the current implementation there is no way to lower the output power but just increase it as said previously.

Oh yeah you're correct, I missed that. We will probably need another switch for it to work. BTW was is the gain on that amplifier?

pascallanger commented 4 years ago

@UnTraDe Frankly, I've got a hard time understanding the PA datasheet. I think the PA gain is 40dB but since they are using a different value for VAPC1 and VAPC2 I'm not fully sure. I've measured VCC1&2=3.3V, VAPC1=2.512V and VAPC2=1.603V.

pascallanger commented 4 years ago

SX1276_SetPaConfig(true, 7, 0); -> the 0 sets it to 2dBm incrementing it up to 0xF would only increase the power output up to 20dBm. => the PA Absolute Maximum Rating input is 10dBm so the value must be limited to a max of 8

Correct, but 20dBm requires special operation, settings SX1276_SetPaConfig(true, 7, 15) alone would give +17 dBm.

By the way the 20dBm is enabled in the current code: SX1276_SetPaDac(true); so SX1276_SetPaConfig(true, 7, 15); would give 20dBm like I've written.

AlessandroAU commented 4 years ago

@pascallanger Do you have a prototype 5in1 module? On the real R9M there is a tiny sot23-6 I2C dac that controls APC2 via voltage and APC1 is pulled high to ~2.6v.

pascallanger commented 4 years ago

@AlessandroAU As far as I know I have the T18 as it is being sold.

AlessandroAU commented 4 years ago

Can you look inside? Did they copy the I2C DAC concept?, that would explain how the output power is being controlled.

pascallanger commented 4 years ago

Do you really think I could miss such a thing... image

AlessandroAU commented 4 years ago

Thanks for the picture :) Looks almost the same as an R9M on the inside!. Do you have schematic as well or just hardware?

BTW, this is how the PA works, you have APC1= ~2.6v so look at green/brown line. image you have APC2 = ~1.6v so total gain is about 25dbm, so 27dbm total.

This is ~500mw which is assume could have been their design goal.

pascallanger commented 4 years ago

Yes we reach the same conclusion of 500mW. But they advertised that the module is 300mW this is why I'm saying I can't be sure about it unless there is a measurement of the actual power to validate it since the difference is large.

UnTraDe commented 4 years ago

Also, they should probably make another revision to add shielding over the RF part, although I'm not sure if that would help, I suspect it might be the antenna from outside which interferes with the switch readings. Anyway, if they're going with another revision, maybe we would recommend them to add another switch and/or connect an adjustable regulator to APC2 like @AlessandroAU said. BTW, we probably don't need it now, but if we're going to add support for more protocols that are using the SX1276 (like TBS crossfire) it might be better to connect more DIO's, maybe other protocols are using some of the automatic features like the implicit header, freq hopping with FhssChangeChannel, etc... which might require using more DIO's for indications.

AlessandroAU commented 4 years ago

Ah right sorry, my bad for not carefully reading the whole thread. As for the question of power. I can help you answer that. On my R9M hardware I can set the Radio to 2db (0b0000 in power reg using PA_BOOST) and then sent APC1 = 2.6 and APC2 = 1.600v, the result is spot on 500mw :)

image

pascallanger commented 4 years ago

@AlessandroAU Thanks for the measurement, it clears out the confusion I had :-) What do you do with this R9M module? Anything that Multi could benefit from?

JyeSmith commented 4 years ago

@pascallanger https://github.com/AlessandroAU/ExpressLRS

pascallanger commented 4 years ago

@JyeSmith Thanks!

@AlessandroAU would you consider to port your protocol to Multi? I can help if you are interrested.

rodrigosclosa commented 4 years ago

Ah right sorry, my bad for not carefully reading the whole thread. As for the question of power. I can help you answer that. On my R9M hardware I can set the Radio to 2db (0b0000 in power reg using PA_BOOST) and then sent APC1 = 2.6 and APC2 = 1.600v, the result is spot on 500mw :)

image

@AlessandroAU wich RF meter is this? Open source?

AlessandroAU commented 4 years ago

@pascallanger Yes, would be very keen to look into porting to multi :), although we have to reach a stable release first :) We've had a lot of lessons learnt from playing with the sx1276 and learning how to optimise things and discover it quirks. I assume some of our experience will be helpful :). Happy to work together.

@rodrigosclosa Power meter is based on an ad8313 module from aliexpress plus an Arduino and an display. I haven't published source but happy to. I don't even have a schematic, it's all basic point to point wiring inside. image

pascallanger commented 4 years ago

@pascallanger Yes, would be very keen to look into porting to multi :), although we have to reach a stable release first :) We've had a lot of lessons learnt from playing with the sx1276 and learning how to optimise things and discover it quirks. I assume some of our experience will be helpful :). Happy to work together.

I'm not sure I get what you are saying. The current release is stable. Just that you can't change the power due to HW limitations... The control of original R9 receivers work on both 915/868MHz including failsafe but no telemetry. There has been a flight test which reached 6km.

AlessandroAU commented 4 years ago

No no, I meant my own project. We are still tweaking and experimenting with different things and modulation parameters. IE in a branch I have improved timings so the FEC coding rate can be increased. If we make changes it will be a hassle to propagate to multi.

UnTraDe commented 4 years ago

@pascallanger

The control of original R9 receivers work on both 915/868MHz including failsafe but no telemetry. There has been a flight test which reached 6km.

Really? That's awesome! With what hardware?

Xedos9er commented 4 years ago

@pascallanger Yes, would be very keen to look into porting to multi :), although we have to reach a stable release first :) We've had a lot of lessons learnt from playing with the sx1276 and learning how to optimise things and discover it quirks. I assume some of our experience will be helpful :). Happy to work together.

I'm not sure I get what you are saying. The current release is stable. Just that you can't change the power due to HW limitations... The control of original R9 receivers work on both 915/868MHz including failsafe but no telemetry. There has been a flight test which reached 6km.

6km on 300mw?? Did failsafe kick in? So power is fixed to 300mw?

pascallanger commented 4 years ago

@UnTraDe 6km with the T18 stock. Failsafe kicked in and plane returned home: image

@AlessandroAU Power is 340mW in 868MHz and 360mW in 915MHz. Don't know why we are not getting the 500mW.

@Xedos9er Power output is fixed to the value above due to the hardware design.

Xedos9er commented 4 years ago

Not adjustable power is a big nogo for me. So need to wait for new hardware? Or just stay with my R9M and use radiomaster :/

pascallanger commented 4 years ago

@Xedos9er ask Jumper...

AlessandroAU commented 4 years ago

@pascallanger Was that measurement peak or average power? I was measuring peak power. Playing with the loRa calculator I see the duty cycle is not 100%, maybe that could help explain the difference?

kilrah commented 4 years ago

Peak.

andika207 commented 4 years ago

@pascallanger I'm not sure I get what you are saying. The current release is stable. Just that you can't change the power due to HW limitations...

I'm getting confused with your messages. You first said that some sort of shielding was required but now you confirm the long range module is stable You also said that you can't lower the power but just increase it to some extent... then what ? can you boost the power or not ?

pascallanger commented 4 years ago

You need to separate the different topics:

annoyinganime commented 4 years ago

There are E32-868t30d modules, which contain sx1276, 1w amplifier and STM8L15x onboard - so everything what's needed to be a standalone 900mhz board. Many of us, including me, have transmitters with built-in 4in1 modules, and adding one external board for more protocols will be an amazing option to have. How hard it will be to port multiprotocol firmware with 915mhz-specific protocols onto STM8L15x?

pascallanger commented 4 years ago

I've solved the issue with 868. The telemetry from RX to TX should work.

pascallanger commented 4 years ago

I've also added the bind options: ch1-8 or ch9-16 and telem on or off. If you want to be able to select you need to compile OpenTX from my branch. Otherwise by default it will be in ch1-8 telem on.

UnTraDe commented 4 years ago

I've solved the issue with 868. I've also added full telemetry from RX to TX. I'll add later TX to RX.

Cool! What was the problem?

pascallanger commented 4 years ago

Cool! What was the problem?

868 binds in 915 and set a flag to tell the RX that it will use 868 after bind. Pascal

pascallanger commented 4 years ago

In v1.3.1.34, TQly is the percentage of the number of received telemetry paquets per second. Perfect link=100%, signal lost=0%.

pascallanger commented 4 years ago

In v1.3.1.35, the telemetry from TX to RX should work (BF and SxR scripts). I have currently no way to test the telemetry so please report.

pascallanger commented 4 years ago

In v1.3.1.37, FCC should work. If someone can test and report.

MahmoudElShazly commented 4 years ago

After upgrading the internal model with v1.3.1.36, I cannot see FRSKYR9 any more in the selection, any idea what may cause this?

benlye commented 4 years ago

@MahmoudElShazly what firmware file did you flash to your radio? Did you compile it yourself or download it? Presumably it does not have R9 support enabled...

MahmoudElShazly commented 4 years ago

I downloaded it from here tried both of these multi-stm-opentx-aetr-inv-v1.3.1.36.bin multi-stm-opentx-aetr-noinv-v1.3.1.36.bin

benlye commented 4 years ago

Those files aren't for the T18 and do not have the R9 protocol.

These ones will work: https://downloads.multi-module.org/?jp-t18int

In other words, the file named multi-t18int-opentx-aetr-noinv-v1.3.1.36.bin is the one you want.

MahmoudElShazly commented 4 years ago

@benlye , thank you so much, I will try this one.

I was following this and stooped at this step "Configure the firmware", how can I do that? (sorry if this is a basic question) do I need to define some constants at the beginning of the board definition?

benlye commented 4 years ago

Everything you need to configure is in the file named _config.h. You shouldn't make changes anywhere else. The configuration file includes lots of comments which tell you what each option does.

MahmoudElShazly commented 4 years ago

I have used it and it works perfectly now, thank you. In companion there is an option to enable voltage telemetry 'faichoice' how can I enable that in the firmware? I am getting the "Cells" sensor but with zero value.

kilrah commented 4 years ago

FAI options are to DISABLE telemetry. You don't want those unless you're participating in a competition where telemetry is forbidden, which is their whole purpose.

MahmoudElShazly commented 4 years ago

My apologies, I have mixed up OpenTx with the 5in1 module firmwares

pierrotm777 commented 4 years ago

TBS Cross Fire protocol will be added in the future ?

longxk commented 4 years ago

@rodrigosclosa Did you figure out whether T16 internal module has any spare SPI pin?

rodrigosclosa commented 4 years ago

I haven't tested the T16 Internal Module... Only Jumper external module...

Em qui., 23 de jul. de 2020 às 09:20, Loong notifications@github.com escreveu:

@rodrigosclosa https://github.com/rodrigosclosa Did you figure out whether T16 internal module has any spare SPI pin?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/issues/303#issuecomment-662975073, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABKLWLP4SNXJ7YBXCS6NWTR5ATJVANCNFSM4JVDW6MQ .

--

Rodrigo Sclosa • Arquiteto de Software

rodrigo.sclosa@gmail.com (19) 99292.6385

facebook.com/rodrigo.sclosa

CarlDavey commented 4 years ago

This is awesome. Thank you. I tested R9 with the T18. I get intermittent periods where the telemetry goes haywire. Values jump around for a few seconds, I had one flight where telemetry distance was over a million kilometres away from home position.

The plane is still responsive to stick inputs.

Radio is on opentx-t18 2.3.10N277 and Multi firmware 1.3.1.47. Receiver is a R9 Mini OTA(EU) on FW-R9MINI-ACCST FLEX firmware v20190201

I posted opentx and blackbox logs over on RC Groups. The issue was first reported by mshagg2 on the T18 thread.

Logs: (from line 533) Zagi_Inav-2020-07-31.zip

Screenshot_2020-07-29-12-35-43-60 Screenshot_2020-07-29-12-35-54-72

RC Groups Post