ELM Home Page

Graphic MP3 Player

October 18, 2007
Updated: March 21, 2008


GMP3

The MP3 players consist of only semiconductor parts and no complex mechanics. This is a great feature for electronics handicrafts because it can be built easy with the same performance as commercial products except for the appearance. After a long blank in MP3 project, I built a new one again as the second MP3 project.

The first MP3 project was Pocket sized MP3 Player built with an MP3 chipset that obtained by chance. I have completed some projects of MP3 application for my business but not for hobby because I have no practice of listening music at the outdoors. Why did I built it in pocket size? Because that was only an impulse and nothing else. BTW, the MP3 player is being used in my car as a car MP3 player :-)

Now, there are many easy-to-use MP3 decoders that integrates DSP, DAC and amplifier on a chip. As the result, the MP3 player becomes to a popular project for electronics handiworks and everybody is enjoying to build it as their original project. One day I got to want to build an MP3 player by a reason (described below) and decided to start a new project. This is a regular project on the MP3 player after 8 years. I designed it as a desktop player because portable player is not useful for me.

Hardware

Block Diagram
Block
Circuit Diagram

Right image shows the block diagram and the circuit diagram of built MP3 player. It has a feature that it has a large color LCD and a touch screen. Followings describe on each block.

Controller

A V850ES/JG2 (NEC Electronics) is used for system control. This is a 32-bit RISC microcontroller with 256KB flash and 24KB RAM. It was not that well known for electronics handiworks but somebody will be interesting in it because the V850 board was bundled as supplement of magazine in this year. For ordinary MP3 players, most 8-bit microcontroller is sufficient to build it. However this project requires a microcontroller with external memory interface because the controller must handle large amount of image data. Of course any popular microcontrollers, such as Renesas SH2 and H8, will able to be used as well. The reason why I chose the V850 is from its very low power consumption and the serial interface is easy-to-use better than Renesas's one. The V850ES/JG2 can run at 20 MHz but it is used at 14.7 MHz (4xPLL from 3.68 MHz xtal) to deliver a clock signal to MP3 decoder and LCDC.

Storage Media

SD Memory Card is the de facto standard of flash memory card. It can be attached to the microcontroller via a few signal lines. FAT format is used to store data files in it so that the project using the memory card must implement the FAT file system. Fortunately, there are various FAT libraries on the web as freeware so that everybody can use the memory card in their project with ease.

LCD Module

A 4″ color STN-LCD module in resolution of 320x240 is used for the display. Recently the price of color TFT-LCD are going falling and color STN-LCD will soon be shut out of the market. This project was started to to use this LCD module before it decays in the junk box.

A touch screen is attached on the LCD module, so that command buttons can be omitted. A CCFL is used for the back light and a CCFL inverter is required to drive the back light.

LCD Controller

The LCD module in this degree of resolution with built-in display buffer is not available and it must be refreshed by external circuit like CRT display system. Therefor it requires an additional LCD controller on the board to drive the graphic LCD module. The display buffer (RAM) is integrated in the LCDC or attached externally. In this project, an S1D13705 (EPSON) is used for LCD control. The S1D13705 has 80KB integrated display buffer and it can display in resolution of 320 by 240 with 8-bit color depth (256/4096 indexed color). It can be attached to the host controller via a 16-bit SRAM like interface.

The LCD module requires a 3.3V logic supply and an LCD bias supply (21-25V/3mA). Generally, the contrast of the STN-LCD in high drive duty ratio is affected by ambient temperature, so that a contrast dial is required to adjust the contrast. The contrast dial varies the LCD bias voltage. In this project, the contrast is adjusted automatically in software with a thermister put on the LCD module and a D-A converter.

MP3 Decoder

Recently VS10xx family (VLSI Solutions) is used for most home-built MP3 projects because it is easy to obtain and use. The VS10xx is designed for portable audio equipments and can drive a headphone directly. However it has only analog outputs and no digital (I2S) output, so that the VS10xx is not good when require an I2S output to attach an external DAC besides the analog performance is not good for Hi-Fi audio.

I chose STA013 (ST Microelectronics) for MP3 decoding. The STA013 have been released at the dawn of the MP3 format and widely used as a well known MP3 decoder chip. It has only digital (I2S) output, so that a proper audio DAC is required. This is an advantage on electronic handiworks because it can use various DAC chips and output audio data in SPDIF format with DAI encoder.

The STA013 has an integrated PLL oscillator to generate an audio timing clock (384fs) depends on DSP clock. If there is a jitter on the sampling clock, SNR of the analog output will be worse especially on Sigma-Delta DAC. Therefore the PLL power should be tightly filtered and pay attention to parts layout around the loop filter.

Analog Block

A PCM1748KE (BurrBrown) is used. The analog performance on the data sheet is not so bad but it is a little difficult to achieve expected performance because it is a Sigma-Delta DAC.

A post-filter is required at DAC output but only a slow roll-off one will do due to integrated 8x over sampling digital filter. In this circuit, the DAC output is filtered with a LPF+buffer and then output it as a line output and there is no speaker out. Therefore the MP3 player is used with any audio power amplifier.

The line output is tied to ADC input of the microcontroller. This is to get amplitude of the line output and display it as a level meter on the LCD. Generally an envelope detector is used for the audio level meter. In this project, to eliminate the envelope detector, the microcontroller samples waveform in sampling rate of 1kHz and detects peak-to-peak value from 20 samples. There will be dip points on the frequency response but there is no problem because this is for only a visual effect.

Building the MP3 Player

The circuit board must be embedded into a space in height of 10mm, so that the allowable height of the components on the circuit board is less than 6mm. Most of components used in this project ware surface mounted device. They are mounted on the proto-board directly and wired with UEW. This method requires soldering skill and practices but there is an advantage that it can achieve the density of double layered PCB or more. The FPC connector (0.5mm) easily creates solder bridge due to its terminal forms, so that solder the wire to the terminal via a stripe PCB instead of solder the wire directly.

The built circuit board is embedded with the LCD module into the case. The case is a clear acrylic case SK-16 (110x78x32mm) sold from Akizuki. Its depth was too long for this project, so that I cut down it to 25mm, paint black from inside and put an aluminum sheet for electromagnetic shield.

Firmware

In this project, in addition to the basic functions of MP3 player, the embedded program must process several functions, such as visualizations and user interfaces, simultaneously. Of course it can be processed with a single program flow. However when different functions are clearly separated each other on the program code, the efficiency of coding and debugging are drastically improved. The Multitasking is useful for such requirements and it has now become to a basic technique on the embedded programming.

The multitasking that talked about embedded engineering is a little different from the multitasking on PC. In concise words, the multitasking on the embedded programming is a coding style to describe the system function into some independent tasks (routines). However when each task is only running in separately, it does not work as an expected system and exclusion control for shared resources is also required. When implement the management mechanism, such as scheduling of each task, synchronization controls and exclusion controls, several tasks can work in real time and synchronously each other. The software library to manage these mechanism is called Real Time OS (RTOS).

Task Manager - main(), taskmgr.s

For the degree of MP3 players, it does not that require highly real-time operations for each task and will able to be developed in traditional single flow program as well. However it becomes to easy-to-develop when separate the system function into individual sub-functions, so that I created a simple task manager. It has only six system functions and the kernel size is approx. 200 bytes. Each task communicates each other in message.

User Interface - tablet()

This task processes the touch screen and send the button commands related to pressed button to the playback task. The visualization of button action is also processed by this task.

Playback Control - player()

This is the most important function of the MP3 player. Most of the code of this task is only copied from another MP3 project :-) because the MP3 players little differ in basic function. Of course some changes are applied to communicate another tasks.

Directory

The audio tracks are managed in unit of album that sub-directories placed at the root directory like shown in right image. Maximum number of albums is defined to 40, and number of tracks (.mp3 files) in an album is 99. Each albums and tracks are sorted in their file name.

The FAT file system used in this project does not support long file name, however it can access the files with alternative short file name (8.3 format). The files can be sorted correctly even if named in long file name by numbering the files in heading two numeric characters. When a playlist (.m3u file) exists in the directory, the listing order follows the play list but in this case, the file names listed in the play list must be short name.

When a PLAY command from user interface task is received, the playback task scans all directories in the root directory and registers valid albums (contains any mp3 files) into the album list. If there is no change to the memory card, start from recent track at last stop. If not, it starts from the first track of the first album. When it finished to play a last track in an album, which track is played next, first track in current album or next album, is depends on the repeat mode (all tracks or within album).

The audio data is read from the file and stored into FIFO buffer during playback state. The data in the FIFO is read and forwarded the audio data to the STA013 via the SPI port by interrupt service routine triggered bt DATA_REQ signal.

Visualization - display()

This task processes to display informations corresponding to playback operations and triggered by messages from playback task. In playing state, level meters and play time must be refreshed in real time, so that it also triggered in interval timer.

When notified to start to play, it gets information of screen layout from configuration file and load image file if needed. The configuration file is placed in each album, as the result the visualization is changed every album change and each album can have different visualization.

System Monitor - monitor()

This is implemented first and it gives a debugging console to control and examine memory, peripherals and functions being debugged. Once the project completed, the system monitor gets unnecessary. But it is left implemented because it does not occupy so large resource.

Intreval Timer - ISR_tmm0()

This is a timer process driven by timer interrupt in interval of 1 millisecond. It works out of control under task manager because the simple task manager does not support preemption (task switch due to interrupt). The touch screen, output amplitude input and system timer used in task manager are driven in this task.

Conclusion

Using the MP3 Player

The MP3 player is controlled with command buttons displayed at left side of the screen. It start to playback when a PLAY command is generated by `Play' button (somewhere on the screen in power-down state) or card insertion. There are some generic playback controls, such as play, pause, next track, next album, previous track, previous album. In stopped state, the button functions are changed to different function to change repeat mode. The current consumption in playing state is approx. 500 mA and the backlight power occupies 80% of the total power. To reduce power consumption, it enters power-down state (backlight off) after a time past in stopped state.

Screen

The track informations, title, artist, track number, number of tracks, play time, progress bar and level meter, are displayed on the screen during playing state. Their color, layout, font and background picture can be configured with a configuration file. The command buttons are fixed to left side because the usability will worse and the screen is stained with fingerprints if the command buttons frequently move anywhere.

The screen layout except for command buttons can be designed for each album like shown in right image. However creating the screen is a troublesome job and any creation tool will be needed. When there is no configuration file in the album, a default layout without background image is used.

Audio Performance

Specs.
Main ICsMCU: V850ES/JG2 (NEC)
LCDC: S1D13705 (EPSON)
DSP: STA013 (ST)
DAC: FN1242A (Nigata Seimitsu)
Memory CardMMC/SDSC/SDHC
Data FormatMPEG1/2/2.5, Layer-3
User I/F4″ColorSTN LCD, Touch screen
Dimensitons110x80x25mm(WxHxD), 170g
Power SupplyDC 5V, 500mA max

The measured analog characteristics are 76dB (SNR) and 0.035% (THD+N). The SNR is inferior to raw DAC performance that the data sheet says and not acceptable for Hi-Fi audio. It seems the DAC performance is not sufficiently brought out. I applied some considerations on the power supply and grounding but the sigma-delta DAC is still difficult to use compared to register network DACs. I will retry it with a different DAC.

Replaceing DAC (Updated: Mar 21, 2008)

I replaced the DAC from PCM1748K (BB) to FN1242A (Niigata Seimitsu). The dataseet is saying that `improved jitter immunity' so that it may able to improve SNR. As the result, 90dB of SNR and 0.004% of THD+N is achieved.

Resources

Sign