We are witnessing an evolution in the personal computing space. Mobile devices, such as phones and tablets, are on the verge of taking over conventional computers. FM radio is one of the popular entertainment channels in developing countries. This forgotten fact, in addition to the advent of internet radio, can potentially kill the existence of FM radios. Often, OEMs consider not having FM radio on a tablet or a mobile device. However, most of the metropolitan cities still have operational FM radio with no plans to outmode it in the near future.
There is a tiny plug-in device which, when attached to a phone or tablet, can bring FM radio service to mobile devices. The plug-and-play FM receiver can be built using an FM receiver chip with a microcontroller or SOC (system on chip). The microcontroller acts as a USB device when communicating with the USB host on the tablet/mobile and receives commands for operations such as channel scan, channel change, or to set output power level. This bus-powered plug-and-play FM receiver accessory can tune in to the local FM channel while consuming significantly less power than would be required by a mobile broadband radio (Internet radio).
FM radio receivers
FM radio receiver chips provide worldwide coverage of 70-108 MHz catering to the US/EU (87.5-108 MHz), Japan (76-90 MHz) and China (76- 108 MHz). Generally, FM radio receivers have the capability to tune frequencies in steps of 50, 100, or 200 kHz. FM radio can also support radio data system (RDS)/radio broadcast data system (RBDS) functionality, which is fully programmable by the host. In addition to transmitted audio, RDS is used to receive text information. This could include the title of the song, name of the program being broadcast, or flash news for display. In case of emergencies, RDS can be used to transmit critical information.
Band scan is a method through which the FM radio chip scans through the complete FM band for available radio channels. The radio then stores the strongest channel frequencies in its internal memory that can be read by the host microcontroller or SOC.
Once the channels are stored, there are three ways of tuning to a specific channel:
Preset tuning: In this method, the tuning frequency of the FM receiver is set to a certain channel as defined by the host.
Search tuning: In this method, the receiver automatically searches for the next available valid channel in increasing (search up) or decreasing (search down) frequency direction.
Stepped tuning: In this method, the receiver simply steps by one channel in increasing order (step up) or decreasing order (step down) of frequency.
Most radio receiver chips available today communicate with the host using standard protocols such as I2C and SPI. The radio receiver chip also demands the host’s attention by generating interrupts on critical events such as:
- Low signal quality when the RSSI (received signal strength indicator) value drops below a threshold level
- Mono to stereo transition (and vice-versa)
- RDS synchronization is acquired
- RDS synchronization is lost
- RDS buffer is full
Since this embedded system runs on devices that are battery powered, efficient power management is of paramount importance. The radio receiver chip supports various power modes that are controlled by the SOC to improve battery life. For this reason, a receiver chip supports the following power modes:
Power Off: In this mode, the power supply is turned off and all internal regulators are disabled.
Power Down: The power supply is on but the internal regulators are still disabled.
Standby: The regulators are functional and the mode of the radio is maintained.
Power Up: This is the normal operational mode in which all the regulators are enabled and the radio is fully functional.
Figure 1 The block diagram of an FM receiver.
The first stage is an analog signal processing stage that converts the RF antenna signal to a low IF (intermediate frequency) digital signal. The AGC (automatic gain control) unit maintains the LNA (low-noise amplifier) in its linear operating range. A mixer is used to downconvert the received RF signal to a low IF signal. The ADC converts the signal to a digital format. The FM demodulation is done in a digital domain. The digital signal processor also handles the RDS data.
FM radio accessory implementation
The block diagram of a simple implementation of a complete FM system using a generic FM radio chip is shown in Figure 2:
Figure 2 Block diagram of the system
With the advent of modern programmable SOCs, there is no need for any additional external components other than a few passive ones to implement the complete design. The SOC sends commands and receives status messages from the FM radio chip over an I2C port. The SOC connects to the tablet through the established USB interface. An application is used as the front-end on the tablet to access the FM radio for scanning and selecting channels.
When the FM radio receives a command to lock to a particular frequency, it outputs analog audio on specific pins. The analog output from the FM radio receiver is further processed by the SOC and the digitized audio is streamed over USB to the tablet computer. The power required for the FM radio chip operation is derived from the USB bus. The current required for most FM radio chip is typically a few milliamps or even less at 1.8V. This is well within the capability of USB bus and an acceptable level for a portable device.
The following resources are required in a SOC to implement a radio accessory:
- Amplifier
- ADC (Analog to Digital Converter)
- Communication protocol (I2C/SPI)
- USB interface
- Filter Block
Generally, the amplitude of the output audio signal from an FM radio chip will be of the order of 100mV. An amplifier is used for the amplification of the analog audio obtained from the FM receiver prior to feeding it to the ADC in a SOC. The strength of the analog audio output is increased after passing it through a PGA (programmable gain amplifier) as shown in the block diagram. This ensures that the entire input range of the ADC is utilized and results in a faithful reproduction of the audio at the output of the FM radio chip. It is also possible to digitize the signal by using an ADC with a smaller input range. However, the smaller the amplitude of the signal, the more vulnerable it is to system noise.
ADC (Analog to Digital Converter) samples the analog output of the amplifier at the rate of 44.1 kHz and converts it to a 16-bit digital value. The sampling rate is chosen as 44.1 kHz which is in accordance with the Nyquist principle which states that the sampling frequency must be at least two times the maximum operating frequency.
Communication Protocol is a standard protocol, such as I2C or SPI, that is used to interface the SOC with the FM receiver. If I2C is used, the SOC will act as the Master and the radio receiver chip will act as the slave, with a data rate of 100/400 kHz. Commands to change the channel or to scan the FM band can be issued to the FM receiver chip from the I2C master over the I2C bus. The FM receiver chip is capable of decoding predefined commands to perform various tasks. If RDS is used, then the digital information received can be read from the FM receiver by the controller using the I2C interface. It is possible to read other status information such as the RSSI from the FM radio receiver via I2C and display the same on the tablet or PC.
DMA (Direct Memory Access) In many microcontrollers, DMA is a powerful feature that helps in offloading data transfers between memory locations to improve performance. DMA can be used to transfer the converted digital values from the ADC to memory or directly to USB while the CPU is handling other critical tasks.
USB is used to interface the host tablet with the SOC. A USB interrupt endpoint is used to receive various commands from the host, such as channel scan, channel increase, channel decrease, etc. Note that if the command size is small, the control endpoint on the USB device can be used to transfer commands. It is possible to use the control endpoint itself for sending commands. The commands can be sent as vendor-defined commands; however, on a control endpoint, a maximum of 8 bytes of data can be sent in one USB packet. The digital data at 44.1 kHz obtained from the ADC is transmitted to the host using Isochronous USB transfer mode. Isochronous transfer is ideal for this transmission as it is capable of maintaining consistent delivery time due to its guaranteed latency, allocated bus bandwidth, and lack of error correction and handshaking. Note that errors are detected through the CRC field but are not corrected. An occasional data error or missed transfer will not be perceived by the human ear; it takes frequent halting to reach the point of notice. As there is no error correction, there is no halt in the data transmission even in the presence of packets containing errors. A microcontroller supports a maximum packet size of 1023 bytes for an isochronous endpoint.
Improving audio quality
In a mobile OS, generally there is a dedicated media server or media engine that is used for playing audio. This same media engine is used to enhance or modify the characteristics of the audio if required by the user. In some mobile processors, there is dedicated DSP hardware to achieve this.
Using the media engine or the DSP will consume additional power, reduce performance, and have a a potentially negative effect on the user experience. An alternate approach is to process the audio in the SOC and then stream the processed audio over USB to the host tablet. All that the tablet needs to do is play this audio on its speaker.
It is possible to provide the user with finer control over the audio quality in the form of "bass" and "treble" controls using resources in the SOC. This can be achieved through the use of DFB (digital filter blocks) in devices such as the PSoC 3 manufactured by Cypress Semiconductor. The DFB block takes digital input data and outputs processed digital data. In this application, data can be streamed into the DFB using DMA, filtered as per the required audio quality, and then sent over USB for playback.
The required quality of the audio is controlled from the GUI (graphical user interface). The GUI will provide an interface similar to an equalizer available in music players. The entire audio frequency range can be divided into discrete bands. Upon changing the position of the controls on the GUI, a new set of coefficients will be loaded onto the DFB. These coefficients will change the gain of each band and hence change the quality of the output audio.
Host Application
The host runs an application that serves as a front-end for controlling the radio receiver. If the host is running the Android OS, a simple GUI can be created using standard Java and android libraries. On a windows tablet, a simple C# GUI can do the job. Control objects such as buttons are provided to select channel, increase, or decrease channel position and so on.
The DirectSound driver in the Microsoft Windows operating system is used with the isochronous transfer mode of USB to stream the audio to the speakers. This feature is available on Windows 7 OS as well. The evolution of Windows 8 OS, which is specifically made for tablets, supports a GUI and audio driver without any changes. Isochronous transfer is not supported on Android tablets at present. Apple's iPad and few other iOS devices have a built-in USB host and isochronous transfers can be used for audio playback.
The Front-End Host Application/Windows Form application in Windows is used to generate events upon requests from the user such as:
- Request for channel scan
- Request for increment in channel
- Request for decrement in channel
- Request for RSSI from the receiver
In the case of Windows, the application can be developed using C# in Visual Studio. The USB device and its endpoints can be accessed using standard libraries or using custom libraries provided by the SOC manufacturer. The library provides methods and objects to access the SOC via the USB interface. A Windows Form can be created to send commands and display status information as shown below.
Figure 3 FM Radio GUI
Control objects, such as buttons, can be added to implement various operations such as channel scan, next channel, previous channel, and volume control. In addition to this, it is also possible to record the digital audio in the form of a .WAV file. Similar applications can be developed for the Android OS and Apple's iOS.
Modern SOCs such as PSoC 3 can be used as a one-chip implementation for plug-and-play FM radio accessories. Amplification of the analog audio, digitization, filtering, and streaming to a host and controlling the FM receiver can be handled efficiently. This bus powered device can be operated in low power modes such as standby and power down modes supported by both the FM receiver and SOC when not in use, thereby proving to be highly efficient in battery-operated hosts such as tablet computers. With the era of tablet computing just at the horizon, tiny accessories like these will add great value with the help of the resources already available in the computing device.
Authors' biographies
Gautam Das is an Applications Engineer at Cypress Semiconductor. He received his B.E from RV College of Engineering. His interests include analog circuit design and embedded systems.
Udayan Umapathi is an Applications Engineer with Cypress. He completed his Bachelor of Engineering in Electronics and Communication from RV College of Engineering, Bangalore. His expertise includes circuit design, embedded system design, and microcontrollers.
This story was originally posted by EE Times.