LoRa Notes 02 Research on the transmit power of LoRa sx1276 sx1278

1 Introduction

The transmit power is also a basic RF indicator. Currently, the SX1278 can support a maximum of 20dBm.

I am learning LoRa and LoRaWAN, and I basically take notes in the way of official materials + sorting analysis + related source code. I believe it will be helpful to many colleagues. You can click here to view the post LoRa study notes_Summary .

The author of this article twowinter, please indicate the author for reprint: http://blog.csdn.net/iotisan/

2 Official datasheet information

5.4.2. RF Power Amplifiers

PA_HF and PA_LF are high efficiency amplifiers capable of yielding RF power programmable in 1 dB steps from -4 to
+14dBm directly into a 50 ohm load with low current consumption. PA_LF covers the lower bands (up to 525 MHz), whilst
PA_HF will cover the upper bands (from 779 MHz). The output power is sensitive to the power supply voltage, and typically
their performance is expressed at 3.3V.

PA_HP (High Power), connected to the PA_BOOST pin, covers all frequency bands that the chip addresses. It permits
continuous operation at up to +17 dBm and duty cycled operation at up to +20dBm. For full details of operation at +20dBm
please consult section 5.4.3

Table 33 Power Amplifier Mode Selection Truth Table

PaSelect Mode Power Range Pout Formula
0 PA_HF or PA_LF on RFO_HF or RFO_LF -4 to +15dBm Pout=Pmax-(15-OutputPower) Pmax=10.8+0.6*MaxPower [dBm]
1 PA_HP on PA_BOOST, any frequency +2 to +17dBm Pout=17-(15-OutputPower) [dBm]
Notes 
- For +20 dBm restrictions on operation please consult the following .
- To ensure correct operation at the highest power levels ensure that the current limiter OcpTrim is adjusted to permit delivery of the requisite supply current.
- If the PA_BOOST pin is not used it may be left floating

5.4.2 Chinese Interpretation

The chip has several different RF pins, PA_HF (greater than 779 MHz) and PA_LF (less than 525 MHz) both output up to 14dBm. PA_BOOST is more powerful, it can continuously output 17dBm, and the periodic work of duty cycled operation can soar to 20dBm.

A friend made an 868MHz LoRa last time and used the RFO_HF pin painfully, which can only output 14dBm. If you look at the datasheet more, you may be able to avoid these problems.

In general, at present, if we use PA_BOOST, then applying the formula, we can routinely output 2-17dBm, which is controlled by the register. If you want to output 20dBm, you need to see the next chapter.

5.4.3. High Power +20 dBm Operation

The SX1276/77/78/79 have a high power +20 dBm capability on PA_BOOST pin, with the following settings:

Table 34 High Power Settings

Register Address Value for High Power Default value PA_HF/LF or +17dBm Description
RegPaDac 0x4d 0x87 0x84 Set Pmax to +20dBm for PA_HP

Notes
- High Power settings must be turned off when using PA_LF or PA_HF
- The Over Current Protection limit should be adapted to the actual power level, in RegOcp

Specific Absolute Maximum Ratings and Operating Range restrictions apply to the +20 dBm operation. They are listed in
Table 35 and Table 36.

The duty cycle of transmission at +20 dBm is limited to 1%, with a maximum VSWR of 3:1 at antenna port, over the
standard operating range [-40;+85°C]. For any other operating condition, contact your Semtech representative.

5.4.3 Chinese Interpretation

If 20dBm is to be set, the high power register (RegPaDac) must be configured. If PA_LF and PA_HF are used then there is no need to set the high power register (RegPaDac). When transmitting at 20dBm, the maximum duty cycle can only be 1%. The antenna standing wave ratio cannot exceed 3:1. The supply voltage is 2.4~3.7V.

IoT expert twowinter Note: In this case, the output power is 20 - (15 - OutputPower), which is 5~20dBm. This is the power parameter declared by most manufacturers at present.

5.4.4. Over Current Protection

The power amplifiers of SX1276/77/78/79 are protected against current over supply in adverse RF load conditions by the over current protection block. This has the added benefit of protecting battery chemistries with limited peak current capability and minimising worst case PA consumption in battery life calculation. The current limiter value is controlled by the OcpTrim bits in RegOcp, and is calculated according to the following formulae:

5.4.4 Chinese Interpretation

Current overload protection. RegOcp's OcpTrim can limit the maximum current.

3 Power consumption under different transmit power

4 Code Analysis

The code in this part of LoRa is defined by the macro LORAMAC_DEFAULT_TX_POWER. The value of this macro is based on the value of each region. The default in some regions is 14dBm, and the default in some regions is 20dBm.
For details, please check the LoRaWAN protocol V1.0.2 Chinese version_Supporting file area parameters (physical layer) .

There are specific calls in the SendFrameOnChannel() function. According to different regional parameters, Radio.SetTxConfig() is called, and all regional parameters are set together.

void SX1276SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev,
                        uint32_t bandwidth, uint32_t datarate,
                        uint8_t coderate, uint16_t preambleLen,
                        bool fixLen, bool crcOn, bool freqHopOn,
                        uint8_t hopPeriod, bool iqInverted, uint32_t timeout )
{
    uint8_t paConfig = 0;
    uint8_t paDac = 0;

    SX1276SetModem( modem );

    paConfig = SX1276Read( REG_PACONFIG );
    paDac = SX1276Read( REG_PADAC );

    paConfig = ( paConfig & RF_PACONFIG_PASELECT_MASK ) | SX1276GetPaSelect( SX1276.Settings.Channel );
    paConfig = ( paConfig & RF_PACONFIG_MAX_POWER_MASK ) | 0x70;

    if( ( paConfig & RF_PACONFIG_PASELECT_PABOOST ) == RF_PACONFIG_PASELECT_PABOOST )
    {
        if( power > 17 )
        {
            paDac = ( paDac & RF_PADAC_20DBM_MASK ) | RF_PADAC_20DBM_ON;
        }
        else
        {
            paDac = ( paDac & RF_PADAC_20DBM_MASK ) | RF_PADAC_20DBM_OFF;
        }
        if( ( paDac & RF_PADAC_20DBM_ON ) == RF_PADAC_20DBM_ON )
        {
            if( power < 5 )
            {
                power = 5;
            }
            if( power > 20 )
            {
                power = 20;
            }
            paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 5 ) & 0x0F );
        }
        else
        {
            if( power < 2 )
            {
                power = 2;
            }
            if( power > 17 )
            {
                power = 17;
            }
            paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 2 ) & 0x0F );
        }
    }
    else
    {
        if( power < -1 )
        {
            power = -1;
        }
        if( power > 14 )
        {
            power = 14;
        }
        paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power + 1 ) & 0x0F );
    }
    SX1276Write( REG_PACONFIG, paConfig );
    SX1276Write( REG_PADAC, paDac );
    ......
}

In addition, the deity also got the official old driver library, just take a look at it. ^_^

1. When setting the frequency point, by the way, whether to configure the PA Select or not.

void SX1276LoRaSetRFFrequency( uint32_t freq )
{
    LoRaSettings.RFFrequency = freq;

    freq = ( uint32_t )( ( double )freq / ( double )FREQ_STEP );
    SX1276LR->RegFrfMsb = ( uint8_t )( ( freq >> 16 ) & 0xFF );
    SX1276LR->RegFrfMid = ( uint8_t )( ( freq >> 8 ) & 0xFF );
    SX1276LR->RegFrfLsb = ( uint8_t )( freq & 0xFF );
    SX1276WriteBuffer( REG_LR_FRFMSB, &SX1276LR->RegFrfMsb, 3 );

    SX1276Read( REG_LR_PACONFIG, &SX1276LR->RegPaConfig );

    if( LoRaSettings.RFFrequency > 860000000 )
    {
        SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_PASELECT_MASK ) | RFLR_PACONFIG_PASELECT_RFO;
    }
    else
    {
        SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_PASELECT_MASK ) | RFLR_PACONFIG_PASELECT_PABOOST;
    }
    SX1276Write( REG_LR_PACONFIG, SX1276LR->RegPaConfig );
}

2. Set whether to enable 20dBm

void SX1276LoRaSetPa20dBm( bool enale )
{
    SX1276Read( REG_LR_PADAC, &SX1276LR->RegPaDac );
    SX1276Read( REG_LR_PACONFIG, &SX1276LR->RegPaConfig );

    if( ( SX1276LR->RegPaConfig & RFLR_PACONFIG_PASELECT_PABOOST ) == RFLR_PACONFIG_PASELECT_PABOOST )
    {
        if( enale == true )
        {
            SX1276LR->RegPaDac = 0x87;
        }
    }
    else
    {
        SX1276LR->RegPaDac = 0x84;
    }
    SX1276Write( REG_LR_PADAC, SX1276LR->RegPaDac );
}

3. In the key part, set the transmit power.

void SX1276LoRaSetRFPower( int8_t power )
{
    SX1276Read( REG_LR_PACONFIG, &SX1276LR->RegPaConfig );
    SX1276Read( REG_LR_PADAC, &SX1276LR->RegPaDac );

    if( ( SX1276LR->RegPaConfig & RFLR_PACONFIG_PASELECT_PABOOST ) == RFLR_PACONFIG_PASELECT_PABOOST )
    {
        if( ( SX1276LR->RegPaDac & 0x87 ) == 0x87 )
        {
            if( power < 5 )
            {
                power = 5;
            }
            if( power > 20 )
            {
                power = 20;
            }
            SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_MAX_POWER_MASK ) | 0x70;
            SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 5 ) & 0x0F );
        }
        else
        {
            if( power < 2 )
            {
                power = 2;
            }
            if( power > 17 )
            {
                power = 17;
            }
            SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_MAX_POWER_MASK ) | 0x70;
            SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 2 ) & 0x0F );
        }
    }
    else
    {
        if( power < -1 )
        {
            power = -1;
        }
        if( power > 14 )
        {
            power = 14;
        }
        SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_MAX_POWER_MASK ) | 0x70;
        SX1276LR->RegPaConfig = ( SX1276LR->RegPaConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power + 1 ) & 0x0F );
    }
    SX1276Write( REG_LR_PACONFIG, SX1276LR->RegPaConfig );
    LoRaSettings.Power = power;
}

4. Overall process

void SX1276LoRaInit( void )
{
    ......
    SX1276LoRaSetRFFrequency( LoRaSettings.RFFrequency );
    SX1276LoRaSetPa20dBm( true );
    SX1276LoRaSetRFPower( LoRaSettings.Power );
    ......
}

End

At the end of the test, I took a screenshot and took a photo. It did reach 20dBm.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324882700&siteId=291194637