Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2023:avaduva:portable_music_player [2023/05/06 09:54]
traian.constantin01 edit2
pm:prj2023:avaduva:portable_music_player [2023/05/20 13:18] (current)
traian.constantin01 blank
Line 1: Line 1:
-====== Portable Music Player ======+======= Portable Music Player ​=======
 by Constantin Traian-Alexandru by Constantin Traian-Alexandru
  
Line 6: Line 6:
 The aim of this project is to build a practical portable music player that is compatible with common hardware and files (standard batteries, microSD cards and .mp3 music files, respectively). The aim of this project is to build a practical portable music player that is compatible with common hardware and files (standard batteries, microSD cards and .mp3 music files, respectively).
 The ultimate goal of this would be to have a music player that can be built from scratch by anyone, and which is able to play music files without relying on cloud services. The ultimate goal of this would be to have a music player that can be built from scratch by anyone, and which is able to play music files without relying on cloud services.
 +
  
  
Line 14: Line 15:
 The Arduino will control the interfacing with the user (control buttons for input, an LCD display for output), as well as the functions of the DFPlayer (play/​pause,​ track selection etc.). The Arduino will control the interfacing with the user (control buttons for input, an LCD display for output), as well as the functions of the DFPlayer (play/​pause,​ track selection etc.).
  
-The LCD Display will show information such as the current track. The buttons can be used to play/pause and navigate, as well as increase/​decrease the volume. The audio can be outputted ​to earphones (through a 3.5mm jack) or to two stereo speakers (powered by an amplifier).+The LCD Display will show information such as the current track. The buttons can be used to play/pause and navigate, as well as increase/​decrease the volume. The audio is outputted to two stereo speakers (powered by an amplifier). 
 + 
 +{{:​pm:​prj2023:​avaduva:​pmp_block_diagram.png?​600}}
  
-{{:​pm:​prj2023:​avaduva:​pmp_block_diagram.png?​1000}} 
  
  
Line 28: Line 30:
   * 2 x 1W 8Ω Speakers   * 2 x 1W 8Ω Speakers
   * LM2596 Adjustable Voltage Regulator   * LM2596 Adjustable Voltage Regulator
-  * 4 x AAA Batteries+  * 9V Battery
   * Various smaller components e.g. buttons, switches, resistors.   * Various smaller components e.g. buttons, switches, resistors.
 +
 +<note tip>
 +The LM2596 regulator has been chosen in order to allow for more current to power the many devices used in this project. Arduino'​s own AMS1117 regulator can provide up to 800mA output according to its datasheet, but the total consumption of the combined devices is only marginally below that parameter, so the LM2596 with its generous 3A maximum output current was used to ensure the proper functioning of the system.
 +</​note>​
 +
 +==== Schematic ====
 +
 +{{:​pm:​prj2023:​avaduva:​pmp_circuit_schematic.png?​800}}
 +
 +<​note>​
 +The schematic is representative of the final product, however the battery and the speakers have not been represented,​ and the connections to the button pins may not be identical. The pinout of the Arduino is visually that of a Nano, however the final product uses an Arduino Uno.
 +</​note>​
 +
 +==== Prototyping ====
 +
 +Breadboard test designs for the screen, DFPlayer, as well as testing the complete functionality using earphones:
 +
 +{{:​pm:​prj2023:​avaduva:​pmp_proto_screen.jpg?​250}}
 +{{:​pm:​prj2023:​avaduva:​pmp_proto_dfplayer.jpg?​250}}
 +{{:​pm:​prj2023:​avaduva:​pmp_proto_final.jpg?​250}}
 +
 +==== Soldered PCBs ====
 +
 +<​note>​
 +While the breadboard prototype is entirely functional, because the project involves sound signals, noise is a significant concern. Noise interference has been observed to occur, primarily due to the many connectors the breadboard has, and therefore a soldered PCB design is more optimal.
 +
 +It is also recommended to use a 1KΩ resistor for the RX pin on the DFPlayer in order to avoid a poor sound quality.
 +</​note>​
 +
 +=== Sound & Power board: front and back ===
 +{{:​pm:​prj2023:​avaduva:​pmp_soldered_spboard_front.jpg?​300}}
 +{{:​pm:​prj2023:​avaduva:​pmp_soldered_spboard_back.jpg?​300}}
 +
 +=== Front Panel board: front and back ===
 +{{:​pm:​prj2023:​avaduva:​pmp_soldered_fpboard_front.jpg?​300}}
 +{{:​pm:​prj2023:​avaduva:​pmp_soldered_fpboard_back.jpg?​300}}
 +
 +<​note>​
 +The front panel board is wired according to the schematic. The sound and power board has both the DFPlayer and the amplifier wired to it, in addition to the DC power jack 9V battery input and the 5V power rails where all the devices draw power from.
 +</​note>​
 +
  
  
 ===== Software Design ===== ===== Software Design =====
 +
 +<note tip>
 +The dedicated TX and RX Arduino pins have been used to communicate with the DFPlayer'​s. However, these pins are also used by the computer in order to program the Arduino, and as such they need to be disconnected while doing so.
 +</​note>​
 +
 +The following libraries have been used in this project:
 +  * Adafruit_GFX.h - The core Adafruit graphics library
 +  * Adafruit_ST7735.h - The hardware-specific library for the ST7735 microcontroller
 +  * SoftwareSerial.h - An USART interface for communicating with the DFPlayer
 +
 +==== The file structure ====
 +
 +Firstly, one major drawback of the DFPlayer in contrast to a normal SD card reader is the fact that it and only it has access to the contents of the micro SD card. The Arduino is able to give commands to the DFPlayer specifying what tracks should be played, but it will never have direct access to them.
 +
 +Consequently,​ in order to allow the users to select the tracks they want to be played, a replica of a file system has been implemented,​ consisting of two multidimensional arrays: the first one, "​filesystem",​ stores the names of the songs (.mp3 files), as well as that of the album (file directory) in which they are located. The second array, "​fileindex",​ is necessary in order to account for the position of the tracks in the "​filesystem"​ array, relative to the order in which they are read in the sequential "​queue"​ of the DFPlayer.
 +
 +The DFPlayer reads from the microSD card a folder structure of the following kind:
 +
 +{{:​pm:​prj2023:​avaduva:​pmp_dfplayer_file_structure.png}}
 +
 +It is to be noted, however, that the files and folders need not be named to 01, 002 etc., as the DFPlayer orders them according to the date and time that they were written to the microSD card.
 +
 +The DFPlayer is also able to read up to 255 files inside 99 folders - however, the small 2kB SRAM of the ATmega328p is not able to even initialize that large of a multidimensional array; the memory of the "file system"​ was restricted to holding 4 folders of 16 files.
 +
 +==== The interface screens ====
 +
 +On the basis of such a file structure as discussed above, I have thought of implementing an interface to navigate through the albums and songs, as well as playing them. The result was a 3-screen system which allows the user to navigate through a list of albums, then a list of songs inside an album, and then allows for playing a song with basic music player controls (play/​pause,​ next, volume up/down). In order to keep the project simplistic, the 5 buttons on the front panel each have specific functions when pressed, depending on the screen which is shown:
 +
 +{{:​pm:​prj2023:​avaduva:​pmp_screen_button_controls.png}}
 +
 +<note tip>
 +Navigation inside the screens is made by moving the orange cursor up and down, then selecting the desired list entry.
 +
 +The screens can be scrolled up and down if the album has many songs that cannot be displayed on the screen, similarly to old Nokia UIs.
 +</​note>​
 +
 +==== Offset bugfix ====
 +
 +When initially tested, I discovered that my ST7735 LCD screen had a problem with the offset of the pixels. This can be attributed to the microcontroller of the display not being an original manufactured by Sitronix.
 +
 +{{:​pm:​prj2023:​avaduva:​pmp_lcd_offset.jpg?​300}}
 +{{:​pm:​prj2023:​avaduva:​pmp_lcd_offset_fixed.jpg?​300}}
 +
 +I managed to correct this problem by adding a manual offset inside the Adafruit library.
 +
 +Inside Documents\Arduino\libraries\Adafruit_ST7735_and_ST7789_Library\Adafruit_ST77xx.cpp:​
 +<code cpp>
 +void Adafruit_ST77xx::​commonInit(const uint8_t *cmdList) {
 +
 +  _colstart = 2;
 +  _rowstart = 1;
 +
 +  begin();
 +
 +  if (cmdList) {
 +    displayInit(cmdList);​
 +  }
 +}
 +</​code>​
 +
 +==== Code summary ====
 +
 +The code can be summarized as follows:
 +
 +  - The initial definitions,​ configurations and variable initializations
 +  - In setup(): defining the songs in the file system
 +  - In setup(): starting the connections from the Arduino to the ST7735 screen and the DFPlayer
 +  - In loop(): multiple if statements that perform the functions assigned for the button presses depending on what is currently displayed on the screen
 +  - Outside of loop(): method definitions for functions that deal with binary commands to the DFPlayer and graphical commands to the screen (these functions are ultimately called by the button presses)
 +
 +==== Resulting screens ====
 +
 +These are the screens rendered by the software (Left to right: albums, songs, playing):
 +
 +{{:​pm:​prj2023:​avaduva:​pmp_screen_1.jpg?​300}}
 +{{:​pm:​prj2023:​avaduva:​pmp_screen_2.jpg?​300}}
 +{{:​pm:​prj2023:​avaduva:​pmp_screen_3.jpg?​300}}
  
  
  
 ===== Results ===== ===== Results =====
 +
 +[[https://​drive.google.com/​file/​d/​1joZeevAr_gyqutyce6VV8bztFbj1lMqA/​view|Functionality demonstration video]]
 +
 +==== Front view ====
 +{{:​pm:​prj2023:​avaduva:​pmp_angle_1.jpg?​500}}
 +
 +==== Back view ====
 +{{:​pm:​prj2023:​avaduva:​pmp_angle_2.jpg?​500}}
 +{{:​pm:​prj2023:​avaduva:​pmp_angle_3.jpg?​500}}
  
  
  
 ===== Conclusions ===== ===== Conclusions =====
 +
 +There are many improvements that can potentially be made to the design, for example: the addition of an EEPROM memory module to expand the capacity of the files; an automated script for copying songs in sync from the PC to both the EEPROM and the microSD card.
 +
 +However, I feel that the scope of the project has been fulfilled and that it demonstrates the capabilities of the Arduino in being used for the implementation of a Portable Music Player.
  
  
Line 46: Line 179:
 ===== Download ===== ===== Download =====
  
 +Archive: {{:​pm:​prj2023:​avaduva:​pmp.zip}}
 +
 +PDF: {{:​pm:​prj2023:​avaduva:​portable_music_player.pdf}}
  
  
-===== Journal ===== 
  
  
  
 ===== Bibliography/​Resources ===== ===== Bibliography/​Resources =====
 +
 +Software used:
 +  * Arduino IDE for programming
 +  * Inkscape for the block diagram
 +  * KiCad for the circuit schematic
 +
 +Study materials:
 +  * [[https://​wiki.dfrobot.com/​DFPlayer_Mini_SKU_DFR0299|DFPlayer Mini wiki]]
 +  * [[https://​ww1.microchip.com/​downloads/​en/​DeviceDoc/​Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf|ATmega328P Datasheet]]
 +  * [[http://​www.goodliffe.org.uk/​arduino/​mp3player.php|Arduino mp3 player with similar functionality but different components]]
 +  * [[https://​electronicslovers.com/​2018/​01/​interface-dfplayer-mini-mp3-module-with-arduino.html|About using the DFPlayer commands]]
 +  * [[https://​forum.arduino.cc/​t/​solved-read-data-from-dfplayer/​1118096/​|About using the EEPROM for file indexing]]
  
  
pm/prj2023/avaduva/portable_music_player.1683356096.txt.gz · Last modified: 2023/05/06 09:54 by traian.constantin01
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0