encode/decode manchester


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Do a SEARCH on 'manchester' on this forum and all will be revealed.

  2. #2
    a_critchlow's Avatar
    a_critchlow Guest


    Did you find this post helpful? Yes | No

    Exclamation ~inword.0[i<<1]

    ive figured out the encoded part but i cant get the decoded part into my head:


    outbyte.0[i] = ~inword.0[i<<1]


    if the counter is at 0, it should put the first bit of the encoded data inversed into the decoded data var. but because of the <<1 it puts the second bit inversed into the first decoded var.




    thanks.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by a_critchlow
    ive figured out the encoded part but i cant get the decoded part into my head:
    Don't bother. If you do not understand this code, there are many other codes doing the same thing. Or better, create your own.

    The idea is this: if you have to send 0 then in manchester you will send 01 pair. If you have to send 1 then in manchester you will send 10 pair.

    So, for the byte

    1 0 0 1 1 0 0 1

    the result would be:

    10 01 01 10 10 01 01 10

    Is it clear now? You can simply do an if-then-else sub routine for the encoder and also the same for the decoder (in reverse of course).

    As Melanie stated, a search will reveal much more. This case is trivial by now...

    Ioannis

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Nicely stated and thanks for spelling it out....at least for me.

    Now that's Manchester for dummies without the gobble dee gook.

    I felt it must have been a 2x code for 1x code or something when I saw it come up in discussions about wireless.

    The opposite of compression? More bits for the same thing?

    I still have some problems with a bit of code that works fine wired but not wireless.

    I would think 2 or 3 qualifiers in a serout string would be good enough for wireless and do the same thing.

    ?

  5. #5
    a_critchlow's Avatar
    a_critchlow Guest


    Did you find this post helpful? Yes | No

    Lightbulb hmm

    yeah i understand how it works, i just dont see how the decoded part of the code works. you need to first decode index at zero before you start moving through the rest of the decoding process. the code says start at counter=0 and move left 1, this does not invert the correct bit.

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Maybe this will help.
    Code:
    Encode:
       For Index = 0 to 7		' loop 8-bits
         Manch.0[(Index<<1)] = ~ByteIn.0[Index] ' Encode bits 0,2,4,6,8,10,12,14 in Manch
         Manch.0[(Index<<1)+1] = ByteIn.0[Index]' Encode bits 1,3,5,7,9,11,13,15 in Manch
       Next Index
       Return
    I'll skip to the decode routine since you already know how the encode routine works.

    Option #1 that you think is wrong.
    Code:
    Decode:
       For Index = 0 to 7   ' loop for 8 bits
         ByteOut.0[Index] = ~Manch.0[Index<<1]' ByteOut=NOT Manch bits 0,2,4,6,8,10,12,14
       Next Index  
       Return
    you need to first decode index at zero before you start moving
    through the rest of the decoding process
    It is starting at 0.

    On the 1st pass through the above loop, when Index = 0, what is the result of Index<<1..?

    Index<<1 is the same as Index*2, and 0 shifted left by 1 or 0*2 is still 0.

    So on the 1st pass through the loop, when Index = 0, ByteOut.0[Index] = ~Manch.0[Index<<1] is working on Manch.bit0.

    Option #2 will also work, but it requires a 2nd bit index pointer.

    Option #2:
    Code:
    Decode2:
       Index2 = 1             ' Bit index pointer for Manch starts at 1 here
       For Index = 0 to 7     ' loop counter & bit index pointer for ByteOut
         ByteOut.0[Index] = Manch.0[Index2] ' ByteOut = ~Manch bits 1,3,5,7,9,11,13,15
         Index2 = Index2 + 2  ' Increment Manch bit index pointer by 2 on each pass
       Next Index             ' I.E. point to bits 1,3,5,7,9,11,13,15 in Manch
       Return
    Decode2 works on the 'true' bits that were encoded. Not the inverted bits.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    a_critchlow's Avatar
    a_critchlow Guest


    Did you find this post helpful? Yes | No

    Smile thanks

    brilliant! thank you very much Bruce, thats the exact answer i was looking for. i see that moving bits left is the same as multiplying.



    thanks again




    andrew.

Similar Threads

  1. 16F84/16F628 and Manchester
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th March 2009, 15:28
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. SERIN2 – SEROUT2 and Manchester mistake.
    By RCtech in forum Serial
    Replies: 8
    Last Post: - 4th September 2007, 22:55
  4. Manchester coding question
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 5th May 2007, 17:35
  5. Help with serin, serout, Manchester encoding
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 5th April 2007, 13:31

Members who have read this thread : 0

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