From dimitri at dotp.com Mon Jul 13 17:12:50 2015 From: dimitri at dotp.com (Dimitri.p) Date: Mon, 13 Jul 2015 14:12:50 -0700 Subject: [GPS_Standard] Converting sample frequency to MHZ Message-ID: <88.7B.03574.BC924A55@cdptpa-oedge02> Montrol will display and log the Current frequency in hex, but what 'd like to do is have mental fun with the actual frequency in MHz. I converted the hex to decimal but have trouble with the "decimal sample frequency". How can I convert the sample frequency of 26631 to MHz? Dimitri From dplatt at radagast.org Tue Jul 14 17:46:50 2015 From: dplatt at radagast.org (Dave Platt) Date: Tue, 14 Jul 2015 14:46:50 -0700 Subject: [GPS_Standard] Converting sample frequency to MHZ In-Reply-To: <88.7B.03574.BC924A55@cdptpa-oedge02> References: <88.7B.03574.BC924A55@cdptpa-oedge02> Message-ID: <55A5834A.7030409@radagast.org> On 07/13/2015 02:12 PM, Dimitri.p wrote: > Montrol will display and log the Current frequency in hex, but what 'd > like to do is have mental fun with the actual frequency in MHz. I > converted the hex to decimal but have trouble with the "decimal sample > frequency". > How can I convert the sample frequency of 26631 to MHz? Well, you'll have to work back (mathematically) from the meaning of this field. It turns out (due to "the nature of the beast") that there's no completely unambiguous mapping of "this value to a frequency", since the value being shown is the result of a modulus operation. However, as long as your oscillator is reasonably close to the correct speed, there's a mapping that you can count on fairly well. The value that you see here (call it X) is equal to: ((the frequency measured in Hz) * 16) modulo 65536 So, if your frequency is dead-on (10,000,000.00 Hz), the value you see will be 160,000,000 mod 65536, or 26624. To a reasonable first approximation, you can figure that every value of 1 different between the value you see, and 26624, means that your oscillator is off by 1/16 cycle out of 10 million, or 1/16 Hz. 26631 is 7 greater than 26624, so your oscillator is running about 7/16 Hz fast, or at around 10000000.4375 Hz. Hence, the frequency you would want to display ("purely for entertainment purposes) would be 10000000 + (X - 26624) / 16 It isn't really meaningful to write out that many digits of precision on the basis of just one sampling period, though... precision does not imply accuracy (as a high school teacher of mine would have pointed out, when he took off points on the test for anybody who provided an answer to more degrees of precision than were present in the numbers given as inputs on the problem).