Help with serin, serout, Manchester encoding


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Posts
    42

    Default Help with serin, serout, Manchester encoding

    I am trying to transmit 4 bits from a TLP-315 transmitter to a RLP-315 receiver for a project. At the receiver, I am taking the four bits and performing some comparisons on it and getting an output. I am using two PIC16F88 microcontrollers. I was wondering whether I coded the Manchester coding and used the serin, serout correct. Also, since I am using Manchester coding, do I have to send a preamble? I have attached my code below.

    'Transmit
    Include "Modedefs.bas"
    v var word 'v is a byte to be encoded
    counter var byte 'counter is a byte
    encoded var word 'encoded is a word sized variable that holds the encoded byte v
    'Code to be transmitted
    v = 1010
    'Manchester Encoding
    For counter = 0 to 3 'number of bits to be encoded (4 bits)
    If v.0[counter]=0 Then
    encoded.0[counter*2]=0
    encoded.0[counter*2+1]=1
    Else
    encoded.0[counter*2]=1
    encoded.0[counter*2+1]=0
    EndIf
    Next counter
    'Serial Out
    serout PORTB.0, n2400, [encoded]


    'Receive

    'Include "Modedefs.bas"
    s var word 's is a byte to be encoded
    B0 var byte 'B0 is a byte
    B1 var byte 'B1 is a byte
    'counter var byte
    encoded1 var word 'encoded1 word sized variable that holds the encoded byte v
    action var byte 'action variable
    alert var byte 'alert variable
    B0=0 'hardwired address
    B1=1 'hardwired address

    'Decoding
    loop:
    serin PORTB.0, n2400, [encoded1]
    For counter = 0 to 3
    s.0[counter]=encoded1.0[counter*2]
    Next counter
    goto loop
    End

    'Tracking code
    If (s.2==0) & (s.3==0) Then 'If the code matches 00 then it is in the tracking mode

    If (s.0==B0) & (s.1==B1) Then 'If the address matches then
    s.2=1 'Change the third bit to 1
    action = s.2
    alert = 0
    serout PORTB.1, n2400, [s] 'Send the changed word back
    Else
    s.2=0 'Since the addresses does not match do not change anything
    action = s.2
    alert = 0
    serout PORTB.1, n2400, [s] 'Send the changed word back
    Endif
    Endif

    'Tracking and Finding code
    If (s.2==0) & (s.3==1) Then 'If the code matches 01 then it is in the tracking and finding mode

    If (s.0==B0) & (s.1==B1) Then 'If the address matches then
    s.2=1 'Change the third bit to 1
    action=s.2
    alert=1
    serout PORTB.1, n2400, [s] 'Send the changed word back
    High 2
    Else
    s.2=0 'Since the address does not match do not change anything
    action=s.2
    alert=0
    serout PORTB.1, n2400, [s] 'Send te changed word back
    Endif
    Endif

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by oneohthree View Post
    v = 1010
    For one thing, sending 1010 isn't going to work. 1010 is one thousand and ten, not 10 or $A). You probably want v = %1010.
    Last edited by skimask; - 30th March 2007 at 18:00.

  3. #3
    Join Date
    Mar 2007
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Also, I tested my transmitter and receiver with the microcontrollers. I was able to transmit the 1101 sequence from the transmitter to the receiver. I got the encoded version of the 1101 sequence. But, the microcontroller on the receiver end the serin command does not work for the microcontroller. When I look at the pins where I have serout on I don't see any signal. Did I do something incorrect?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by oneohthree View Post
    But, the microcontroller on the receiver end the serin command does not work for the microcontroller.
    What? Doesn't make any sense...

  5. #5
    Join Date
    Mar 2007
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    I don't know what is wrong either. Somehow the serin command isnt taking the data that I send in from the receiver. I check the output at pin 1 and pin 3 using a logic analyzer and I get nothing. Is there something wrong with my receiver code. Also, should I send data in inverted (n2400) or non-inverted (t2400)?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by oneohthree View Post
    I don't know what is wrong either. Somehow the serin command isnt taking the data that I send in from the receiver. I check the output at pin 1 and pin 3 using a logic analyzer and I get nothing. Is there something wrong with my receiver code. Also, should I send data in inverted (n2400) or non-inverted (t2400)?
    No, I meant your sentence didn't make any sense...

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  4. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

Members who have read this thread : 2

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