arduino with nrf2401a tranciever ??

hi all

has anyone interfaced the arduino with the nrf2401a tranciever SparkFun Trace Antenna Transceiver - nRF2401A - WRL-00153 - SparkFun Electronics

i have tried for the last few days and havnt managed to get it going as yet

thanks if you can help and sorry for being such a pain on the forums

callum

I think someone just posted a question about this product on the Pololu forums in this thread:

http://forum.pololu.com/viewtopic.php?f=1&t=986

I'm not sure exactly what problems you are having, but maybe my answer there can help you, or perhaps the poster can lend you some insight based on what he's tried so far.

  • Ben

my problem is i just cannot get the thing to go i have tried breaking it down into sending single bits at a time and still i cannot get it to talk between two of them (i have them both hooked up to one arduino)

if anyone out there has used the thing could they please post their code?

thankyou everyone

Are you using their slave select lines to make sure you're only talking to one at a time? And how did you send single bits at a time? SPI transfers sixteen bits per transaction (eight on MOSI, eight on MISO).

  • Ben

configuration:
ok so i set CS (chip select) high then send a single bit then write the CLK high then low then send next bit... once iv sent all the bits i set CS low

unfortunatly it doesnt work

im kicking myself for buying the nrf 2401a over the newer nRF24L01 but i would pefer to get what i have going instead of wasting over $50 on them

thanks for helping ben

callum

Anyone out there? :-[

ok first off sorry 4 bumping my own thread
second heres my code... still not going :cry: :cry:

byte config_setup[119];
 
 
int txdata = 3;
int txclk = 4;
int txdr = 5;
int txcs = 6;
int txce = 7;

int rxdata = 8;
int rxclk = 9;
int rxdr = 10;
int rxcs = 11;
int rxce = 12;


byte tx_address[5] = {'B1', 'B0', 'B0', 'B0', 'B1'};
byte data[5] = {'B1', 'B0', 'B0', 'B1', 'B1'};
int recievedata[10];
int counter;
int packet_number;
 void setup(){
  pinMode(txdata, OUTPUT);
  pinMode(txclk, OUTPUT);
  pinMode(txdr, INPUT);
  pinMode(txcs, OUTPUT);
  pinMode(txce, OUTPUT);
 
  pinMode(rxdata, OUTPUT);
  pinMode(rxclk, OUTPUT);
  pinMode(rxdr, INPUT);
  pinMode(rxcs, OUTPUT);
  pinMode(rxce, OUTPUT);
 
  Serial.begin(9600);
  setconfig();
  configtx();
  configrx();
 
  pinMode(txdata, OUTPUT);
  pinMode(rxdata, INPUT);
 
  digitalWrite(txce, HIGH);
  digitalWrite(rxce, HIGH);

Serial.println("ready");
 }


void loop() {
  if(Serial.read() != -1){
    Serial.println("transmitting");
    transmit();
  }
  //if(rxdr == HIGH){
    recieve();
    printrecieved();
    Serial.println();
    Serial.print("done");
    Serial.println();
  //}
}
 
void printrecieved(){
  Serial.println("recieved data:");
  Serial.println();
  for(int i =0; i<10; i++){
    Serial.print(recievedata[i]);
  }
  Serial.println();
}
 

void recieve(){
  pinMode(rxdata, INPUT);
 for(int i = 0; i<10; i++){
   recievedata[1] = 0;
 }
 for(int h = 0; h<10; h++){
   recievedata[h] = digitalRead(rxdata);
 }
}

void transmit(){
  address();
  senddata();
}

void address(){
  pinMode(txdata, OUTPUT);
  for(int i = 0; i<5 ; i++){
    shiftOut(txdata, txclk, MSBFIRST, tx_address[i]);
    delay(10);
  }
}
 
void senddata(){
  pinMode(txdata, OUTPUT);
  for(int i = 0; i<5 ; i++){
    shiftOut(txdata, txclk, MSBFIRST, data[i]);
    delay(10);
  }
}

void configtx(){
    //Config Mode
    pinMode(txdata, OUTPUT);
    config_setup[0] = B0;
    txce = LOW; rxcs = HIGH;

  for(int i = 119; i>0 ; i--){
    shiftOut(txdata, txclk, MSBFIRST, config_setup[i]);
    delay(10);
  }
 
   //Configuration is actived on falling edge of CS (page 10)
    txce = LOW; txcs = LOW;
}


void configrx(){
    //Config Mode
    pinMode(rxdata, OUTPUT);
    config_setup[0] = B1;
    rxce = LOW; rxcs = HIGH;

  for(int i = 119; i>0 ; i--){
    shiftOut(rxdata, rxclk, MSBFIRST, config_setup[i]);
    delay(10);
  }
 
   //Configuration is actived on falling edge of CS (page 10)
    rxce = LOW; rxcs = LOW;
   
}


void setconfig(){
config_setup[0] = B10;
config_setup[1] = B0;
config_setup[2] = B1;
config_setup[3] = B1;
config_setup[4] = B0;
config_setup[5] = B0;
config_setup[6] = B0;
config_setup[7] = B0;

config_setup[8] = B1;
config_setup[9] = B0;
config_setup[10] = B1;
config_setup[11] = B1;
config_setup[12] = B0;
config_setup[13] = B0;
config_setup[14] = B1;
config_setup[15] = B0;

//crc
config_setup[16] = B1;
config_setup[17] = B1;

//addr
config_setup[18] = B0;
config_setup[19] = B0;
config_setup[20] = B0;
config_setup[21] = B1;
config_setup[22] = B0;
config_setup[23] = B0;

//data1
config_setup[24] = B1;
config_setup[25] = B0;
config_setup[26] = B0;
config_setup[27] = B0;
config_setup[28] = B1;
config_setup[29] = B0;
config_setup[30] = B0;
config_setup[31] = B0;
config_setup[32] = B0;
config_setup[33] = B0;
config_setup[34] = B0;
config_setup[35] = B0;
config_setup[36] = B0;
config_setup[37] = B0;
config_setup[38] = B0;
config_setup[39] = B0;
config_setup[40] = B0;
config_setup[41] = B0;
config_setup[42] = B0;
config_setup[43] = B0;
config_setup[44] = B0;
config_setup[45] = B0;
config_setup[46] = B0;
config_setup[47] = B0;
config_setup[48] = B0;
config_setup[49] = B0;
config_setup[50] = B0;
config_setup[51] = B0;
config_setup[52] = B0;
config_setup[53] = B0;
config_setup[54] = B0;
config_setup[55] = B0;
config_setup[56] = B0;
config_setup[57] = B0;
config_setup[58] = B0;
config_setup[59] = B0;
config_setup[60] = B0;
config_setup[61] = B0;
config_setup[62] = B0;
config_setup[63] = B0;

//addr2
config_setup[64] = B0;
config_setup[65] = B0;
config_setup[66] = B0;
config_setup[67] = B1;
config_setup[68] = B0;
config_setup[69] = B0;
config_setup[70] = B1;
config_setup[71] = B1;
config_setup[72] = B0;
config_setup[73] = B0;
config_setup[74] = B0;
config_setup[75] = B0;
config_setup[76] = B0;
config_setup[77] = B0;
config_setup[78] = B0;
config_setup[79] = B0;
config_setup[80] = B0;
config_setup[81] = B0;
config_setup[82] = B0;
config_setup[83] = B0;
config_setup[84] = B0;
config_setup[85] = B0;
config_setup[86] = B0;
config_setup[87] = B0;
config_setup[88] = B0;
config_setup[89] = B0;
config_setup[90] = B0;
config_setup[91] = B0;
config_setup[92] = B0;
config_setup[93] = B0;
config_setup[94] = B0;
config_setup[95] = B0;
config_setup[96] = B0;
config_setup[97] = B0;
config_setup[98] = B0;
config_setup[99] = B0;
config_setup[100] = B0;
config_setup[101] = B0;
config_setup[102] = B0;
config_setup[103] = B0;

//data1
config_setup[104] = B1;
config_setup[105] = B0;
config_setup[106] = B1;
config_setup[107] = B0;
config_setup[108] = B0;
config_setup[109] = B0;
config_setup[110] = B0;
config_setup[111] = B0;

//data2
config_setup[112] = B0;
config_setup[113] = B0;
config_setup[114] = B0;
config_setup[115] = B0;
config_setup[116] = B0;
config_setup[117] = B0;
config_setup[118] = B0;
config_setup[119] = B0;
}

again sorry and thankyou

not sure if you still have the same problem with nRF24L01 but have a look at the following URL: http://www.robotcraft.ca/webshop/p26/November-28,-2008---BUGGER-UPDATE.../pages.html

You might pick up some answers there (hopefully :-?).

Also if I understood your code correctly, you are using different values for rxce/txce and rxcs/txcs variables. Now, if you consider those to be pins, you need to assign rxce/txce to one value and rxcs/txcs to another value. You only should have two pins of atmega committed to control CS and CE pins on nRF24L01.

The receive side wont work because you simply have:-

for(int h = 0; h<10; h++){
recievedata = digitalRead(rxdata);
}[/quote]
This is just reading the pin as fast as you can having no regard for the timing. What I expect you will see here is a long string of ones followed by all zeros, or more likely just one logic level.
Don't you need to synchronise data coming in with something? I would guess the clock that you are using to drive the shift register but you say you have only one Arduino. This code won't send and receive at the same time it will either do one or the other. You need to receive at exactly the same time as you send, you need two arduino's.
Or am I missing something?