Phil's lockdown project - a 4ch propo NRF24 set

Any old or new electronic projects on the go
Post Reply
User avatar
Phil_G
Posts: 444
Joined: 15 Feb 2018, 23:32
Contact:

Phil's lockdown project - a 4ch propo NRF24 set

Post by Phil_G » 01 Apr 2020, 13:27

Edit: this hybrid-hopping project is obsolete now, see the full FHSS version here: viewtopic.php?f=42&t=971



Edit 8/4/20: Added a form of frequency hopping, see bottom of this post. This hopping/scanning puts it a step up from the usual fixed channel sets you see on the net, It has good range, its solid around other transmitters, the code is simple to follow and its easy to build - even easier if you use an RFnano for the receiver - just add servos! The set is working out really well, have a go, its cheap enough!

This is one of my lockdown projects - entertaining myself using bits I already have to hand :D
I was pondering options now that RF modules are hard to come by, and remembered that Tobe had kindly sent me some NRF24L01+ boards which I'd not done much with. Its been a while so I did a bit of revising and set about a simple project purely for interest. The NRF24s are buttons cheap and really easy to use, if a bit messy with their extra wiring.

The encoder body is adapted from the 7ch encoder with some changes and has the usual S/C escapement emulation, rates, expo, hardware & soft throttle locks, Vtail & elevon mixers, minute-minder, inactivity alarm, etc. I had to find a few more pins as the NRF24 interface needs seven (rather than the pos, neg, ppm we're used to) so theres no S/C sequential, but I've never seen anyone use that yet so its no loss!
I settled on a 4ch version, it could easily be extended but 4 is enough for me, its less birdsnest wiring and ultimately I didnt want to drill more holes in the Pico :D Theres room in each NRF packet for 16 or more full resolution channels, so one packet can conveniently hold everything we need.
The NRF handling was originally pinched straight from the simple library examples found in the IDE - but as always it has developed since then. Initially for example I didnt do any channel setting at all, whereas now it hops.

The receiver is a 3v3 promini with another NRF24 piggy-backed, the promini 3v3 vcc regulator supplying the Promini and the radio board. It has a built-in aerial and programmable failsafe on all channels set by momentarily placing a link on the rx. There are no spare LEDs so it confirms failsafe has been stored by wiggling a servo ;)
For ease I chose the servo leads like old retro receivers used to have rather than a header block, it keeps the receiver nice & small. Having the aerial on-board is neat, though obviously the usual rules apply, dont hide it behind a battery, etc.

These are the low-power NRF modules, I have some high power (LNA+PA) ones on order from Banggood but they've not arrived yet. [Edit: yes they have!] Range on the low power ones I found was at least 200 yards where I ran out of space, everything was still working and no failsafes. I'd happily use it in a boat as it is, but I'm waiting for the higher power versions to arrive before trying it in a plane.
Besides the "NRF24L01+" theres an older NRF24L01 (no plus) which I'd avoid except for experiments, they both have the 1M and 2M datarates but the later 'plus' version also does a lower datarate of 250khz which gives more range.

The diagrams below show the essential connections, the rest follows the usual "7ch+S/C" principles, though note some pins have had to be moved. It was very much a make-it-up-as-you-go-along project ;)

There are a few similar projects on the net but I did find what might be a common misunderstanding about the NRF24L01... I noticed that often the author goes to some length to reduce the payload to 32 bits, by limiting the resolution to 8 bits and the channels to 4, 8x4=32. However, this isnt the case, the NRF24 maximum packet size is 32 bytes not bits, so they could have avoided all the downgrading and had 16 or more full resolution channels like we have here. I dunno, is it a misunderstanding or did I miss something? :D

Cheers
Phil






IMG_20200401_155152_822.JPG
NRF24L01+ and Promini


IMG_20200401_000425_884.JPG
The completed (?) combo


IMG_20200401_000924_902.JPG
Rx size against a standard servo


IMG_20200401_000722_020.JPG
Thats the aerial on the left of the Promini


IMG_20200401_151405_447.JPG
More receivers...


IMG_20200401_151755_678.JPG
The blue heatshrink covers the five-into-one neg and pos bundles, aerial can be seen on the right


nrf24_rx_wiring_philg.jpg
Receiver diagram


nrf24tx_wiring_philg.jpg
Transmitter diagram
The remaining connections are similar to the "7ch+s/c" document but with the following pin assignments:
D2 is the DC buzzer
D3 is the minute minder button pin
D4 is the optional faster S/C escapement emulation pin
D5 is the 50:50 Vtail mixer
D6 is the 75:25 elevon mixer
D7 is the throttle-lock toggle
D8 is the pushbutton for s/c compound, & stick calibration

Any 328P board is suitable but for convenience I used an old ebay Redboard for the tranny, by isolating vref with a track-cut the vref pin was in a convenient place for 3.3v to the NRF24, so all its connections are in a row - I used a single 7-way header strip across the seven signal pins. On these headers the pos & neg rows are not used, just 3v3, gnd, and D9 to D13 signal pins:


ebay_red_board_mod.jpg
Repurpose vref as a 3.3v supply to the NRF24

IMG_20200401_224547_859.JPG
Just use the signal pins row, red at the far end is the repurposed vref pin, now supplying 3.3v to the RF board


I quite fancy doing a single-channel 'button' version at some stage, plenty of free time at the moment...



Important (thanks Mike!!!)
I forgot to say, if anyone fancies playing with this do change the pipeOut line in the tx (and the pipeIn line in the rx) to your own unique number, I suggest using the last 5 digits of your phone number, as this is almost certain to be unique amongst our little group.

The 'number' idea is just to simplify addressing, so instead of the usual complicated-looking:
const uint64_t pipeOut = 0xEEEE0000F1LL; // same in rx 'pipeIn' line
we can use:
const byte pipeOut[] = "39965"; // last 5 digits of your phone number, make rx the same

Also, less vital but beneficial, change the channels to six widely-spaced numbers between 1 and 125:
eg in the tx:

/************* Radio config - make it unique! **********************************/
const byte pipeOut[] = "39965"; // same as rx, last 5 digits of your phone number
const byte mychannels[] = {117, 99, 57, 71, 35, 13}; // choose 6 widely-spaced 'hopping' channels
/*******************************************************************************/

and use the same values in the rx:

/************* Radio config - make it unique! **********************************/
constbyte pipeIn[0] = "39965"; // same as tx, last 5 digits of your phone number
const byte mychannels[] = {117, 99, 57, 71, 35, 13}; // choose 6 widely-spaced 'hopping' channels
/*******************************************************************************/





Edit 8/4/20:
Wahoo, after a lot of experimentation I've got a rudimentary but functional form of hopping working.
Its slightly unconventional in that the transmitter is FHSS but the receiver only hops when it needs to.
So overall its not classical FHSS like Werners bjt works perfectly. To explain:
The transmitter reads the joysticks, assembles that data into a packet, then sends the same data on six RF channels in sequence. These six channels are widely spaced through the 2.4g band and no channel has preference.

The receiver sits on one channel and whilst everything is working it stays there. If it loses a couple of packets, it moves to the next channel and so on. At this point it picks up where it left off, but if not it keeps trying the next channel in sequence, eventually scanning the six channels and settling on the first one it finds with a good signal. If you like, as an option on the rx you can add three 5v LEDs on D14, D15 & D16 (A0, A1 & A2) which show in 3-bit binary which channel slot is in use. Or use a TIL311 for a numeric display.
I dont know if this particular channel-swapping concept has a name, someone may have done it before I dont know, I certainly couldnt find anything similar.
Its a little bit like Spektrums DSM2 but with six channels to choose from instead of two. I settled on six after looking on the spectrum analyser, any more than six looks greedy and probably isnt necessary. Spekky were happy with 2!
In practise the single fixed channel is super reliable and I would happily have flown with it, but this should make it even more solid in a noisy environment. I'm really quite chuffed with it :D
_
Attachments
Enc_4ch_sc_v4_nrf24_250k_tx.ino
Transmitter code
(15.76 KiB) Downloaded 94 times
Enc_4ch_sc_v4_nrf24_250k_rx.ino
Receiver code
(4.97 KiB) Downloaded 81 times

User avatar
F2B
Posts: 163
Joined: 16 Feb 2018, 11:23
Location: 20 m NE of Amsterdam

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by F2B » 01 Apr 2020, 19:19

Great project, Phil!

I'll study details later,

Bruno
F2B or not to be....

User avatar
Shaun
Posts: 594
Joined: 15 Feb 2018, 21:49
Location: West Yorkshire

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by Shaun » 01 Apr 2020, 19:50

Brilliant, perfect for indoor flying.

Mike_K
Posts: 394
Joined: 16 Feb 2018, 06:35

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by Mike_K » 01 Apr 2020, 21:25

Hi Phil

What an ingenious project. At first I thought it was one of the best April Fools jokes, but looking at the code, I realise you've put a lot of work into it and it's no joke, just coincidence the date you've chosen to post it.

Once I've finished my latest conversion and a couple of GG projects, I'll have a go at building one,I have all the bits required.

Just one small thing I'm not certain about, the "pairing code" (eophil or whatever) would needs to be unique for each transmitter I assume. I hope you don't get 10 people turning up at the next Ponty meet (whenever that may be) all with home made transmitters with the same code and start shooting each other down!

Mike

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

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by Phil_G » 01 Apr 2020, 21:54

Thanks Mike I forgot to say that very important statement!!!

Yes, anyone building one will need to come up with their own unique or random value for 'pipeOut' and 'pipeIn'

const uint64_t pipeOut = 0xEEEE0000F1LL; // same in rx. eeeeooophil. Geddit?

The 'LL' at then end isnt part of the number, that just means 'long long' data type, any hex digits will do up to 10 hex digits. Or five chars, like '12345'. Basically its a 5-byte address which needs to be unique.

Heres an idea, you could use the last 5 digits of your phone number.
So mine would be
const byte pipeOut[] = "39964";
but the 5 characters dont have to be numbers, any 5 ascii characters will do, like:
const byte pipeOut[] = "JB007"; or
const byte pipeOut[] = "MikeK";

Well spotted, cheers Mike

Phil

PS do a fresh download, I added the following lines to the radio config, tx and rx:

Code: Select all

  radio.setAutoAck(false);          // dont wait for acks
  radio.setDataRate(RF24_250KBPS);  // slower goes further (though higher MU)
With only a packet every 20ms the MU is low but I was thinking about further reducing it by only transmitting when the controls have moved - why send identical data repeatedly? I was also thinking that whilst full hopping is complex, alternating two-channels like DSM2 would be a simpler compromise.
The first enhancement will be to have it choose a quiet RF channel rather than the default one.

WernerL
Posts: 19
Joined: 22 Jan 2020, 02:30

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by WernerL » 02 Apr 2020, 02:25

Very nice, and so simple!

I am using a DIY nRF24 based TX/RX since 2.5 years on airplanes very successfully (and before that on cars).
Surprisingly the PCB antenna on the nRF module works fine as receiver, I have not seen any range difference compared to the traditional pig-tail antennas (for those I use nRF24 RF modules from CDEByte eBay/AliExpress/LCSC).

However, on the TX side I highly recommend the version with the PA (RF amplifier). Without it, the range can be very low --even in an open field. I would not dare flying an outdoor airplane without PA.

If anyone builds Phil's system, please note that there is no frequency hopping involved. The TX sends on one frequency only.
If you use Phil's code, any RX will receive from any TX because you are using the same "address" (pipeOut in the Arduino library). Simple to fix: just pick a different "pipeOut" value than Phil, and use setChannel() to switch to a different channel. (So now instead of frequency-flags we will see "nrf channel" flags on our transmitters :D )

To implement frequency hopping the code would have to be able to send RF packets with very precise timings (i.e. Interrupt driven) and a sequence must be negotiated between the TX and RX. This adds quite some complexity.

My own TX and RX projects are published on https://github.com/laneboysrc/rc-headless-transmitter and https://github.com/laneboysrc/nrf24l01-rc if anyone is interested.
They are quite complicated and very specific to my personal need, but for example the doc/ folder in the receiver project contains a nRF24 protocol description for a proven 8-channel protocol with 12-bit resolution per channel, that supports model binding, failsafe and 20 channel frequency hopping with a frame-time of 5ms, which may be able to spark further ideas.

Speaking about channels: the nRF24 can do 125 RF channels from 2.4 to 2.525 GHz. Legally, in the 2.4 band we should only use channels 0..69 (2.4 .. 2.469 GHz). This may be country dependent, but that's what I've seen commercial TX/RX stick to.

A note regarding the receiver: the the nRF24 has an "LE" version that contains an 8051 MCU together with the RF chip. My receiver project has a sub-project with such modules. They cost slightly more (USD 4-5) than the bare module + Arduino, but you can make a much smaller 4-channel receiver with them.
But the software would need to be ported from Arduino to 8051, plus you will need to build a custom programmer (one can find nRF24LE1 programmers based on PIC on the Internet). So not as easy as Phil's solution for sure.
There is also the nRF51822, which can be wrestled into speaking the same protocol as the nRF24 and has an ARM Cortex-M0 core plus lots of flash and RAM. But they do not usually come with a PA, so they could only really work on the RX side where we don't really need such a capable MCU.

I am so glad I discovered this forum; so many great electronics, radios and plane projects!

greetings from Singapore, Werner

WernerL
Posts: 19
Joined: 22 Jan 2020, 02:30

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by WernerL » 02 Apr 2020, 02:39

Some photos of my 4-channel receivers, one based on LPC812 MCU and the other one using nRF24LE1.
RX DIY front.jpg
RX DIY back.jpg

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

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by Phil_G » 02 Apr 2020, 03:14

Once again I'm humbled by other peoples projects, those are superb Werner, really neat :D
I realise I'm late to the party but it was just a project for fun, I enjoy messing around and lockdown is the ideal time but maybe I shouldnt have presented it as a project when there are far more capable NRF projects.

I need to study the datasheet more before tackling a hopping scheme, I understand that barring collisions several NRF24's can share a channel provided they have different pipe numbers, by virtue of the short and infrequent packets - one every 20ms in my case - and that all receivers on the channel would receive all packets but would only act on those with the correct 'pipe' number. I might try a minimal hopping method where the tx tells the rx which channel to use next, take the seed from a joystick position which would be random enough. Or not :D its just re-inventing the wheel. Maybe move on to another project.

I also have a few A7105 chips, some with PA and I know Francesco here on the forum had success with the Flysky code from RCGroups, I may give that a try ;)

Wow, I just noticed its 3:15am - way past my bed time :D

Night all !
Phil

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

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by Phil_G » 03 Apr 2020, 13:54

I've just been browsing Werners github page and I'm completely awestruck at the fantastic work he's done - as an example just watch this video and see what I mean, you too will be equally gobsmacked:



The ethos is very familiar, ie resurrecting old and retro transmitters so they keep the same old look and feel but with all the modern gizmos we've come to expect. At the most fundamental level its what we've been doing too, but Werners projects raise it to another level entirely, its very humbling. Anyone want to buy a box full of Arduinos, a scope and a soldering station? maybe I could try fishing or cake decorating... :D

Cheers
Phil

WernerL
Posts: 19
Joined: 22 Jan 2020, 02:30

Re: Phil's lockdown project - a 4ch propo NRF24 set

Post by WernerL » 04 Apr 2020, 00:54

Thanks for your kind words, Phil!

Don't be fooled though, it is not as good as it looks. The project would need a lot of polish in order to be usable for anyone other than me.

For example, at the moment the user interface only has the most basic mixer building block: apply an operation on a input and output it on a channel, replacing or adding to the previous operation on that channel. So even a simple V-tail mixer requires the user to add four of those building block to achieve the task. Almost requires a degree in IT...
(but: with those building blocks you /can/ do anything. I've set up a full house DLG with flight modes and everything, no problem).

While I do not have a lot of old transmitters, I converted a few car transmitters as can be seen here:


I also converted a 8-channel Heathkit single stick and a World Expert single stick transmitter, but I do not use them regularly as they are awkward to hold and use. My current daily driver is a converted Graupner E8 SSM (1990s JR).

My design goal was: I want to be able to use any transmitter with any model. This works beautifully. The transmitter also starts up in less than 100 ms, so when we try out one of the weird single stick ones, we usually get the plane up with the "regular" transmitter and then switch over mid-flight without even triggering failsafe.

A few months ago I added USB to the firmware. Thanks due to the WebUSB technology available in Google Chrome it is now possible to directly connect the transmitter via USB to a computer or Android phone. This gets rid of the clumsy white "configurator" box show in the video. Now changing models and adjusting endpoints is as comfortable as on a Taranis or Spectrum transmitter. I should do a video on that...

greetings from Singapore, Werner

Post Reply