Do a SEARCH on 'manchester' on this forum and all will be revealed.
Do a SEARCH on 'manchester' on this forum and all will be revealed.
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.
Don't bother. If you do not understand this code, there are many other codes doing the same thing. Or better, create your own.Originally Posted by a_critchlow
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
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.
?
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.
Maybe this will help.
I'll skip to the decode routine since you already know how the encode routine works.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
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 ReturnIt is starting at 0.you need to first decode index at zero before you start moving
through the rest of the decoding process
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:
Decode2 works on the 'true' bits that were encoded. Not the inverted bits.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
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.
Bookmarks