Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
guitardenver
PostPosted: Apr 10, 2012 - 05:45 PM
Rookie


Joined: Dec 13, 2011
Posts: 23


Is there a good library already written for the NRF24L01+ wireless transceiver that is NOT for the arduino?? I use WIN-AVR.

If I use the ATMega328p would I be able to use the arduino libraries?? That would be cool.

Here is a link to the chip I will be using. It has a built in antenna.
http://www.ebay.com/itm/Perfect-High-Quality-New-NRF24L01-2-4GHz-Wireless-Transceiver-Module-Arduino?item=260920481575&cmd=ViewItem&_trksid=p5197.m7&_trkparms=algo%3DLVI%26itu%3DUCI%26otn%3D3%26po%3DLVI%26ps%3D63%26clkid%3D7625350354661330880#ht_3057wt_905
 
 View user's profile Send private message  
Reply with quote Back to top
jwatte
PostPosted: May 03, 2012 - 07:51 AM
Wannabe


Joined: Apr 28, 2012
Posts: 72


I found a library here:
http://www.tinkerer.eu/AVRLib/nRF24L01

However, it uses the non-plus version of the transmission protocol, with fixed buffer size etc. It also had some other integration problems with my current project, so I'm actually trying to write one from the data book. Currently I'm stuck at not receiving the IRQ signal back somehow, and I don't have a scope to look at it Sad
Maybe tomorrow will bring more clarity.

iteadstudio.com sells the modules for $5.50, and has some sample code, although it's very crufty:
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=7&products_id=53
Note: they also have Arduino sample code, but the code in the archive of support files is not Arduino-based.
 
 View user's profile Send private message  
Reply with quote Back to top
guitardenver
PostPosted: May 13, 2012 - 10:58 PM
Rookie


Joined: Dec 13, 2011
Posts: 23


I just got code working to be able to read and write to registers. That was even a pain for me. Now i'm trying to get the right configuration to get it transmitting. I'm not even worrying about the receiver yet. I want to be able to have the chip transmit, do the number of re-transmits and then have the IRQ pin go low. I cant seem to trigger any kind of interrupt on that pin.

How far have you gotten?
 
 View user's profile Send private message  
Reply with quote Back to top
stedew
PostPosted: May 16, 2012 - 05:19 PM
Newbie


Joined: Dec 22, 2003
Posts: 6


I can understand that without scope it's hard to find the problem on the SPI-bus.
However i get progres from the moment i used a logic analyser. (ikalogic) but any other type will do also i think. I hope you find anything usefull in the attatchment. It contains two folders (TX&RX) The original files are from sparkfun etc. I made a mash-up of various things and authors it was for testing the NRF but i found that the actual range was to short.
Regards.
 
 View user's profile Send private message  
Reply with quote Back to top
guitardenver
PostPosted: May 17, 2012 - 10:14 PM
Rookie


Joined: Dec 13, 2011
Posts: 23


I looked at the configuration for RX and TX. I'm doing the same thing it seems like. My transmitter is transmitting. I send the STATUS register to my computer and is has the "data sent" interrupt triggered after I transmit. The IRQ pin does not trigger but the status reg says it did. I'm just not receiving anything.
I attached my code if anyone wouldn't mind looking at it. The important functions are setup_RX, setup_TX, TX, and write_payload.
 
 View user's profile Send private message  
Reply with quote Back to top
stedew
PostPosted: May 19, 2012 - 08:16 AM
Newbie


Joined: Dec 22, 2003
Posts: 6


I did a quick look to your code but in the TX part you call the RX config in the TX module I think this is incorrect. In the SPI_INT (init) you enable the interrupt of the SPI and the global Interrupt flag (sei) before the clock source is selected. this can cause strange results (in the simulator the interrupt is fired by this for example and stops in a infinite loop) I suggest that you first try a working example from someone and modify this to your needs. Also build a test without interrupts, when this works (by polling as you do for the status reg). Provide also the exact device you use (otherwise the forum users have to guess it )I hope this will help you.
 
 View user's profile Send private message  
Reply with quote Back to top
vvyogi
PostPosted: May 24, 2012 - 07:46 AM
Hangaround


Joined: Apr 04, 2010
Posts: 196
Location: india

Hey stedew,
I am also using the nRF24l01+ chip from sparkfun. I am using it with stefan's library (Here http://www.tinkerer.eu/AVRLib/nRF24L01 ). I used interrupt driven approach for sending the packet. and used polling at receiver. The devices do communicate flawlessly sometimes. These are the problems i'm getting,
When i reset my uC during communication, the uC and communication both hang, and there is no effect of further resetting either Rx,Tx or both, They only work again when i power off them and Re power them.????
HAs anyone else got similar issue's.
I have tried clearing the PWR_UP bit upon reset then wait and again set it.

I feel there really should be a reset pin on these nRF24l01+ ic's. Confused

_________________
- Will find's a Way.
 
 View user's profile Send private message  
Reply with quote Back to top
stedew
PostPosted: May 24, 2012 - 07:15 PM
Newbie


Joined: Dec 22, 2003
Posts: 6


MR vvyogi,
I had this item also with the NFR24L01+ after a (long) idle period there is no means to get the communnication back on rails. And as you stipulated only a compleet power shutdown off the NRF make it responsive again. To be very honest i never had a clou why this happens because on the spi-bus side everything seems to work? A have found that the problem was on one side (RX -ithink ). The problem seems that the NRF sometimes looses his configuration (especially RF-channel and RX/TX Adress) The "dirty" approach is to reconfigure every TX (not optimal)A global config (and state) reset command should be helpfull idd.Maybe you can order a batch by Nordic Wink
 
 View user's profile Send private message  
Reply with quote Back to top
vvyogi
PostPosted: May 25, 2012 - 06:21 AM
Hangaround


Joined: Apr 04, 2010
Posts: 196
Location: india

Thank you for you reply Stedew,
I was in haze regarding this problem and i thought this was probably a programming error. As from your confirmation now i am quite sure.
AS you say
Quote:
The "dirty" approach is to reconfigure every TX (not optimal)A global config (and state) reset command should be helpfull


Have you tested the above approach ? Does it work ?

Till now I did following at my receiver side:
1. Set myRX_add = TX_add( address of target nRF).
2. Write payload to pipe0, and wait for either TX_DS or MAX_RT flag in STATUS register of nRF.
3. Set myRX_add( now my own address). wait for 10ms to get a packet back from the target nRF.
4. so on.

When i reset the device, i guess it hangs at step 2 above( as i wait for the TX_DS/ MAX_RT using a while loop)... Sad

Now i am going to try the transmitter without the interrupt led approach like this,
1. Set myRX_add = TX_add( address of target nRF).
2. Write payload to pipe0, wait for a predetermined time( i am unsure how much to wait at this point Confused suggestions invited )
3. Set myRX_add( now my own address). wait for 10ms to get a packet back from the target nRF.
4. so on.

_________________
- Will find's a Way.
 
 View user's profile Send private message  
Reply with quote Back to top
vvyogi
PostPosted: May 25, 2012 - 11:16 AM
Hangaround


Joined: Apr 04, 2010
Posts: 196
Location: india

The following code hangs on startup.. just after the line where "init.." is printed.
on resetting the code runs flawlessly, but no data is received. At the Receiver side even worse, for the first time it gives acknowledge that it has received a packet, then it is just sitting there.

_________________
- Will find's a Way.
 
 View user's profile Send private message  
Reply with quote Back to top
vvyogi
PostPosted: May 25, 2012 - 12:06 PM
Hangaround


Joined: Apr 04, 2010
Posts: 196
Location: india

This is the interrupt driven code that i came up with earlier.
It just works best....
Only problem, is the occasional reset issue. It (occasionally) hangs on uC reset while ongoing communication. still trying to fix it.
There has to be a solution.
This code is for transmitter and does works with the receiver code i posted in previous post. Guy's if you can help fixing this plz do !!!

_________________
- Will find's a Way.
 
 View user's profile Send private message  
Reply with quote Back to top
stedew
PostPosted: May 25, 2012 - 05:03 PM
Newbie


Joined: Dec 22, 2003
Posts: 6


I don't have build the complete project but in your main loop the first instruction is sei(); because you gonne use mystdout() i think the interrupt will fire as soon anything is written to the uart because the uart is not set to stdout will this work? i suggest that you set the sei instruction after your hardware initialitation (and use other means for debugging this section a HW pin..for ex. ) In the TX_I example i can't find why you change the RADDR this shouldn't needed i think. In a few weeks i will have time again and maybe you can post your zipped solution(s) so other can run download and run it (aws-file and source).[quote]
 
 View user's profile Send private message  
Reply with quote Back to top
vvyogi
PostPosted: May 26, 2012 - 06:14 AM
Hangaround


Joined: Apr 04, 2010
Posts: 196
Location: india

Quote:
i think the interrupt will fire as soon anything is written to the uart because the uart is not set to stdout will this work

No, it's done . see the third statement in my while(1) loop
Quote:
stdout = &mystdout;

also the output settings are as
Quote:
Code:
static int put_char(char c, FILE *stream);
static int get_char( FILE *stream);
static FILE mystdout  = FDEV_SETUP_STREAM(put_char,get_char,_FDEV_SETUP_RW);
static int put_char(char c, FILE *stream)
   {
      while(!(UCSRA & (1<<UDRE)))
      ;
      UDR = c;
      return 0;
   }

Quote:
In the TX_I example i can't find why you change the RADDR this shouldn't needed i think

I did it as said in the page 60,75 in nRF24l01+ datasheet.( see image attached)

_________________
- Will find's a Way.
 
 View user's profile Send private message  
Reply with quote Back to top
vvyogi
PostPosted: May 31, 2012 - 09:33 AM
Hangaround


Joined: Apr 04, 2010
Posts: 196
Location: india

Code Working Fine now. Used A polled Transmit and Interrupt driven receive.
Now it doesn't hangs on reset. and working beautifully.

Thanks for help guy's.

_________________
- Will find's a Way.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits