ELM Home Page


March 1, 2010

Portable PCM player


About 10 years ago, I built a Portable MP3 Player first and I have done a number of MP3 related projects for hobby and business until now. However because I do not listen music out of door, that portable player have been used as only car audio player and I had not built portable one. The first portable player uses a SmartMedia (SM) as data recording media because the available memory card at that time was only SM and CF. The SM was closed soon and replaced by SD memery card (SDC). Therefore the data storage media of the player has been outdated and I decided to build a new one. The main application is car audio player so that the design should be specified for such use. But I tried to build it again as a small portable player by my preference.

Background

It is not hard to re-build the player because it needs to replace only storage media and nothing else. However such the project is uninterenting and it will not be easy because many conditions have been changed while 10 years. The problem is availability of the main components. The MP3 chipset, Micronas MAS3507D and DAC3550A, used in the first portable player has been discontinued. Nowadays VLSI Solutions VS10xx family MP3 decoder with built-in DAC is usually used for home build MP3 projects. It has a decent audio performance for out-door and car use but not good (especially SNR) for listening in silent room with headphones. Therefor VS10xx is not suitable for Hi-Fi audio and any other separated DAC should be used instead for such applications.

Of cource changes are not to only MP3 chip set. The density of memory cards was increased by 1000 times while the 10 years and also its dimensions decreased to a size that difficult to pick with fingers. This enables to record the audio data in uncompressed LPCM format. The portable audio player with memory card could be realized by MP3 data compression technology, however many audio freaks say that 'Bad sound!', 'Data compression has become needless'. But I cannot find any difference between 192kbps MP3 and LPCM :-)

Hardware

The basic design is determined by above background and the key features are:

Block Diagram

Figure 1. Block Diagram
Block

Figure 1 shows the block diagram of the built LPCM player. The interesting feature of the player is that drives an audio DAC in software. To realize it, the sampling data must be sent to the DAC in constant period. Some microcontrollers have on-chip IIS interface to input/output the digital audio data. However Atmel AVR microcontroller used in this project does not have such useful feature so that the audio DAC must be driven with generic SPI port and timer interrupt.

The analog output of DAC is attenuated with an analog volue, fed to buffer amplifier and output via a headphone jack. The attenuation can also be done before DAC (digital attenuation) but it decreases SNR at normal volume because the noise level (thermal noise and quantization error) generated at DAC is constant regardless signal level. To avoid this problem, DAC is driven in full-scale and adjust the volume with a post-DAC attenuator.

A LiPo battery is used for power supply. It is built-in the chassis and cannot replace it easy. Of cource a battery nanager is needed on the board. The LiPo cell is a sensitive chemical device, it must be used with proper design or it can result smoke, fire or explosion.

A 128 x 64 graphics OLED module is used to display track information. This is very thin compared to generic back-lit LCD modules and it enables to reduce thickness of the mobile equipments. However because OLED is a self-light emitting device, there is a disadvantage that the power consumption is large compared to reflective LCD modules.

Circuit Diagrams

Photo 2. Main Board
main_pcb
Figure 2. Circuit Diagram

The circuit board is divided in two parts, main board and display board. Photo 2 and Figure 2 shows the built main board.

The battery voltage is distributed by two LDO regurators. The digital power is supplied to microcontroller, memory card and display board. The analog power is supplied to the DAC and radio receiver. The reason why power supply is separated for two domains is to insulate analog circuit from a large noise generated by memory card. The buffer amplifier also separated from the analog supply and tied to the battery directly due to the same reason. The digital power supply is turned on by a push button switch and held by microcontroller. This is called 'software controlled power switch'. This is the common principle of the first built one. The analog power supply is controlled by only microcontroller. The charge control of the LiPo battery is done by a charge control IC BQ2057C independed of microcontroller.

This project uses an Atmel ATmega644P microcontroller with built-in 64K bytes flash memory and 4K bytes RAM. The maximum clock rate at 3.3V is 13.3MHz but I did not have a proper crystal so that a 14.745MHz crystal is used. This is +10% out of specs but it will a degree that no problem for hobby use.

Most audio DACs have an 8th order interpolation filter in it. The built-in digital filter requiers a 256, 384 or 512fs over-sampling clock (OCK) in addition to BCK/LRCK so that it is difficult to use such DACs with the general purpose serial interface. When an OCK can be generated, the DAC will not accept software generated digital audio signal because phase relationship between BCK/LRCK/OCK is not stabled. The Rohm BU9480F audio DAC that I chose does not have interpolation filter.

The analog output of the DAC is attenuated with a volume and bufferred with an op-amp (BurrBrown OPA2353). Because the supply voltage is less than 4 volts, normal op-amps that non-RRO type cannot be used. When any low voltage headphone amplifier is available, it is good for such purpose rather than op-amps. This poject also use the headphone cable as an antenna for FM-radio receiver so that the headphone jack must be RF-floated with inductors.

The FM-radio receiver has been drastically simplified. The RDA5800C used in this project is a complete FM receiver integrated in a 4x4mm QFN package. At first I used an NS953M FM receiver module but it is less sensitivity, at next I replaced it with RDA5800C and got a good sensitivity. The analog output of the tuner-IC is tied to the DAC output via registers when it is enabled and disconnected from DAC when it disabled.

Photo 3. Display Board
disp_pcb
Figure 3. Circuit Diagram

Photo 3 and Figure 3 shows the display board. It is stacked on the main board with pin headers. There are an OLED disypaly module, a DC-DC converter to generate OLED drive voltage, an LED and a light detector (CdS) on the borad. The light detector is to control display inetnsity to keep the best visiblity that a common feature on most mobile equipments. The OLED module is consist of two glass boards without cover and only 1.7mm in thickness. It is fitted in the circuit board.

Chassis

A Takachi PB-1 plastic case (75 x 50 x 20mm) is used for this project. The material is clear polystyrene, it is easily cracked and chipped when drilling holes so that it should do with care. I painted the case from inside with conductive paint to create electromagnetic shield. There are two type of conductive paint. One is carbon based (black) and the other is nickel based (darkgray). The second one seems to have less resistance and better electromagnetic shield performance. When paint the polystyrene case, it should be done in two or three times to avoid to dissolve the surface. Of cource the display window must be masked from the paint.

The control buttons are laid out on side of the case to prevent unintentional operation. There are two mounting methods for the push button switch shown in Figure 4 and Figure 5.

Software

DAC controls

The software DAC control is the main feature in this project. The sampling clock (LRCK) is generated with PWM function of TC1. The audio data is sent via USART1 configured in SPI mode. When LRCK is low, the left sample is sent to the DAC, and vice versa. Two separated interrupts are generated on both edge of the LRCK and each ISR reads audio data from data FIFO, mix beep sound (if it in sound) and send it to the USART1. These background processes occupy the CPU power of about 4MHz at sampling rate of 48kHz. The left processing power for the main process is about 11MHz. Some CPU registers are reserved for the background process so that it must be declared in all modules.

Audio player

When PLAY button is pressed, digital supply is tuened on and the microcontroller starts to work. If the card has not been replaced from previous power-off, it start to play at top of the interrupted track. The audio files (tracks) are stored into the sub-directories (albums) placed on the root directory. The number of albums is 20 maximum and the number of tracks per album is 99 maximum. Albums and tracks are sorted by file/directory name. If a play list (.m3u/.wpl file) is exising in the album, it follows the list order.

The PLAY button while playback toggles pause/play state. NEXT button jumps next track and wraps around to the first track if reached last track. NEXT button is held down for 0.7 second, it jumps out the album and enter next album. PREV button jumps top of the current track and jumps previous track by a double click.

During playback, main process must read audio data from the memory card and store it into the audio FIFO. A long interrupt can result FIFO underrun. Any other processes, such as user command and display control, are executed while FIFO is full.

Radio Receiver

The two functions, PCM player and FM-radio receiver, are switched by long press of the STOP button. In radio mode, receiving frequency is tuned by PREV/NEXT button and there are two tuning modes. One is preset mode and the other is free tuning mode. The tuning mode is toggled by PLAY button. The preset channels are changed with a setup file on the memory card. It is read and copied into EEPROM when it has been changed.

Display Control

Photo 4. Display
display

The PCM player has a 128 x 64dot graphics OLED module. It can also display Kanji fonts. However the Kanji fonts are very large in data size and it cannot be included in program code. The Kanji fonts are stored into the memory card that has unlimited space for the font data. In case of the font data could not be read due to any reason, white blocks are displayed instead.

Photo 4 shows the lay out on the display. The album name (directory name) is displayed in its LFN. The artist and title are got from the INFO chunk in the wav file. If there is no INFO chunk, the file name is displayed instead. To use the FatFs with LFN enabled in code page 932 (SJIS), at least 64K bytes program memory is required for the FatFs module itself. I solved this problem by reducing the size of code conversion table with some tricks.

The font images are drawn in proportional spacing and it could increase the character density about 20%. The display brightness is controlled by ambient light. When it is in dark place like pocket or bag, OLED display is turned off to reduce power consumption but lit on track change or any button.

When the player is off-state, the microcontroller is powered while in charge and the LED is blinked slowly to indicate that it is in charge.

Conclusion

This is a portable audio player project after the lapse of 10 years. I measured the audio characteristics of the player and the result is: 95dB SNR and 0.055% THD+N. This is the same performance as DAC itself and it seems to work perfectly. The battery life is about 20 hours.

The performance was better than one expected and too good for car audio so that I decided to modify the first project [ja] to continue to use it. After all, this project might be meaningless but it is not a problem because I could enjoy this project very much.

Downloads

Sign