16F84/16F628 and Manchester


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2007
    Location
    Mississauga, Ontario, Canada
    Posts
    29

    Default 16F84/16F628 and Manchester

    Hi all...

    OK, OK... I realize that the Manchester topic has been beaten to death here. I promise you that I've read pretty much every post on it but I still have questions and I hope some of you will steer me in the right direction.

    Here is the deal: I'm trying to design a wireless link between two PIC devices using a 433 MHz RF module. Device1 will be sending information such as temperature, garage door status, garage lights status, etc, to Device2.

    Initially I was going to make life simple and modulate the RF TX by a PIC serial port and send out your typical ASCII type data, but then I stumbled across some information on the benefits of Manchester coding and decided to go with that instead.

    Since I have an abundance of 16F84 and 16F628 chips, I'd prefer to concentrate on those as much as possible.

    Here are some of the questions that linger:

    1. I've noticed some examples here make use of HSEROUT/HSERIN commands. I tried writing the code using these and the program (Microcode Studio with PBP) would not compile it. Subbing these commands for SEROUT/SERIN eliminated these problems. I'm assuming my chips do not support these commands. Am I correct?

    2. OK...old school thinking here. Since each Manchester data word is 16 bits long.... how do I send it out of the PIC that has a start, 8 data byta, stop , parity bits? Some examples here were using SEROUT2 as opposed to SEROUT command and I did some research on those in the Microcode Help file. Am I correct in assuming that SEROUT2 allows to transmit longer data and is not limited to just 8 bits?

    3. I understand that one needs to send out a preamble allowing the receiver to stabilize before it accepts good data. Does the preamble need to be sent out before every data word, or just at the beginning of the entire data sequence?
    If the latter, how does the receiver distinguish between each data word, other than couting the incoming bits? Would it be wise to insert some sort of a control character in front of each data word so the receiver has better time separating one data word from the next?

    I think this is it for now. I'm sure there will be more questions but these three should be enough to get me started.

    Any help would be greatly appreciated.
    Thanks!

    Alex

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Navaidstech View Post
    I promise you that I've read pretty much every post on it
    Seems not...

    Quote Originally Posted by Navaidstech View Post
    1. I've noticed some examples here make use of HSEROUT/HSERIN commands. I tried writing the code using these and the program (Microcode Studio with PBP) would not compile it. Subbing these commands for SEROUT/SERIN eliminated these problems. I'm assuming my chips do not support these commands. Am I correct?
    Correct. Have you read the chips data sheets???


    Quote Originally Posted by Navaidstech View Post
    2. OK...old school thinking here. Since each Manchester data word is 16 bits long.... how do I send it out of the PIC that has a start, 8 data byta, stop , parity bits? Some examples here were using SEROUT2 as opposed to SEROUT command and I did some research on those in the Microcode Help file. Am I correct in assuming that SEROUT2 allows to transmit longer data and is not limited to just 8 bits?
    No. You still send bytes but every data byte is encoded in two Manchester bytes.

    Quote Originally Posted by Navaidstech View Post
    3. I understand that one needs to send out a preamble allowing the receiver to stabilize before it accepts good data. Does the preamble need to be sent out before every data word, or just at the beginning of the entire data sequence?
    Only at the start of the data sequence.

    Ioannis

  3. #3
    Join Date
    Aug 2007
    Location
    Mississauga, Ontario, Canada
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Obviously I missed a few posts.


    Thanks for the info there Ioannis.


    I searched the forum some more this morning and I was able to whip out a tx/rx pair that ALMOST works, based on code tidbits I found..
    At the moment the two modules are connected with wires but once I get the code rectified a bit, I'll move up to RF modules.

    I say "ALMOST" because the tx part seems to be working ok, however the receiver isn't quite there yet.

    Here is the code that I'm using for transmitting (I have observed it on the oscilloscope and it appears to be working):

    dataport var PORTB.0

    START:
    serout2 PORTB.0,813,[$55, $55, $55, $AA]
    mydata = "T"

    dataport = $00
    pause 1000
    goto start


    ENCODEMANCHESTER:
    ManchesterWord=0
    For CounterA=0 to 7
    If MyData.0=0 then
    ManchesterWord.14=1
    else
    ManchesterWord.15=1
    endif
    If CounterA<7 then ManchesterWord=ManchesterWord>>2
    MyData=MyData>>1
    Next CounterA
    serout2 dataport,396,[manchesterword.lowbyte, manchesterword.highbyte]

    Return



    And here is the receiver code:



    RECEPTION var PORTB.0
    INFO VAR PORTB.2
    ERROR var PORTB.1



    START:
    manchesterword=0

    SERIN2 reception, 813, [WAIT($AA),ManchesterWord.LowByte,ManchesterWord.Hi ghByte]
    gosub ManchesterDecode

    goto start

    ManchesterDecode:
    ErrorFlag=0
    For CounterA=0 to 7
    If ManchesterWord.1=0 then
    MyData.7=0
    ERROR = 0
    If ManchesterWord.0=0 then
    ErrorFlag=1
    ERROR = 1
    endif
    else
    MyData.7=1
    ERROR = 0
    If ManchesterWord.0=1 then
    ErrorFlag=1
    ERROR = 1
    endif
    endif
    ManchesterWord=ManchesterWord>>2
    If CounterA<7 then MyData=MyData>>1
    NEXT COUNTERA
    serout2 info, 813, [Mydata]

    Return


    I set PORTB.1 as an indicator telling me whether or not the Manchester code has errors in it... I was monitoring that pin with a scope and not once did it light up, yet I'm getting garbage coming out on pin 2.

    Somehow I'm thinking that the receiver code is missing something but I'm hoping if you guys could point out where the problem lies.

    thanks

    Alex

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    I cannot see how these two pieces of code (tx and rx) can work together.

    Read your code again,or post the working code.

    Or try the untested one that is attached.

    Rename to .bas and burn it.

    Ioannis
    Attached Files Attached Files

  5. #5
    Join Date
    Aug 2007
    Location
    Mississauga, Ontario, Canada
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Of course!

    I'm sending the preamble at a wrong baud rate! DOH!

    Changed it and it works ok now....

    thanks!!!

    Alex

  6. #6
    Join Date
    Aug 2007
    Location
    Mississauga, Ontario, Canada
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Ioannis...

    looks like I jumped the gun there. Your code seems to be working much better than the one I used.

    Thank you for your help. Hopefully I'll be ok from hereon.

    Alex

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Navaidstech View Post
    ...looks like I jumped the gun there...
    ? I am not sure i follow...

    You are welcome!

    Ioannis

  8. #8
    Join Date
    Aug 2007
    Location
    Mississauga, Ontario, Canada
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    In my previous message I indicated that once the baud rate was changed, the original program that I posted was working ok.
    Then I noticed some errors popping up so I decided to delve further into the program... it didn't look right so I decided to use your untested routines and they worked great.

    Thanks again!

Similar Threads

  1. Manchester coding/decoding Code help
    By financecatalyst in forum Code Examples
    Replies: 0
    Last Post: - 25th August 2009, 20:05
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  3. SERIN2 – SEROUT2 and Manchester mistake.
    By RCtech in forum Serial
    Replies: 8
    Last Post: - 4th September 2007, 23:55
  4. Help with serin, serout, Manchester encoding
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 5th April 2007, 14:31
  5. Manchester and baud [II]
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd December 2006, 23:35

Members who have read this thread : 1

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