Prepared by: Ameed Darawsha
Date: May 2, 2026
This project implements a simple simulation of Manchester Encoding using Python. The program reads text from an input file, converts it into binary bits, applies Manchester Encoding, decodes the encoded data back into binary, reconstructs the received file, and compares it with the original input file.
The full project report is available here: docs/report.pdf.
Manchester Encoding is a line coding technique used in digital communication systems. It represents each bit using a transition, which helps the receiver maintain synchronization with the transmitter.
In this project, the transmitter side reads data from input.txt, converts it to
binary, and applies Manchester Encoding. The receiver side decodes the Manchester
data, reconstructs the original file as received_file.txt, and checks whether
the transmission was successful.
This project uses the following mapping:
0 -> 10
1 -> 01
Example:
Binary: 01000001
Manchester: 1001101010101001
The project has two main parts:
- Transmitter side
Input File -> Text -> Bytes -> Binary Bits -> Manchester Encoding
- Receiver side
Manchester Data -> Decoded Bits -> Bytes -> Received File
- Read
input.txtusing UTF-8 encoding. - Remove an extra trailing new line from the input text.
- Convert each character to bytes.
- Convert each byte into an 8-bit binary value.
- Encode each bit using the Manchester rule.
- Decode every Manchester pair back into binary.
- Rebuild the received file from the decoded bits.
- Compare the received file with the original input file.
| Function | Description |
|---|---|
file_to_bits(filename) |
Reads the input file and converts its content into binary bits. |
bits_to_manchester(bits) |
Converts binary bits to Manchester encoded data. |
manchester_to_bits(encoded) |
Decodes Manchester data back into binary bits and counts errors. |
bits_to_file(bits, output_filename, original_size) |
Reconstructs the received file from decoded bits. |
compare_files(file1, file2) |
Checks whether the received file matches the original file. |
.
|-- ManchesterEncoding.py
|-- input.txt
|-- readme.md
|-- docs/
| `-- report.pdf
`-- assets/
`-- images/
|-- binary-conversion.png
|-- bits-to-manchester.png
|-- file-to-bits.png
`-- program-output.png
- Python 3
- No external libraries are required
- Put the text you want to transmit inside
input.txt. - Run the Python file:
python ManchesterEncoding.pyWhen the program runs, it generates these files:
| File | Description |
|---|---|
binary.txt |
Binary representation of the input file. |
manchester.txt |
Manchester encoded output. |
decoded_bits.txt |
Binary data after decoding the Manchester stream. |
received_file.txt |
Reconstructed file at the receiver side. |
These files are generated automatically and are ignored by Git.
Manchester Encoding Project
---------------------------
Input file: input.txt
Output file: received_file.txt
Original bits: 8
Manchester bits: 16
Decode errors: 0
Transmission success: True
The program shows that the transmitted file can be reconstructed successfully when no transmission errors are introduced. Manchester Encoding improves synchronization because every bit contains a transition, but it also doubles the number of bits compared with the original binary data.
The decoder also counts invalid Manchester pairs, such as 00 or 11, as decode
errors.
This project demonstrates the basic transmitter and receiver flow for Manchester Encoding. It converts file data into binary, encodes it, decodes it, rebuilds the received file, and verifies the result by comparing the original and received files.



