EEVblog Electronics Community Forum

Electronics => RF, Microwave, Ham Radio => Topic started by: sairfan1 on May 02, 2024, 07:25:51 pm

Title: Using spectrum analyzer to debug NRF24 module
Post by: sairfan1 on May 02, 2024, 07:25:51 pm
Let me explain a bit back ground, long ago I used LEDs and Serial port to debug SPI, I2C communication which was quite hard. Then I came to know about Logic Analyzer, oh god it made my life so easy.

A few months back I started working on NRF24L01 modules to communicate between two uC, I gave myself a challenge to build it by getting help only from its datasheet. After setting up RX, TX nodes I had no idea if TX really transmitted anything?? this bring me to search for Spectrum Analyzer so that I know if my modules are really working.

So I started searching around for reasonable Spectrum Analyzer after reading/exploring a lot of options, I bought two devices. HackRF One and Signal Hound SA44B. Now when I transmit I do not see any signal on any of these device, that made me think may be I do not know how to use it in this scenario.

While working with logic analyzer we have trigger to make it ready to listen/log data, my question is how can I snif tranmitted packets to analyze if everything is correct? please help me what terms are used for it, what kind of procedures used so that I can further learn it. One thing I found tricky that Spectrum analyzer (at least my devices) can't continiously minitor the signal, alway there is a small gap in between a sweep how do I overcome this, because I do not have trigger like a logic analyzer to ensure SA is looking for packet right after it transmitted.
Title: Re: Using spectrum analyzer to debug NRF24 module
Post by: Bicurico on May 02, 2024, 07:37:27 pm
You either use a realtime spectrum analyser or you reduce the frequency range to a few MHz.

Also, you want to switch on MAX hold, so that the pulses keep visible after they are long gone.

If you just want to see if there is a signal, without wanting to actually measure it, use the HackRF with the spectrum analyse software. This is realtime if you keep the span under 10MHz.

https://github.com/pavsa/hackrf-spectrum-analyzer

Try to look at WLAN Signals, to get a feel for it.

But if your signal is like ms or us, you might not catch it in a regular sweep.

Title: Re: Using spectrum analyzer to debug NRF24 module
Post by: selcuk on May 02, 2024, 07:37:49 pm
I suggest you to find a quiet place in terms of RF radiation at the beginning.

You may prepare a test firmware on your MCU to continuously send packets with some delay and by incrementing the frequency between each packets. Return to the first frequency after the last one. Then run the spectrum analyzer and set the measurement frequency band. After waiting a few seconds or minutes you can observe expected signals. After that turn off the MCU, save the signal and run the spectrum analyzer with the same range but on a different colored channel. This will be the base signal. After waiting a few seconds or minutes save this signal as well. Then subtract these two signals to see the nrf24 transmission.

You may find easier to observe if you increment the frequency after sending the same frequency multiple times instead of one. That is another method.

Title: Re: Using spectrum analyzer to debug NRF24 module
Post by: MarkF on May 03, 2024, 02:04:25 pm
Have you seen this thread?
https://www.eevblog.com/forum/projects/setting-up-the-nrf24l01-for-transmitting-and-receiving/ (https://www.eevblog.com/forum/projects/setting-up-the-nrf24l01-for-transmitting-and-receiving/)

Show us your hardware and how the nRF24L01 is connected.

Are you using the nRF24L01 or the nRF24L01+

I've found that a bulk capacitor of 1uF near the nRF24L01+ is necessary.

Also, checkout the nRF24 library for Arduino (https://github.com/nRF24/RF24).
Even if you're not using an Arduino, the code is the same.
Forget about hardware debugging.  It's not going to help.
Title: Re: Using spectrum analyzer to debug NRF24 module
Post by: sairfan1 on May 03, 2024, 03:20:12 pm
Thaks, that post looks very interesting.  Let me work on it and I'll get back.
Title: Re: Using spectrum analyzer to debug NRF24 module
Post by: sairfan1 on May 29, 2024, 11:54:49 pm
I'm not sure if I took wrong path, as I was not able to see any signals on spectrum analyzer i thought first ensure if I was able to write registers (NRF configurations) correctly, but i found somethig weird.

I'm writing to register some values but when i read the same registers it throws back some different values everytime, looks like writing configurations command are failed for some reason. I'm pasting some code here

Code: [Select]

unsigned char ADDRESS_DATA_PIPE0[5] = {0xE7,0xE7,0xE7,0xE7,0xE7};

// in NRF init function i initialize it
 NRF_WB(W_REGISTER | RX_ADDR_P0, ADDRESS_DATA_PIPE0 , 5); 

// Write buffer code, pasting only related code here
void NRF_WB(unsigned char data, unsigned char *buffer, unsigned char bytes){
unsigned char i;
NRF_CSN = 0;                                   
SPI1_Transfer(data);                       
for(i = 0; i < bytes; i++)     
   {
    SPI1_Transfer(*buffer);
    buffer++;
   }
NRF_CSN = 1; 
}

// SPI, pasting only related code here
uint8_t SPI1_Transfer(uint8_t data) {
    SSP1BUF = data;  // Load data into buffer
    while (!SSP1STATbits.BF);  // Wait until transfer is complete
    return SSP1BUF;  // Return received data
}

// in main function calling back the config

        NRF_CSN = 0;       
        SPI1_Transfer(R_REGISTER | RX_ADDR_P0);
        SPI1_BufferRead(buffer, 5);       
        NRF_CSN = 1;

// spi buffer read
void SPI1_BufferRead(void *block, size_t blockSize)
{
    uint8_t *data = block;
    while(blockSize--)
    {
        //*data++ = SPI1_ByteExchange(0);
        *data++ = SPI1_Transfer(0);
       
    }
}


May be we can ignore all logic in the code because logic analyzer is showing what's going on, for last two days im trying to understand this behavior, I checked at least 5 different types of NRF modules, they return different values but non of them match with what i set on it. during this operation CE is LOW