theboot999 / NRFFHSS

3 stars 1 forks source link

A little conversation #1

Open HamzaYslmn opened 3 weeks ago

HamzaYslmn commented 3 weeks ago

I haven't been able to fully test every feature yet. As someone using your code for the first time, I wanted to share some experiences I had, which might be helpful for further development.

First of all, since you've modified other libraries and presented this code, there might be updates or conflicts in the future. To prevent this, I would suggest using the libraries in your code without modifying them (if you have made changes).

Normally, we would set the power level using the radio.setPALevel(RF24_PA_MIN); command.

Additionally, I think if you make the code compatible with ESP32 and RTOS, it could be used by more people. I'm experiencing conflicts when sending large data due to interrupts. If RTOS is supported, it could be used in larger projects (e.g., RC planes, RC cars).

While using your code, I encountered frequent issues like watchdog errors. Thanks to FHSS, I can leverage ESP32's Bluetooth and Wi-Fi features to parallelize data to my main device while also working long-range with NRF.

theboot999 commented 3 weeks ago

Thank for the input and thanks for trying it!

Yes It'd probably a good idea to include the rf24 library. It's using the stock version of the rf24 library.

The interrupt is very short. It's only grabbing a timestamp off when a packet is received.

Your problem likely stems from having set the slowest data rate (512) and a large packet size with a high framerate. At 512 data rate and sending 3 packets per frame the rf24 is blocking for each send, and takes a long time to send

Feel free to use and grab whatever you want from here. I made a version that used a teensys frequency clock counter rather than micros to get more accurate time stamps when packets are received. I'm not sure if the esp32 has an easily readable clock counter register.

HamzaYslmn commented 3 weeks ago

https://iotcircuithub.com/esp32-internal-rtc-timer-control-relay/

esp32 has direct RTC inside :D

image

theboot999 commented 3 weeks ago

Great! You would get more accurate timing of the rtc as well.

I figured putting the interrupt inside the Slave.cpp made it easier to use without having to set up the interrupt yourself.

The timing was difficult to get right. Even if the master sends a packet at exactly the same time the nrf24 always has a slight variance in time when it will trigger the interrupt. Also using nanos (or even a teensy 4.1) the clock speeds are always slightly different. So it will adjust the frame time slightly to try and compensate. You can read the amount kts adjusted from totalAdjustedDrift.

The hardest part to get stable was if the master turns off and back on and getting the slave to resync. It should be pretty solid but.

The biggest issue would be using a slow data rate, large packet size and high framerate and the rf24 takes too long a frame time to send the data

Let me know if you have some success with it.

HamzaYslmn commented 3 weeks ago

also bidirectional FHSS would be nice

theboot999 commented 3 weeks ago

It is bidirectional.

I'm using it for an rc plane with gps, gyro and barometer with homecoded autopilot etc.

Check the 2 examples. Master sends to slave and slave sends to master.

theboot999 commented 2 weeks ago

Did you test bidirectional?

HamzaYslmn commented 2 weeks ago

image

I need to reorganize your code for ESP32. I'm still trying to understand your code, trying to simplify it.

Also, my NRF modules sometimes don't communicate. Even though I touch the antennas.

So I am trying to solve those problems too.

HamzaYslmn commented 2 weeks ago

Also, since I plan to have multiple devices, I need to take some precautions to prevent them from interfering with each other.

HamzaYslmn commented 2 weeks ago

00:51:51.498 -> 00:51:51.498 -> 00:51:51.498 -> 00:51:51.498 -> ELF file SHA256: 9ee11132962ddd7f 00:51:51.498 -> 00:51:51.625 -> Rebooting... 00:51:51.625 -> ets Jul 29 2019 12:21:46 00:51:51.625 -> 00:51:51.625 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) 00:51:51.625 -> configsip: 0, SPIWP:0xee 00:51:51.625 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 00:51:51.625 -> mode:DIO, clock div:1 00:51:51.625 -> load:0x3fff0030,len:1288 00:51:51.625 -> load:0x40078000,len:13872 00:51:51.625 -> load:0x40080400,len:4 00:51:51.625 -> ho 8 tail 4 room 4 00:51:51.625 -> load:0x40080404,len:3048 00:51:51.625 -> entry 0x40080590 00:51:51.795 -> Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled. 00:51:51.827 -> 00:51:51.827 -> Core 1 register dump: 00:51:51.827 -> PC : 0x400f5c2c PS : 0x00060b30 A0 : 0x800d1a37 A1 : 0x3ffb3220
00:51:51.827 -> A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
00:51:51.827 -> A6 : 0x00000003 A7 : 0x00060223 A8 : 0x3ffc15a4 A9 : 0x00000000
00:51:51.827 -> A10 : 0x00000002 A11 : 0x00000010 A12 : 0x8008a6eb A13 : 0x3ffb2090
00:51:51.869 -> A14 : 0x00000003 A15 : 0x00060023 SAR : 0x0000000f EXCCAUSE: 0x0000001d
00:51:51.869 -> EXCVADDR: 0x00000001 LBEG : 0x4008429d LEND : 0x400842a5 LCOUNT : 0x00000026
00:51:51.869 -> 00:51:51.869 -> 00:51:51.869 -> Backtrace: 0x400f5c29:0x3ffb3220 0x400d1a34:0x3ffb3250 0x400d1a85:0x3ffb3280 0x4008a46d:0x3ffb32a0 00:51:51.869 ->

I'm still trying to solve RTOS problems :D

HamzaYslmn commented 2 weeks ago

image

There are still some problems but I seem to have solved them at a basic level. My work for RTOS continues :D

HamzaYslmn commented 2 weeks ago

I wonder what kind of arrangement we can make to avoid conflicts on multiple devices side by side using the same code?

HamzaYslmn commented 1 week ago

In my fork I added functions for Custom naming and Seed to create 40 hop channels in a certain channel range, you might want to take a look.