FS-TH9x + nRF24L01+ PA + LNA

Where to find parts? Refactoring your entire transmitter, new cases? Sticks etc..
Post Reply
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

Hi guys,

I modified my FS-TH9x Transmitter a little bit. Because I don't want to use the antiquated PPM/PCM signal I bought me two nRF24L01+ PA + LNA transceivers for $18 each. To adapt the nRF24L01+ PA + LNA to the FS-TH9x I used the "free" Ports for Software-SPI (PB7, PG2, PC0,PC6,PC7) and for the interrupt the PPM_IN (PE7). I used an UDMA100 cable to get the SPI signals in my tramsmit module place without modifying the FS-TH9x casing (I used the hole which was provided for the antenna cable in V1).
With this module I don't have any limitations for transmit and receiver data. So I don't need a Telemetry module or something like this. The Range is about 1km at 250 kbaud, and about 500m at 2 Mbaud. I think this should be enough.
On the stripboard is only a 3.3V regulator for VCC, because all input pins of the nRF24L01 are 5V tolerant nothing has to be done additionally.

Everything works whell for now. For now my work is to programm the firmware by my own. I used only the LCD-Lib from er9x, but the rest is build on my own.
Attachments
fs_th9x_nrf_1.jpg
fs_th9x_nrf.jpg
Last edited by MasterFX on Sun Jul 15, 2012 9:08 am, edited 1 time in total.

User avatar
Rob Thomson
Site Admin
Posts: 4543
Joined: Tue Dec 27, 2011 11:34 am
Country: United Kingdom
Location: Albury, Guildford
Contact:

FS-TH9x + nRF24L01+ PA + LNA

Post by Rob Thomson »

Are you able to provide pictures and schematics?


Sent from my iPhone using Tapatalk
Slope Soaring, FPV, and pretty much anything 'high tech'
...........if you think it should be in the wiki.. ask me for wiki access, then go add it!
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

Normally I attached some pictures on the first post, mybe they were to big. I updated the first post again.
I will do some schematics today I think. The schematic isn't really complicated
Last edited by MasterFX on Sun Jul 15, 2012 9:33 am, edited 1 time in total.
User avatar
Rob Thomson
Site Admin
Posts: 4543
Joined: Tue Dec 27, 2011 11:34 am
Country: United Kingdom
Location: Albury, Guildford
Contact:

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Rob Thomson »

Assume you have custom firmware to support this?

Would be good to open a google code project?

Sent from my iPhone using Tapatalk
Slope Soaring, FPV, and pretty much anything 'high tech'
...........if you think it should be in the wiki.. ask me for wiki access, then go add it!
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

Yes I did a custom firmware. Well I would say I just started to develop. Nothing presentable for now. But the communication works. Of cause you need the nRF24L01 for the receiver (Quadrocoper, Heli...) as well.
I do the firmware from scatch because the programming style of the er9x, radioclone etc. is awful sometimes.
Maybe I'will start a google code project next month. But first I want that the basics running fine.

User avatar
Rob Thomson
Site Admin
Posts: 4543
Joined: Tue Dec 27, 2011 11:34 am
Country: United Kingdom
Location: Albury, Guildford
Contact:

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Rob Thomson »

Shout when ready... We can create a custom firmware section for you.

As a thought... I am pretty certain you could get help from mike/Bertrand/erazz to make a compiled in option to the existing firmwares to support this?

Rob


Sent from my iPhone using Tapatalk
Slope Soaring, FPV, and pretty much anything 'high tech'
...........if you think it should be in the wiki.. ask me for wiki access, then go add it!
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

Here is the connection between the Atmega and nRF24L01 module.

PS: It it really obstructive that every post has to be approved by a Mod, because you can't edit the post immediately, if you forgot an image or so.
Attachments
fs-th9x_nrf_sch.jpg
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Kilrah »

It's only the first 5 posts :)
Could maybe be changed to 2? It's enough to recognise a spammer...
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MikeB »

MasterFX wrote:I do the firmware from scatch because the programming style of the er9x, radioclone etc. is awful sometimes.
In what way don't you like the programming style? There are things I don't like, but the code is:
a) inherited but functions correctly.
b) Sometimes coded to save program space as it is tight.

Is it the layout of the code or the actual structure of the code you consider bad?

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Kilrah »

I thought he meant "how to program the models" rahter than the actual software coding...
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

MikeB wrote:
MasterFX wrote:I do the firmware from scatch because the programming style of the er9x, radioclone etc. is awful sometimes.
In what way don't you like the programming style? There are things I don't like, but the code is:
a) inherited but functions correctly.
b) Sometimes coded to save program space as it is tight.

Is it the layout of the code or the actual structure of the code you consider bad?

Mike.
Well I will not say that everything is bad. But I can't understand why to punish a µC with C++ including classes etc? I didn't think this is more efficient concerning to the resources.
I whould not say that my coding is better in general, but you often see that code can get really confusing if many persons are working on a project and more and more functions are implemented frantically in the existing code. Of cause, all seems to work fine.

As far as I studied the er9x code and similar, I think it is easier to build my own firmware from scratch which fullfil my requirements for my application.
Of cause it will be configureable with curves, calibration etc. but not all that stuff which is maybe used from some other people. So I get less complexity, more clarity and more available resources.
Furthermore, I like to do things from scratch.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by jhsa »

On behalf of all the other people I wish you good luck with your project..
The difference is, er9x, open9x, etc, are made for the people..
Apparently you are doing yours for yourself ;)
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

Thanks jhsa.
You are right, I do it for myself. But I wouldn't keep back my idea.
We will see how good my idea works soon. I think not to use PPM is straight forward, like PCM. The nRF24L01 does all the CRC, retransmit etc. automatically which is very nice for security. The frequency hopping will be implemented by myself when everything is working fine.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MikeB »

MasterFX wrote:But I can't understand why to punish a µC with C++ including classes etc? I didn't think this is more efficient concerning to the resources.
While the files are .cpp, most of the code is actually just C, there is no code overhead doing this.
What few classes there are in er9x do produce less code than without being a class, otherwise I would have re-coded them to save code space.
I agree that at first sight, the source code looks complex, but then so is the functionality we have.
There is much useful stuff in it. You could try just taking the 'standard' version of the code (no telemetry/FrSky), and modify that. Still, good luck with whatever you do.

I would have thought that if you are doing your own software, and with the number of wires you are soldering to the processor, you would have chosen to re-route the signals from the hardware SPI port and used that!

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

MikeB wrote: While the files are .cpp, most of the code is actually just C, there is no code overhead doing this.
Well, declaring variables within a for-loop isn't C. This is done in most cases. I wouldn't say it's bad.
MikeB wrote: I would have thought that if you are doing your own software, and with the number of wires you are soldering to the processor, you would have chosen to re-route the signals from the hardware SPI port and used that!
I thought about it, but I have to cut some traces an I'm not backward compatible anymore with other firmware. My idea is to modify the basic hardware as less as possible.

With my software-SPI solution I got about 2 Mbit/s, which is fast enough. And the routine is quite simple:

Code: Select all

uint8_t SPI_RW(uint8_t  value)                                    
{                                                           
	uint8_t bit_ctr;
	for(bit_ctr=0;bit_ctr<8;bit_ctr++)   // output 8-bit
	{
		if(value & 0x80)
			MOSI=1;
		else
			MOSI=0;		

		value = (value << 1);           // shift next bit into MSB..
		SCK = 1;				 // Set SCK high..
		value |= MISO;       		  // capture current MISO bit
		SCK = 0;            		  // ..then set SCK low again
	}
	return(value);           		  // return read UINT8
}  
Thats it.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MikeB »

While writing:

for( uint8_t i ; . . .

may not be quite normal C, declaring variables within almost ANY pair of braces {} has been valid ever since the days of Kernighan & Ritchie.

Out of curiousity, where you have:
value = (value << 1);
is there any reason you didn't write:
value <<= 1 ;
I personally find it more readable, and depending on the compiler often generates shorter code..

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

MikeB wrote: Out of curiousity, where you have:
value = (value << 1);
is there any reason you didn't write:
value <<= 1 ;
I personally find it more readable, and depending on the compiler often generates shorter code..
This is just because I copied the code from an app-note :D
I don't know any compiler which produces different assembler code from this construct depending on writing style. This is a really basic and common construct which all compilers should recognize as the same.
It is more a matter of taste how to write it.

But if you take a look in the last lines of "er9x.cpp"

Code: Select all

int16_t calc1000toRESX(int16_t x)  // improve calc time by Pat MacKenzie
{
    int16_t y = x>>5;
    x+=y;
    y=y>>2;
    x-=y;
    return x+(y>>2);
    //  return x + x/32 - x/128 + x/512;
}
Maybe "MacKenzie" thought his code is faster because he turns the divisions by 32,128 and 512 into shift operations. Of cause this results in much less assembler lines and faster code, but I don't know if he knows why...
Well it is because of the signed int which are used here. Lets say x is "-7". Then the "optimized" function as it is will return "-8". If you turn the function back to the division operator

Code: Select all

int16_t calc1000toRESX(int16_t x)  // improve calc time by Pat MacKenzie
{
    int16_t y = x/32;
    x+=y;
    y=y/4;
    x-=y;
    return x+(y/4);
    // or you can also write "return x + x/32 - x/128 + x/512;"
}
you will get "-7";

The "shift" in this case does't handle with negative value correctly because the negative values are rounded in the "wrong" direction. By using the division operator the compiler does the handling with negative values correctly but it results in more instructions of cause. So the functions AND their behavior aren't the same as MacKenzie did expected. Of cause in this case it isn't that critical because the fault on the result is very small if you use bigger values. If you use unsigned int then the compiler produces exact the same assembler from "return x + x/32 - x/128 + x/512;" but it is more readable. Compilers aren't that silly as many people think.

I also could ask why in the lcd.h and some headers all function are declared as "extern". You don't have to do this because function do have external linkage by default.

There are many things where everybody has its own way to write, but in most cases the compilers are smart enough to recognize and optimize it to the same assembler.

But I think all this discussion is on the wrong place here
Last edited by MasterFX on Tue Jul 17, 2012 6:27 am, edited 1 time in total.
bertrand35
9x Developer
Posts: 2764
Joined: Fri Dec 30, 2011 11:11 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by bertrand35 »

Could be less agressive with Mike and Pat who did a wonderful work (even if you are right)! Or it's my poor english which makes me hurted in their place?
Bertrand.
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Kilrah »

There is so much optimisation required to fit all the functionality that, well... if that function never gets called with negative values, then there's no need to ensure it works with them. And checking the value is positive at entry time would be a waste of memory too. Maybe a comment saying "positive values only" would be appropriate, but from the code side of it - we probably wouldn't have er9x/open9x today if priority was put towards "textbook coding" instead of towards writing code that is less clean but as efficient as possible.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MikeB »

I've met some very silly compil;ers in my time, and even good ones do odd things sometimes.
Yes, the function int16_t calc1000toRESX(int16_t x) might be more accurate with division, instead of shifts, but this needs to be taken in the context of why it exists.
The output PPM puls widths are in units of 0.5uS and range from 1500 - 512 uS to 1500 + 512 uS. In the units of 0.5 uS these are from 3000 +/- 1024. Within the code, there are some values that are +/- 1000 theat need to be scaled to +/- 1024. This is where this function is used. Yes, it might give a result 1 different from absoluty expected, but I would be very surprised if your servos can tell the difference of 0.5 uS in the pulse width!.

Hopefully, if you are using some of the code we have made available, and you 'publish' it as open source (as we do), you will follow the GNU license and keep the names of all the contributors in the source files.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by jhsa »

bertrand35 wrote:Could be less agressive with Mike and Pat who did a wonderful work (even if you are right)! Or it's my poor english which makes me hurted in their place?
Bertrand.
Bertrand, you are damn right.. It would be nice if people show some respect for the other members of this forum, specially for those that spend a lot of their time working for free on the firmwares so other people like myself can play with it and enjoy some quality flying time..
What's the point of being agressive anyway??..
I think there's nothing to prove here.. This here is a nice friendly community and so it should continue to be like that..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

Hey guys,
I never wanted to be disrespectful. Of cause it is a great work which was done. But "jhsa" asked me some things and I just say what I've seen. Whats wrong about this?
And I also said:
MasterFX wrote:... Of cause in this case it isn't that critical because the fault on the result is very small if you use bigger valuese
I mean I only posted a couple of code of some app-note and the then I get hints how to make it better wether "value == (value << 1)" or "value <<= 1".
I don't wanted to start a discussion about other firmwares in this thread. I mean nobody saw anything of my firmware for now, so why start a senseless discussion?

That was not the way I wanded to discuss about my "hardware mod". That I do have to do a firmware mod with this kind of hardware mod is inevitable. And how I'm going to do that is my thing.

If only a couple of code lines starting that kind of discussion I don't see any appeal to publish my code under GPL (and thats compliant with GPL since I only use it "internal").

And I you think about it... why should I publish my hardware mod without publishing a corresponding firmware? Of cause I want/wanted to to that. And I already said that too: viewtopic.php?f=26&t=1188&p=16925#p16724
User avatar
Rob Thomson
Site Admin
Posts: 4543
Joined: Tue Dec 27, 2011 11:34 am
Country: United Kingdom
Location: Albury, Guildford
Contact:

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Rob Thomson »

Oh joy... One of the tough things is written text being taken out of context :)


Sent from my iPhone using Tapatalk
Slope Soaring, FPV, and pretty much anything 'high tech'
...........if you think it should be in the wiki.. ask me for wiki access, then go add it!
MasterFX
Posts: 10
Joined: Sat Jul 14, 2012 4:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MasterFX »

Maybe there was some/a lot of misunderstanding. I will now continue to work on my project. CU

PS: I think the Mod can delete the thread, or the OT-Stuff. I'll maybe come back if I have enough to show.
User avatar
Rob Thomson
Site Admin
Posts: 4543
Joined: Tue Dec 27, 2011 11:34 am
Country: United Kingdom
Location: Albury, Guildford
Contact:

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Rob Thomson »

I think it would be a shame to not come back.

I personally think it is great to have 'new blood' and 'new ideas'.

Yes. Agreed maybe the initial posts sounding like an attack, but I don't think that was intended

We should all try to realise that questioning how or why things are done is a good thing!

And..

Yes... We are protective of our firmware. Great! But it is not for everyone. We all like different things :). Let's accept that, and move on.

I hope that we do see more of this potential alternative firmware. Who knows... It may be very good!





Sent from my iPhone using Tapatalk
Slope Soaring, FPV, and pretty much anything 'high tech'
...........if you think it should be in the wiki.. ask me for wiki access, then go add it!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by MikeB »

I certainly didn't take anything posted as an "attack", or as 'disrespectful'. I'm just taking an interest, and being curious. I normally follow a particular coding style, but have had to fit in with the code as it is.

It's often quiote useful to have someone else look at the code, sometimes we can be too close to it and miss things.

There is a lot of code in er9x/open9x that may be useful. If you ever want to use you setup as a 'teacher' with a buddy bos 'student' you may want the PPM in code, and if you want to use your TX with a SIM you will still likely need the PPM out.

Feel free to come back and ask questions about the code, and do post about your progress.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
kiwicraig
Posts: 4
Joined: Mon Sep 22, 2014 11:01 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by kiwicraig »

guys, has anyone actually gotten a NRF24l01 setup to work?

I'm very interested int his as there are a allot of RC models now using this protocol and I'd really like to keep my 9x unit rather than buy a devo and start all over again.

I'm no electronic guy okay so please bare with moe on this, why cant we simply add the NRF chip set into a module fitted into the rear of the 9X like the orange module or the stock flysky module ? something to do with the PPM vs how the NRF sends it signal deal ? this guys seems to have solved the pinout match, so is it just down to firmware setup ? Any plans to write code to suit the nRF24 chip sets ?

Clearly it's doable on the devo or should I just accept fate and buy a devo Tx......... don't really want to but........


Thanks

kiwi-craig
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by Kilrah »

lehoa72
Posts: 1
Joined: Fri Oct 17, 2014 6:50 pm
Country: -

Re: FS-TH9x + nRF24L01+ PA + LNA

Post by lehoa72 »

Hi guys
When use these module,
What will changed in the program code?
I have worked with these, and it not transmit power, i receive current over these are abould 14 mA not 100mA.
What is my wrong?
Thank you!

Post Reply

Return to “Hardware Mods”