PIC to PIC TX RX and PIC to PC COM RX ..a little help please


Closed Thread
Results 1 to 40 of 68

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default I have that distance

    Hi Dave Houston

    Thanks million for the reply.

    I have them even farther apart >3m
    If I am closer I receiver more transmitted frames, as I move further so the number decreases.

    I tried the same transmitter and receivers using your code as well but have no success when I use it but it does work when the two PICS are connected by wire !

    I will most certainly try increasing or reducing the range...
    and then update a little later :-)
    I will also try your code using the PIC 12F629's as well

    If you have any more suggestions I would happily try them and submit feedback

    Thanks again

    Dennis

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I think the modules you are using are the same as Bruce sells, the RWS/TWS ones?
    What are you using for an antenna and how long is it? Should be around 6.5 inches. Ground plane? Anything around that could be causing interference? A picture of the setup might help.

    Can you post the code that is sorta working? At this point it could be a number of things. We have to rule out hardware or software.

    Now try to tighten things up a bit.

    Code:
    TRAIN  VAR BYTE
    train =  $B3
    SYNK VAR BYTE
    SYNK = $7E
    
    SEROUT2 PORT??, BAUD?,[TRAIN, SYNK, DEC 23]
    Code:
    SYNK VAR BYTE
    SYNK = $7E
    MYVAR  VAR BYTE
    
    SERIN2  PORT??, BAUD?, [WAIT(SYNK), DEC MYVAR]
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default IT WORKS better than before :-)

    Dave :-)

    It's working like a charm :-)....I think, just getting an

    extra character on every second line :-)
    Range is awesome in the house, reaches all distant corners

    --will do range tests tomorrow and feedback to you.

    Here's the OLD code

    Which worked but wasn't too accurate

    TX CODE
    Code:
    TRAIN	VAR BYTE
    TRAIN=$55
    
    
    hSEROUT [TRAIN,TRAIN,TRAIN,TRAIN,TRAIN,"9",dec 3,$d,$a]
    RX code
    Code:
    HSERIN [WAIT("9"),DEC NET]
    
     HSERout ["I Recived this number ",DEC NET,$d,$a] 'net var 
    
    value should show in hyperterminal
    Heres the NEW TX code
    USING HSER

    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous 
    
    receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 207 ' 2400 Baud @ 32MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    test:
    TRAIN  VAR BYTE
     train =  $B3
     SYNK VAR BYTE
     SYNK = $7E
    
    hserout [TRAIN,SYNK,DEC 23]
    goto test


    and the RX code:

    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous 
    
    receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 207 ' 2400 Baud @ 32MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    test:
    
    high led
    
    hserin [WAIT(SYNK), DEC net]
    
    
    toggle LED
    HSERout ["I Recived this number ",DEC NET,$d,$a] 'net var 
    
    value should show in hyperterminal
    
    goto test


    Here's my receiver output from MCS serial tool window
    Code:
    I Recived this number 2
    I Recived this number 23
    I Recived this number 2
    I Recived this number 23
    I Recived this number 2
    I Recived this number 23
    As you can see I'm receiving DEC 2 and 23.
    Where is the number 2 coming from ?
    Eerie ?

    Now all I need to do is akind of checksum for example, if

    the number 23 is received 3 times then it's a VALID TX.

    Any more optimizations or tweaks I should try ?

    Thanks a million

    Kind regards

    (From a very happy:-))
    Dennis

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    COOL!!!!

    Probably the easiest thing to do for this app would be a simple check.
    Code:
    hserin [WAIT(SYNK), DEC net]
    IF net = 23 THEN ...
    Or build a checksum... but try the above first, keep it simple.
    Last edited by mackrackit; - 6th December 2009 at 04:38.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Dennis, you should remove the DEC command from the HSEROUT see the code below.


    Code:
    A0 var BYTE
    
    A0=23
    'hserout [TRAIN,SYNK,DEC 23]
    hserout [TRAIN,SYNK, A0]
    Al.
    All progress began with an idea

  6. #6


    Did you find this post helpful? Yes | No

    Default Ok will try :-)

    Hi Al

    How are you?

    Thanks for the tip will definitely try it :-)

    Kind regards

    Dennis

  7. #7
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dennis View Post
    I tried the same transmitter and receivers using your code as well but have no success when I use it but it does work when the two PICS are connected by wire !
    If it works wired but not wireless, the most likely explanation is that you have something amiss in the way you have connected the TX/RX modules.

  8. #8


    Did you find this post helpful? Yes | No

    Default uncanny behaviour!!

    Hi Al, Dave and Dave

    This appear to be an HSEROUT issue!!

    When I use HSERIN with a string before the variables like this - check reciver code HSEROUT line
    RECEIVER
    Code:
    'variables begin here
            A0 var byte
            net var byte
            led var PORTD.0
            SYNK VAR BYTE
            SYNK = $7E
    
    'end of variables
    
    test:
    
    hserin [WAIT(SYNK),DEC net]
        
        
        if net = 23 then 
        lcdout "i got 23 "
        toggle LED
        'lcdout $fe,1
        endif
    
     HSERout ["got this",DEC net,$d,$a] 'net var show in hyperterminal 
    
     got test 
    
    end


    TRANSMITTER
    Code:
     'RF variables
     'A0 var BYTE
     'A0=23
      'TRAIN	VAR BYTE
     'TRAIN=$55
     TRAIN  VAR BYTE
     train =  $B3
     SYNK VAR BYTE
     SYNK = $7E
    
     'Variables end here
    
        
    loopy:
    
    high LED '  LED on
    hserout [TRAIN,SYNK,dec 23]
     low led 'LED off
     Goto loopy  ' Go back to loop and blink LED forever
            End
    then the number 23 as well as the number 2 appears !!
    See here:
    Code:
    got this23
    got this2
    got this23
    got this2
    got this23
    got this2
    got this23
    got this2
    got this23
    got this2
    If I remove the string of letters , in this case "got this " then every single received line shows only the number 23 which is what we are expecting to see!
    See here:
    Code:
    23
    23
    23
    23
    23
    3
    23
    23
    23
    23
    23
    23
    PERFECT except for once in a while the occasional number like 2 or 3 shows up!

    And trying Al's suggestion of removing the DEC modifier (only on receiver side and for both hserin and hserout)
    I get this
    Code:
    got this2
    got this2
    got this2
    got this2
    got this2
    got this2
    got this2
    got this2
    Now tell me that's not a strange one


    Now...some really awesome observations from my tests here :

    First off this is working like a charm !
    It's pretty damn close to near perfect in terms of reliable data transfer! (would love any further suggestions re checksums -- I though of something like catching a few instanced of the byte and then accepting it as correct!

    Range is awesome ! Right now, as I am typing this the Transmitter is outside my house at the edge of the property - well over 200m and I have taken it upstairs and downstairs every little nook and cranny and it's still spot on !

    Speed is fantastic - its so fast the led hardly blinks and the MCS serial tool window is filled up in less than a second

    I have both receiver and transmitter hooked up to a 9V battery and then into a 5V regulator with no caps anywhere. My entire house is flooded with 2,4 and 5,8 GHz wireless and there are electrical appliances plentifold.

    If the receiver is left in powered on happily waiting for it's signal , as the transmitter is powered on the receiver has already caught at least 6 bytes :-) ...this is how wireless should be in a perfect world :-)
    I would be happy to report that the combination of train and sync byte are a winner! Spot on Mackrackit - thank you!



    I am extremely happy with verything so far and just want to thank all of you who have guided me with code snippets, corrections and everything else!

    Thank you so much !!

    Dave Houston I will still definitely be getting you code working too, come rain hail or snow!

    All that remain (for now :-)) is the ability to send more than one byte.
    I was thinking 3 bytes. (24 bits total)
    So my question is this:
    Assuming I am to stick with this method , what is the best method (most relaible) to be adding more bytes to be sent ?

    Thanks yet again

    Kind regards

    Dennis

  9. #9
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    ...And trying Al's suggestion of removing the DEC modifier (only on receiver side and for both hserin and hserout)
    Dennis, I suggested you to remove the DEC modifier in Transmitter not in the receiver side.

    The reason is that you Tx a pure ascii code and convert it to decimal at the receiver side, while now you are modifying the byte twice (at Tx & at Rx) and can yield wierd results.

    Al.
    All progress began with an idea

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Thanks Al for pointing out my mistake.

    Dennis,
    Just for fun, send this straight to the terminal, you might find it interesting.
    Code:
    XNUM    VAR BYTE[8]
    XNUM = 225 'CHANGE THIS NUMBER AS NEEDED
    
    SEROUT2 GPIO.5,16780,[TRAIN,SYNK,DEC XNUM.7,DEC XNUM.6,DEC XNUM.5,_
       DEC XNUM.4,DEC XNUM.3,DEC XNUM.2,DEC XNUM.1,DEC XNUM.0,_
       "--",DEC XNUM,$d,$a]
    More bytes?
    SEND
    Code:
        XNUM    VAR BYTE
        YNUM    VAR BYTE
        ZNUM    VAR BYTE
        
        XNUM = 225
        YNUM = 100
        ZNUM = 4
        START:
        SEROUT2 GPIO.5,16780,[TRAIN,SYNK,XNUM,YNUM,ZNUM,$d,$a]
        PAUSE 5000
        GOTO START
    RECEIVE
    Code:
        XNUM    VAR BYTE
        YNUM    VAR BYTE
        ZNUM    VAR BYTE
        
        START:
        SERIN2 GPIO.5, 16780,[WAIT(SYNK),XNUM,YNUM,ZNUM]
        
        SEROUT2 GPIO.4,16780,["X-",DEC XNUM," Y-",DEC YNUM," Z-",DEC ZNUM,$d,$a]
        GOTO START
    Dave
    Always wear safety glasses while programming.

  11. #11


    Did you find this post helpful? Yes | No

    Default ok.... just for fun !

    Al thanks a million for the clarity on that one .. will check and feedback !

    Dave ... ok just for fun so be it !
    And if I get greedy would the Var bytes be num num num ? :-)

    Expect Feedback .. results may vary :-0

    Kind regards

    Dennis

  12. #12


    Did you find this post helpful? Yes | No

    Default working!!

    Hi Dave ;-)

    That TX RX code you passed on works like a charm too X Y and Z coming through clear as day although I changed it for HSERIN and HSEROUT

    Not sure what you want me to try with this code though ??

    [code]
    XNUM VAR BYTE[8]
    XNUM = 225 'CHANGE THIS NUMBER AS NEEDED

    SEROUT2 GPIO.5,16780,[TRAIN,SYNK,DEC XNUM.7,DEC XNUM.6,DEC XNUM.5,_
    DEC XNUM.4,DEC XNUM.3,DEC XNUM.2,DEC XNUM.1,DEC XNUM.0,_
    "--",DEC XNUM,$d,$a]
    [code]

    Did you want me to TX/RX it ? modify and put on send and receive side ?

    Dennis

Similar Threads

  1. Direct PIC to PC without MAX232
    By acjacques in forum Serial
    Replies: 14
    Last Post: - 23rd October 2014, 22:32
  2. Serial VB 2005 pic 16f877a problems
    By Snap in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 8th July 2013, 01:52
  3. PIC or xbee times out after Tx 504 bytes
    By archendekta in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd November 2009, 09:45
  4. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 15:46
  5. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 01:13

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