This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiceiver with 3 Devices Using nrf24L01+

I am trying to setup and use the multiceiver scenario. I have setup 4 devices, with one PRX and 3 PTX. I can only get 2 of the PTX to work, but no more. I am aware that by default only Pipe0 and Pipe1 are enabled, and I think I am enabling them all.

Here is my initialization code that works for PTX 1, and PTX 2,but not PTX 3

 // Set radio channel// channel is 7 bits
 Execute(Commands.W_REGISTER, Registers.RF_CH, new[] { (byte)(channel & 0x7F) });

// Set Data 
var regValue = Execute(Commands.R_REGISTER, Registers.RF_SETUP, new byte[1])[1];

 regValue &= (byte)~(1 << Bits.RF_DR_LOW);  // 0
 regValue &= (byte)~(1 << Bits.RF_DR_HIGH); // 0
 // Set data rate
  Execute(Commands.W_REGISTER, Registers.RF_SETUP, new[] { regValue });

  // Enable dynamic payload length
  Execute(Commands.W_REGISTER, Registers.FEATURE, new[] { (byte)(1 << Bits.EN_DPL) });

  // Set auto-ack
  Execute(Commands.W_REGISTER, Registers.EN_AA, new[] { (byte)(1 << Bits.ENAA_P0 | 1 << Bits.ENAA_P1 | 1 << Bits.ENAA_P2 | 1 << Bits.ENAA_P3 | 1 << Bits.ENAA_P4 | 1 << Bits.ENAA_P5) });

// Set dynamic payload length for pipes
Execute(Commands.W_REGISTER, Registers.DYNPD, new[] { (byte)(1 << Bits.DPL_P0 | 1 << Bits.DPL_P1 | 1 << Bits.DPL_P2 | 1 << Bits.DPL_P3 | 1 << Bits.DPL_P4 | 1 << Bits.DPL_P5) });


// Flush RX FIFO
Execute(Commands.FLUSH_RX, 0x00, new byte[0]);

// Flush TX FIFO
Execute(Commands.FLUSH_TX, 0x00, new byte[0]);

// Clear IRQ Masks
 Execute(Commands.W_REGISTER, Registers.STATUS, new[] { (byte)(1 << Bits.MASK_RX_DR | 1 << Bits.MASK_TX_DS | 1 << Bits.MAX_RT) });

// Set default address width
Execute(Commands.W_REGISTER, Registers.SETUP_AW, new[] { AddressWidth.Get(address) });

//Enable Pipes 0, 1, 2
 Execute(Commands.W_REGISTER, Registers.EN_RXADDR, new[] { (byte)(1 << Bits.ERX_P0 | 1 << Bits.ERX_P1 | 1 << Bits.ERX_P2 ) });

Execute(Commands.W_REGISTER, Registers.RX_ADDR_P0, _slot0Address);//Pipe 0  unique Address
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P1, Encoding.UTF8.GetBytes(BaseAddress + 1));
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P2, Encoding.UTF8.GetBytes(BaseAddress + 2));

// Set retransmission values
Execute(Commands.W_REGISTER, Registers.SETUP_RETR, new[] { (byte)(0x0F << Bits.ARD | 0x0F << Bits.ARC) });


Execute(Commands.W_REGISTER, Registers.RX_ADDR_P0, _slot0Address);
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P1, Encoding.UTF8.GetBytes(BaseAddress + 1));
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P2, Encoding.UTF8.GetBytes(BaseAddress + 2));

Execute(Commands.W_REGISTER, Registers.CONFIG, new[] { (byte)(1 << Bits.PWR_UP | 1 << Bits.CRCO | 1 << Bits.PRIM_RX) });
  • It seems like you are writing twice to the RX_ADDR_Px registers. What's the actual value of BaseAddress and the slot0Address? Are you sure you are writing pipe1 and pipe2 addresses in the correct way. Could it be that you are writing it the opposite way with regard to LSB and MSB? This would explain why pipe1 works, but pipe2 doesn't.

    Also, could you read out the register values after you have configured them to make sure that they match with what you intend them to be?

  • Thanks for the clarification and the answer. I see that I was writing values twice and removed that. Here is what I use to create the addresses, and then the values in the registers after that on the PRX:

    //primary address of PRX

    myAddress = Encoding.UTF8.GetBytes("HUB00");

    //addreses of the other 3 PTXs first matches the PRX address

    clients[0] = Encoding.UTF8.GetBytes("HUB00");

    clients[1] = Encoding.UTF8.GetBytes("NETP" + 1);

    clients[2] = Encoding.UTF8.GetBytes("NETP" + 2);

    Relevant Registers

    EN_AA: 0000001100001111 HEX 0E3F

    EN_RXADDR: 0000001100001111 HEX 0E3F

    RX_ADDR_P0: 0000001100111111 HEX 0EE7

    RX_ADDR_P1: 0000001100011111 HEX 0E4E

    RX_ADDR_P2: 0000001100001111 HEX 0E32

    RX_ADDR_P3: 0000001100111111 HEX 0EC4

    RX_ADDR_P4: 0000001100111111 HEX 0EC5

    RX_ADDR_P5: 0000001100111111 HEX 0EC6

    Thanks.

  • Just to add some clarification and what I am doing, but seems pipe1 does not have a good address?

    I set the addresses as follows:

    for (int i = 0; i < numberOfPipes; i++)

                {
                    if (i == 0)
                        Execute(Commands.W_REGISTER, Registers.RX_ADDR_P0, "HUB00");
                    else if (i == 1)
                        Execute(Commands.W_REGISTER, Registers.RX_ADDR_P1, Encoding.UTF8.GetBytes("NETP" + i));
                    else if (i == 2)
                        Execute(Commands.W_REGISTER, Registers.RX_ADDR_P2, Encoding.UTF8.GetBytes("NETP" + i));
                    else if (i == 3)
                        Execute(Commands.W_REGISTER, Registers.RX_ADDR_P3, Encoding.UTF8.GetBytes("NETP" + i));
                    else if (i == 4)
                        Execute(Commands.W_REGISTER, Registers.RX_ADDR_P4, Encoding.UTF8.GetBytes("NETP" + i));
                    else if (i == 5)
                        Execute(Commands.W_REGISTER, Registers.RX_ADDR_P5, Encoding.UTF8.GetBytes("NETP" + i));
    
                }
    

    Then the output for the registers is like this:

    EN_AA: 0000001100001111 HEX 0E3F

    EN_RXADDR: 0000001100001111 HEX 0E3F

    RX_ADDR_P0: 0000001100011111 HEX 0E48

    RX_ADDR_P1: 0000001100011111 HEX 0E4E

    RX_ADDR_P2: 0000001100001111 HEX 0E32

    RX_ADDR_P3: 0000001100001111 HEX 0E33

    RX_ADDR_P4: 0000001100001111 HEX 0E34

    RX_ADDR_P5: 0000001100001111 HEX 0E35

  • Ok, problem solved. I was doing 2 things wrong, and I missed it somehow in the documentation.

    1. The LSByte issue - I was using addresses in form base + 1, base + 2, etc and should have used 1 + base, 2 + base to generate the pipe1-5 addresses.

    2. More importantly, I missed the fact that addresses 2-5 are only 1 byte, and not 5 as the rest, so I was setting addresses in the form above, but for pipe address 2-5, I should have only used the 1, 2, 3 etc and not include the base in it.

Related