This shows you the differences between two versions of the page.
|
pm:prj2026:jan.vaduva:robert.rachieru [2026/05/27 07:15] robert.rachieru [Software Design] |
pm:prj2026:jan.vaduva:robert.rachieru [2026/05/27 12:03] (current) robert.rachieru |
||
|---|---|---|---|
| Line 38: | Line 38: | ||
| | Potentiometer | 10k Ohm Rotary | Menu navigation and mode selection | | | Potentiometer | 10k Ohm Rotary | Menu navigation and mode selection | | ||
| | Power Supply | 12V DC / 2A | Powering motors and logic (via step-down) | | | Power Supply | 12V DC / 2A | Powering motors and logic (via step-down) | | ||
| + | |||
| + | == Assembly == | ||
| + | |||
| + | {{https://ocw.cs.pub.ro/courses/_media/pm/prj2026/jan.vaduva/plotter_asm.jpg?700}} | ||
| == Hardware Implementation Status == | == Hardware Implementation Status == | ||
| Line 125: | Line 129: | ||
| ===== 3. Novelty of the Project ===== | ===== 3. Novelty of the Project ===== | ||
| - | The defining novel element of this software architecture is the **Custom Interrupt-Driven Kinetics Engine**. In standard hobbyist plotters, stepper motors are driven using blocking delay loops (e.g., ''_delay_ms()''), which paralyzes the microcontroller. In this project, the **Bresenham Line Algorithm** is deeply integrated into an AVR Hardware Timer Interrupt Service Routine (ISR). This allows the ATmega2560 to pulse the motors seamlessly in the background at exactly 4,000 Hz, while the main loop simultaneously parses complex G-code, updates the UI, and communicates over Serial without dropping a single physical step. | + | The defining novel element of this software architecture is the **Custom Interrupt-Driven Kinetics Engine**. In standard hobbyist plotters, stepper motors are driven using blocking delay loops (e.g., ''_delay_ms()''), which paralyzes the microcontroller. In this project, the **Bresenham Line Algorithm** is deeply integrated into an AVR Hardware Timer Interrupt Service Routine (ISR). This allows the MCU to pulse the motors seamlessly in the background at exactly 4,000 Hz, while the main loop simultaneously parses complex G-code, updates the UI, and communicates over Serial without dropping a single physical step. |
| ===== 4. Utilization of Laboratory Functionalities ===== | ===== 4. Utilization of Laboratory Functionalities ===== | ||
| Line 137: | Line 141: | ||
| * **Interaction:** The primary infinite loop reads characters from UART and text lines from the SD card. When a coordinate is parsed by the ''gcode'' module, it invokes ''moveTo()''. The ''moveTo()'' function calculates the discrete step vectors and safely loads them into ''volatile'' memory. The ''Timer1'' ISR then automatically takes over, converting those vectors into physical step pulses asynchronously. | * **Interaction:** The primary infinite loop reads characters from UART and text lines from the SD card. When a coordinate is parsed by the ''gcode'' module, it invokes ''moveTo()''. The ''moveTo()'' function calculates the discrete step vectors and safely loads them into ''volatile'' memory. The ''Timer1'' ISR then automatically takes over, converting those vectors into physical step pulses asynchronously. | ||
| * **Validation:** The system was validated progressively. The UART command parser was tested via Serial Monitor for logic verification. The stepper kinetic logic was validated by ensuring no serial buffer overflow occurred during movement. Finally, overall system integration was proven by exporting an SVG file to G-code via CAM software and successfully observing the machine plot mathematically correct curves on paper without stuttering or crashing. | * **Validation:** The system was validated progressively. The UART command parser was tested via Serial Monitor for logic verification. The stepper kinetic logic was validated by ensuring no serial buffer overflow occurred during movement. Finally, overall system integration was proven by exporting an SVG file to G-code via CAM software and successfully observing the machine plot mathematically correct curves on paper without stuttering or crashing. | ||
| + | |||
| + | ===== 6. Finite State Machine (FSM) UI Implementation ===== | ||
| + | To manage the user interface and system modes without blocking the main execution loop, a **Finite State Machine (FSM)** was implemented. The system operates in one of four distinct states at any given time, defined by an ''enum'': | ||
| + | * ''STATE_MAIN_MENU'' | ||
| + | * ''STATE_SD_MENU'' | ||
| + | * ''STATE_TOUCH_DRAW'' | ||
| + | * ''STATE_HOME'' | ||
| + | |||
| + | The FSM is driven by the UART non-blocking parser. When a user issues a command (such as ''SELECT 1'' or ''BACK''), the parser acts as a state transition controller, updating the ''currentState'' variable and setting a ''needsRendering'' boolean flag. The primary infinite loop evaluates a ''switch(currentState)'' statement and routes execution to the appropriate module to redraw the TFT LCD. | ||
| + | |||
| + | This FSM architectural pattern is critical: it prevents the microcontroller from getting trapped in nested sub-menu loops. Because the state machine evaluates and exits rapidly, the main loop is free to continuously poll for new serial commands, read the SD card, and pass coordinates to the interrupt-driven kinetic engine simultaneously. | ||
| + | |||
| + | ==== Bibliography/Resources ==== | ||
| + | |||
| + | Stepper Motor Setup https://www.makerguides.com/drv8825-stepper-motor-driver-arduino-tutorial/ | ||
| + | |||
| + | ILI9486 LCD + SD Reader Datasheet https://datasheet4u.com/datasheets/ILITEK/ILI9486/945603 | ||
| + | |||
| + | FAT32 File System Module https://elm-chan.org/fsw/ff/00index_p.html | ||
| + | |||
| + | Github Project https://github.com/Hatmanul-RRC/ProiectPM-Plotter | ||