Go Down

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

edgar1421

Hello,


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

Thanks.

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 ?

edgar1421

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

ard_newbie

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() {
 
  Serial.begin(250000);
  Serial1.begin(1000000);
  Serial2.begin(1000000);

  Serial2.print("Hello");
}


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

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

  }
  if (s.length() > 0) {
    Serial.println(s);
    Serial2.print(s);
  }
  delay(1000);
}





edgar1421

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?


ard_newbie


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.

edgar1421

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?

ard_newbie


Yes, mostly US_MR and US_MAN are concerned.

Is it a uni assignment ?

edgar1421

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

Go Up