const byte CONFIG[][2] =
{
/* 0x01 */ { REG_OPMODE, RF_OPMODE_SEQUENCER_ON | RF_OPMODE_LISTEN_OFF | RF_OPMODE_STANDBY },
/* 0x02 */ { REG_DATAMODUL, RF_DATAMODUL_DATAMODE_PACKET | RF_DATAMODUL_MODULATIONTYPE_FSK | RF_DATAMODUL_MODULATIONSHAPING_00 }, //gaussian, bt=1.0
/* 0x03 */ { REG_BITRATEMSB, RF_BITRATEMSB_38400}, //default:4.8 KBPS
/* 0x04 */ { REG_BITRATELSB, RF_BITRATELSB_38400},
/* 0x05 */ { REG_FDEVMSB, RF_FDEVMSB_50000}, //default:5khz, (FDEV + BitRate/2 <= 500Khz)
/* 0x06 */ { REG_FDEVLSB, RF_FDEVLSB_50000},
/* 0x07 */ { REG_FRFMSB, (freqBand==RF69_315MHZ ? RF_FRFMSB_315 : (freqBand==RF69_433MHZ ? RF_FRFMSB_433 : (freqBand==RF69_868MHZ ? RF_FRFMSB_869 : RF_FRFMSB_915))) },
/* 0x08 */ { REG_FRFMID, (freqBand==RF69_315MHZ ? RF_FRFMID_315 : (freqBand==RF69_433MHZ ? RF_FRFMID_433 : (freqBand==RF69_868MHZ ? RF_FRFMID_869 : RF_FRFMID_915))) },
/* 0x09 */ { REG_FRFLSB, (freqBand==RF69_315MHZ ? RF_FRFLSB_315 : (freqBand==RF69_433MHZ ? RF_FRFLSB_433 : (freqBand==RF69_868MHZ ? RF_FRFLSB_869 : RF_FRFLSB_915))) },
// looks like PA1 and PA2 are not implemented on RFM69W, hence the max output power is 13dBm
// +17dBm and +20dBm are possible on RFM69HW
// +13dBm formula: Pout=-18+OutputPower (with PA0 or PA1**)
// +17dBm formula: Pout=-14+OutputPower (with PA1 and PA2)**
// +20dBm formula: Pout=-11+OutputPower (with PA1 and PA2)** and high power PA settings (section 3.3.7 in datasheet)
///* 0x11 */ { REG_PALEVEL, RF_PALEVEL_PA0_ON | RF_PALEVEL_PA1_OFF | RF_PALEVEL_PA2_OFF | RF_PALEVEL_OUTPUTPOWER_11111},
///* 0x13 */ { REG_OCP, RF_OCP_ON | RF_OCP_TRIM_95 }, //over current protection (default is 95mA)
// RXBW defaults are {RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_24 | RF_RXBW_EXP_5} (RxBw: 10.4khz)
/* 0x19 */ { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_16 | RF_RXBW_EXP_2 }, //(BitRate < 2 * RxBw)
/* 0x25 */ { REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_01 }, //DIO0 is the only IRQ we're using
/* 0x29 */ { REG_RSSITHRESH, 220 }, //must be set to dBm = (-Sensitivity / 2) - default is 0xE4=228 so -114dBm
///* 0x2d */ { REG_PREAMBLELSB, RF_PREAMBLESIZE_LSB_VALUE } // default 3 preamble bytes 0xAAAAAA
/* 0x2e */ { REG_SYNCCONFIG, RF_SYNC_ON | RF_SYNC_FIFOFILL_AUTO | RF_SYNC_SIZE_2 | RF_SYNC_TOL_0 },
/* 0x2f */ { REG_SYNCVALUE1, 0x2D }, //attempt to make this compatible with sync1 byte of RFM12B lib
/* 0x30 */ { REG_SYNCVALUE2, networkID }, //NETWORK ID
/* 0x37 */ { REG_PACKETCONFIG1, RF_PACKET1_FORMAT_FIXED | RF_PACKET1_DCFREE_OFF | RF_PACKET1_CRC_ON | RF_PACKET1_CRCAUTOCLEAR_ON | RF_PACKET1_ADRSFILTERING_OFF },
/* 0x38 */ { REG_PAYLOADLENGTH, MAX_DATA_LEN }, //in variable length mode: the max frame size, not used in TX
//* 0x39 */ { REG_NODEADRS, nodeID }, //turned off because we're not using address filtering
/* 0x3C */ { REG_FIFOTHRESH, RF_FIFOTHRESH_TXSTART_FIFONOTEMPTY | RF_FIFOTHRESH_VALUE }, //TX on FIFO not empty
/* 0x3d */ { REG_PACKETCONFIG2, RF_PACKET2_RXRESTARTDELAY_2BITS | RF_PACKET2_AUTORXRESTART_ON | RF_PACKET2_AES_OFF }, //RXRESTARTDELAY must match transmitter PA ramp-down time (bitrate dependent)
/* 0x6F */ { REG_TESTDAGC, RF_DAGC_CONTINUOUS }, // run DAGC continuously in RX mode
{255, 0}
};
This one's free.
Set reg 0x58 to 0x2D
It increases the sensitivity by 2-3db by enabling the low noise pre-amp.
Good for more distance!
By the way, if someone has nice results or wants to share another driver (maybe Drae with the TCP/IP-ish approach?) and is willing to do a writeup, I would be more than happy to post it on the blog.
/* 0x03 */ { REG_BITRATEMSB, RF_BITRATEMSB_55555}, //default:4.8 KBPS
/* 0x04 */ { REG_BITRATELSB, RF_BITRATELSB_55555},
/* 0x05 */ { REG_FDEVMSB, RF_FDEVMSB_50000}, //default:5khz, (FDEV + BitRate/2 <= 500Khz)
/* 0x06 */ { REG_FDEVLSB, RF_FDEVLSB_50000},
/* 0x03 */ { REG_BITRATEMSB, RF_BITRATEMSB_1200}, //default:4.8 KBPS
/* 0x04 */ { REG_BITRATELSB, RF_BITRATELSB_1200},
/* 0x05 */ { REG_FDEVMSB, RF_FDEVMSB_2000}, //default:5khz, (FDEV + BitRate/2 <= 500Khz)
/* 0x06 */ { REG_FDEVLSB, RF_FDEVLSB_2000},
/* 0x19 */ { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_16 | RF_RXBW_EXP_2 }, //(BitRate < 2 * RxBw)
The Duty Cycle of transmission at +20dBm is limited to 1%, with a maximum VSWR of 3:1 at antenna port, over the
standard operating range [-40;+85°C].
Useful reference for BR, Fdev and RxBw:
https://lowpowerlab.com/forum/rf-range-antennas-rfm69-library/definition-of-rxbw-with-rfm69/
From this the rules are (assuming you're not not using AFC):
1) 0.5 <= 2 * Fdev/BR <= 10 (modulation index, MI)
2) BR < 2*RxBw (bit rate)
3) RxBw >= Fdev + BR/2 + LOoffset (receiver bandwidth)
4) Fdev + BR/2 < 500kHz (maximum RxBw setting)
So at BR =1200, Fdev = 2000 you need RxBw >= 2600 + LOoffset. However LOoffset can be quite high. At a nominal 20ppm (+/-10ppm) that can be 8.6kHz at 433MHz, but if you take into account temperature and drift it could be as high as +/-35ppm, or 70ppm for LOoffset. That's worst case and the crystals are better speced than that, but it's still much higher than your RxBw which you've set to 5.6kHz!
So I'd try setting RxBw to 31.3kHz, i.e. reg 0x19 set to 0x44.
Mark.
When we loaded the Fdev = 20000 it all lighted up like a Christmas tree.
Not completely understanding this. We are running 1200 bauds and communicating.
I think those 'rules' may need some additional qualification.So what you set in registers is 1/2 of that is really going on? Something like +/- FDEV & LOoffset? But LOoffset can be set in positive or negative way. And from what you say AFC is a must and will be much better than setting LOoffset. And with AFC and good signal, is there any penalty?
At the transmitter there will be two modulation frequencies, FDEV either side of the transmitter carrier. At the reveiver those frequencies are (FDEV + LOoffset) and (FDEV - LOoffset) relative to the receiver's carrier. It appears that without AFC the radios stop receiving if there is a significant difference between these two deviations. Worst case is both these deviations could appear on the same side of the receiver carrier if LOoffset is large enough. So even though the receiver bandwidth is large enough to see both of those frequencies, the demodulator has trouble demodulating.
With AFC the receiver carrier frequency is adjusted to be the same as the transmitter carrier, but it requires a longer preamble. It does appear that even if both transmitted frequencies are on the same side of the receiver carrier the AFC is still capable of adjusting correctly (assuming of course the receiver bandwidth is large enough to capture them).
So what you saw when you increased FDEV is that the relative percentage difference of the two frequencies either side of the receiver carrier reduced to the point it started to work.
I think you're going to have to use AFC. It's not that complicated, you need to set RxBwAFC and have a longer preamble (which you can calculate from formulae in the datasheet). Once AFC is done it will then automatically use RxBw so that can be set significantly lower because LOoffset is no longer a factor, in other words subsequent reception has a higher signal to noise for more robust reception.
Mark.
So what you set in registers is 1/2 of that is really going on? Something like +/- FDEV & LOoffset? But LOoffset can be set in positive or negative way. And from what you say AFC is a must and will be much better than setting LOoffset. And with AFC and good signal, is there any penalty?The benefits of AFC are you can use narrow bandwidths for RxBw to reduce the noise floor and increase transmission distance. Now you could say 'but I have to have a wider RxBwAfc, doesn't that reduce the distance anyway?'. Normally a signal would need to have a certain S/N ratio to get an acceptable bit error rate, but AFC may not need such a high S/N ratio because it is effectively averaging out noise during that period with a known pattern, so the reality is you can do an AFC at a lower signal S/N ratio than the data. Unfortunately this difference isn't documented which is a shame.