RX / TX duo


Closed Thread
Results 1 to 20 of 20

Thread: RX / TX duo

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    76


    Did you find this post helpful? Yes | No

    Default Oops...sorry about the last post

    Sorry Bruce, my browser freaked out for a second and I didn't scroll down to see the rest of your post. Thanks for the help!!

    -Mike

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Nothing wrong with your schematic. Same basic design I use. As far as manchester code...roll your own. You wouldn't like what I'm using, kludged up, works for me, but it's ugly.
    JDG

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


    Did you find this post helpful? Yes | No

    Default

    I rarely use manchester, but here's a simple version you can run with a
    terminal program to see how it works. You can easily change it to work
    with serial comms between two PIC via RF.

    You still want to include a preamble & synch byte before each packet.

    The assembler routine is a slightly modified version of one done by Les
    Johnson a long time ago, and it's very fast.

    This version is for an 18F. Just make the rotate instruction change as shown
    to use it on a 12F or 16F part. You'll want to change banka to bank0 also.
    Code:
    ; Compile with MPASMWIN
    X           VAR BYTE
    Y           VAR BYTE
    BitCount    VAR BYTE banka system ' Bank0 system so we don't need an underscore
    ByteIn      VAR BYTE banka system ' to access BASIC variables from assembler
    ByteOut     VAR BYTE banka system
    Manch       VAR WORD banka system ' Holds manchester encoded word
    Temp        VAR WORD banka system ' Temp var
    CRC         VAR BYTE system
    Enc_Dat     VAR WORD[6]           ' Holds 6 manchester encoded words
        
        GOTO Main   ' Jump over encode/decode routines
        
    ASM  ; Note: For 14-bit core just change Rlcf to Rlf
         ; Manchester encode routine
    _Encode
    	Movlw   8
    	Movwf   BitCount
    E_Repeat
    	Rlcf    ByteIn,F   
    	Btfss   STATUS,C
    	Goto    BitClr     
    BitSet                 
    	Rlcf    Manch,F
    	Rlcf    Manch+1,F
    	bcf     STATUS,C
    	Rlcf    Manch,F
    	Rlcf    Manch+1,F
    	Goto    E_Loop
    BitClr                 
    	Rlcf    Manch,F
    	Rlcf    Manch+1,F
    	bsf     STATUS,C
    	Rlcf    Manch,F
    	Rlcf    Manch+1,F
    E_Loop
    	Decfsz  BitCount,F
    	Goto    E_Repeat
    	Return
    ENDASM
        
    ASM
        ; Manchester decode routine.
    _Decode
    	Movf    Manch+1,W
    	Movwf   Temp+1
    	Movf    Manch,W
    	Movwf   Temp
    	Movlw   8
    	Movwf   BitCount
    Repeat
    	Rlcf    Temp,F       
    	Rlcf    Temp+1,F  
    	Rlcf    ByteOut,F  
    	Rlcf    Temp,F      
    	Rlcf    Temp+1,F   
    	Decfsz  BitCount,F
    	Goto    Repeat
    	Return
    ENDASM
    	
    Main:
        ' Manchester encode ASCII characters "A" to "F"
        Y = 0       ' Start array index pointer at 0
        FOR X = "A" to "F"
         ByteIn = X
         CALL Encode
         Enc_Dat[Y] = Manch
         HSEROUT ["Encoded ",X," = ",IBIN8 X," = ",IBIN16 Enc_Dat[Y],13,10]
         Y = Y + 1  ' Increment array index pointer
        NEXT X
        
        ' Decode & print results
        FOR Y = 0 to 5
         Manch = Enc_Dat[Y]
         CALL Decode
         HSEROUT ["Decoded ",IBIN16 Manch," = ",ByteOut,13,10]
        NEXT Y
        PAUSE 10000
        GOTO Main
        
        END
    Here's the output;

    Encoded A = %01000001 = %0110010101010110
    Encoded B = %01000010 = %0110010101011001
    Encoded C = %01000011 = %0110010101011010
    Encoded D = %01000100 = %0110010101100101
    Encoded E = %01000101 = %0110010101100110
    Encoded F = %01000110 = %0110010101101001
    Decoded %0110010101010110 = A
    Decoded %0110010101011001 = B
    Decoded %0110010101011010 = C
    Decoded %0110010101100101 = D
    Decoded %0110010101100110 = E
    Decoded %0110010101101001 = F

    Manchester does have its advantages, but I rarely use it. A big factor is
    getting the receiver/transmitter in synch.

    Like in my previous post, I would definitely use a preamble followed by a
    synch character. That really makes a big difference.
    Regards,

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

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I was doing some reading awhile back on these various modules using On/Off keying, FSK/ASK, whatever. I can see the modules working fine when only sending small data packets that only end up lasting a few milliseconds (with a good preamble of course). But, from what I've read, it seems that the data slicer will lose it's mind after that especially if the data has a lot of repeating 0's or 1's.
    Correct or wrong?
    JDG

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


    Did you find this post helpful? Yes | No

    Default

    Long periods of 0's will cause problems.

    Short bursts of information like preamble,synch,address,data,checksum etc
    work just fine. The payload is delivered just after everything is stable and in
    synch. Even a few bytes of data with large numbers of 0's works, but you
    wouldn't want to stuff 50 words in there made up of all 0's.

    If you're transmitting long streams of serial data that can vary from all 0's
    to all 1's, then you might want to look into using manchester.

    Here's one example of how a simple remote control encoder works.
    http://www.linxtechnologies.com/docu...datastruct.pdf
    Regards,

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

  6. #6
    Join Date
    Jul 2006
    Posts
    76


    Did you find this post helpful? Yes | No

    Default WAIT(Synch)

    Bruce,
    I didn't read your first post carefully enough. In your receiver code you had the SERIN line say:

    SERIN2 D_IN,BAUD,[WAIT(Synch),ADD_IN1,DAT_IN1,ADD_IN2...]

    What does the WAIT(Synch) line do?

    I appreciate your answering, as this is probably a stupid question.

    Thanks!!

    -Mike

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


    Did you find this post helpful? Yes | No

    Default

    It WAITs for the Synch byte. Look in your PBP manual under SERIN2 for the
    WAIT modifier. This forces the SERIN2 line to wait until this specific byte
    arrives before receiving the rest of the serial packet.
    Regards,

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

Similar Threads

  1. Replies: 67
    Last Post: - 8th December 2009, 02:27
  2. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  3. RX - TX timming
    By ruijc in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th February 2009, 00:06
  4. TX RX Buffer Question
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2005, 01:49
  5. Tx and Rx of Single Pin PIC's
    By Dwayne in forum Code Examples
    Replies: 0
    Last Post: - 26th May 2004, 14:55

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