Sunday 27 March 2016

Arduino TEA 5767 FM radio

An FM radio using a TEA5767 FM radio module and an Arduino

Main parts

The main parts used are
  • TEA 5767 FM Stereo Radio Module for Arduino 76-108MHZ (http://www.aliexpress.com)
  • TOOGOO(R) Keypad Shield Board  (amazon)
  • Arduino
  • FM aerial
  • Headphones / speakers

The TEA5767 FM module provides the stereo FM radio recevier and headphone outputs. The receiver is controlled by the Arduino via I2C. 

The TOOGOO keypad shield provides a two line display for displaying the current frequency and signal strength etc. It also provides the buttons that are used to control the radio.

TEA5767 FM Stereo Radio Module

 The datasheet for the TEA5767 can be found here datasheet

Source code

My source code for the project can be found at the Git hub repository source code

The software radio supports 5 modes which are cycled through using the up and down keys

  1. Signal mode - the display shows the current frequency and signal strength. Volume is controlled with the left and right keys
  2. Manual mode - left and right keys change the tuned frequency
  3. Scan mode - left and right keys scan for the next radio station
  4. Preset mode - recall a saved preset radio station. Use left and right keys to select the preset and the select key to recall it
  5. Programme mode - save the current radio station as a preset. Use the left and right keys to select the preset and the select key save

Presets are saved in the Arduino EEPORM so they are not lost when the power is turned off. 

The software includes a library of functions for controlling the TEA5767. This library works with the TEA5767 in I2C mode therefore the BUSMODE pin needs to be connected to ground to select ITC mode. The IC address is 11000001.

The most fiddly operation provided for by the library is setFrequency(double freq)which sets the radio frequency. The radio uses a Phased Lock Loop (PLL) and to tune the radio to a wanted frequency the corresponding PLL word must be calculated. This is a 14bit word that is sent to the programmable divider. 

The PLL word for high side injection mode is calculated as follows

    // calculate PPL word for high side injection
    // PPL = 4 * freq(Hz) + 225kHz / clock(Hz)
    frequencyB=round( ( 4*( (freq*1000000)+225000) ) /32768);

My library only uses the high side injection mode when tuning the radio. According to the datasheet the function should tune the radio to both the high side and low side and then select the one with the strongest signal but in practice I've found using only the high side seems works fine for demo purposes. 

Wiring

The wiring should be connected as follows
 
TEA5767 wiring
 * SCA to Arduino SDA
 * SDL to Arduino SDL
 * VCC to 5V
 * GND to GND

LCD wiring
 * R/W (pin 1) to GND
 * VCC (pin 2) to 5V
 * V0 (pin 3) to variable resistor (contrast)
 * RS (pin 4) to Arduino digital pin
 * E  (pin 6) to Arduino digital pin 9
 * D4 (pin 11) to Arduino digital pin 4
 * D5 (pin 12) to Arduino digital pin 5
 * D6 (pin 13) to Arduino digital pin 6
 * D7 (pin 14) to Arduino digital pin 7