Help with Manchester Encoding


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2007
    Posts
    34

    Default Help with Manchester Encoding

    Hello All,
    A while ago I found a code posted by dhouston for Manchester encoded RF communication. http://www.picbasic.co.uk/forum/showthread.php?t=6261
    I have been trying to compile the code using Microcode Studio and the PBP compiler but have come across some problems.

    The first problem I came across was the PIC fuse settings, the code would not compile when the “@ __config” line was present. I did some searching and found that when using Microcode Studio with PBP, the fuse settings needed to be written differently;

    It is written like this in dhouston’s examples (MPASM);
    <code>@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF</code>

    Converted fuse settings, thanks to Melanie’s Post(PM);
    <code>@ DEVICE PIC12f629, INTRC_OSC_NOCLKOUT
    @ DEVICE PIC12f629, WDT_OFF
    @ DEVICE PIC12f629, PWRT_ON
    @ DEVICE PIC12f629, MCLR_OFF
    @ DEVICE PIC12f629, BOD_ON
    @ DEVICE PIC12f629, CPD_OFF</code>

    I made the changes and removed “CP_OFF” from the code because I don’t think the 12F629 supports that setting. The Transmitter code then compiled successfully with no errors.

    Unfortunately the Receiver code did not compile successfully, it produces the same three errors for both line 41 and 42.

    Line 41: <code>If RF[0]+RF[1]<>&HFF Then init</code>
    Line 42: <code>If RF[2]+RF[3]<>&HFF Then init</code>

    Errors produced by Microcode Studio whilst compiling;
    ERROR Line 41: Bad expression. (RX.pbp)
    ERROR Line 41: Bad expression or missing THEN. (RX.pbp)
    ERROR Line 41: IF without a matching ENDIF. (RX.pbp)
    ERROR Line 42: Bad expression. (RX.pbp)
    ERROR Line 42: Bad expression or missing THEN. (RX.pbp)
    ERROR Line 42: IF without a matching ENDIF. (RX.pbp)

    Can anyone see any problems with the code that could cause such an error? I have attached copies of the full code just in case.

    Thank you all for your help,
    Jeremy
    Attached Files Attached Files
    Last edited by jhorsburgh; - 11th August 2008 at 12:51. Reason: Spelling

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


    Did you find this post helpful? Yes | No

    Default

    try to put the result of the addition into a temp var and then do the comparisson.

    Ioannis

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jhorsburgh View Post
    Line 41: <code>If RF[0]+RF[1]<>&HFF Then init</code>
    Line 42: <code>If RF[2]+RF[3]<>&HFF Then init</code>
    Code:
    	If RF[0]+RF[1]<>&HFF Then init
    	If RF[2]+RF[3]<>&HFF Then init
    What is this?
    I don't see any reference to &H to represent hexadecimal in the PBP manual...Assembler yes, PBP no...
    Code:
    	If ( RF[ 0 ] + RF[ 1 ] ) <> $FF Then init
    	If ( RF[ 2 ] + RF[ 3 ] ) <> $FF Then init

  4. #4
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks Skimask, i made the changes to the code and it compiled with no errors.

    I managed to download the HEX files to both the transmitter and reciever chips and installed them back into the circuit. I connected it to the computer and started HyperTerminal. When i powered the circuit up, Hyperterminal displayed "uB=" three times and then no more information was displayed.

    I am still new to this so i am not sure whether i have stuffed up the circuit or the code. I have attached a copy of the circuit design, can anyone's see anything wrong with it or programmed it incorrectly?

    Thanks again,
    Jeremy
    Attached Images Attached Images   
    Attached Files Attached Files

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jhorsburgh View Post
    I managed to download the HEX files to both the transmitter and reciever chips and installed them back into the circuit. I connected it to the computer and started HyperTerminal. When i powered the circuit up, Hyperterminal displayed "uB=" three times and then no more information was displayed.
    Re-Read your PBP manual SLEEP section VERY VERY carefully.
    Then compare that chapter to your code and you will have your answer.

    I believe that the thread referenced in post #1 is flawed in one particular aspect (it also contain the phrase 'this example has not been tested'), and it is this aspect in which yours is also flawed...
    Last edited by skimask; - 13th August 2008 at 03:59.

  6. #6
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks Skimask, i had to read over the SLEEP definition a couple of times but i got it in the end. The code worked fine when there is a wire between the PIC's but when i use the RF Modules the first signal goes through to the computer but after that only 30% make it.

    I looked around and found that almost all similar project use an external oscillator, so i changed it to external and added leds to both circuits so i know when a signal is sent and recieved. That didn't really do much more than tell me that the reciever wasn't getting the signal.

    Would a preamble be needed to make this more reliable. If so how would i go about doing that?
    Thanks,
    Jeremy

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


    Did you find this post helpful? Yes | No

    Default

    Are your modules capable of sending serial data? If not, then manchester encoding - decoding is a must. Also preamble always needed.

    This case has been brought up many times, just have a look around.

    Ioannis

  8. #8
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thank you all for your help.
    I have moved back to SEROUT/SERIN to keep things simple. The RF seems to be working great, now i just have to get the IR working.

    Thanks Again,
    Jeremy

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


    Did you find this post helpful? Yes | No

    Default

    Serin/Serout has nothing to do with the modules ability to send raw binary or encoded data for Data slicer balancing. Be carefull with that.

    Ioannis

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. SERIN2 – SEROUT2 and Manchester mistake.
    By RCtech in forum Serial
    Replies: 8
    Last Post: - 4th September 2007, 22:55
  3. Help with serin, serout, Manchester encoding
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 5th April 2007, 13:31
  4. Manchester encoding
    By jonathanRF in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th February 2007, 19:05
  5. Manchester encoding
    By jonathanRF in forum Off Topic
    Replies: 3
    Last Post: - 8th February 2007, 18:56

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