How do I send MANCHESTER encoded data over serial comm?
+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french region)
    Posts
    755

    Default How do I send MANCHESTER encoded data over serial comm?

    Hi All,

    I am wondering how I can really send MANCHESTER encoded data over serial comm.

    I'm tuning up a project involving the use of RF modules (such as TLM434) where MANCHESTER coding makes it possible to use them. Actually it works, but not with 100% reliability; in fact, it's much, very much less.

    For any reason, I didn't notice up to now that my MANCHESTER encoded sent data doesn't really look like to be MANCHESTER encoded.

    Name:  MANCHESTER.jpg
Views: 132
Size:  33.4 KB

    Where in the green square I send "U" characters as a preamble (%01010101), the "MANCHESTER encoded" data (see a piece of it in the orange square) shouldn't, IMHO, look like this.

    This is the way I send the data:
    Code:
    ...
    HSEROUT ["UUU!",Encoded,13]
    ...
    ...where Encoded is a WORD variable (containing i.e.: 182 => 10110110 => 1001101001101001).

    MANCHESTER coding should format the data to be at a maximum of two similar logic signals in a row (or I got it wrong).

    Where a "0" or a "1" lasts (in this example @ 4800bps) 0.2ms as seen in the green square, a "00" or "11" MANCHESTER encoded sequence should not be greater than 0.4ms. But, as you can see in the orange square, this low state lasts 0.8ms meaning I send four zeros in a row (!?).

    So, how do I do this?
    Roger

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,671

    Default Re: How do I send MANCHESTER encoded data over serial comm?

    i don't think its possible to send truely manchester encoded 8 bit data through a euart module , for the simple reason that you cannot control the start and stop bits. before i gave up using crappy rf modules always bit banged the manchester or biphase encoded data. reliability was fairly good but reception is processor intensive. if you want easy/100% reliable rf data transmission use something better like rfm69
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,872

    Default Re: How do I send MANCHESTER encoded data over serial comm?

    Maybe not 100% Manchester, as it still includes the start/stop bits of the protocol, but close enough.

    Code:
    for i=0 to 7
       if myarray.i=1 then
            temparray.[i*2]=1:temparray.[i*2+1]=0
       else
            temparray.[i*2]=0:temparray.[i*2+1]=1
        endif
    next i
    Now that way you get your 8 bits into a temp array of 16 bits, manchester encoded and then you can send them over a serial port.

    Ioannis

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    1,671

    Default Re: How do I send MANCHESTER encoded data over serial comm?

    Maybe not 100% Manchester, as it still includes the start/stop bits of the protocol, but close enough.
    maybe mabye not. the whole point of manchester encoding is to reduce the "DC" component of the tx signal to zero so that the AGC of the cheap crappy
    receivers does not cause signal loss by setting itself incorrectly during tx pauses or sustained signal periods . to do it properly the entire tx data "packet" must be encoded as one block not as individual bytes .if you don't do it properly you don't really get any advantage .simple encoding like done in IR controllers is simpler and just as effective but still not achievable from a uart
    This is more entertaining than Free to Air TV

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french region)
    Posts
    755

    Default Re: How do I send MANCHESTER encoded data over serial comm?

    Thank you Ioannis,

    This is the encoding code I already use

    Still trying to make my communication better. Need a little more time...
    Roger

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,872

    Default Re: How do I send MANCHESTER encoded data over serial comm?

    As Richard stated, with USART you will never do that. The point is not to have the same bit repeated (like 1,1 or 0,0). You need to send the zero like 01 and the 1 like 10 and maintain the DC bias of the receiver as close to 1/2 Vcc as possible.

    The stuff has to do with the way the receiver Data Slicer works.

    I had success with the above code over long period of data transmissions.

    Ioannis

  7. #7
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french region)
    Posts
    755

    Default How do I send MANCHESTER encoded data over serial comm?

    Quote Originally Posted by Ioannis View Post
    ...with USART you will never do that
    Ioannis, may I ask what type of transmission you use then - if it is not serial?
    Roger

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,872

    Default Re: How do I send MANCHESTER encoded data over serial comm?

    I output directly the data from the array to the pin.

    This is very easy from the transmitter side but adds a lot of difficulty on the receiver's side since you have to do all the work to decode the incoming data through the noise.

    It needs to include fast interrupts and maybe some assembly.

    Ioannis

  9. #9
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french region)
    Posts
    755

    Default How do I send MANCHESTER encoded data over serial comm?

    Okay, this is what I was assuming.

    I agree with Richard. I have put my cheap modules by side (= dropped into the bin); too much effort to get them deliver something acceptable.

    Name:  IMG_20190103_140851.jpg
Views: 83
Size:  264.9 KB


    ...but adds a lot of difficulty on the receiver's side since you have to do all the work to decode the incoming data...include fast interrupts and maybe some assembly.
    Since I'm quite lazy and most probably not enough skilled to do all this interrupts and ASM coding, I grabbed a few old LINX rf modules in my drawer and the result is without any surprise.

    Serial data transmission rate up to 9600bps, no MANCHESTER coding - ultra simple, in fact. More expensive but so much more easy to use

    Name:  IMG_20190103_133908.jpg
Views: 89
Size:  220.6 KB


    BTW, in the transmitter's code, I removed any terminator (CR/LF) at the HSEROUT command and this is what I get send 5 zeros MANCHESTER coded:

    Name:  MANCHESTER.jpg
Views: 87
Size:  45.1 KB
    Attached Files Attached Files
    Roger

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,872

    Default Re: How do I send MANCHESTER encoded data over serial comm?

    If you use a modem then there is no point in manchester encoding for your payload. But I am not sure if you are allowed to send non ASCII data over the modems. Maybe you have to convert them to ascii first.

    Say,if your ADC has a value of binary 5 then convert it to ASCII 5, that is 53decimal or 35 hex.

    This means you have to send 3 bytes for the 123 binary data as ASCII 49,50, 51

    Please check the datasheet of your modem about this. Some use non ASCII data to enter configuration mode! This is dangerous.

    Ioannis
    Last edited by Ioannis; - 4th January 2019 at 01:31.

Similar Threads

  1. Replies: 9
    Last Post: - 27th August 2008, 21:07
  2. Replies: 2
    Last Post: - 24th August 2008, 20:03
  3. Replies: 8
    Last Post: - 22nd July 2008, 20:31
  4. Serial Comm startup
    By ruijc in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th January 2008, 15:20
  5. send serial data to PIC 16f84 ausing VB6
    By win_832001 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th March 2006, 21:14

Members who have read this thread : 22

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts