SX1276 transmission power managment

Hi,
I want to verify if my information about the Tx output power is correct or no, because i’m kinda confused, so if you could bear with me to tell you want i know or at least what i think it’s true about this subject:

  • in Tx they are 3 power modes:

1- RFO: from -4 dBm to 15 dBm (Pout=Pmax-(15-OutputPower) = 10.8 + 0.6 * 7 - (15 - 15) = 15) 7 is the max value for the MaxPower and 15 is the max value for the outputPower so that’s way the RFO can reach 15 dBm, but i don’t know why they said it’s only +14dBm? and set the PaSelect to 0 to use this mode and make sure the PA_Dac set to 0x04 (default value)

2- PA_Boost: from 2 dBm to 17 dBm (Pout=17-(15-OutputPower)) this is clear. set PaSelect bit to 1 to activate this mode. and make sure to set the PA_Dac to 0x04 (default value) (PA_DAC register = 0x84)

3- +20dBm: 20 dBm, to use this option we need to be in the PA_Boost mode (set PA_Boost bit to 1) and set the PA_DAC to 0x07 (PA_DAC register = 0x87).

About the RFO where i need to set 2 variable “MaxPower” and “Output Power”, i don’t know what is the right way to do that, i mean which one should i adjust to get the Tx power the user want to use. or should i set the “MaxPower” to 7 so the Pmax = 15 and from there i set the “Output Power” to get the Pout (which is the Tx power) the user wants, because it’s gonna be easy to go from 15 to 0 by step of 1 dBm. hope one of you have a better solution?!

Now the last thing, the OCP, which is require for the PA_Boost and +20 dBm option because both works in high power (PA_HP) and i don’t know how to set that register, i mean how to calculate Imax. i need help about this, and do i need to set this register for the RFO mode too?? if yes then how? (by the way, i know about the table of OCP in the datasheet and how to calculate the OCP from Imax, the problem that i don’t know how to get or figure about the Imax.

One last question, is the order to configure the PaSelect Variable and MaxPower and Output Power and PA_DAC register and OCP register matters, my real confusion is about PaSelect variable and Output Power variable and PA_DAC register configuration order.

I hope i was clear and i will appreciate your help to correct me and confirm my information. Thank YOU.

In there a problem with the TTN library you are using ?

I thought the power setting was simplewith the TTN libraries so why are you directly manipulating the SX127x registers ?

I’m not using the TTN libraries. i’m creating my own library. just using SPI to communicate directly with lora by write/read register. so here i am, trying to figure out the right way to configure the Tx section, which offre some power consumption control and and Tx power management. nothing is related to TTN library, hope i didn’t ask my question in the wrong forum!

guess :roll_eyes:

I saw many ppl asking all kind of questions about lora here, even me, asked a question before about ttgo board that equipped with lora chip and it had nothing about library or even any sort of code. and ppl helped me and answer with kindness. any way, soon i figure out the answer i will post it here, maybe it will help someone else.

we don’t say it’s not interesting, but it’s not directly related to the network as you mentioned yourself.
tnx

What are you trying to do here?

Implementing LoRaWAN yourself to talk to TTN is on topic (ie, there are many ways to do this beside using “the TTN library” - whatever that is or was, it is not what most people are using to begin with)

But using a LoRa chip for something other than implementing LoRaWAN to interoperate TTN is off topic

Of course as a practical matter, if you are embarked on DIY project for any purpose, one thing you could do is temporarily fire up some existing code such as LMiC or whatever and either make it log the SPI operations it performs, or use a cheap little USB logic analyzer to see what it is doing.

If your writing your own library, its beholdent on you to check that it is correct yourself.

Thus whatever the datasheet says your going to have to measure the power output in reality across a few different modules. And if your going to have to do that a few simple tests will confirm if your reading of the datasheet is correct.

Ok, to answer some of my questions:

  • what i said about RFO was right, but i still don’t know why they said it’s between -4 to 14 dBm and in the same datasheet in other section they said it’s 15 dBm. anyway, about how to set this in the register because you have 2 variable you need to set (maxPower, and outoutPower), you can notice we have 2 regions, from -4 to 0 dbm and from 0 to 15 dBm. for [-4, 0[ set the maxPower to 0 and that will give you a Pmax = 10.8 and from this equation Pout = Pmax - 15 + outputPower = 10.8 -15 + outputPower = -4.2 + outputPower, we can find outputPower = Pout + 4.2, and for the region [0, 15] we set the maxPower to 7 (the max value) so we will have this now , Pout = 15 - 15 + outputPower = outputPower.
  • About the PA_BOOST it a forward calculation nothing fancy, outputPower = Pout - 2 and don’t forget Pout should be between 2 and 17,
    to switch betwen RFO and PA_BOOST, set the bit 7 in PaConfig register. and disable the +20 dBm option in the Pa_Dac register.
  • About the +20 dBm option, it’s the same as PA_BOOST but instead of Pmax = 17, Pmax = 20 so outputPower = Pout - 5 , and you need to enable the PA_BOOST and then set the PA_Dac to 0x87, 7 to enable the +20 dBm option, , note : just by setting the outputPower to 0xf (15) you will get the 20dBm, and to disable this feature just set PaDac varaible to 4 ( set the PaDac register to 0x84) to disable it.

for the OCP, they have a table that gives you how to calculate the ocp value from the Imax,
ocp-trim [0-15], Imax [45, 120 mA] , Imax = 45 + 5 * ocpTrim
ocp-trim [16-27], Imax [130, 240 mA] , Imax = -30 + 10 * ocpTrim
ocp-trim > 27, Imax = 240mA , Imax = 240 mA

and about the Imax which is the current need for the Tx we can find this in the datasheet:
RFOP = 13 dBm uses 28mA
RFOP = 7 dBm uses 20 mA
PA_BOOST = 17 dBm uses 90 mA
+20 dBm opton uses 120mA

the OCP need to be enabled if you want to use the PA_BOOS.
about the order of the settings. i will just try to set the register in order, just in case.

1 Like

Hi.
Did you solve your problem ?
These days, I’m making tests with Riot-OS, sx1276 & Loramac Semtech .

If you’re stuck, I can add some debugs to Spi Writes of sx1276 driver so you can compare.

Contact me directly if needed.

Olivier Fauchon

Definetly worthwhile checking that the power level you think you are writing to the SX1276 matches the reality.

I remember looking at a well known library some time back, due to an error in the library code it was setting up the SX127x for 2dBm more than intended.

I’m not sure if you are aware but every implementation I’ve seen chooses either RFO or BOOST in hardware. You can see it on the PCB.

The HopeRF module connects BOOST. It’s not documented for some reason.

@ofauchon, I’m comparing my code with an existing library, “pyLora” and “raspi-lora” and for the moment i’m able to transmit a message from my raspberry pi (that uses lora bee “sx1276”) to a lora-ttgo board. the problem i’m facing now it’s about the range, i mean i’m using the same Tx power for both examples (example uses raspi-lora library after correcting it to use the lora mode and in the other example i’m using my library) and when i use my library i need to get both boards closer to be able to catch the data which is weird because i’m almost sure we have the same function that writes the output power and maxpower to the SX1276 register. i will upload the code to github soon and i will send you the link so you can have a look. and about your suggestion it will be a pleasure for me to have more information how things suppose to be done. thank you.

@LoRaTracker: well about the power level i’m not really sure if it matches what i want, but if i compare my code to anther library about the Tx power section i’m kinda sure we have the same code. but when i test it i face a distance problem, i mean i need to get my distance closer to be able to receive a message even i’m using the same Tx power with other library. for now, i will try to read that register after using the library without clear it and compare it to what i get from the register after using my code. thanks

@cjhdev, RFO or BOOST it’s for the Tx power range you want to use, RFO is between -4 to 15 (or 14) dBm when the BOOST can reach 17 dBm and with the +20dBm option you can reach the 20dBm. and i’m working below the 14 so if i want to consume less power i need to use RFO unless i need to work above the 15 dbm. thank you

Yes I am aware, but since they are separate power amplifiers, you can’t use the one you want if it isn’t physically connected.

For example, the sx1272 mbed shield connects RFO but not BOOST.

https://wiki.dragino.com/index.php?title=Lora_BEE

this is the specification of the lore bee module, and they mentioned you can reach the +20dBm or use the 14dBm, which mean the can use the PA_BOOST because if you want to use +20dBm option you need to use the PA_BOOST. and i my code i’m not using the PA_BOOST any way, i’m using the RFO which is the main PA that uses a low power consumption. but to be clear here, i already can receive data but the problem here it’s not from a long distance, let’s forget about the long distance for now, if i use raspi-lora library and use Tx power = 8 dBm i can receive a data in 1 meter distance, if i change the code and use my library with the same Tx power = 8 dBm i can’t receive any data and i need to get the board closer to transmitter ( about 0.5 meter) then i can receive data, which is weird especially the Tx power function in my library and the other library looks the same.

1 Like

There is no way I know of to reduce the TX power enought to cut the line of sight range down to 1m or less. So if you cannot communicate over that distance there is probably another fundamental issue.

Measuring the actualpower output is where I would start loooking for issues.

Is this a TTN library you are writing ?

1 Like

The same, except you say you are using RFO and not BOOST, which on that HopeRF module is not physically connected to the matching components and antenna.

Explains why it only works at 0.5m.

edit:

For some extra detail, the PA connected to the ‘PA_BOOST’ pin can operate in 2-17dBm mode or fixed 20dBm.

The RFO PA is not connected to the ‘PA_BOOST’ pin.

1 Like

i’m not using RF96/95, this lora bee uses the sx1276, and about the antenna if is it connected to PA_BOOST or the RFO, i don’t know, i didn’t even though that is an option, though the antenna suppose to work for both, i guess i need to check that out. now after i have checked the raspi-lora library, i found this :

       if self._tx_power < 20:
            self._spi_write(REG_4D_PA_DAC, PA_DAC_ENABLE) # enable the +20 dBm option, `0x07`
            self._tx_power -= 3
        else:
            self._spi_write(REG_4D_PA_DAC, PA_DAC_DISABLE) # disable the option, `0x04`

which is the opposite of what should happen, and after that i checked the PA_BOOST register and it’s always enabled, which mean this library use all the time the PA_BOOST. i guess the antenne is connected to that PA_BOOST pin. and about the 20 dBm option the description in the datasheet said this option will Set Pmax to +20dBm for PA_HP doesn’t that mean "Pout=Pmax-(15-OutputPower) " will become “Pout=20-(15-OutputPower)” ?!