I am having a problem getting AFC to work.
Here is what I am trying to do:
I am building a multi-node outdoor sensor network, using RF69HCW nodes, that needs to operate at seasonal temperature extremes with an indoor gateway. By temperature extremes, I mean at least 0F to 100+F, which is typical of my area in coastal eastern New England. Range is also important.
My initial prototype was operated indoors using data rate of 4800 and Fdev of 4800. Frequency is 904020000 (somewhat arbitrary, but I will operate in the 915 ISM band.) Also turned on ATC. I left other radio parameters pretty much default as they are set in the RFM69 library, This worked nearly flawlessly over indoor ranges, until I got a new device, and tried taking one of the nodes outdoors, at which point the links got unreliable or failed completely. This is clearly due to temperature drift and also XO variability.
Next step was to go to a higher data rate, with associated wider Fdev, and increase RxBW to accommodate the higher data rate and 20 kHz of frequency offset:
radio.writeReg(REG_BITRATEMSB, RF_BITRATEMSB_19200);
radio.writeReg(REG_BITRATELSB, RF_BITRATELSB_19200);
radio.writeReg(REG_FDEVMSB, RF_FDEVMSB_20000);
radio.writeReg(REG_FDEVLSB, RF_FDEVLSB_20000);
// RxBW is one sided bandwidth, so RF bandwidth = 2*RxBW
// set the RxBW to 42 kHz, so RF BW = 84 to match 2*FDEV + BITRATE + Max frequency error =~ 80 kHz
// These parameters (Mantissa = 24, Exponent = 3, get us 32e6/24/32 ~= 83kHz
radio.writeReg(REG_RXBW, (RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_24 | RF_RXBW_EXP_3));
// Set RSSI Threshold to D0 ==> -104 dBm
radio.writeReg(REG_RSSITHRESH, 0xD0);
// increase preamble length to 6 bytes, and RF sync length to 4 bytes
radio.writeReg(REG_PREAMBLEMSB, 0x00);
radio.writeReg(REG_PREAMBLELSB, 0x06);
radio.writeReg(REG_SYNCCONFIG, RF_SYNC_ON | RF_SYNC_FIFOFILL_AUTO | RF_SYNC_SIZE_4 | RF_SYNC_TOL_0);
//sync words are 31-ML sequence with a 0-bit tacked on
radio.writeReg(REG_SYNCVALUE1, 0xFA);
radio.writeReg(REG_SYNCVALUE2, 0x25);
radio.writeReg(REG_SYNCVALUE3, 0x61);
radio.writeReg(REG_SYNCVALUE4, 0xCC);
This so far works fine, but anticipating issues with aging, greater variability from device to device, and greater temperature offsets than I am currently experiency, I want to get AFC working. However, when I try to enable AFC on my devices, links that work error free without it become either unreliable, or fail completely. This happens even at short range (-40 to -60 dBm).
Following advice in the forum, and particularly in the NXP AN4983 document, I have tried to use recommended configuration for AFC, but for the moment stick with the 19200 BPS data rate and 20kHz Fdev. Here are the settings I use,
// Set RSSI Threshold to D0 ==> -104 dBm
radio.writeReg(REG_RSSITHRESH, 0xD0);
// increase preamble length to 6 bytes, and RF sync length to 4 bytes
radio.writeReg(REG_PREAMBLEMSB, 0x00);
radio.writeReg(REG_PREAMBLELSB, 0x06);
radio.writeReg(REG_SYNCCONFIG, RF_SYNC_ON | RF_SYNC_FIFOFILL_AUTO | RF_SYNC_SIZE_4 | RF_SYNC_TOL_0);
//sync words are 31-ML sequence with a 0-bit tacked on
radio.writeReg(REG_SYNCVALUE1, 0xFA);
radio.writeReg(REG_SYNCVALUE2, 0x25);
radio.writeReg(REG_SYNCVALUE3, 0x61);
radio.writeReg(REG_SYNCVALUE4, 0xCC);
radio.writeReg(REG_AFCFEI, radio.readReg(REG_AFCFEI) | RF_AFCFEI_AFCAUTO_ON | RF_AFCFEI_AFCAUTOCLEAR_ON);
// Make the AFC BW a bit wider (Mantissa = 16, Exponent = 3 gets us 32e6/16/32 = 62.5kHz
radio.writeReg(REG_AFCBW, (RF_AFCBW_DCCFREQAFC_010 | RF_AFCBW_MANTAFC_16 | RF_AFCBW_EXPAFC_3));
// Turn on " optimized AFC " for low bandwidth signal
radio.writeReg(REG_AFCCTRL, RF_AFCCTRL_LOWBETA_ON);
radio.writeReg(0x71, 0x07);
I have tried this with and without the "optimized AFC" settings, but it doesn't make a difference. It is unclear whether this is a good idea when Fdev ~= BR. Also note that I am treating RxBW and AFCBW as single-sided values, so that the effective RF bandwidth values are twice that.
With AFC running, the gateway node reports frequency offsets in the range from a few 100 Hz to more than 15 kHz, when it actually receives a packet. These values do not seem at all stable, they vary pretty wildly from packet to packet.
Also complicating matters, I am having trouble with changing the AFC settings: If I run the nodes for a few minutes with the settings above, then edit the code to turn off AFC, and upload the edited, newly compiled code, the new register values (specifically REG_AFCFEI) don't get reset. I typically have to remove power and let the devices sit without power for a few minutes, then upload the code again, to get AFC really turned off. This happens on at least two devices, so I don't think that it is a device-specific hardware issue.
Also, the prevalent failure mode is for the gateway node to receive packets from the sensor node more reliably than the sensor node receives ACKs, so that all uplink packets go un-acked from the POV of the sensor node, but the gateway node sometimes gets three copies of packets from the sensor node, due to retries.
Apologies for the long-winded post, thank you in advance for reading it and any input you might be able to provide in helping me get AFC up and running.
--John