// ---------------------------------------------------------------------------- |
Title: Manchester and the implementation of the differential Manchester coding |
Analysis: Manchester code is to the central implementation of each code to jump, the specific code word is expressed as: |
1->10,0->01. |
Difference Manchester Coding Each code element is based on the previous one, in the event of a 1 jump, 0 keep |
If the former is: 01, then 1->10 0->01 |
If the former is: 10, then 1->01 0->10 |
Implementation: Define two arrays, one to place the input to encode the sequence, the other to put the encoded sequence |
// |
// |
// ----------------------------------------------------------------------------
/**/ /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////
Header file
#include < stdio.h >
#include < assert.h >
#include < string. h >
/**/ /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////
Global variables
#define M 10
Int J; An array subscript pointing to the encoded sequence
int i; Array subscript for input code word
int length; Evaluate the length of the input array
/**/ /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////
Parameter table
int Direct_code (char str0[])/Direct encoding
... {
Char Dirct_code[2*m];
memset (DIRCT_CODE,0,2*M);
dirct_code[0]= ' 0 ';
dirct_code[1]= ' 1 ';
j=2;
extern length;
for (i=0;i<length;i++)
... {
Circular entry Data
printf ("Current character are:%c", Str0[i]);
Cyclic treatment, 0->01 1->10
if (str0[i]== ' 0 ') ... {dirct_code[j++]= ' 0 ';d irct_code[j++]= ' 0 ';}
else if (str0[i]== ' 1 ') ... {dirct_code[j++]= ' 1 ';d irct_code[j++]= ' 1 ';}
else ... {printf ("Input error,exit ... ...) "); return 1;} Input error
Data after cyclic processing
printf ("-----");
printf ("After process:%c%c", dirct_code[j-2],dirct_code[j-1]);
}