Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UART Frame Classifier

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.


What it does

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

Installation

Step 1 — Make sure Python is installed

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"


Step 2 — Open the project folder in a terminal

On Windows:

  1. Open the uart_classifier folder in File Explorer
  2. Click the address bar at the top, type cmd, press Enter

On Mac/Linux:

cd path/to/uart_classifier

Step 3 — Install dependencies

pip install -r requirements.txt

This installs PyTorch, NumPy, matplotlib, and scikit-learn. It may take a few minutes the first time.


Step 4 — Run the project

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 epochs
  • confusion_matrix.png — per-class prediction breakdown

Project structure

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

Expected results

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.


CV project description

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.

About

1D CNN for UART frame fault detection — PyTorch, synthetic ATmega8515 signal pipeline, 4-class classification (valid frame, parity error, framing error, noise burst)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages