RF and Manchester


Closed Thread
Results 1 to 13 of 13

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Here's a simple set of manchester encode/decode routines.
    Code:
    inbyte	VAR	BYTE
    outword	VAR	WORD
    inword	VAR	WORD
    outbyte	VAR	BYTE
    i	VAR	BYTE
    
    Begin:
        CLEAR
        inbyte = 12	       ' byte for test
        GoSub Encode       ' convert to Manchester word
        inword = outword
        GoSub Decode       ' convert from Manchester word
        outbyte = 0
        goto begin
        
    Encode:
    	For i = 0 to 7 ' loop for 8-bits
    	  outword.0[(i*2)] = ~inbyte.0[i] ' Get bit value for bits 0,2,4,6,8,10,14 in outword
    	  outword.0[(i*2)+1] = inbyte.0[i]' Get bit value for bits 1,3,5,7,9,11,13,15 in outword
      	Next i  ' 
    Return
    
    Decode::
    	For i = 0 to 7			' loop for 8-bits
    	  outbyte.0[i] = ~inword.0[i<<1]	' outbyte bits 0-7 = inword bits 0,2,4,6,8,10,14
    	Next i  ' Inverts each 2nd bit position in inword I.E. 01 = 0, 10 = 1
    Return
    Regards,

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

  2. #2


    Did you find this post helpful? Yes | No

    Default

    HI,
    Bruce thank you verymuch,now I can good sleep :-).
    I must now this test !
    Now I understand how word modifier are working.
    Thank you .
    Thank you.

    Regard Pesti.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I have another question Bruce how can I compare 2 or more bytes when I just a example receive from transmitter byte0 = 241 byte1= 246 on the decoder output?
    Can I do that like this:
    if (outbyte = $F1) & (outbyte = $F6) then hserout [outbyte]

    Thanks.
    regard Pesti.
    Last edited by Pesticida; - 1st November 2005 at 13:49.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Pesti,

    Your example should work fine.
    Regards,

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

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,
    I have analysed the data from my transmitter I become this when i push the button:
    24124625025424224224824225424124625025424224224824 2254

    But when I dont push the button ,the receiver send to PIC this"I think this is just noise or Alien data :-)" :
    24224224324124024025525524324124124024025525524324 32412402532402552412402552522472472502502492462552 49244253240244247255245244255255255249248255249244 25524124125524724324324924024024025525324025525424 72432432412402442552552412542552442552552542472432 41241240255250251241242255253246247243241241255253 24724724324124124025525325525125125524124225525325 52422402522492532472432432412412402552552552412402 55254255246247243249243244255240255255240248255252 25425425424324124124425525524925425425225524725524 32552522542462472432412412402552432412482552402482 55251252252254246255248255253244255240255241240255 24624324324124124825524124024325524124024025524025 5251244255244248247255244248"FromHERE2412462502542 42242248242254241246250254242242248242254ToHere"24 224224324124024.............

    I must to filter the data what I need :2412462502542422422482422542412462502542422422482 42254
    I try this: if (outbyte = $F1) & (outbyte = $F6) then hserout [outbyte] but dont work !


    How can I do this Bruce, simple as possible :-)

    Thanks.
    Regard Pesti
    Last edited by Pesticida; - 1st November 2005 at 15:02.

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


    Did you find this post helpful? Yes | No

    Default

    A few things to consider.

    1. If you do not clear a variable it will retain the last value placed in it.
    2. Most inexpensive or sensitive RF receivers will output random noise spikes when the transmitter is idle.

    Try sending data in packets of a specific size, and using some form of synchronization byte at the start of each packet. Receive your data in a specific number of bytes. If the first byte is not the synch value or character, dump the data packet.

    It's rare that you'll see a solid RF application just flinging random data at a receiver.
    Regards,

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

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Did some one know how can I separate from a word bytes,Example :
    I receive with serin 10 bytes,how can i show this bytes with serout.

    Regard Pesti.

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. Manchester Coding / Decodeing for RF Modules
    By charudatt in forum Code Examples
    Replies: 23
    Last Post: - 31st January 2009, 10:51
  3. Serial rf communication
    By tazntex in forum General
    Replies: 8
    Last Post: - 2nd August 2008, 16:27
  4. Problem with manchester code for RF
    By Dhanushka in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 6th August 2007, 11:46
  5. Manchester coding question
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 5th May 2007, 17:35

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