As discussed here #125 (comment) there are a few improvements that could be made to the Si5351 clock synthesis for the RX-888.
One of them is replacing the current algorithm use to select the multisynth settings with a best rational approximation algorithm (based on continued fraction) that can find the optimal a + b/c values for the Si5351 multisynth.
This approach has a couple of advantages:
- it can synthesize most commonly used frequencies exactly
- it achieves the best approximation (i.e. the closest value) that is synthesizable by the Si5351 multisynth in the other cases
Before writing any new code, we need to think about this issue: the best rational approximation algorithm allows for arbitrary frequencies, even frequencies that have a fractional value of Hz. This can be useful for accurate adjustments of the reference clock, using ppm (or ppb).
Unfortunately the STARTADC command accepts an integer (uint32_t) value, that can't be used to represent floating point values.
In order not to break existing applications the STARTADC command should probably be kept the way it is now, and a new command, called say STARTADCFP should be implemented; this new command would expect a double precision (float64_t) frequency value, and can be used to select an arbitrary frequency (possibly non integer).
The old STARTADC command could then be changed to just convert its integer argument to double precision and pass it to the function that implements STARTADCFP.
As suggested by David in the other thread, the tests that need to be implemented should follow these guidelines:
the tests needs to be updated with a small set of additions to fx3_cmd and fw_test. No control features go in without tests that also get added into, typically, fw_test, fx3_cmd. A simple test for this would be going through a set of random frequencies and running it for X seconds and generally getting the number of samples you expected - there is an existing STREAMING TEST as well as ADC setting tests, though they need to be extended to determine if the code always comes up with a solution.
The FX3 code implementing the best rational approximation algorithm for the Si5351 multisynth can be found here: https://github.com/fventuri/DFC-transceiver/blob/main/fx3-firmware/si5351.c
Franco
As discussed here #125 (comment) there are a few improvements that could be made to the Si5351 clock synthesis for the RX-888.
One of them is replacing the current algorithm use to select the multisynth settings with a best rational approximation algorithm (based on continued fraction) that can find the optimal a + b/c values for the Si5351 multisynth.
This approach has a couple of advantages:
Before writing any new code, we need to think about this issue: the best rational approximation algorithm allows for arbitrary frequencies, even frequencies that have a fractional value of Hz. This can be useful for accurate adjustments of the reference clock, using ppm (or ppb).
Unfortunately the STARTADC command accepts an integer (uint32_t) value, that can't be used to represent floating point values.
In order not to break existing applications the STARTADC command should probably be kept the way it is now, and a new command, called say STARTADCFP should be implemented; this new command would expect a double precision (float64_t) frequency value, and can be used to select an arbitrary frequency (possibly non integer).
The old STARTADC command could then be changed to just convert its integer argument to double precision and pass it to the function that implements STARTADCFP.
As suggested by David in the other thread, the tests that need to be implemented should follow these guidelines:
The FX3 code implementing the best rational approximation algorithm for the Si5351 multisynth can be found here: https://github.com/fventuri/DFC-transceiver/blob/main/fx3-firmware/si5351.c
Franco