Pages: [1] 2   Go Down
Author Topic: rf2401 problem with mega 2560  (Read 13483 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

12/11/11 Thanks for being open. I'm new to arduino.

I'm having troubles getting a MEGA2560 (not r3) to connect with a NANO v3 using the rf24L01+ radio.
I'm using arduino 1.0 IDE and maniacbug-RF24-53cb579.zip (12/11/11) for the radio's library.

For code I'm Using the maniacbug's examples GettingStarted.pde. Nothing else on any of arduinos boards.
Used the same code for all the arduinos for testing GettingStarted.pde

I first had a working radio connection with the UNO board and the NANO.
They both worked fine as either RX or TX.

Then I traded the UNO for the MEGA2560.
With the MEGA2560 as the TX:
The NANO would recieve the correct time, but the MEGA2560
would not get an ok ping back from GettingStarted.pde's ok = radio.write(...)
and then it would time out. Below is some of the Serial dialog:

Serial on MEGA as TX :
Code:
** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
Now sending 5976...failed.
Failed, response timed out.
... repeats
Serial on NANO as RX:
Code:
Got payload 5976...Sent response.
... repeats keeps getting time right

Reversing the TX and RX With NANO as the TX and
the MEGA2560 as the RX. The Mega fails to see anything.
/// NANO transmitter with MEGA recieving
Code:
** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
Now sending 347419...failed.
Failed, response timed out.
......repeats

Nothing more from MEGA's serial.
----
Below other attempts to solve the problem:

My first thoughts were wiring errors, but UNO worked fine.
The Hardware wiring differents for UNO, NANO and MEGA:
For UNO/NANO mosi:11 miso:12 sck:13
For MEGA2560 mosi:51 miso:50 sck:52 
Did not connect IRQ on any arduino.


Other software tries with same results. That is NANO would recieve but MEGA would not Recieve.
Tried different versions of arduino v22 and v23. no help.
Tried different versions of maniacBug's lib. no help
Tried maniacBug's pingpong examples. (earlier versions) no help

Tried using the mirf's library. Had same problems. The forum has thread that is similiar.
Sounds like the same problem to me.
Topic: Problem with Nrf24L01+ and arduino MEGA  (Read 294 times)
Threads ends with following:
"Had the same problem using the resistors / voltage dividers!
If you connect the nrf2410 direct to the MEGA 2560 problem seems to be fixed.
The fault seems to be on pin 5 SCK when you use resistors / voltage dividers!"

I've not used the resistors directly, I did try to connect some pins on rf24 with 
some of the ICSP header pins for awhile, which I believe has some resistor in line.
That didn't help. So, I check my clock SCK wire, shorten it. But no help.
--
Tried ElecFreaks code (ElectFreakLIB(10-11)_SPI_rf24L01(1).zip) they said was for MEGA2560.
Didn't work for me.

Some earlier forums reports were concern with SPI library and the MEGA.
So I had the adruino 1.0's  SPI.cpp Serial print the DEFINES pre pinMode() assigments.
UNO/NANO had MOSI:11 MISO:12 SCK:13 SS:10 and MEGA had MOSI:51 MISO:50 SCK:52 SS:53.
Seems ok to me?  I Checked to make sure the MEGA2560 was getting define as  (__AVR_ATmega2560__) it was.

 
Hardware tries:
Swapped radios modules (with the wiring) from UNO to MEGA. UNO still worked and the MEGA still did not work.
Swapped out the MEGA2560 with a different MEGA2560. No help.
Tried different (ce, csn) pins on MEGA (8,9), (4,5) and (9,53) for GettingStarted.pde RF24 radio(9,10);
Tried flashing leds on MEGA's 50-53 pins to make sure that they sort of worked and I was lining pins up right.
LEDs Worked fine.

Below is the status reports.
I added a radio.printDetails(); after the GettingStarted.pde's
bool ok = radio.write( &time, sizeof(unsigned long) );
for both UNO and MEGA. Both were the same, both had config= 0x0C as the only differents from below status.


MEGA status
Code:

RF24/examples/GettingStarted/
ROLE: Pong back
*** PRESS 'T' to begin transmitting to the other node
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 <0> = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5 <0> = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
RX_PW_P0-6 <0> = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR <0> = 0x03
RF_CH = 0x4c
RF_SETUP <0> = 0x07
CONFIG = 0x0f
DYNPD/FEATURE <0> = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH


UNO' status

RF24/examples/GettingStarted/
ROLE: Pong back
*** PRESS 'T' to begin transmitting to the other node
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 <0> = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5 <0> = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
RX_PW_P0-6 <0> = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR <0> = 0x03
RF_CH = 0x4c
RF_SETUP <0> = 0x07
CONFIG = 0x0f
DYNPD/FEATURE <0> = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH


NANO status

RF24/examples/GettingStarted/
ROLE: Pong back
*** PRESS 'T' to begin transmitting to the other node
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 <0> = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5 <0> = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
RX_PW_P0-6 <0> = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR <0> = 0x03
RF_CH = 0x4c
RF_SETUP <0> = 0x07
CONFIG = 0x0f
DYNPD/FEATURE <0> = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH

Hopefully, someone can see where I when wrong.  Thanks.
Logged

France
Offline Offline
Sr. Member
****
Karma: 2
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm waiting for 2 nanos and 2 RF24 modules. I already own an Mega board.

I will try to understand why there are trouble with this board. Hope we will find the reason why it doen't works for the moment.

Best Regards

May be we have to consider the CSN (or SS) pin on the mega, that is the 53 pin.

Can you post the ref of the RF24 module you use ?

The 2 I will get are : http://www.satistronics.com/mini-24ghz-wireless-nrf24l01-nrf24l01-transceiver-module_p2450.html

There is alsa an CE pin that must be set or unset considering TX or RX according the doc. Isn't it ?
« Last Edit: December 14, 2011, 05:55:22 am by Grag38 » Logged

France
Offline Offline
Sr. Member
****
Karma: 2
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Otherway also readed on the SPI library doc from arduino :

http://arduino.cc/en/Reference/SPI

On the Arduino Duemilanove and other ATmega168 / 328-based boards, the SPI bus uses pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). On the Arduino Mega, this is 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SS). Note that even if you're not using the SS pin, it must remain set as an output; otherwise, the SPI interface can be put into slave mode, rendering the library inoperative.

So may be we have to add int the code : PinMode(53, OUTPUT); in the setup...

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for replying Grag38

Quote
May be we have to consider the CSN (or SS) pin on the mega, that is the 53 pin.
Yes, In my 1st post:
Tried different (ce, csn) pins on MEGA (8,9), (4,5) and (9,53) for GettingStarted.pde RF24 radio(9,10);  
So, yes I think this involved. The UNO and nano's CSN(SS) is pin10 and I tried using different pins in the radio(CE,CSN) 's function (and rewiring) with no problems.

Quote
Can you post the ref of the RF24 module you use ?
I bought the rf24 modules from YourDuino.com.  Terry has links to some setup notes at,
http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

Best ref for me, The nordic chip user ref manual:
http://www.nordicsemi.com/eng/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf


Quote
thanks for the link, I'll look at it later.

Quote
"There is alsa an CE pin that must be set or unset considering TX or RX according the doc. Isn't it ?"
Yes this my understanding also, the SPI lib, the example GettingStarted.pde and  maniac's lib should be handling this?  They did for the UNO and nano run, with no problems.
------


Quote
"So may be we have to add int the code : PinMode(53, OUTPUT); in the setup..."
I did try variations of this earlier, but later stop trying, when I seen the  arduino1.0's SPI.cpp does this.
Code:
void SPIClass::begin() {
  // Set direction register for SCK and MOSI pin.
  // MISO pin automatically overrides to INPUT.
  // When the SS pin is set as OUTPUT, it can be used as
  // a general purpose output port (it doesn't influence
  // SPI operations).

  pinMode(SCK, OUTPUT);
  pinMode(MOSI, OUTPUT);
  pinMode(SS, OUTPUT);
  
  digitalWrite(SCK, LOW);
  digitalWrite(MOSI, LOW);
  digitalWrite(SS, HIGH);

..........
I'm still trying things ... Azar3
« Last Edit: December 14, 2011, 04:49:49 pm by Azar3 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

on my mega board i'm usuing ce as 49 and csn as 53

syntex shown below:

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

RF24 radio(49,53);
RF24Network network(radio);


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for replying. hdphilip

Quote
...on my mega board i'm usuing ce as 49 and csn as 53..
It's good to see that the mega2560 is working with a rf24L01+ some where. Are you connect to other megas? unos?
I tried 49,53 (most of the pins together there, seems like a good idea), but had the same problem of the mega not receiving.
I tried to connect 2 different mega2560, no help.
Although, if I put both mega256 to TX ing, the nano would see both of the TX times correctly.   

I'd got out an old dual trace scope to check and compare the pins.  It seemed that mega's CE and CSN pins were the same as the UNO. The UNO has a working rf24 communications with a nano.
The SPI's clock pin, SCK pin's (13 UNO) and (52 mega) were some what different. The mega's had a lot of noise(ring at end of the pulse). While UNO's clock was sharper. One of arduino's SPI pulse were almost 3 pulses to the others 4 pulses across the screen. I was at 5 MicroSec/cm sweep.
I had not use the scope in 10+ years. And I was having troubles remembering how to work the scope. Sadly, before I could test much, the crt of scope went out.

Azar3
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Azar, the board i'm usuing is the 1280, here's my code i use on my mega
Code:
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>


RF24 radio(49,53);//  ce 49 & csn 53

RF24Network network(radio);// Network uses that radio
const uint16_t this_node = 0;// Address of our node
const uint16_t other_node = 1;// Address of the other node

void setup()
{
  Serial.begin(57600);
 
  Serial.println("RF24Network/examples/helloworld_rx/");
 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
}

void loop()
{
 
  network.update();// Pump the network regularly
 
  while ( network.available() ) // Is there anything ready for us?
  {
    RF24NetworkHeader header;
    static char message[32];
    network.read(header,message,sizeof(message));
    Serial.print("Received: ");
    Serial.println(message);
   
}
}
// vim:ai:cin:sts=2 sw

I didn't have any issues getting it to work,
 although i never was able to get any of the Mirf,mirf libarys to work on any of my boards, uno, mega and my homemade boards.

here's an idea, write a small program to test all of your mega pins,   
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (CSN),49(ce) for input and output function, just to make sure their working.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I didn't have any issues getting it to work,
I've not used the  <RF24Network.h> yet.  Looks good I'll look at it.
It's good, it's working with the radio. Gives me hope mine will.
I've not seen a statements yet, that someone was using mega256 with the radio. But I do think they are, or I would have seen more talk.

Quote
never was able to get any of the Mirf,mirf libarys to work
I remember having issues, had to adjust defines or some thing, but the nano and uno both were working fine after. But, my goal was just to try a different library, the maniac bug library is best for me.

Quote
here's an idea, write a small program to test all of your mega pins,   
Sort of did that, from 1st post:
Quote
Tried flashing leds on MEGA's 50-53 pins to make sure that they sort of worked and I was lining pins up right.
LEDs Worked fine.

The scopes test was more interesting to me.  I have an old 386 that has a good enough scope card to retest. But I've order more nano, they seemed the best for me. The mega uses 3x power and has a hard time talking on the  radio. 
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just tested 2 Nrf24L01 modules, one connected to an Uno the other to a Mega 2560. I tested them with the getting started sketch that comes with the library. In the sketch for the Mega I set (radio(49,53)) and set pinMode 53 to output. I works but not like it should. About 80% of the pings times out when I transmit from the Mega, when I transmit from the Uno it's a little bit better (about 40% times out). Anyone have any ideas how I can improve this?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2/3/12 nRF24L01 problems with mega2560
Bajdi,
Quote
Anyone have any ideas how I can improve this?

You're not using the  "resistors / voltage dividers" on the data or clock pins to adjust for the 5v logic are you?
see below from earlier forum topic  "Problem with Nrf24L01+ and arduino mega." (Carynx was using the mirf library, but similair problem.)

http://arduino.cc/forum/index.php?topic=71574.0
Quote
"Had the same problem using the resistors / voltage dividers! If you connect the nrf2410 direct to the mega 2560 problem seems to be fixed. The fault seems to be on  pin 5 [should be pin 52] SCK when you use resistors / voltage dividers! "

Your 80% time outs with TX on the mega would be an improvement for me. While my mega2560 has TX to the uno, the mega always times out and never received any TXs.
That is, the MEGA2560 never gets an ok ping back from GettingStarted.pde's ok = radio.write(...)   

Recently I've rewired the test circuits back to where I was when I gave up. The nano to nano (using a nano instead of the uno now) is still working fine in both RX and TX. The mega2560 to nano has the  mega2560 timing out still.

I'm using radio(CE,CSN), RF24 radio(49,53) also, seems convenient.
My understanding is, in SPI that CE and CSN  are both user assignable. This tests out when using working the nano to nano configuration. 
Although, if mega's SS pin 53 is not used for CSN, then the mega's SS pin 53 still needs to be output or at least HIGH input. This keeps the mega2560 from becoming a slave (LOW input).
The MOSI(pin 51 mega), MISO (pin 50 mega) and SCK (clock pin 52 mega) are hardwired into the ATmel chip.

Some good docs for the arduino hardware SPI's stuff below. 
http://atmel.com/dyn/resources/prod_documents/doc2585.pdf

I'm thinking about connecting the different systems with just a SPI connection, thus elimating the rf24 factor to see which side the problem is on, RF24 lib or SPI lib.

Let me know if you come up with a solution.     
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I got it working after trying lots of things. I found a solution but it's a bit weird. When I connect the RF24 module to my Mega 2560 and take the 3,3V from my lab power supply it works... 100% response rate. My Mega 2560 is a Chinese clone, maybe it has bad 3,3 voltage circuit, I don't know. But it works smiley
I found this out because I have 4 RF24 modules, 2 small ones with the antenna on the board and 2 big ones with preamp and amp and external antenna. The big ones draw quite a lot of current and you must power them from a separate power supply. I first tested the 2 small ones and ran in to the above problems. After a lot of head scratching I thought that maybe I had a bad module so I connected the 2 big ones and used external power, they worked. I then tried the 2 small ones using the same power supply and they suddenly worked like they should. I then removed the external power supply from the one connected to my Uno and that also worked. When I removed the external power from the one connected to the Mega 2560 and used the 3,3V from the Mega it stopped working, switching back to the external power supply everything was back ok. Weird things... On my Uno and Duemilanove I can use the internal 3,3V but not on the Mega 2560.

« Last Edit: February 04, 2012, 02:53:58 pm by Bajdi » Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Badji,
Thanks much, for your solution.  I first used a extra nano's 3.3v to power the mega's nRf24L01 and it worked fine.  Next I removed the extra nano voltage supply and put a Tantalum capacitor 4.5uF across the mega's 3.3v  and it worked fine.       Good design principles pays off.
« Last Edit: February 06, 2012, 01:06:10 am by Azar3 » Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's very interesting, I'll definitely try that.
Logged


Ukraine
Offline Offline
Newbie
*
Karma: 1
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I do confirm the same issue and same solution as Azar3 had: tried tons of wiring, coding, red eyes etc. And got them working enough fine only when I plugged in external power adaptor to Mega board. One week of wasting time smiley-sad Finally I may continue.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I verified that I'm having the same problem with a couple of Mega's - the RF24 works fine when connect it to the Mega2560 and I power it from an Uno, but not when it's powered from the Mega directly. I would not have found that without your post, so thanks for that!

Azar3 - you said "Next I removed the extra nano voltage supply and put a Tantalum capacitor 4.5uF across the mega's 3.3v  and it worked fine." Can you elaborate? Where does the capacitor go exactly - between the Mega's 3.3v and gnd?

Also, I measured the voltage output from the mega's 3.3 pin with a multimeter, and was surprised to see that it was a completely steady 3.30 volts. I guess there's something wrong with the voltage that doesn't get picked up by the multimeter?

Remko
Logged

Pages: [1] 2   Go Up
Jump to: