Go Down

Topic: Coding/Decoding Manchester (Read 845 times) previous topic - next topic



There is some library to carry out the coding and decoding in manchester code that works for the arduino DUE.



Oct 30, 2018, 02:55 pm Last Edit: Dec 17, 2018, 04:58 am by ard_newbie
I don't know any Manchester library for the DUE, however it should be rather easy to alter a Serialx (x = 1,2,3 or 4) to code/decode with the Manchester method thru a USARTn since, for what I have seen( in Manchester chapter, from page 782 of Sam3x datasheet), only US_MR and US_MAN registers are concerned.

The datasheet states:

When the Manchester encoder is in use, characters transmitted through the USART are encoded based on biphase Manchester II format.

Therefore the first question you have to answer is: does the equipment supposed to communicate with the DUE will be able to use the same Manchester Format ?


Yes, since the idea is to use an Arduino DUE to transmit and another Arduino DUE to receive


Then you could try firstly to alter the code of USART1 and USART2 in the basic sketch below within a single DUE board.

Connect a jumper between RX1 and TX2 and another one between RX2 and TX1, keep Serial1.begin() and Serial2.begin() to initialize a bunch of registers, then alter US_MR and US_MAN of USART0 (Serial1) and USART1(Serial2) as per datasheet.

Code: [Select]

char c = 0;
void setup() {


void loop() {
  String s;
  s = "";

  while (Serial1.available() > 0) {
    c = Serial1.read();
    s += c;

  if (s.length() > 0) {


Ok, it works. Thanks.

I understand that the coding and decoding is done internally. My question is there is some way to get that coding, for example, if Hello is coded by 0101, I can get that 0101.

The idea was to make a LI-FI system, the arduino transmitter transmits the data through a led and the receiver receives the data through a photoreceptor. That's why I need to encode the data and transmit the 0101 and the other Arduino decodes it and gets the Hello.

Any ideas?


I guess if you connect an led to TX1 and a photoresistor to RX2, you will transmit and receive Manchester encoded signals, provided you previously modified the register accordingly.

Page 782:

An example of Manchester encoded sequence is: the byte 0xB1 or 10110001 encodes to 10 01 10 10 01 01 01 10, assuming the default polarity of the encoder. Figure 35-8 illustrates this coding scheme.


Thank you very much for your help.

When you say this "As long as you have previously modified the record accordingly",
Do you mean these registers US_MR and US_MAN?


Yes, mostly US_MR and US_MAN are concerned.

Is it a uni assignment ?


I am reading and testing but I do not know how to configure US_MR and US_MAN, any help? :smiley-confuse:

Go Up