Manchester and differential Manchester coded implementation of C program __ Code

Source: Internet
Author: User

// ----------------------------------------------------------------------------     |
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]);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.