Author Topic: rfm69.h Default Frequency values not the real ones  (Read 1942 times)

Charly86

  • Jr. Member
  • **
  • Posts: 74
  • Country: fr
rfm69.h Default Frequency values not the real ones
« on: October 16, 2015, 11:02:05 PM »
Hi guys,

I was working to get RadioHead lib same settings than RFM69 library (because I noticed that I've got better results with RFM69 lib defaults settings than with RadioHead defaults)

When I was looking at datasheet on the 3 registers of frequency (0x07, 0x08, 0x09) there are 3 possibilities on RFM69.h file, theese are :

Code: [Select]
#define RF_FRFMSB_433             0x6C
#define RF_FRFMID_433             0x40
#define RF_FRFLSB_433             0x00
#define RF_FRFMSB_434             0x6C
#define RF_FRFMID_434             0x80
#define RF_FRFLSB_434             0x00
#define RF_FRFMSB_435             0x6C
#define RF_FRFMID_435             0xC0
#define RF_FRFLSB_435             0x00
So for
433MHz = 0x6C4000 => frf=7094272 decimal
434MHz = 0x6C8000 => frf=7110656 decimal
435MHz = 0x6CC000 => frf=7127040 decimal

but when I apply formula on datasheet page saying frequency = frf * fstep
Frequency synthesizer step FSTEP = FXOSC/2^19 = 61.0Hz

433MHz = 7094272*61 = 432.750592 MHz
434MHz = 7110656*61 = 433.750016 MHz
435MHz = 7127040*61 = 434.749440 MHz

So let me know if I'm wrong but I think the real values should be
Code: [Select]
#define RF_FRFMSB_433             0x6C
#define RF_FRFMID_433             0x4F
#define RF_FRFLSB_433             0xF8
#define RF_FRFMSB_434             0x6C
#define RF_FRFMID_434             0x90
#define RF_FRFLSB_434             0x02
#define RF_FRFMSB_435             0x6C
#define RF_FRFMID_435             0xD0
#define RF_FRFLSB_435             0x0B

Of course I totally understand no change will be done to avoid any board effect, but it's just to know.

I think it's not really a problem, but I'm just wondering is there is any reason for this ?

Anyway, for RadioHead to be compatible (just for frequency) you need to setFrequency(432.75) and not setFrequency(433.0) as you would expect


 
« Last Edit: October 16, 2015, 11:41:04 PM by Charly86 »

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: rfm69.h Default Frequency values not the real ones
« Reply #1 on: October 17, 2015, 06:36:27 AM »
One quick note.

FSTEP = FXOSC/2^19 = 61.03515625 Hz

Not 61.0. This does count when working with such high numbers. Try calculating with higher precision, and if you still have an unacceptable margin of error, then I think you should report back.

Charly86

  • Jr. Member
  • **
  • Posts: 74
  • Country: fr
Re: rfm69.h Default Frequency values not the real ones
« Reply #2 on: October 18, 2015, 11:33:24 AM »
@kobuki,

Thanks for this explanation,
I noticed the FXOSC/2^19 but didn't calculated this one since datasheet reading says it was 61.0.
I didn't realize that they rounded the result, makes sense now, thanks  ;)

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: rfm69.h Default Frequency values not the real ones
« Reply #3 on: October 18, 2015, 12:00:05 PM »
@kobuki,

Thanks for this explanation,
I noticed the FXOSC/2^19 but didn't calculated this one since datasheet reading says it was 61.0.
I didn't realize that they rounded the result, makes sense now, thanks  ;)

Yes, but what you noted about the RadioHead library makes me wonder. I've looked at their code and the definition for Fstep seems to be properly formulated. When setting via setFrequency(), both libs should produce the same register values (I haven't verified it myself since I haven't used RH yet). It might worth notifying them or file a bug report (if they have such a facility).