Embedded Systems & RoboticsCompleted
MetroExpress — Ticket Machine
Finite State Machine railway ticketing firmware for ATmega32 with analog quantity selection
SimulIDE Circuit & Peripheral SchematicATmega32 Wiring

Hardware & Peripheral Allocation
Microcontroller:ATmega32
Architecture Pattern:Layered Architecture (App, Controller, Passenger, Logger, HAL, MCAL)
Simulation Environment:SimulIDE circuit with push buttons, LED status array, potentiometer, and serial monitor
Peripheral & Pin Allocation:
- ▹ADC (Channel 0 for potentiometer ticket count selection)
- ▹Timer0 (Periodic tick for inactivity timeout countdown)
- ▹INT0 (External falling-edge interrupt for emergency cancel button)
- ▹USART (Maintenance and audit trail logging at 9600 baud)
- ▹PORTC/PORTD (LED indicators for destination line and dispensing status)
Technical Overview
MetroExpress simulates a self-service railway ticket machine. Developed for DECI Level 5, the firmware emphasizes reliable user interaction through embedded peripherals. The software is organized into distinct sub-modules (App, Controller, Passenger Interface, Logger) built on top of MCAL register drivers.
It features deterministic state management via an FSM, ensuring that passenger actions (destination button presses, quantity adjustment, payment confirmation, or cancellations) only execute when valid for the current state.
Engineering Decisions & Rationale
Why the system is structured this way rather than standard simplifications.
1.Deterministic Finite State Machine (FSM)
To avoid race conditions or invalid transitions, all user inputs are evaluated through an explicit transition matrix.
2.Hardware Interrupt for Emergency Actions
The cancel operation is wired to the ATmega32 INT0 pin, halting transaction processing immediately regardless of current operations.
Key Technical Highlights
- Rigorous Finite State Machine (Idle, Destination Selection, Quantity Input, Payment, Dispense, Cancel)
- Continuous analog sampling using ADC potentiometer to dynamically select ticket counts
- Hardware timer-based inactivity timeout returning the terminal to Idle if abandoned
- External interrupt (INT0) for immediate emergency cancellation and state rollback
- UART audit logger recording transactions, state transitions, and cancellation events
Embedded CATmega32SimulIDEFSMADCTimers & InterruptsCMakeUART