This shows you the differences between two versions of the page.
pm:prj2023:avaduva:portable_music_player [2023/05/05 15:05] traian.constantin01 created |
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 ======= |
- | ===== Introducere ===== | + | by Constantin Traian-Alexandru |
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | 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. | ||
+ | |||
+ | |||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | A DFPlayer Mini module will be used to read the .mp3 files inside the microSD card and will output the decoded audio. The DFPlayer will be used instead of a conventional SD card reader due to the difficulty in decoding .mp3 signals on an Arduino. | ||
+ | |||
+ | 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 is outputted to two stereo speakers (powered by an amplifier). | ||
+ | |||
+ | {{:pm:prj2023:avaduva:pmp_block_diagram.png?600}} | ||
+ | |||
+ | |||
+ | |||
+ | ===== Hardware Design ===== | ||
+ | |||
+ | The following components will be used in the project: | ||
+ | * Arduino Nano | ||
+ | * DFPlayer Mini | ||
+ | * ST7735 LCD Display | ||
+ | * PAM8403 Amplifier | ||
+ | * 2 x 1W 8Ω Speakers | ||
+ | * LM2596 Adjustable Voltage Regulator | ||
+ | * 9V Battery | ||
+ | * Various smaller components e.g. buttons, switches, resistors. | ||
<note tip> | <note tip> | ||
- | Prezentarea pe scurt a proiectului vostru: | + | 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. |
- | * ce face | + | |
- | * care este scopul lui | + | |
- | * care a fost ideea de la care aţi pornit | + | |
- | * de ce credeţi că este util pentru alţii şi pentru voi | + | |
</note> | </note> | ||
- | ===== Descriere generală ===== | ||
- | <note tip> | + | ==== Schematic ==== |
- | O schemă bloc cu toate modulele proiectului vostru, atât software cât şi hardware însoţită de o descriere a acestora precum şi a modului în care interacţionează. | + | |
- | Exemplu de schemă bloc: http://www.robs-projects.com/mp3proj/newplayer.html | + | {{: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> | </note> | ||
- | ===== Hardware Design ===== | + | ==== Prototyping ==== |
- | <note tip> | + | Breadboard test designs for the screen, DFPlayer, as well as testing the complete functionality using earphones: |
- | Aici puneţi tot ce ţine de hardware design: | + | |
- | * listă de piese | + | {{:pm:prj2023:avaduva:pmp_proto_screen.jpg?250}} |
- | * scheme electrice (se pot lua şi de pe Internet şi din datasheet-uri, e.g. http://www.captain.at/electronic-atmega16-mmc-schematic.png) | + | {{:pm:prj2023:avaduva:pmp_proto_dfplayer.jpg?250}} |
- | * diagrame de semnal | + | {{:pm:prj2023:avaduva:pmp_proto_final.jpg?250}} |
- | * rezultatele simulării | + | |
+ | ==== 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> | </note> | ||
- | ===== Software Design ===== | + | === 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 tip> | + | <note> |
- | Descrierea codului aplicaţiei (firmware): | + | 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. |
- | * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) | + | |
- | * librării şi surse 3rd-party (e.g. Procyon AVRlib) | + | |
- | * algoritmi şi structuri pe care plănuiţi să le implementaţi | + | |
- | * (etapa 3) surse şi funcţii implementate | + | |
</note> | </note> | ||
- | ===== Rezultate Obţinute ===== | + | |
+ | |||
+ | ===== Software Design ===== | ||
<note tip> | <note tip> | ||
- | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | + | 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> | </note> | ||
- | ===== Concluzii ===== | + | 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 | ||
- | ===== Download ===== | + | ==== The file structure ==== |
- | <note warning> | + | 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. |
- | O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului: surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-). | + | |
- | Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:pm:prj20??:c?** sau **:pm:prj20??:c?:nume_student** (dacă este cazul). **Exemplu:** Dumitru Alin, 331CC -> **:pm:prj2009:cc:dumitru_alin**. | + | 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. |
- | </note> | + | |
- | ===== Jurnal ===== | + | 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> | <note tip> | ||
- | Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. | + | 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> | </note> | ||
- | ===== Bibliografie/Resurse ===== | + | ==== 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 ===== | ||
+ | |||
+ | [[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 ===== | ||
+ | |||
+ | 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. | ||
+ | |||
+ | |||
+ | |||
+ | ===== Download ===== | ||
+ | |||
+ | Archive: {{:pm:prj2023:avaduva:pmp.zip}} | ||
+ | |||
+ | PDF: {{:pm:prj2023:avaduva:portable_music_player.pdf}} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== 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]] | ||
- | <note> | ||
- | Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. | ||
- | </note> | ||
<html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | ||