Skip to content

Latest commit

 

History

History
272 lines (186 loc) · 8.38 KB

File metadata and controls

272 lines (186 loc) · 8.38 KB

Hardware Communication Protocol

University project implementing a custom bidirectional communication protocol between programmable hardware devices.

The project explores how data can be transmitted without relying on an existing communication protocol such as UART, SPI, or I²C. Messages are split into small bit fragments, synchronized through a clock signal, protected with CRC32, and exchanged through digital input and output pins.

Two hardware configurations were implemented:

  1. B15F-to-B15F communication between two computers
  2. B15F-to-Arduino communication, with the Arduino output monitored through a serial receiver

The project was developed as part of a university hardware programming course.

What the project demonstrates

The implementation covers:

  • communication through hardware registers and digital pins
  • automatic coordination between two communicating devices
  • clock-based synchronization
  • message fragmentation into 2-bit data units
  • control and acknowledgement signals
  • CRC32 error detection
  • packet retransmission when acknowledgement is missing
  • simultaneous sending and receiving
  • serial communication between an Arduino and a Linux computer
  • low-level device access in C++ using POSIX APIs

Communication variants

B15F-to-B15F

This variant connects two B15F boards, each attached to a separate computer.

The same program is started on both computers:

PC 1                 PC 2
┌──────────────┐     ┌──────────────┐
│ B15F program │     │ B15F program │
└──────┬───────┘     └──────┬───────┘
       │                    │
   ┌───▼───┐            ┌───▼───┐
   │ B15F  │◄───────────►│ B15F  │
   └───────┘            └───────┘

The devices determine their roles from the available clock signal. One device provides the clock and acts as the master, while the second device connects as the slave.

Both sides use the same communication logic and can exchange data through the connected hardware pins.

The implementation is located in:

src/b15f/b15f_peer_communication.cpp

Received message and CRC bit streams can be written to the results/ directory for later inspection.

B15F-to-Arduino

This setup uses a B15F board on one computer and an Arduino on the other.

PC 1                                  PC 2
┌───────────────────────────┐         ┌──────────────────────────┐
│ b15f_arduino_communication│         │ arduino_serial_receiver  │
└─────────────┬─────────────┘         └────────────┬─────────────┘
              │                                    │ USB serial
          ┌───▼───┐                            ┌───▼─────┐
          │ B15F  │◄──────────────────────────►│ Arduino │
          └───────┘                            └─────────┘

On the first computer, the B15F communication program is started:

src/b15f/b15f_arduino_communication.cpp

On the second computer:

  1. the Arduino sketch is uploaded to the Arduino,
  2. the Arduino is connected through USB,
  3. the serial receiver reads and displays its output.

The Arduino sketch is located in:

src/arduino/arduino_communication.ino

The serial monitoring program is located in:

src/b15f/arduino_serial_receiver.cpp

The serial receiver does not participate in the hardware protocol itself. It reads the diagnostic and received data that the Arduino sends through its USB serial connection.

Protocol overview

Messages are divided into small packets before transmission.

Each byte is split into four 2-bit fragments. An additional control bit is used to identify protocol states such as the beginning or end of a packet.

A simplified transmitted unit is:

┌─────────────┬───────────┐
│ Control bit │ Data bits │
│      1      │     2     │
└─────────────┴───────────┘

The protocol uses separate signals for:

  • data
  • clock synchronization
  • control states
  • acknowledgement

For each message block:

  1. input data is divided into packets,
  2. each byte is split into 2-bit fragments,
  3. a CRC32 checksum is calculated,
  4. message fragments and checksum fragments are transmitted,
  5. the receiver validates the data,
  6. an acknowledgement is returned,
  7. packets without acknowledgement can be transmitted again.

Project structure

.
├── src/
│   ├── arduino/
│   │   └── arduino_communication.ino
│   │
│   └── b15f/
│       ├── b15f_peer_communication.cpp
│       ├── b15f_arduino_communication.cpp
│       └── arduino_serial_receiver.cpp
│
├── test_data/
│   ├── master_input.txt
│   └── slave_input.txt
│
├── results/
│   └── .gitkeep
│
├── .gitignore
└── README.md

Requirements

The required hardware depends on the selected communication variant.

B15F-to-B15F

Hardware:

  • two computers
  • two B15F boards
  • physical connections between the B15F input and output pins

Software:

  • Linux environment on both computers
  • C++ compiler with C++17 support
  • B15F library and development headers
  • access to the B15F hardware interface

The same b15f_peer_communication program must be built and started on both computers.

B15F-to-Arduino

Hardware:

  • two computers
  • one B15F board
  • one Arduino-compatible board
  • USB connection for the Arduino
  • physical connections between the Arduino and B15F pins

Software on the B15F computer:

  • Linux environment
  • C++ compiler with C++17 support
  • B15F library and development headers

Software on the Arduino computer:

  • Arduino IDE or Arduino CLI
  • compiler support for the selected Arduino board
  • Linux environment for the serial receiver

Serial receiver

The serial receiver uses /dev/ttyUSB0 by default:

./arduino_serial_receiver

A different serial device can be supplied as an argument:

./arduino_serial_receiver /dev/ttyUSB1

The user must have permission to access the selected serial device.

Depending on the Linux configuration, this may require membership in the dialout group.

Building

The B15F programs must be compiled in an environment where the B15F library and headers are installed.

They require C++17 because the project uses standard-library functionality such as filesystem paths.

The exact linker configuration depends on the B15F environment provided by the university hardware setup.

The Arduino program can be compiled and uploaded with the Arduino IDE or Arduino CLI.

Running the project

B15F-to-B15F

On both computers:

  1. connect the two B15F boards,
  2. build b15f_peer_communication.cpp,
  3. start the program on both systems,
  4. enter data on either computer,
  5. inspect the console output and generated result files.

The program started first without detecting an existing clock becomes the clock-providing side. The other instance connects to the existing signal.

B15F-to-Arduino

On the Arduino computer:

  1. upload arduino_communication.ino,
  2. connect the Arduino through USB,
  3. start arduino_serial_receiver.

On the B15F computer:

  1. connect the B15F board to the Arduino pins,
  2. build and start b15f_arduino_communication,
  3. enter the data to transmit.

Results

Generated communication output is stored in:

results/

These files are runtime artifacts and are therefore excluded from version control.

The directory itself remains in the repository through .gitkeep.

Technical notes

This repository represents the final state of an experimental university hardware project.

The communication protocol was developed iteratively and tested directly on the available B15F and Arduino hardware. Some timing values are therefore closely related to the original physical setup and may require adjustment when using different boards, wiring, or execution environments.