Skip to content

incorrect output power settings #3

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

Closed
jerryneedell opened this issue May 3, 2018 · 5 comments
Closed

incorrect output power settings #3

jerryneedell opened this issue May 3, 2018 · 5 comments

Comments

@jerryneedell
Copy link
Contributor

This is just a heads up It looks like the output power level is not being set correctly resulting in the output power being significantly lower than expected. What I thought was a simple fix, does not appear to have worked so I'll continue digging and will post a detailed explanation soon. I just wanted to put out a warning in case anyone else notices this.

In brief:
I think this patch is needed in any case, but it does not seem to result is a significant improvement.
From the data sheet and comparing to the Arduino RadioHead code, subtracting 3 from the request power should be done here to ensure that the value sent to the register at lin 507 (requested power -5) is between 0 and 15. The register only accepts a 4 bit value. Without this change, a setting of 23 will result in a value of 18 being sent, but 18 &0xf is 2 not the desired 15 for maximum power.

https://github.com/adafruit/Adafruit_CircuitPython_RFM9x/blob/master/adafruit_rfm9x.py#L513

patch to fix power level:

diff --git a/adafruit_rfm9x.py b/adafruit_rfm9x.py
index 72d5d93..9b33184 100644
--- a/adafruit_rfm9x.py
+++ b/adafruit_rfm9x.py
@@ -507,6 +507,7 @@ class RFM9x:
             # Enable power amp DAC if power is above 20 dB.
             if val > 20:
                 self.pa_dac = _RH_RF95_PA_DAC_ENABLE
+                val -= 3
             else:
                 self.pa_dac = _RH_RF95_PA_DAC_DISABLE
             self.pa_select = True

Applying this patch does not result in the expected output power improvement so I'll keep looking into it,

@jerryneedell
Copy link
Contributor Author

update - still working on power setting but I tried configuring one LORA unit via Arduino (Radiohead) and it cannot communicate with the CP configured unit.
If both are configured via Arduino they work or if both are configured via CP they work but as far as I understand, they should be able to communicate Arduino to CP.
When both are configured via Arduino I do get much better range and much lower RSSI readings.

@jerryneedell
Copy link
Contributor Author

jerryneedell commented May 4, 2018

Major progress - The frequency configuration was not correctly implemented. The transmitting frequency was not actually getting set and defaulted to 434Mhz, not 915MHz. I think it worked because it was being done the same on both boards but tit was not transmitting optimally thus the poor range and RSSI. Now I get much better RSSI readings and much longer range. I'm still having issues with Arduino vs CP compatibility and will hold off on a PR until I resolve that.

current diff:

index 72d5d93..17ec80a 100644
--- a/adafruit_rfm9x.py
+++ b/adafruit_rfm9x.py
@@ -374,7 +374,7 @@ class RFM9x:
         # Set preamble length (default 8 bytes to match radiohead).
         self.preamble_length = preamble_length
         # Set frequency
-        self.frequency = frequency
+        self.frequency_mhz = frequency
         # Set TX power to low defaut, 13 dB.
         self.tx_power = 13
 
@@ -487,6 +487,7 @@ class RFM9x:
         self._write_u8(_RH_RF95_REG_06_FRF_MSB, msb)
         self._write_u8(_RH_RF95_REG_07_FRF_MID, mid)
         self._write_u8(_RH_RF95_REG_08_FRF_LSB, lsb)
+        self.low_frequency_mode = 0
 
     @property
     def tx_power(self):
@@ -507,6 +508,7 @@ class RFM9x:
             # Enable power amp DAC if power is above 20 dB.
             if val > 20:
                 self.pa_dac = _RH_RF95_PA_DAC_ENABLE
+                val -= 3
             else:
                 self.pa_dac = _RH_RF95_PA_DAC_DISABLE
             self.pa_select = True

@tannewt
Copy link
Member

tannewt commented May 4, 2018

Thanks for sorting this out @jerryneedell !

@jerryneedell
Copy link
Contributor Author

submitted PR #4 - I hope this fixes these issues.
The main problems were the frequency setting and the baudrate. See PR notes for details.

@jerryneedell
Copy link
Contributor Author

closed via PR #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants