0% found this document useful (0 votes)
30 views4 pages

Machester Encoding

Manchester encoding is a digital encoding technique used in communication that encodes both clock and data in the signal. The encoding defines each bit by the direction of transition from low to high or high to low. The program code provided implements functions for encoding and decoding data using the Manchester encoding technique.

Uploaded by

dipti.ghukse.ds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

Machester Encoding

Manchester encoding is a digital encoding technique used in communication that encodes both clock and data in the signal. The encoding defines each bit by the direction of transition from low to high or high to low. The program code provided implements functions for encoding and decoding data using the Manchester encoding technique.

Uploaded by

dipti.ghukse.ds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Manchester Encoding Technique

Theory:

Manchester encoding is a synchronous clock encoding technique used by the physical layer of the Open System
Interconnection [OSI] to encode the clock and data of a synchronous bit stream. The idea of RZ and the idea
of-L are combined in manchester. Different encoding techniques are used in data communication to ensure
data security and transmission speed. Manchester encoding is an example of digital encoding. Because each
data bit length is defined by default, it differs from other digital encoding schemes. The bit state is defined by
the direction of the transition. Bit status is represented in various ways by different systems, although most
systems use 1 bit for low to high transitions and 0 bit for high to low transitions.

Program

#include "Manchester.h"

#include <stdexcept>

#include <sstream>

#include <cstring>

#include <cstdlib>

#ifdef DEBUG

#include <iostream>

#endif

int *Manchester::encode(int *data, int length)

int *output = new int[length * 2];

for (int i = 0; i < length; i++)

// Work out the array indexes to use

int bid = i * 2;
int nbid = bid + 1;

// Get the data

int real = data[i];

int bit = 0;

int nbit = 0;

// Work out what it is

switch (real)

case 0:

bit = MANCHESTER_ZERO[0] - '0'; // Subtract 48 to work out the real value

nbit = MANCHESTER_ZERO[1] - '0';

break;

case 1:

bit = MANCHESTER_ONE[0] - '0'; // Subtract 48 to work out the real value

nbit = MANCHESTER_ONE[1] - '0';

break;

#ifdef DEBUG

std::cout << "[encode] " << real << " [" << bit << nbit << "]" << std::endl;

#endif

output[bid] = bit;

output[nbid] = nbit;
}

return output;

int *Manchester::decode(int *data, int length)

if ((length % 2) != 0)

throw std::range_error("length is not a multiple of 2");

int *output = new int[length / 2];

for (int i = 0; i < (length / 2); i++)

// Work out the array indexes to use

int bid = i * 2;

int nbid = bid + 1;

// Get the data

int bit = data[bid];

int nbit = data[nbid];

// Put the data into a stringstream for comparison

std::stringstream con;

con << bit << nbit;


const char* sbit = con.str().c_str();

int real = 0;

// Compare the data and work out the value

if (strcmp(sbit, MANCHESTER_ONE) == 0)

real = 1;

} else if (strcmp(sbit, MANCHESTER_ZERO) == 0) {

real = 0;

#ifdef DEBUG

std::cout << "[decode] bit: " << bit << nbit << " [" << real << "]" << std::endl;

#endif

output[i] = real;

return output;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy