Author Topic: Real time RSSI measurement broken RFM69CW?  (Read 47322 times)

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Real time RSSI measurement broken RFM69CW?
« Reply #105 on: February 25, 2016, 04:13:34 PM »
Perhaps this solves the noise mystery:

I just noticed that RSSI operates the same in both OOK and FSK modes (Figure 18 from the datasheet doesn't distinguish between them).  However, by definition of RxBw, the OOK bandwidth is half that of FSK for any given pair of mantissa and exponent, and therefore there should be less noise reflected in RSSI if measured with OOK rather than with FSK.  As a quick test, I just enabled OOK modulation, and re-ran the test measurements, and lo and behold, it does, on average, eliminate most of the remaining noise that we were puzzling over.  For convenience, I measured outside of the sealed can using the solder tacked Moteino, and the average RSSI was -126.23:

http://pastebin.com/7CcPkE0D

The OOK bandwidth is 1300Hz.

[Edit: At these low RSSI values, there's a skewing going on that's worth noting.  According to the datasheet:  "RssiValue can only be read when it exceeds RssiThreshold."  So, the atmega will never receive an interrupt on DIO0 if RSSI were to measure at -127.50.  That's why all the measured values are -127.00 and higher.  However, by adding an external timer interrupt, we could infer an RSSI value of <= -127.50 if DIO0 doesn't trigger within the expected timeframe.  I haven't done that yet, but the fact of the matter is that it takes a very noticeable amount of time to acquire the 1000 datapoints using just the DIO0 interrupt using the above congfiguration, and so I rather suspect that the majority of the time the effective RSSI using this method would show <=  -127.50.  That would be pretty awesome, wouldn't it?  For instance, if you wanted to, you might be able to do very sensitive OOK signalling (though possibly at a very slow datarate) using this method to get much better range than what's possible with normal RFM69 settings.]
« Last Edit: February 25, 2016, 05:34:45 PM by WhiteHare »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Real time RSSI measurement broken RFM69CW?
« Reply #106 on: February 25, 2016, 07:19:43 PM »
So, for fun, I tried measuring the 1300Hz bandwidth OOK RSSI on a non-impaired Moteino (i.e. one with a regular wire antenna), running on a battery, using the same tricks of sleeping the atmega328p and the flash memory during the RSSI measurement, and waking the atmega328p when DIO0 (mapped to RSSI) goes high to record the latched RSSI value (before it unlatches).  Again, this was outside the sealed metal can.  This time the average RSSI was higher, as you would expect, but still impressively low:  -124.56

http://pastebin.com/Y3Gaxnk3

[That compares to -118.46 average RSSI if running the same Moteino with FSK and with sensitivity boost OFF, also from battery:  http://pastebin.com/ArbC7qSX]
« Last Edit: February 25, 2016, 08:53:42 PM by WhiteHare »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Real time RSSI measurement broken RFM69CW?
« Reply #107 on: February 25, 2016, 09:55:59 PM »
Interesting. I am puzzled by the 400k pulldown. I've never had to do anything like that on a SPI device. Not sure what to say about that.

I switched to a 1 MegaOhm pulldown, because on a different Moteino the RFM69 would still sometimes hang during initialization if using the 400K  resistor.  So far, it seems to work.   :)

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Real time RSSI measurement broken RFM69CW?
« Reply #108 on: April 09, 2016, 12:59:55 PM »
I think I've come up with the most reliable way to measure RSSI. I had all kinds of issues and interference. But this actually works well and reliably:

To test whether there's noise at rssi value R you:

0.) Map RSSI to DIO0
1.) Set the radio to RF69_MODE_SYNTH
2.) Set threshold R as RSSITHRESH
3.) Set the radio to RF69_MODE_RX
4.) powerDown for 60ms
5.) Check whether an IRQ has hit

Do this for all values R from 255 to 150. Repeat 5 times. Now you have a good feel for the level of noise.

Instead of powerDown you can try busy waiting. Or you could even poll a RFM69 register during the wait. At least polling a register has a sizable influence on the level of noise - likely transmitted via the SPI bus. Busy waiting hardly creates any noise though.

This setup allows you to measure different power sources for their noise impact. The result is quite profound. Even an iPhone power adapter adds 23dBm in noise. Use a macbook connected USB cable as power source and it will set you back 46dBm. As a reminder: an improvement of 6 dBm about doubles the range.

Here's some of the data I've taken today. I used a long range profile with rxbw of 2.6khz. RF_TESTLNA_HIGH_SENSITIVITY is set. I used 5 iterations and listed is the highest level that got all 5 iterations hit with a RSSI irq, plus all others that are different from 0.

 328p in Powerdown:

Mac:
Apr  9 13:51:58 espgw.fritz.box  193:1 194:1 195:4 195:5

iPhone power adapter:
Apr  9 13:54:51 espgw.fritz.box  216:1 217:2 218:4 219:5

Battery:
Apr  9 13:50:06 espgw.fritz.box  239:1 240:1 241:5

328p busy wait:

Battery:
Apr  9 14:25:41 espgw.fritz.box  240:1 241:5

328p Polling RSSIThresh via SPI:

Battery:
Apr  9 14:18:34 espgw.fritz.box  233:5

I think these results are very encouraging in that they show it might still be possible to fix the AGC handling in RFM69 by lifting RSSITHRESH to a reasonable level and use timeouts to catch false triggers. I also think this shows that a noise optimized gateway can make a huge difference in supporting long range setups. Just think about it: only 1/16th of the potential range just by using an iPhone power adapter (if these numbers translate directly according to the 6dBm doubles range rule of thumb). I don't want to even speculate about what adding a Pi to the mix would do.

Joe

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Real time RSSI measurement broken RFM69CW?
« Reply #109 on: April 09, 2016, 01:33:47 PM »
This is really good work, and thank you for sharing the results.

This seems like a very practical approach, and one we should probably all be using.  We'd get even more leverage by pooling our results, because it might help identify configurations that are especially low noise.  There's a bit of gray zone though, because you're measuring the top of the noise floor rather than the bottom of the noise floor.  That's where your earlier histogram (on another thread) adds a level of insight.  So if, say, using a particular power source caused high interference 10% of the time, maybe you could still receive your packets from far away if one of the re-transmits happens during the other 90% of the time.  Of course, to save power one wants to minimize the number of re-transmits needed, but the end result may not be quite so dire.  Still, one can what-if and analyze things to death, and I think there's a lot to be said for keeping things simple so that everyone can use it.  Your approach steers clear of the grey zone, which is what we should all be aiming to do anyway.  So, bottom line: hip,  hip, hooray!

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Real time RSSI measurement broken RFM69CW?
« Reply #110 on: April 09, 2016, 01:43:09 PM »
Quote
There's a bit of gray zone though, because you're measuring the top of the noise floor rather than the bottom of the noise floor.

Not necessarily - I measure whether the noise floor hits the level during a 60ms window. Say if you have a signal source that sends once a second you'd clearly see it with this method. BTW, the fact that the floor is so narrow is partially a consequence of using the low bitrate which leads to averaging of the rssi level during detection (2 * tbit is long ).

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Real time RSSI measurement broken RFM69CW?
« Reply #111 on: April 09, 2016, 02:10:37 PM »
Quote
There's a bit of gray zone though, because you're measuring the top of the noise floor rather than the bottom of the noise floor.

Not necessarily - I measure whether the noise floor hits the level during a 60ms window. Say if you have a signal source that sends once a second you'd clearly see it with this method. BTW, the fact that the floor is so narrow is partially a consequence of using the low bitrate which leads to averaging of the rssi level during detection (2 * tbit is long ).

Ahhh, good point.

One TL;DR for the benefit of anyone who may be reading this: when it comes to using this new approach to better inform how to set your RFM69's RSSI threshold (unless you're using some kind of adaptive algorithm to set it for you), you'll want to use the same RxBw (and probably the same bitrate too(?)) as you'd normally be using.  At wider bandwidths, the amount of received noise goes up.  That may be common knowledge in some circles, but I didn't realize that's how it worked until I did the measurement experiments earlier in this thread.
« Last Edit: April 09, 2016, 02:17:39 PM by WhiteHare »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Real time RSSI measurement broken RFM69CW?
« Reply #112 on: April 09, 2016, 02:27:43 PM »
Quote
you'll want to use the same RxBw (and probably the same bitrate too(?)) as you'd normally be using.

That's right. On the other hand the RSSI value during reception of a signal is fairly independent of the parameters as long as the signal sits firmly within rxbw. Whether I use Felix settings or the long range ones - it's not much of a difference.

So what I plan to do to see how to achieve a given communication objective is: measure noise floor and then RSSI during signal with the long range settings. Then you know how much additional noise due to broader rxbw you can tolerate and thus how high you can take the bitrate. At least that's the theory  ;)

emjay

  • Full Member
  • ***
  • Posts: 119
  • Country: nl
Re: Real time RSSI measurement broken RFM69CW?
« Reply #113 on: April 09, 2016, 09:19:57 PM »
@joelucid,

I haven't come across any BER v. input power curves for the RFM69/SX1231H, but they are published for the older RFM12B.  If you refer to page p.37 of the Si4421 spec sheet, the curves give a good guide to what improvement you would need in S/N ratio to step up to the next baud rate at constant BER.
Different chip I know, but most of this comes from the generic requirements of decoding FSK, so similar curves should apply.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Real time RSSI measurement broken RFM69CW?
« Reply #114 on: April 10, 2016, 02:56:56 AM »
Ever wonder why the data sheet quotes the receiver sensitivity at 5khz Fdev? Now we know:

Apr 10 06:54:49 espgw.fritz.box  246:1 247:5

Another 5dBm improvement over the 1260hz Fdev setting. Increasing from there makes things worse.

This is nice - less of a need of AFC, particularly when using temp correction. I think I'll do a range test today with these settings:

         RF_BITRATEMSB_1200, RF_BITRATELSB_1200,
         RF_FDEVMSB_5000, RF_FDEVLSB_5000,
         RF_RXBW_DCCFREQ_000 | RF_RXBW_MANT_24 | RF_RXBW_EXP_5

Note that I increased DccFreq to 16% given the high modulation index.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Real time RSSI measurement broken RFM69CW?
« Reply #115 on: April 10, 2016, 06:06:29 AM »
Just did a range test. I was limited by the terrain. 1.85km was the longest I could go. Wasn't quite line of sight either. This is with a rfm69hw, 433 mhz, both Moteino's running on batteries.

Code: [Select]
RF_BITRATEMSB_1200, RF_BITRATELSB_1200, 
RF_FDEVMSB_5000, RF_FDEVLSB_5000,
RF_RXBW_DCCFREQ_000 | RF_RXBW_MANT_24 | RF_RXBW_EXP_5,
RF_TESTLNA_HIGH_SENSITIVITY, RF_PACKET1_FORMAT_VARIABLE | RF_PACKET1_DCFREE_WHITENING |   RF_PACKET1_CRC_ON | RF_PACKET1_CRCAUTOCLEAR_ON | RF_PACKET1_ADRSFILTERING_OFF

In all the excitement I had a couple of errors in the earlier posts. rssiThresh is measured in 1/2 dBm steps. So the last improvement only added 3 dBm. And the iPhone charger only costs 12, for a 1/4th reduction in range.

Joe
« Last Edit: April 10, 2016, 06:15:02 AM by joelucid »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Real time RSSI measurement broken RFM69CW?
« Reply #116 on: April 10, 2016, 09:32:35 AM »
1.85km was the longest I could go.

Was that 1.85km with a BER of <1%, or was that the range at which you could just barely receive any packets at all? 

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Real time RSSI measurement broken RFM69CW?
« Reply #117 on: April 10, 2016, 10:52:05 AM »
Quote
Was that 1.85km with a BER of <1%, or was that the range at which you could just barely receive any packets at all?

My problem is finding an area with line of sight for testing. Just did another test and got 2.1km. But still some trees etc in the way. So what happens is when you have a spot where there's reception at all I see just about every packet (and I uses CRC so that means no bit errors). If too much is in the way nothing comes through.

I take that as indication that with line of sight there's still room for substantial improvement.

But not today - my feet hurt  ;)

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Real time RSSI measurement broken RFM69CW?
« Reply #118 on: April 10, 2016, 02:10:14 PM »
This is too cool not to share. Packet reception at an RSSI of -121. That's why you need low noise receivers:

Code: [Select]
Apr 10 19:47:00 espgw.lx  [254] [RX_RSSI:-56,1,8,45]
Apr 10 19:47:00 espgw.lx  !RSSI:-120
Apr 10 19:47:03 espgw.lx  [254] [RX_RSSI:-55,1,8,45]
Apr 10 19:47:03 espgw.lx  !RSSI:-118
Apr 10 19:47:06 espgw.lx  [254] [RX_RSSI:-56,1,8,45]
Apr 10 19:47:06 espgw.lx  !RSSI:-117
Apr 10 19:47:09 espgw.lx  [254] [RX_RSSI:-56,1,8,45]
Apr 10 19:47:09 espgw.lx  !RSSI:-117
Apr 10 19:47:12 espgw.lx  [254] [RX_RSSI:-56,1,8,45]
Apr 10 19:47:12 espgw.lx  !RSSI:-121
Apr 10 19:47:16 espgw.lx  [254] [RX_RSSI:-56,1,8,45]
Apr 10 19:47:16 espgw.lx  !RSSI:-120
Apr 10 19:47:22 espgw.lx  [254] [RX_RSSI:-55,1,8,45]
Apr 10 19:47:22 espgw.lx  !RSSI:-117

Joe

PS: The !RSSI entries count. The [254] entries are from my main gateway. I use a battery powered Moteino as receiver for this test to enable these low noise measurements. Results are then forwarded to the main gw for logging purposes.
« Last Edit: April 10, 2016, 02:13:42 PM by joelucid »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Real time RSSI measurement broken RFM69CW?
« Reply #119 on: April 10, 2016, 02:51:49 PM »
Is it saying that the battery powered moteino is receiving packets from the espgw at an RSSI of -56, and then it sends that RSSI Rx info in a packet back to the espgw, which receives it at an RSSI of -121?

Or is it saying that the battery powered moteino is receiving packets at an RSSI of -56 at a time (just before or after) that the background noise level (!RSSI) is -121?