Frequency hopping experiments on the NRF24

Any old or new electronic projects on the go
Post Reply
User avatar
Wayne_H
Posts: 810
Joined: 17 Feb 2018, 05:26
Location: Temora, NSW. Australia
Contact:

Re: Frequency hopping experiments on the NRF24

Post by Wayne_H »

Congrats Phil - perseverance pays off!

Your code may not be as "advanced(?)" compared to Martin's & Werner's approach, but it still impresses the heck out of me!! While I've been mostly able to follow the logic & context of your descriptions during development, I wouldn't have a clue how to actually write such code :o :oops:

Again, well done!
Cheers,

Wayne
Once a Retrobate, always a Retrobate............ ;)
User avatar
PaulJ
Posts: 598
Joined: 16 Feb 2018, 19:01
Location: Ipswich, UK

Re: Frequency hopping experiments on the NRF24

Post by PaulJ »

I too feel the need to congratulate all you guys on your incredible projects! :o :P Most of it has been way above my pay grade but reading it has at least given me an inkling of how it works....... Thank you all!!!

Paul
User avatar
Phil_G
Posts: 597
Joined: 15 Feb 2018, 23:32
Contact:

Re: Frequency hopping experiments on the NRF24

Post by Phil_G »

Steady on chaps I can see you're all excited to go flying again.... soon :D

Its had a couple of days of every test I could think of, in as heavily-RF-saturated an environment as I could muster, no problems at all, power cycling, power cycling at range, deliberate introduction of a few 'wrong' RF channels individually, alternately and in groups - no problems. The only thing I've not done is an absolute full-power range test which with the high-power modules I expect will be fine, if so I'm happy to fly it :D
One suggestion - with the high power modules a good 3v3 supply is absolutely essential, so if anyone is buying these modules I would suggest buying the piggy-back adapter too.

Edit: The RF-Nano receivers are fine, they've a 16mhz processor and work perfectly but I need to make some changes to suit the 8mhz 3v3 promini receivers. All the 16mhz clock receivers work great, which is what I've been testing on. I'll try to get the 3v3 Prominis working too, but if not, using RF-Nanos is no hardship :D

Update:
Edit: this update is out of date. I now use timer2 for the FHSS hopping, and the timer1 servo library works at 16 and 8mhz so this is no longer an issue. I left it here for the sake of 'the story' :)
Okay thats the 3v3 Promini receiver sorted, as supplied the ServoTimer2 library is hard coded for 16mhz operation, I searched for an 8mhz version and all I found was people asking for an 8mhz version, but no answers!
So I've had to modify the library for 8mhz, see attached. This amended library only suits 8mhz now, dont use it with 16mhz or the servos will see half the required pulsewidth. This is only for home-made receivers with a 3v3 8mhz Promini and separate NRF24L01, for the integrated RF-Nanos the original ServoTimer2 library is the one to use. I might try integrating it all into the receiver code, and give it an 8mhz/16mhz switch option.

You can install both versions in the /arduino/libraries/ folder as they're separate libraries - see attachments below.

PS when using both, remember that CE & CSN are reversed on the RFnano!

Also, sorry chaps, I just realised that whilst testing the receiver I'd taken the "set-failsafe" bit out, so whilst failsafe still worked it was fixed at the default low throttle and neutral everything else. Heres the code with the set-failsafe put back in, just move the controls where you want them to failsafe to, ground D7 (edit: now D8) and it waggles a servo to confirm. Its a 'safe failsafe' :D in that if you forget to set it, it defaults to low throttle anyway. For cars or boats of course thats full reverse so amend to suit!!!! ie:
#define thr_failsafe 1100 change to #define thr_failsafe 1500

The RF-Nano receivers are really neat and so easy to do, just add servo wires, choose a block like Tobe's or separate servo leads. On the block, the end pin is for setting failsafe, Tobes idea!

RF-Nano receiver
RF-Nano receiver

Meanwhile I've converted a nice OS Cougar that Gary gave me a while back. It uses the RF modules &
FHSS software from this thread and is working great on the bench, but unflown as yet of course :cry:
The NRF board needs 7 wires and is connected via two sideways servo plugs with D9,10 & 11 on one plug and D12,13 and ground on the other. The plugs are bottom right. Pos comes straight from the on-off switch.
It has the usual expanded scale meter reading from 6 to 8.5 volts which suits the 2S Li-ion perfectly.


Nice, clean & stock-looking OS :-)
Nice, clean & stock-looking OS :-)

Look Ma, no DFT !   <br />Uses an old Ebay redboard
Look Ma, no DFT !
Uses an old Ebay redboard


All the code, diagrams & photos are attached to the opening post.



.
User avatar
Phil_G
Posts: 597
Joined: 15 Feb 2018, 23:32
Contact:

FHSS range test:

Post by Phil_G »

FHSS range test:
I find it easier to do long range-tests at night, I have a homebrew two-way channel-switch thingy with two superbright leds, red for left, green for right, and at night its visible over incredible distances.
I wasnt sure what to expect when using an RF-Nano as a receiver, I'd only seen figures between two RF-Nanos whereas on the transmitter we're using the 'high power' modules.

Theres a long, straight & quiet road nearby and I set up the FHSS receiver & leds on a plastic bollard on the furthest edge of one roundabout. It was running from a single 18650 Li-ion cell connected to vcc (the 5v rail) and had settled at 4.05 volts. I then took the OS Cougar on a walk on to the next roundabout, checking all the way, occasionally power-cycling to make sure it hooked up again - and at the next roundabout it was still solid and instant. Thats just over 700 metres and it was as far as I could go in a straight line - with a longer road I'm certain it would have been further, and thats ground range with streetlamps & signage. Tried a few long range power cycles and it hooked up immediately with no delay. I'm perfectly happy with a ground range of at least 700 metres so I'm going to put it in the Junior 60 for trials, whenever that might be :lol:

I should add that this is a really quiet road, there was no traffic at all, I wouldnt be flashing LEDs where there was traffic.

Must say I'm really pleased with the RF-Nano as an R/C receiver, it works way better than I imagined, I dont think I'll bother faffing with the Promini plus NRF board receivers now, the RF-Nanos are just the job :D

At some stage I might think about doing a receiver that uses two for diversity, but so far I dont think its necessary, surely no-one is going to put this in anything big, fast or dangerous.


707 metres and still solid
707 metres and still solid


I've since made a couple of purely cosmetic changes to the receiver, added an LED (5v type) that alternates on/off every 20th packet, this is just a confidence thing and also shows failsafe. Using a 5v LED avoids the need for a resistor. It fits flush, pos (longest leg) to A0 and neg to A1. This was after the range test - I'd cover it with black tape for any further tests.
And I made two servos waggle to indicate that the programmable failsafe has just been set, rather than one. Otherwise no functional code changes, it works great!


With &amp; without the 5v LED
With & without the 5v LED


All the code, diagrams & photos are attached to the opening post.




.
bluejets
Posts: 316
Joined: 19 Jun 2019, 04:09

Re: FHSS range test:

Post by bluejets »

Phil_G wrote: 14 May 2020, 23:16
I find it easier to do long range-tests at night,
Like minds.... I do the same with a small servo and an LED on each end of the throws.
Works great.
Original idea came from the surveyors when I worked at the Water Resources Commission.
They used a small torch bulb in a case and it could be detected for miles at night.
MaxZ
Posts: 330
Joined: 31 Jan 2019, 11:48
Location: Boskoop, Netherlands

Re: Frequency hopping experiments on the NRF24

Post by MaxZ »

Hi Phil,
As the DHT module I ordered from HK seems to be stuck somewhere between HK and Singapore, I am seriously considering trying the NRF24 option.

Just to recap, besides the usual control elements and switches I will need for the Tx:
- high power version NRF24L01 + PA, for example this https://www.aliexpress.com/item/3297131 ... hweb201603_
- Arduino ProMini 3.3 V
- Voltage Regulator, stepdown to 3.3V like this: https://www.aliexpress.com/item/3277409 ... hweb201603_
( or do I need a step up/stepdown booster regulator?)
- Single cell LiPo

and for the Rx:
- combined Arduino Nano with NRF24L01 : https://www.aliexpress.com/item/4000112 ... hweb201603_
- Battery, 4x NiMh

Is this correct?
It seems there is no combined Arduino Nano or ProMini version together with the high power version of the NRF24...........

Cheers,
Max.
User avatar
Phil_G
Posts: 597
Joined: 15 Feb 2018, 23:32
Contact:

Re: Frequency hopping experiments on the NRF24

Post by Phil_G »

Hi Max, for the transmitter I would definitely get the proper adapter, makes it much easier - see earlier photos: https://www.aliexpress.com/item/1876127 ... 4c4d0U7DeZ
The adapter is the first 'colour' option, just 38 pence! On the OS Cougar I powered this board directly from the on/off switch with 2S battery voltage. Ground and the 5 signals go to the Nano/Promini gnd,D9,10,11,12,13.


ali.jpg


The high power modules need a really good supply and this specific board is the best option.
Then you can use a standard 5v 16mhz Promini or Nano, and you dont need any additional regulator.

For the receiver, yes the RF Nano, £3 from Aliexpress. Beware its 5 volts vcc, 6v could kill the NRF chip.
I use a single 4.2v 18650 Li-ion cell. I'd buy at least two, then you can use one for your initial transmitter experiments. Remember this system is unflown as yet :D

Once you have the hardware set up, you can try the 'lockdown project' hybrid semi-hopper too, and the 'single-RF-channel' projects like the Elektor and RCtractorGuy ones, as well as the single-chip, single-channel-emulation thing :D
Just watch CE and CSN, pins D9 and D10 are swapped on the RF-Nano:

Code: Select all

// RF24 radio(9, 10);
RF24 radio(10, 9);  // RF NANO
In future I will stick with the RF-Nano convention for both transmitters and receivers, but both of our model car radios and the MPX Pico were wired '9, 10' before I heard of RF-Nanos, hence the option.

Also remember to change your pipe address and maybe pick your own 'mychannels[]'
(spread them out over the 126 possibilities)

Code: Select all

/************* Radio config - make it unique! **********************************/
const byte pipeIn[] = "34567";   // last 5 digits of your phone number
const byte mychannels[] = {116, 98, 56, 70, 36, 12, 6, 16, 22, 26, 34, 43, 85, 122, 110, 2};  // 16 FHSS hopping channels
/*******************************************************************************/
...and the same for pipeOut[] in the transmitter

Its a great feeling when someone has a go at one of your projects, let us know how you get on Max :D

By the way Ebay reds are still available quite cheaply and ideal for playing with the RF-Nano:

https://www.ebay.co.uk/itm/Red-And-Blac ... 2578566922


ebay_redboard.jpg


Whilst these boards are quite a bit larger than the DIY-More's we're used to, they are easily lost inside a transmitter, in fact my Horzion 2 which is a very small set, was built by Ron using an ebay red & a Nano.
This diagrams hows how two servo plugs make the NRF --> redboard connections easy peasy, the plugs fit across D9 to D13 and conveniently, the pin after D13 is GND:



nrf24l01_highpower.jpg
MaxZ
Posts: 330
Joined: 31 Jan 2019, 11:48
Location: Boskoop, Netherlands

Re: Frequency hopping experiments on the NRF24

Post by MaxZ »

Phil_G wrote: 17 May 2020, 13:58 Then you can use a standard 5v 16mhz Promini or Nano, and you dont need any additional regulator.
5V ?? I would have thought the serial connections from the Arduino needed to match the 3.3V level of the NRF24.

And I guess I could purchase the high power NRF24L01 from the same vendor as the regulator ("RoarKit"), right?

Cheers,
Max.
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Frequency hopping experiments on the NRF24

Post by Martin »

I suppose we could use the RF-Nano, as a receiver, powering it via its VIN input which then uses the Nano's on-board voltage regulator to regulate down to 5 volts?

The recommended voltage range for VIN is 6V to 12V, so a 2-cell LiPo would be fine. If you're using a 3-cell pack on an electric model, the freshly-charged voltage is a bit above the recommended range. You'd probably get away with it, but it would be advisable to use a dropper diode (or LED) in the line to VIN. An ordinary diode drops about 0.7 volts, a red LED about 1.8 volts and as you go through the spectrum of LEDS the voltage rises up to about 3 volts for a blue LED.

Don't try to power any servos from the RF-Nano's VCC though - again the on-board regulator can't supply much current - so you'd power the servos in the usual way from the ESC BEC, but the control signals to the servos (which don't carry much current) would come from the RF-Nano.

The regulator on the RF-Nano is an AMS 1117 which is rated up to 1.5 amps, but I wouldn't like to power even small servos from it, except for bench tests with no servo load.
User avatar
Phil_G
Posts: 597
Joined: 15 Feb 2018, 23:32
Contact:

Re: Frequency hopping experiments on the NRF24

Post by Phil_G »

No Max, the NRF24 inputs are 5v tolerant, the RF-Nano for example is a 5v board Image

Yes, the high-power module and the adapter are available from the same 'Roarkit' listing (linked in my last post). Incidentally you can power the adapter directly from the tx battery too, its just the usual AMS1117-3v3 regulator. Thats what I've done as I'm not keen on cascaded regulators.


Buy the +PA modules and the adapters
Buy the +PA modules and the adapters


For a model boat or car, you can do the whole project with two RF-Nanos Image



Martin wrote: 17 May 2020, 16:56Don't try to power any servos from the RF-Nano's VCC though....
...just to clarify, what Martin means is not to power servos from the on-board 5v Vcc regulator output when using 2S on vraw (Vin, same thing). I'm powering mine via Vcc as an input with 5v (actually a Li cell, but could be a BEC) so its perfectly fine to connect the servos to Vcc too. What you cant do is power it via a 2S on Vraw and then power 5v servos from Vcc as an output, as Martin said ;)
Martin wrote: 17 May 2020, 16:56... so you'd power the servos in the usual way from the ESC BEC, but the control signals to the servos (which don't carry much current) would come from the RF-Nano.
If you're using a 5v BEC, then the BEC positive feeds all the servo positives, and the RF-Nano's Vcc pin. In this case vraw (Vin) isnt used. Same with a Li-ion cell. All negs are commoned of course.

The 'servo block' method makes this really easy and reduces the total number of wires. It commons all the positives at the block, including servos, Li-cell or BEC - and all negatives, and takes one wire from common pos and another from common neg back to the Nano Vcc and Gnd respectively. Its worth checking that it is a 5v BEC though, some are intentionally 5.5 or even 6v :D
A 2S LiFePo4 seems a popular choice, in which case take the common pos to Vin (raw) rather than to vcc, but first check that your servos will take 7.2 volts.

Basically, if the power supply is over 5v (eg 2S Li) use the Nano's Vin (raw), if its 5v or slightly less (eg 5v BEC or a single Li-cell) then use Vcc. I use Vcc because I'm running the rx from a single 18650 Li-ion cell or a 5v BEC.


Tobe's servo-block idea <br />Easy, neat, convenient and works well
Tobe's servo-block idea
Easy, neat, convenient and works well

Note: Failsafe moved to D8 ! (was D7)<br />Compare this with the diagram above
Note: Failsafe moved to D8 ! (was D7)
Compare this with the diagram above

... and flipped over...
... and flipped over...


I'll probably move the 'set failsafe' from D7 to say D14 to leave D7 & D8 free for more channels in a neat row. Since theres no PPM frame for them to squeeze into, you can have as many channels as you like! Then again, four channels is three too many... :D EDIT: Failsafe is now on D8
Post Reply