-
-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSSI when snr>0 #291
base: master
Are you sure you want to change the base?
RSSI when snr>0 #291
Conversation
Due to linearity issues, we do (RSSI=-139+16/15*PacketRssi) [https://www.mouser.com/ds/2/761/sx1276-1278113.pdf, Section 5.5.5 Note-3]
I think this PR is wrong. packetSNR correction should be applied when SNR < 0, from the pdf: Packet Strength (dBm) = -157 + PacketRssi + PacketSnr * 0.25 (when using the HF port and SNR < 0) Also HF and LF port midband threshold is not 868E6, more likely 525E6 or any other freq between bands but not IN bands. Take a look at Semtech's reference code:
RF_MID_BAND_THRESH is 525E6 and offsets are -164 and -157. |
Correct me if I am wrong. The following snapshot is for the correction of packetStrength for snr<0 which is different from the RSSI. Maybe, we can incorporate a function for it in this library. The point I am concerned about is the RSSI value for the cases when the transmitter is close to the receiver. In other words, when signal strength is above -80 dBm or so. For this, on the same page, in the note, the doc has specified the RSSI correction when snr>0. Lora-net/LoRaMac-node#420 : Here is the discussion on the same in LoRaMac library. Correct me if I am wrong. :) |
I think the documentation is a bit confusing on this. My understanding is that there are two registers RegPktRssiValue (0x1A) and RegRssiValue (0x1B) working like this: It seems RegRssiValue is an instant RSSI value meant to be used by sampling it during packet reception and offers better linearity and precision. Due to difficult implementation (you'd have to detect packet start and end via ValidHeader and RxDone IRQs and do the sampling and averaging in code) I have not seen any driver implementation using this approach. On the other hand RegPktRssiValue offers an averaged RSSI value of the last packet received, calculated by the chip itself. In the documentation the RSSI value calculated from this register is called PacketStrength (I think to differentiate it from the RSSI value you could calculate from the RegRssiValue register) but, in practice, this register is what is used to calculate the "RSSI" value on all driver implementations. Now, about calculating RSSI from RegPktRssiValue:
I'll take a look at different implementations and see if I can draw further conclusions, but when in doubt I think a good idea is to mimic Semtech code behaviour, as the docs are not very clear on some aspects. |
@sergio303 thank you very much for this detailed research, my time has been pretty tight lately and this is an extremely helpful overview. Let us know what your additional research yields and hopefully the three of us can get a solid solution together in the next week or two. |
after taking a look at project LoRaMac-node (where Semtech people maintain code and response to issues), I think I've found an issue response by Semtech that clarifies this: Looking at point 2, it seems like datasheet specification is incomplete (overlooking situations where RSSI is high and SNR is negative), and the recommended approach is to apply the 16/15 scaling factor for all SNR values. I've checked and that's the way it's implemented in latest Semtech drivers. I'll submit a PR on the coming days implementing this approach. Also, does it make sense in the library to have packetSnr as a float ? just a fast bit shift would suffice to divide register by 4, but changing it may break code using the library, don't know if I should change this. |
When I start to enable LNA, in some cases, SNR < 0. LoRaMac has not changed the calculation yet. However, RadioLib changed the calulation. Hence, when SNR < 0, the RSSI is reduced, too. @morganrallen @sandeepmistry : Should we fix this? |
@IoTThinks after reading @manvendra88's comment in #291 (comment) I believe there is some confusion. Here is my understanding, please correct me if I am misunderstanding something.
This would be an improvement if "very good RSSI precision is needed ..."
|
I see your point. Normally, RSSI implies packet strength. If snr > 0, Packet Strength = Packet RSSI Wondering how much SNR can go low below 0? So SNR can go down until -148 dBm? If yes, then the Packet Strength can go down to -200. |
Updated packetRSSI
(RSSI=-139+16/15*PacketRssi) for cases when snr>0
[https://www.mouser.com/ds/2/761/sx1276-1278113.pdf, Section 5.5.5 Note-3]