DIY Arduino FM Radio Shield.

I’ve been visiting local convenience store (Dollarama, here in Montreal, Canada) and notice nice looking FM Radio, just for only $3. Why not to try to interface it to my lovely Arduino? Idea looks quite challenging, the same time what is the point in interfacing a DSP radio shield to arduino? I don’t need a radio, I want to have fun experimenting with it, so  lets go to the bare metal!

You, probably, could find the same or very similar radio all around the globe, with two buttons user interface, powered by two AAA or one CR2032 coin battery (like in my case), and low price. Hardware design based on IC TDA7088 (depending on the manufacturer, may be “clones” SC1088, SA1088, CD9088, D7088, or YD9088). My radio has YD9088  inside. Quick search on a Google, brings a  data sheet. I’d say, It’s not very informative, but at least it shows basic application circuit.

 HARDWARE.

 The most difficult part of this project, is soldering to surface mount radio components. In minimum configuration just two wires, “interfacing” two front-panel buttons. (Other two, for powering up the radio from arduino +3.3 V on-board voltage regulator instead of battery, should be much easier to attach). I solder wires to the caps, on the side, which connected  to the pins 15 and 16 of the IC. In this case, there is minimum impact on usability of the radio, as buttons were not touch. May be important for debugging. If your soldering skills are not as good as mine, you could solder to the traces, removing buttons. On the pictures below you would find two more wires, attached to pin 1 and to earphone’s jack-connector, but they are not in use in this project, and you could left them out.

If you look at the electrical drawings of the shield, you would notice  1 k pot. I build a first version using just two resistors divider, as it shown in “Reset” signal line. But it turns out, that IC is quite capricious for the voltage level it senses on the “Scan” input. On some occasions, it refused  to change a station, and in some it flipped to “reset”. Trim the pot, to get voltage at pin 15 about 3.1 – 3.2 V.  It would be easy to measure voltage with DMM, temporary changing “delay” in this section of the code:

 if (incomingByte == 's') { // SCAN - UP 
  digitalWrite( scan_pin, HIGH ); 
  delay(50); 
  digitalWrite( scan_pin, LOW ); 
  } 

to 10000 or even 20000.  You may need something to be plugged in the earphones jack, as radio is using wires like an antenna. Headphones, or USB speakers cable, works quite well. BTW, the default value 50 may not be enough to “push” a radio up with strong RF signal. Try to send a few “s” simultaneously, “ss” or “ssss”. Setting delay higher than 50 is not recommended, as “jump” may be to wide, so you likely to miss something interesting in broadcasting.

SOFTWARE.

int tunning = 0;

const uint8_t scan_pin = 14;
const uint8_t reset_pin = 15;

void setup() {
Serial.begin(115200); 
 ADCSRA = 0x87; // turn on adc, freq = 1/128 , 125 kHz. 
 ADMUX = 0x44;

pinMode ( scan_pin, OUTPUT );
pinMode ( reset_pin, OUTPUT );
digitalWrite( scan_pin, LOW );
digitalWrite(reset_pin, LOW );
}

void loop() {
char incomingByte;

 ADCSRA |= (1<<ADSC);
 while(!(ADCSRA & 0x10));

 uint16_t temp = 0;

 for( uint8_t i = 0; i < 16; i++ ) {
 ADCSRA |= (1<<ADSC);
 while(!(ADCSRA & 0x10));
 temp += ADC;
 } 
 tunning = (5 * temp) / 16;

 if (Serial.available() > 0) {
 incomingByte = Serial.read();
 if (incomingByte == 'x') { // 
 Serial.print(F("\t Tunning = "));
 Serial.print( tunning, DEC);
 Serial.print(F("\t Frequency = "));
 Serial.println(( 92.5 + pow((3340 - tunning), 0.85)/ 24.5), 1);
}

 if (incomingByte == 's') { // SCAN - UP
 digitalWrite( scan_pin, HIGH );
 delay(50);
 digitalWrite( scan_pin, LOW );
 }
 if (incomingByte == 'r') { // RESET - RESTART
 digitalWrite(reset_pin, HIGH );
 delay(50);
 digitalWrite(reset_pin, LOW );
 }
 } 
}

As you can see, arduino is not doing much in the scetch, only constantly monitoring “tunning” line and checking serial if there is any command waiting to be proceed. CLI includes 3 commands, so far, “x”, “s” and “r”. Sending last two, is equivalent to pressing “switch to next” and “reset” buttons. First one, would print out current “tunning” settings of the radio in millivolts and in MHz. Very likely, you will have to change a coefficients in frequency calculation formula (power regression equation):

92.5 + pow((3340 – tunning), 0.85)/ 24.5

In order to find right digits, you would need to run a full “scan” of all available radio stations in your area. Write down a name of radio station, and corresponding voltage you are getting constantly sending “x”. Than, replace the names with appropriate frequency numbers to any radio station in your list. Look up for such data over Internet at  the station’s web page.  If you do have an another radio with digital scale, than tune this radio on the same radio station as your shield currently preset, and write down a frequency – voltage table.  Filling this data in LibreOffice spreadsheet and plotting a chart would reveal some-kind of non-linear curve:  On the picture you can see:  blue line – real data for my DIY FM Radio shield, orange line – linear approximation, and yellow line is a “power – polynom” approximation. Linear gives big error in the middle, around 1 MHz “off”. Polynomial is much better, and stay close to real data with accuracy +- 0.2 MHz, which is quite good. All you have to do, is “tweak” a coefficients to find the best approximation. Start with lowest frequency you get in your list ( 92.5 and 3340 in an example), than vary 24.5 to get close for highest radio station data. Very likely, 0.85 will be the same, I just have no clue why is it so. To do calculation right, a lot of information is missing, I even don’t know the varicap diode they use to tune a radio!


[original story: coolarduino]