Abstract
In this last part we provide a basic front-end for the FM radio and a simple example program. Moreover, we provide full documentation for all the TEA library and their classes.
This project is a simple implementation of a FM Radio player based on the FM module. The radio has a simple front-end consisting of the LCD module and its buttons. The are five possible working modes. For more details on the working modes see the Section "Using the radio".
Building the radio
Just stack the LCD module (more infos here) on your Arduino and connect the FM module as explained here. That's all!Display and buttons
In all working modes (except for the sub-modes) the information is displayed in a standard format on the LCD. The first line indicates the frequency of the current station being reproduced (approx to 2 decimal digits) and the current working mode. The second line displays the audio level (a number between 0 and 16) and if the reception is stereo or mono. The following figure gives a more visual illustration of the display organisation.Figure 1. Display organisation in main working modes. |
The radio uses 4 out the 5 buttons on the LCD module (the leftmost ones). The leftmost button (button 1) and the its neighbor (button 2) are used as navigation buttons. In standard mode (STD), they are used to search backward (resp. forward) for the next station to reproduce. In recording mode (REC) and in memory mode (MEM), they are used to move backward or forward in the memory array. Button 3 is called mode button and it is used to change the working mode. Button 4 is called action button and it is used to confirm actions for the current working mode. For example, when choosing a memory slot for memorizing the current station in the memory array, if this button is pressed then the frequency of the current station is recorded and the radio returns in STD mode. The following figure illustrates buttons positions.
Figure 2. Buttons of the LCD module. |
Warning
For lack of space when displaying information on the LCD, some shortcuts are used. For example, btn means "button" and act means "action", etc.
Using the radio
At power on time, the radio is tuned at frequence 87.5 MHz on the US/European FM band, if a station is present then the radio starts reproducing it, otherwise noise is heard. Standard mode (STD) is activated. All entries of the memory array are initialized at 87.5MHz. The backward and forward buttons can be used to select other stations in the band. The search for the next station wraps around the band limits.Using the mode button, the working mode can be changed. The radio has five operating modes:
- standard (STD): we just described this.
- recording (REC): in this mode the user can save the current frequency to memory. The user is prompted to choose a slot in the memory in which to store the frequency of the current station. Once the slot number is chosen, press the action button to confirm selection. Use the forward/backward buttons to navigate in the memory array.
- memory (MEM): reproduces the station memorized at current position in the memory array. Use the forward/ backward buttons to navigate in the memory array.
- preselect (PRE): this mode automatically preselects the stations with better reception level (SEARCH_LEV_MEDIUM) and memorize them into the memory array. The scan is started from the current frequency toward the superior band limit and restarts from the inferior band limit if the memory has not been completely filled. The filling of the memory follows a greedy policy. The scan is stopped if after two successive trials no station is found.
- standby (SBY): sets the radio in standby. Press action button to return in STD mode.
Configuration and fine tuning
Configuring the front-end. The radio class has been kept as simple as possible. In this way its configuration is very simple. All you need to edit it is the file FM_Radio_Config.h and update information about the pins used by the LCD module. You need also to specify the size of the memory array (constant MEMOMAX) that will be used by the radio to store the frequency of your preferred radio stations.Configuring the FM module. The radio is configured to work with EU/US band limits. If you want to change japanese band limits, then you have to replace EUROPEAN_FM_BAND by JAPANESE_FM_BAND in function TEA576X::begin(). Please check also the working parameters of your FM module (crystal frequency, etc) and configure them accordingly. Remark also that high side injection is selected by default.
Delays. In the reading and write operations (immediately after them) it is often used a delay to allow the operation to finish. The delays are sometimes overestimated to be sure to work with most modules. Maybe the user can change them to adapt more closely to his module and increase the overall performances.
Also in the front-end (FM_Radio.cpp) a number of delays are set. Also those can be change to improve performance or user experience.
Test sketch
The simplicity of the design allows to run our radio with a very simple sketch.#include <SPI.h> #include <Wire.h> #include <LiquidCrystal.h> #include "FM_Radio.h" FM_Radio radio; void setup() { radio.begin(LCD_BTN, MEMOMAX); } void loop() { radio.loop(); }
No comments :
Post a Comment