This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Getting RSSI

Hi everyone,

How can i modify the ez430's demo program for getting RSSI data in dBm? The demo program shows the RSSI in %.

I'm looking the demo program's code but i cant find a solution for dBm. The datasheet says that;

1) Read the RSSI status register
2) Convert the reading from a hexadecimal
number to a decimal number (RSSI_dec)
3) If RSSI_dec ≥ 128 then RSSI_dBm =
(RSSI_dec - 256)/2 – RSSI_offset
4) Else if RSSI_dec < 128 then RSSI_dBm =
(RSSI_dec)/2 – RSSI_offset

void transmitData(int addr, signed char rssi,  char msg[MESSAGE_LENGTH] )
{
  char addrString[4];
  char rssiString[3];
  volatile signed int rssi_int;

  addrString[0] = '0';
  addrString[1] = '0';
  addrString[2] = '0'+(((addr+1)/10)%10);
  addrString[3] = '0'+((addr+1)%10);
  rssi_int = (signed int) rssi;

 if (rssi_int >= 128) 
      RSSI_DBM = (int)((int   )(rssi_int - 256) / 2) - 72; 
   else  
      RSSI_DBM = (rssi_int / 2) - 72;


  rssiString[0] = '0'+(rssi_int%10);
  rssiString[1] = '0'+((rssi_int/10)%10);
  rssiString[2] = '0'+((rssi_int/100)%10);

  transmitDataString( addrString, rssiString, msg );
}

 

i made modifications but RSSI data is not shown true. Any help?

thanks a lot

  • The code you are showing is calculating the value in dBm, not percent.

    I'm not sure what the RSSI_DBM variables is, if it is the RSSI register then you cannot write to it.

    Jim Noxon

     

  • Yeah code tries to calculate in dBm. I mean the original demo program calculates in percentage.No RSSI_DBM is a variable not register. I made some modifications for calculating in dBm but it shows strange results on the hyperterminal screen.I m copying the original program part below:

    *
    ------------------------------------------------------------------------------*/
    void transmitData(int addr, signed char rssi,  char msg[MESSAGE_LENGTH] )
    {
      char addrString[4];
      char rssiString[3];
      volatile signed int rssi_int;

      addrString[0] = '0';
      addrString[1] = '0';
      addrString[2] = '0'+(((addr+1)/10)%10);
      addrString[3] = '0'+((addr+1)%10);
      rssi_int = (signed int) rssi;
      rssi_int = rssi_int+128;
      rssi_int = (rssi_int*100)/256;
      rssiString[0] = '0'+(rssi_int%10);
      rssiString[1] = '0'+((rssi_int/10)%10);
      rssiString[2] = '0'+((rssi_int/100)%10);

      transmitDataString( addrString, rssiString, msg );
    }

    /*------------------------------------------------------------------------------

     

     

    Modified program part :

    *
    ------------------------------------------------------------------------------*/
    void transmitData(int addr, signed char rssi,  char msg[MESSAGE_LENGTH] )
    {
      char addrString[4];
      char rssiString[3];
      volatile signed int rssi_int;

      addrString[0] = '0';
      addrString[1] = '0';
      addrString[2] = '0'+(((addr+1)/10)%10);
      addrString[3] = '0'+((addr+1)%10);
      rssi_int = (signed int) rssi;

    if (rssi_int >= 128) 
          rssi_int = (int)((int   )(rssi_int - 256) / 2) - 72;   //calculating in dBm if its below 128
       else  
          rssi_int = (rssi_int / 2) - 72;    //if its above 128

      rssiString[0] = '0'+(rssi_int%10);
      rssiString[1] = '0'+((rssi_int/10)%10);
      rssiString[2] = '0'+((rssi_int/100)%10);

      transmitDataString( addrString, rssiString, msg );
    }

    /*------------------------------------------------------------------------------

     

    Thanks for your reply Noxon..

     

    Rommedahl

  • Since the code to output the value (as opposed to the code to calculate the value) hasn't changed, I would try sending the value out in its original form.  i.e. comment out the entire if statement and see if you get on the terminal what you are passing to the code.  Also you may want to simply pass a constant or incrementing value for now just to make sure the code is generating the output correctily.

    Once you have the code generating the output correctly, then you can take a look at the real RSSI values again.

    By the way, a simpler form for calculating the RSSI woudl be as follows

    rssi_int = ((signed int)((signed char)rssi) / 2) - RSSI_OFFSET;

    This works because of the cast to signed char initially.  The long drawn out method described in the spec sheet is assuming you will be reading the RSSI register as an unsigned char which when cast to a signed int will not correctly manage the sign bit in the 8 bit 2's compliment representation of the RSSI register.  By casting it back to a signed char first, the promotion to a signed int properly sign extends the value from which you don't need to make the extra calculation decisions to correct the value, just divide by two so it is in full dBm steps and subtract off the offset.

    Regards,

    Jim Noxon