Neural network-based classification of synthetic UART serial signals using PyTorch.
Inspired by coursework implementing the ATmega8515 USART module at 2400 baud — the synthetic signals mirror real parameters: 8 data bits, even parity, 1 stop bit.
Generates synthetic UART signals and trains a 1D CNN to classify frames into:
| Class | Label | Description |
|---|---|---|
| Valid Frame | 0 | Correctly formed UART frame |
| Parity Error | 1 | Flipped parity bit |
| Framing Error | 2 | Invalid stop bit (0 instead of 1) |
| Noise Burst | 3 | Heavily corrupted signal |
Open a terminal (Command Prompt on Windows, Terminal on Mac/Linux) and run:
python --version
You need Python 3.9 or newer. If you don't have it: → Download from https://www.python.org/downloads/ → During install on Windows, tick "Add Python to PATH"
On Windows:
- Open the
uart_classifierfolder in File Explorer - Click the address bar at the top, type
cmd, press Enter
On Mac/Linux:
cd path/to/uart_classifier
pip install -r requirements.txt
This installs PyTorch, NumPy, matplotlib, and scikit-learn. It may take a few minutes the first time.
python main.py
You will see training progress printed to the terminal.
When finished, two plots are saved to the results/ folder:
training_curves.png— loss and accuracy over epochsconfusion_matrix.png— per-class prediction breakdown
uart_classifier/
├── main.py ← entry point, run this
├── requirements.txt
├── results/ ← plots saved here after running
└── src/
├── data_generator.py ← generates synthetic UART signals
├── dataset.py ← PyTorch Dataset wrapper
├── model.py ← 1D CNN architecture
├── trainer.py ← training loop
└── evaluator.py ← metrics and plots
Training takes ~1–2 minutes on CPU. Typical test accuracy: ~74%.
The model struggles most with parity errors vs valid frames (both have correct framing), which is expected and interesting to discuss.
Developed a Python/PyTorch pipeline for UART signal fault detection using a 1D Convolutional Neural Network. Generated synthetic datasets modelling ATmega8515 USART parameters (2400 baud, even parity), applied full preprocessing–training–evaluation cycle, and achieved ~74% test accuracy across four frame-integrity classes.