I've been playing with some Moteinos and trying the Wireless Programming stuff. I noticed that the code to shift channel when programming (so as to minimize congestion) only changes the MSB frequency register.
radio.writeReg(REG_FRFMSB, radio.readReg(REG_FRFMSB) + 1);The datasheet for the RFM69 states that:
QuoteA change in the center frequency will only be taken in acount when the least significant byte FRF in RegFRFLSB is written.
Which leads me to believe that the code in the Wireless Programming library does not actually shift the centre frequency.
I only had a fairly rubbish SDR available to test this. The following is an image taken from the SDR software while running a test program on the Moteino. The test program sets the FRFMSB register then transmits every 20/25 ms.
As you can see the centre frequency stays at 433 MHz (a little off due to lack of calibration etc).
(https://tomblanch.files.wordpress.com/2014/11/test.png)
If I then modify my code to set the FRFMSB register and then also set the FRFLSB register (to whatever it already set to) the result can be seen in the following image. The centre frequency has clearly shifted.
(https://tomblanch.files.wordpress.com/2014/11/test2.png)
Anyone with better equipment than me that can verify this? It my be that this is a known issue but the code in github hasn't been changed to reflect it.
Tomme,
Thanks for taking the time to report and document this. You are spot on, this is an epic fail on my part to read the datasheet thoroughly or look at the fine print.
I made some modifications to the main library setFrequency() which will now set the frequency in Hz instead of the value of the registers.
I also added a getFrequency() function that will return the actual frequency in Hz. With the help of these 2 functions it's now as easy as setting the frequency to whatever you want, say just add 4mhz to the original, then switch back.
The changes are on github. For my sanity, could you please give it a try and confirm that the changes are working?
It took me quite a while to find the relevant lines in the datasheet and I only looked because I was planning to experiment with a channel hopping idea I had! Your fixes look spot on, although I've only had a chance to have a quick look. I did notice that the HandleSerialHEXDataWrapper (lines 255-262 of WirelessHEX69.cpp) function wasn't updated although the HandleWirelessHEXDataWrapper was? I don't have a Moteino to hand but I will run a quick test on Monday when I'm back in the lab. Thanks for getting to this so quickly!
Ha ... I think I had a serious concentration problem yesterday, thanks for the pointer. It's fixed now in the serial function as well.