Differences

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

Link to this comparison view

pm:prj2025:iivasciuc:marius.zaharia2305 [2025/05/18 13:26]
marius.zaharia2305 [Background and General details]
pm:prj2025:iivasciuc:marius.zaharia2305 [2025/05/25 18:30] (current)
marius.zaharia2305 [Results]
Line 169: Line 169:
  
 ====Implementation details==== ====Implementation details====
 +===Modules===
 +**pins** ​
 +  * Contains the mappings between Arduino pins and peripheral components pins.
  
-===== Results =====+**sounds** 
 +  * Contains various sounds for the buzzer, used as audio feedback for the user after certain actions.
  
 +**lights**
 +  * Contains multiple color schemes for the RGB LED, used as visual indicators of the menus the user is navigating.
  
 +**wdt_counter**
 +  * Controls the Watchdog Timer, by setting it up to generate an interrupt every second.
 +  * It is used as a time-keeper for managing the interest gain of the savings accounts (every 15 seconds, interest is applied).
 +  * It is preferred instead of Timer0/1/2, because these might be controlled by the ''​millis()''​ function, which is also used in the project.
 +  * If, at a later time, another configuration of the WDT might be preferred (i.e. interrupt after a time interval), only this module is to be modified, without interfering with other sections that use timers.
 +  * The source file contains a static variable (private to the file) that represents the counter, offering an init and a getter method for outside modules.
 +  * The ISR is rather short and simple, by only incrementing the counter value.
 +  * The live value of the counter can be observed in the debug menu.
  
-===== Conclusions =====+**debounce** 
 +  * Offers methods for checking if the joystick is flicked to the right/​left/​up/​down,​ if the joystick button is pressed and if the red button is pressed. 
 +  * In the source file, multiple static variables for debounce handling are used, which must not be accessible from the outside. 
 +  * For button debouncing, a generic function is implemented,​ which is used by specific functions for the two buttons. 
 +  * For joystick flicks checking, it is verified if a certain time has passed since the last registered flick, such that there is a delay in the menu navigation system (i.e. the menus do not fall through instantly).
  
-===== Download =====+**utils** 
 +  * Contains utility data structures, constants, global variables marked as ''​extern''​ and various helper functions. 
 +  * The ''​User''​ structure is declared here, containing the necessary information each user must posses. 
 +  * Functions for keyboard reading, user management, UID card reading and notification handling are specified here.
  
 +**menus**
 +  * The enum class that encodes the menus and the functionality of each menu are described here.
  
 +**main**
 +  * Initializes the global variables, the user database and all the peripheral devices.
 +  * Contains the main loop, which presents the ''​switch''​ statement by which the current menu function is chosen
  
-===== Timeline ===== 
  
 +===How it works===
 +  * The users are stored in a statically allocated array, each of them having a predefined name and UID. Initially, all of them are marked as not registered and have to go through the ''​register''​ menu to become active.
 +  * The ''​main loop''​ is rather simple: at each iteration, it checks the value of the ''​curr_menu''​ global variable via a ''​switch''​ and launches the associated routine accordingly. Each such routine then displays its message and enters a ''​while(true)''​ loop, waiting for user input.
 +  * The menus communicate with each other by altering the values of the global variables and of the static variables from the ''​menus.cpp''​ file.
 +  * The goal was to develop a device as realistic and error-less as possible, so extreme cases are always considered, such that: the user is forced to enter a 4-digit PIN code (is not allowed to submit it until it has 4 digits and cannot input more than 4 digits), the user is always allowed to cancel his current action if he changes his mind, hypothetical error states are checked, sending the system to the ''​ERROR''​ menu if such a case occurs (i.e. if the current menu is the home page of a user, but there is no user logged in).
 +  * ''​enum class''​ have been used for their own namespace feature and for their expressivity compared to numerical constants.
 +
 +===Correctness validation===
 +  * Each component was firstly tested alone to validate that the hardware was functional.
 +  * The system as a whole was incrementally tested, after each new feature added.
 +
 +===Optimizations===
 +  * Because the maximum number of users is 6, their ''​registered''​ status was saved as a single 8-bit variable, using bitwise operations: user i is registered if the i-th bit (from the right) of the variable is 1. If each user had a boolean variable associated for this matter, 6 bytes would have been used in total, instead of 1. Thus, 5 bytes are saved.
 +  * As the available RAM memory is limited, all the menu message strings were stored on the Flash rather than the RAM, via the ''​F()''​ macro. Also, variable types from ''<​stdint.h>''​ were used, for a better control.
 +  * The notifications are encoded for memory efficiency: the ''​Notification''​ struct contains the type (''​RecvFromFriend'',​ ''​FriendReq'',​ ''​ReqAccepted''​),​ the index of the user who sent it and the sum of money sent (used when it is the case).
 +
 +
 +
 +===== Results =====
 +  * The final result is a fully functional, robust device, that encompasses all the proposed features in an intuitive and efficient way, both hardware and software wise.
 +  * [[https://​youtu.be/​4Y1_n8hq_Kc|Demo on YouTube]]
 +
 +
 +
 +===== Conclusions =====
 +  * To sum up, this project achieved its goal of getting hands-on experience with embedded design, from wiring up the components all the way to writing efficient and functional software.
 +  * For me, it was a fun experience with satisfactory results, which I will surely cherish in the future!
  
  
pm/prj2025/iivasciuc/marius.zaharia2305.1747564014.txt.gz · Last modified: 2025/05/18 13:26 by marius.zaharia2305
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