Author Topic: Freq Vs. Temperature Update  (Read 50860 times)

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: Freq Vs. Temperature Update
« Reply #15 on: March 10, 2015, 09:06:38 PM »
John gave us the polynomial he calculated (it's on the image). I think it's just the simple matter of applying it to your desired frequency value, as a function of ambient temperature. Though he measured the error with a 915 MHz module IIRC. But since the xtal is the same on all modules, I think it's safe to assume the same corrections need to be applied on all of them, if you scale the error relative to 915 MHz.

luisr320

  • Sr. Member
  • ****
  • Posts: 255
  • Country: pt
Re: Freq Vs. Temperature Update
« Reply #16 on: March 10, 2015, 10:09:22 PM »
But where and how would I implement that polinomial function as a correction?
There must be some obscure instruction that I must call to enter a corrective value on the frequency as a function of the temperature.

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: Freq Vs. Temperature Update
« Reply #17 on: March 11, 2015, 03:25:13 AM »
No, there isn't. You calculate the coefficient based on the formula, subtract it from the desired frequency, then set the result on the module via a simple call.

luisr320

  • Sr. Member
  • ****
  • Posts: 255
  • Country: pt
Re: Freq Vs. Temperature Update
« Reply #18 on: March 11, 2015, 07:18:32 AM »
Ah, thank you for your reply.
And what would that call be? And where would you insert it? In the loop() on in setup()?
« Last Edit: March 11, 2015, 07:20:08 AM by luisr320 »

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: Freq Vs. Temperature Update
« Reply #19 on: March 11, 2015, 07:32:08 AM »
It depends on your code, but most probably in your init() function, with a call to RFM69::setFrequency(). There are several tutorials for Moteino, I'm sure you can easily find them. They will guide you through the basics.

luisr320

  • Sr. Member
  • ****
  • Posts: 255
  • Country: pt
Re: Freq Vs. Temperature Update
« Reply #20 on: March 11, 2015, 03:31:08 PM »
I hope you meant setup() function.

But since the temperature will vary as a function of time, frequency correction must be cyclical and as such, I think it should be inserted in the main loop().

Something like this:
Code: [Select]
void loop() {
float x = getTemp();//a call to the usual getTemp function
float adjFreq = ((123*x^3)+(123*x^2)+(123*x)+123); //our polynomial function
float newFreq = (433 - adjFreq);//Being 433 the expected frequency of 433 Mhz
RFM69::setFrequency(newFreq);

Serial.print(temp); Serial.print (" - "); Serial.println(adjFreq);
delay(100);
}


This, of course, bring in a new problem. How do I get the polynomial function for my 433 Mhz radio? For that I would need a Spectrum Analizer, something I don't have.

If I mail a moteino with a 433Mhz radio, could someone with the right gear be willing to produce the curve related to a similar temp variation presented in the posted graph?

Do you think that the above sketch would work as is?
« Last Edit: March 11, 2015, 03:33:02 PM by luisr320 »

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: Freq Vs. Temperature Update
« Reply #21 on: March 11, 2015, 03:35:56 PM »
Disregard what I wrote about where to apply the EC. Yes, for continuous operation, you need to apply the EC value periodically. I've already hinted how I suggest calculating the values for 433 MHz. Please see in one of my previous posts. Most probably that will work, but it'd be nice to hear John's suggestions too.

luisr320

  • Sr. Member
  • ****
  • Posts: 255
  • Country: pt
Re: Freq Vs. Temperature Update
« Reply #22 on: March 11, 2015, 04:02:36 PM »
Are you talking about measuring the RSSI on a second Moteino? I think I read that one. I'll take a look at it again. Its not very "scientific" but if it works, it sure is a good idea.
Thank you for hanging in there with me on this one

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: Freq Vs. Temperature Update
« Reply #23 on: March 11, 2015, 04:05:21 PM »
No, sorry, I don't even know what RSSI measurement you're talking about.

This is my post I was referring to.

luisr320

  • Sr. Member
  • ****
  • Posts: 255
  • Country: pt
Re: Freq Vs. Temperature Update
« Reply #24 on: March 11, 2015, 04:24:01 PM »
OOOHHH  :o

So I just use the same function for the 433Mhz radio?
And subtract the error from 433 to scale it to 433.
Nice!

I'll make some tests during the weekend to try the RSSI readings on a moteino with and without the other having its freq corrected.

luisr320

  • Sr. Member
  • ****
  • Posts: 255
  • Country: pt
Re: Freq Vs. Temperature Update
« Reply #25 on: March 11, 2015, 04:53:36 PM »
I'm adding an Excel file with the polynomial function applied to a temperature range from -20ºC to 90ºC and the respective frequency correction and final frequency for 433MHz and 915Mhz.
It is the same data as the one that produces the posted graph but coming from an editable Exel file.
« Last Edit: March 11, 2015, 05:07:33 PM by luisr320 »

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: Freq Vs. Temperature Update
« Reply #26 on: March 12, 2015, 03:12:31 PM »
So I just use the same function for the 433Mhz radio?
And subtract the error from 433 to scale it to 433.

My idea is to calculate the error based on temperature, scale it according to the used frequency range and then apply it. So a calculated value of E915 for 915 MHz is scaled for 433 MHz as E433 = 433 / 915 * E915

luisr320

  • Sr. Member
  • ****
  • Posts: 255
  • Country: pt
Re: Freq Vs. Temperature Update
« Reply #27 on: March 12, 2015, 05:37:29 PM »
Hummm, that's interesting. You are assuming that there is a linear correlation between the difference in frequency and the difference in error caused by the temperature. I guess the only way to be sure would be trough testing with a spectrum analyzer.
How sure are you that that correlation is linear?
« Last Edit: March 12, 2015, 05:39:31 PM by luisr320 »

Nuudeli

  • NewMember
  • *
  • Posts: 14
Re: Freq Vs. Temperature Update
« Reply #28 on: November 13, 2015, 05:03:45 AM »
I fully agree with kobuki's approach. XO's have same frequency vs. temperature error in all RF frequency variants (when XO's are similar) but RF frequencies are generated by multiplying XO frequency which leads to larger absolute error for higher RF frequencies.

Corrected luisr320 excel and attached it here (btw. there was typo on polynomial coefficient).






Nuudeli

  • NewMember
  • *
  • Posts: 14
Re: Freq Vs. Temperature Update
« Reply #29 on: November 25, 2015, 03:27:40 PM »
Finally had some time to wrote recent findings what I made with RF69HCW on temperature chamber.

So I tested one RF69HCW assembled on small PCB together with ATMEGA328P (comparable to Moteinos) on temperature chamber to see how frequency drifts over temperature. My setup was SDR for frequency sniffing, K-type thermocouple for crystal temperature and DS18B20 for chamber temperature (altought it has internal sensor). Swept was made from 20 to -30 celsius and back from -30 to 70 celsius with ~20min settling time for each step. RX was continuously on which caused radio & crystal to have higher temperature than chamber. Controlling TX, requesting internal & DS18B20 temperature was done via serial commands. Frequency was measured with "pre-heated" SDR so that its own frequency shift due self heating could be minimized.

First figure represents the correlation between internal, K-type and DS18B20 temperatures to ambient temperature. Naturally DS18B20 measures quite nicely 1:1 what chamber was set. Also it seems that radio is ~10 celsius hotter than ambient over the range. Crystal temperature behavior is not 100% clear to me, as it seems to run hotter than radio in cold but vice versa in hot. Could be also measurement error as K-type sensor is attached on top of the crystal and measured with multimeter.. Anyway, my point was to run tests and see if I could use internal sensor to read temperature and make frequency corrections according that information when I have somewhat stable case (eg. RX continuously on, just after wakeup etc...).

Second figure shows the frequency drift over internal temperature. S-type curve seems quite familiar from Johns post but the swing of frequency shift have huge difference when comparing to first post of this topic. John has measured ~14kHz swing and I did measure "only" ~8kHz. This cannot be explained by the fact that I have 868MHz and John have 915MHz radio (see the previous post) or that John has measured crystal temperature with DS18B20 and I use radios internal temperature (using different temperature doesn't have impact on swing). It could be explained by different or broken crystal or some measurement error.

In addition to this, when comparing to first freq vs. temp results by John, it seems that my results have clear correlation to those measurements (https://lowpowerlab.com/forum/index.php/topic,135.msg453.html#msg453). I did convert my results to 915MHz and shifted it to same temperature, see the figure 3.

I'm going to implement simple temperature compensation and re-test this with few radios in temperature chamber to see how it works. Any thought/ideas on this?