Microcontroller with 2 way paging application problem


Results 1 to 31 of 31

Threaded View

  1. #30
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Delete the colon from the Next counter command!

    Quote Originally Posted by oneohthree View Post
    'Transmitter Code
    Include "Modedefs.bas"
    trisb = 0
    main:
    u var byte : counter var byte : encode var byte : u = %1000
    'u is the byte containing the input in binary, counter is a byte that describes the amount of bits to encode
    'encode is the variable holding the encoded value
    'Manchester encoding
    For counter = 0 to 3
    If u.0[counter]=0 Then
    encode.0[counter*2]=0 : encode.0[counter*2+1]=1 'If it is a zero make the first bit 0 and second bit 1
    Else
    encode.0[counter*2]=1 : encode.0[counter*2+1]=0 'If not then make first bit 1 and second bit 0
    EndIf
    Next counter : <<<<<<<<<<<------- Here!!
    write 0, encode 'Write to EEPROM Location 0
    High 1 'High on Port B Pin 1
    Pause 1000 'Pause
    Low 1 'Low on Port B Pin 1
    serout PORTB.0, n2400, [ $55 , $55 ,$55, $55, $aa , encode ]: 'send out preamble and encoded from Port B Pin 0
    goto main
    You do not need to count the preamble bytes. Just wait for the start character, $AA, and grab the next character


    Quote Originally Posted by oneohthree View Post
    Receiver (434 to 315)
    Include "Modedefs.bas"

    ct55 var byte: encoded1 var byte: s var byte: counter var byte: e var byte: action var byte:
    encoded var byte: encoded2 var byte: action2 var byte: B0 var bit: B1 var bit: B0=1: B1=0
    s=0: e=0: encoded1=0: counter = 0: action=0: action2=0: encoded=0: encoded2=0:

    Main:

    Clr:
    s=0: e=0: encoded1=0: action=0: action2=0: encoded=0: encoded2=0

    Maina:
    ct55=0 'counter for $55 is zero

    ''''''''''''Wait55:
    ''''''''''''serin PORTB.0, n2400, encoded1
    ''''''''''''If encoded1 = $55 Then
    ''''''''''''ct55 = ct55 + 1
    ''''''''''''If ct55 = 4 Then goto Waitaa
    ''''''''''''Else
    ''''''''''''goto Maina
    ''''''''''''Endif
    ''''''''''''goto Wait55

    Waitaa:
    serin PORTB.0, n2400, [($AA)],encoded1
    write 0, encoded1
    I think here you have error in decoding the manchester. I suggest thew following:

    Quote Originally Posted by oneohthree View Post
    For counter = 0 to 3 : s.0[counter] = encoded1.0[counter*2]:Next counter
    write 1,s

    For counter=0 TO 3
    IF encoded1.0[counter*2]=0 Then
    IF encoded1.0[counter*2+1]=1 Then
    s.0[counter]=0
    EndIF
    Else
    s.0[counter]=1
    EndIF
    Next

    e = s: <<<<<<<<<<<<<<<< DO NOT PUT SPACES IN LABELS!!!
    I have no time to follow the rest of your code now. Please try the suggested encoding for the transmission and see how it goes for one direction. Then try it on the other direction and make sure you have good RF com.

    Ioannis
    Last edited by Ioannis; - 20th April 2007 at 07:53.

Similar Threads

  1. PIC KIT 2 writing problem ?
    By KaanInal in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd January 2010, 12:59
  2. Unusual Interrupts Application Problem
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th May 2009, 11:55
  3. Replies: 7
    Last Post: - 15th December 2008, 05:18
  4. PWM Problem
    By cihhan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th June 2008, 18:43
  5. Replies: 18
    Last Post: - 24th January 2008, 22:44

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