Hello! I am using this library (GitHub - etherkit/Si5351Arduino: Library for the Si5351 clock generator IC in the Arduino environment) with an Arduino MEGA, and the SI5351 to create a clock signal that is controlling a BBD chip. So far the code is working great but I have run into a click or pop that I can't get rid of.
I have noticed that when the clock frequency passes over a value like 128000, 64000, 32000, 16000, 8000, 4000 etc there is a audible pop that I can't seem to remove. Here is my process to dial this in.
clockRaw = analogRead(A0);
clockFreq = map(depthRaw, 0, 1023, 63999, 64001);
clockFreq = clockFreq * 200;
si5351.set_freq(clockFreq_4, SI5351_CLK0);
By selecting such a narrow window with the map I'm able to consistently make the module pop. The same goes if I were to select:
clockFreq = map(depthRaw, 0, 1023, 31999, 32001);
clockFreq = map(depthRaw, 0, 1023, 15999, 16001);
clockFreq = map(depthRaw, 0, 1023, 7999, 8001);
I've tried everything I can think of to avoid this tiny piece of data and nothing is working. I tried this code below and as soon as the value got on the other side it popped again.
if (clockFreq_1 < 63999) {
si5351.set_freq(clockFreq_4, SI5351_CLK0);
}
if ((clockFreq_1 >= 63999) && (clockFreq_1 <= 64001)) {
// DO NOTHING
}
if (clockFreq_1 > 64001) {
si5351.set_freq(clockFreq_4, SI5351_CLK0);
}
I imagine there is a buffer that is filling up and once it gets past these key multipliers it is resetting or something.
Here is some very simplified code. This does everything that I would need but when you get on top of 8/16/32/64/128 it chatters away like a geiger counter. If any of you know how I can resolve this, please let me know. I'm more than happy to pay you for you time.
All the best!
#include <si5351.h>
Si5351 si5351;
int loveHertzRaw;
long loveHertz;
void setup()
{
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0); // ADDRESS is 0x61 or 97
}
void loop()
{
loveHertzRaw = analogRead(A0);
loveHertz = map(loveHertzRaw,0,1023,18000,200000); // 4.000kHz minimum
loveHertz = loveHertz * 100;
si5351.set_freq(loveHertz, SI5351_CLK0);
}