Differences

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

Link to this comparison view

pm:prj2026:vlad.radulescu2901:andrei.giurgiu0801 [2026/05/23 23:19]
andrei.giurgiu0801 [Software Design]
pm:prj2026:vlad.radulescu2901:andrei.giurgiu0801 [2026/05/24 20:44] (current)
andrei.giurgiu0801 [Resources]
Line 2: Line 2:
  
 |^Name | Giurgiu Andrei-Ștefan | |^Name | Giurgiu Andrei-Ștefan |
-|^Group | 335CA |+|^Group | 335CA | Invader a fost aici
 ===== Introduction ===== ===== Introduction =====
  
Line 100: Line 100:
  
 ===== Software Design ===== ===== Software Design =====
- 
-** Under construction. ** 
  
 This project will be developed using the PlatformIO extension in Visual Studio Code. This project will be developed using the PlatformIO extension in Visual Studio Code.
Line 128: Line 126:
   * For debouncing, I decided to use the FreeRTOS delay mechanism, which basically yields the core for the specified interval of time (30 ms).   * For debouncing, I decided to use the FreeRTOS delay mechanism, which basically yields the core for the specified interval of time (30 ms).
   * The LCD will have ''>''​ cursor in front of the song that is currently selected to be played.   * The LCD will have ''>''​ cursor in front of the song that is currently selected to be played.
-  * In order to optimize reading the analog pin where the potentiometer is connected, I check the potentiometer value once every 250ms (the UI task runs once every 25ms and I read it once in 10 runs).+  * In order to optimize reading the analog pin where the potentiometer is connected, I check the potentiometer value once every 100ms (the UI task runs once every 10ms and I read it once in 10 runs).
   * Each time NEXT and PREV button are pressed, the LCD updates the cursor and the menu.   * Each time NEXT and PREV button are pressed, the LCD updates the cursor and the menu.
   * When the user hits the SELECT button, the lyric file is fully loaded in memory and parsed. This is done so that the SPI bus won t be a bottleneck when reading the audio file.   * When the user hits the SELECT button, the lyric file is fully loaded in memory and parsed. This is done so that the SPI bus won t be a bottleneck when reading the audio file.
Line 140: Line 138:
  
 === Lyric Task === === Lyric Task ===
-  * **Tomorrow**+  * This task will run once every 50ms. 
 +  ​If a new song just started, all the lyric state variables are reset. 
 +  ​If the user still browses the menu, only the lyric positions are reset, to not show any lyrics while the user decides what song to listen to. 
 +  ​One smart feature of this task is how synchronization is done. I rely on two time functions: one from the audio library (''​getAudioCurrentTime''​) and one from the FreeRTOS system tick for that specific iteration, using the ''​xTaskGetTickCount''​ function. 
 +  ​getAudioCurrentTime only returns the time in seconds and for a nice UX I need millisecond precision. For this specific reason, I keep the moment of time when a full second passed, in the ''​last_sync_tick''​ variable. This is where the ''​now_tick''​ variable comes to play. This variable is the key to have milisecond precision, since it tells me how many milliseconds passed since the last update. This is because it uses the FreeRTOS clock. In order to see how much time has passed since the last full second of the song started, I substract from the ''​now_tick''​ variable the ''​last_sync_tick''​ variable. 
 +  * After that, I sequentially iterate through the ''​current_lyrics''​ array to see if I need to update the text on the LCD. 
 +  * When the track is paused, the reference second time is equal to the current time to not lose the synchronization. 
 +  * When the song ends, the lyric state variables are reset to show the menu UI.
  
 +=== Audio Task ===
 +  * The audio task, since it is very important, it runs once every 2ms. 
 +  * This task reads from the Queues to see if the audio needs to be paused, if the track needs to be changed or if the volume needs to be adjusted.
 +  * When it's not paused, I call the ''​loop()''​ method from the audio object to play the music. This handles behind the curtain mp3 decoding and sending input to the amplifier via I2S.
  
-===== Results ===== 
  
-**To be determined after Software Milestone.** +===== Testing ​=====
-===== Concluzii ​=====+
  
-**To be determined after Software Milestone.**+  ​When the parts came, I assembled the circuit and checked if the audio plays correctly on the speaker. I had to solder the wires so that was a bit stressful, since it was the first time for me doing this. The result can be seen in the first demo in the demos section below. 
 +  ​Before the lab for the software milestone, I implemented a demo synchronization between the speaker and the LCD on a single song. The UI was tested only by myself, with the synchronization being validated by the laboratory assisted. ​   
 +  ​I tested the UI, by keeping the buttons pressed for a very long time, pressing them in fast succesion. Also, the pause/​resume button was tested in the same way and the volume regulator played a big role to see if the speaker behaved correctly at both low and high volume. 
 +===== Optimizations and elements of originality ===== 
 + 
 +  * This project doesn'​t rely on dynamic memory allocations,​ using only stack allocated char arrays instead of String objects for the text processing. This stops fragmentation of the RAM memory and brings stability to the system. 
 +  * The functionality separation two different cores, means that the main players of this architecture won't fight for resources, eliminating glitches in the music stream. 
 +  * Using FreeRTOS timers as high-precision synchronization mechanisms. 
 + 
 + 
 + 
 +===== Conclusions ===== 
 + 
 +  * This project was a really fun experience, where I experimented with many new concepts, like Real Time Operating Systems and audio processing API's for embedding systems. 
 +  * Also learning how to solder is a really valuable skill that I will definitely use in the future.
 ===== Download ===== ===== Download =====
  
Line 160: Line 181:
   * 12.05.2026: Refine the electrical scheme and add a short description of the software.   * 12.05.2026: Refine the electrical scheme and add a short description of the software.
   * 16.05.2026: Add simple demo.    * 16.05.2026: Add simple demo. 
-  * 23.05.2026: ​Finish ​software ​milestone+  * 23.05.2026: ​90% of software ​implementation ready
- +  * 24.05.2026: Fine tuned the implementation.
  
  
Line 169: Line 189:
 {{ pm:​prj2026:​vlad.radulescu2901:​circuit.jpg?​500 | Physical circuit }} {{ pm:​prj2026:​vlad.radulescu2901:​circuit.jpg?​500 | Physical circuit }}
  
-{{https://​drive.google.com/​file/​d/​1OYpMS8L2arQ9ElOX3gjKkMVgnoy5mhVk/​view?​usp=sharing ​Demo video}}+<​html>​ <a href="https://​drive.google.com/​file/​d/​1OYpMS8L2arQ9ElOX3gjKkMVgnoy5mhVk/​view?​usp=sharing"> ​Demo video </a> </​html>​
  
 I did a small demo, where I just played the audio to see if the ESP32 can read the microSD card and if the speaker works. Also, in the video, you can see that the I2C module is connected and gets the text from the ESP32 that says "SD card mounted successfully"​. I did a small demo, where I just played the audio to see if the ESP32 can read the microSD card and if the speaker works. Also, in the video, you can see that the I2C module is connected and gets the text from the ESP32 that says "SD card mounted successfully"​.
 +
 +Below, you can see the final version of the project demo:
 +
 +<​html>​ <a href="​https://​drive.google.com/​file/​d/​1ybvt2zewgrId33BIKKeVnXzge2cTux3o/​view?​usp=sharing">​ Final demo </a> </​html> ​
 ===== Resources ===== ===== Resources =====
  
Line 185: Line 209:
 | MB102 Power supply module| <​html>​ <a href="​https://​www.handsontec.com/​dataspecs/​mb102-ps.pdf">​ Datasheet MB102 </​a></​html>​ | | MB102 Power supply module| <​html>​ <a href="​https://​www.handsontec.com/​dataspecs/​mb102-ps.pdf">​ Datasheet MB102 </​a></​html>​ |
 | MicroSDHC reader module| <​html>​ <a href="​https://​components101.com/​sites/​default/​files/​component_datasheet/​Micro-SD-Card-Module-Datasheet.pdf">​ Datasheet MicroSDHC </​a></​html>​| | MicroSDHC reader module| <​html>​ <a href="​https://​components101.com/​sites/​default/​files/​component_datasheet/​Micro-SD-Card-Module-Datasheet.pdf">​ Datasheet MicroSDHC </​a></​html>​|
 +
 +FreeRTOS documentation <​html><​a href="​https://​www.freertos.org/​Documentation/​00-Overview">​ (link here) </​a></​html>​.
 +
 +AudioI2S documentation <​html><​a href="​https://​registry.platformio.org/​libraries/​esphome/​ESP32-audioI2S">​ (link here) </​a></​html>​.
 +
  
 <​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>​
  
pm/prj2026/vlad.radulescu2901/andrei.giurgiu0801.1779567545.txt.gz · Last modified: 2026/05/23 23:19 by andrei.giurgiu0801
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