TEA5767 TX clicking on analogread

Hi there,
i´m pretty sure this problem got mentioned elsewhere, but i can´t find a proper solution to this and somehow in can´t accept that this is it now ....

I´m into building a CV controlled FM Radio for modular synthesizers with an Arduino DIY and SMT assembled.
I got everything running pretty well, but there´s one thing on arduino´s side that kills it all.

It´s about the clicking / ticking while reading out the analog in for adjusting the frequency.
I kinda know why it happens, but i don´t know how to prevent.

Does anyone in here have a solution?

#include <Wire.h>

unsigned char frequencyH = 0;
unsigned char frequencyL = 0;

unsigned int frequencyB;
double frequency = 0;

void setup()
{
Wire.begin();
frequency = 106.8; //starting frequency
setFrequency();
//Serial.begin(9600);
}

void loop()
{
int reading = analogRead(0);
frequency = map((float)reading, 0.0, 1024.0, 87.5, 108.0);

frequency = ((double)reading * (108.0 - 87.5)) / 1024.0 + 87.5;
frequency = ((int)(frequency * 10)) / 10.0;

setFrequency();
Serial.println(frequency);
}

void setFrequency()
{
 static byte freqH=0;
 static byte freqL = 0;

  frequencyB = 4 * (frequency * 1000000 + 225000) / 32768;
  frequencyH = frequencyB >> 8;
  frequencyL = frequencyB & 0XFF;

 if ((frequencyH == freqH) && (frequencyL == freqL)) return;  // no change
 freqH= frequencyH; 
 freqL= frequencyL;

  Wire.beginTransmission(0x60);
  Wire.write(frequencyH);
  Wire.write(frequencyL);
  Wire.write(0xB0);
  Wire.write(0x10);
  Wire.write((byte)0x00);
  Wire.endTransmission();
 delay(120);  
}

It seems more likely to me that the clicking is caused by updating the radio module with the new frequency, not actually by reading the analog value. I can't be sure, of course, because you didn't post a schematic!

If I'm right, there may be nothing you can do to eliminate the click, it's a feature of the radio module. But perhaps you can reduce it significantly, or make it less noticeable, by only updating the radio module when the frequency changes. Right now, it gets updated every 120ms even if the frequency is unchanged.

I would do this by keeping the previous value of your variable frequencyB in a new global or static variable. Each time frequencyB is calculated, compare the value with the previous value. If it is the same, do not update the radio module.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.