PIC 2 PIC communication


+ Reply to Thread
Results 1 to 17 of 17
  1. #1
    Mario's Avatar
    Mario Guest

    Exclamation PIC 2 PIC communication

    I am using PIC to PIC communication with the help wireless module TLP/RLP 434A pair from laipac.com. I verified my output from serial transmition from PIC on the oscilloscope using this code.
    ………………………
    ' TX code
    ' OSC 4M
    TRISB=%10000000
    While portb.7 =1
    Serout2 0,16780,($55,$55,"A",170)
    wend
    End
    ……………………..
    My RF component can be viewed using spectrum analyzer and I realize that my transmitter block including PIC and TLP 434A working fine. But in the receiver (RLP 434A) digital and analog output I got garbage.

    So Finally, I decided not to overrun the receiver so I didn't use while in the following code:
    ……………………
    ' TX code
    ' OSC 4M
    TRISB=%10000000
    Serout2 0, 16780, [$55,$55,"A",170]
    End
    …………………..

    But also it is not succeeded…………!!!!!!!!
    Here my code for RX
    ……………………
    ' TX code
    ' OSC 4M
    TRISA=0
    Mydata var byte
    PORTA=0
    Pause 1000
    Serin2 0, 16780, [wait ("A"),Mydata ]
    PORTA = Mydata
    Pause 2000
    End

    I appreciate any kind of help……………………….

  2. #2
    Join Date
    Oct 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Mario,


    Your serin and serout commands are setup for a basic stamp, particularly your baud rates are wrong. You need to read the Pbasic manual and select the proper ones for Melabs Pbasic or Pbasic pro.
    Try changing them to the following.

    Serout2 0,N2400,($55,$55,"A",170)
    Serin2 0, N2400, [wait ("A"),Mydata ]


    Mike

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I'm attempting the same thing with RF PIC-PIC serial communication. Any chance you could clear up a few things for me?

    what is the reason for sending ($55,$55,"A",170) instead of just your data? I take it your data in this case is 170? Also, why is the sent data in curved brackets () and the recieved in square brackets []?

    Thanks

  4. #4
    Mario's Avatar
    Mario Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47
    I'm attempting the same thing with RF PIC-PIC serial communication. Any chance you could clear up a few things for me?

    what is the reason for sending ($55,$55,"A",170) instead of just your data? I take it your data in this case is 170? Also, why is the sent data in curved brackets () and the recieved in square brackets []?

    Thanks
    This $55 just to make you receiver (wake up) ready to receive your valuable data ,so the receiver will wait until it reach to "A" then save whatever you send in the variable....

    actually ,the correct bracket is [] for pic basic pro and () for basic one

  5. #5
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Smile Pic 2 Pic

    Why using SerOut2 and SerIn2?
    The following code works perfect in RF applications, I construct my own transmitter with a BFR92A with a saw resonator and a RR3 receiver module with a range of up to 300M, your qualifier "A" or any other character is adequate handshaking.
    Transmitter:
    SerOut PORTA.6,N1400,["A",data,data,.....]
    Receiver:
    SerIn PORTA.5,N1400,["A"],B0,B1,B2,.... ' depending on how many bites you want to receive

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    If it was as this simple... Manchester and any other method would never exist

    It will depend of tons of elements.. this is why i hate RF stuff.

    Try to keep your lady Happy without any 'Preamble' and good method... May work sometimes...
    Last edited by mister_e; - 17th March 2006 at 00:57.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Talking Steve

    It is that simple and it works every time (klokslag) here is one of those learning opportunities, keep your leads short!

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    In ideal weather, environement it always work... But those ideal conditions are not 100% guarantee... or i live in a really bad country and MUST absolutely move to another to ensure all those Thousands RF-Stuff i design will always work... problem-free by using your method.

    OUfs at least i'd never had to spend more than 50 000$ for any IFR spectrum Analyser/Signal Generator and such to analyse/record any site we install those units... I'm just too familiar with RF to know what may happen or not.

    Even worst when you analyse a site for a TV or Music show with over 30 RF frequency to match together in any condition...

    Just kidding Chris, don't take it too hard.
    Last edited by mister_e; - 17th March 2006 at 15:51.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Wink Pic 2 Pic

    Yes Steve I agree with you, where there is modulation, FM or AM but at 1400 baud who is worried about QRM or frequency drift and with a solid state antenna (PCB loop) that $50,000 spectrum analyzer will only pick up the first harmonic.

    PS PS I send my data in a 5X loop one of the streams will be received
    Last edited by ChrisMicro; - 18th March 2006 at 07:15.

  10. #10
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Smile Pic 2 Pic

    Mario
    If you still get garbage try the following
    Transmitter:
    SerOut PORTA.6,N1400,["A",data,data,.....]
    Receiver:
    SerIn PORTA.5,T1400,["A"],B0,B1,B2,.... '
    Check on your scope if the output of your receiver is the same polarity as the input of your transmitter, if its not you will get garbage
    Last edited by ChrisMicro; - 18th March 2006 at 11:18.

  11. #11
    Mario's Avatar
    Mario Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    If it was as this simple... Manchester and any other method would never exist

    It will depend of tons of elements.. this is why i hate RF stuff.

    Try to keep your lady Happy without any 'Preamble' and good method... May work sometimes...
    If there are many (tons) thing i have to take in consideration to transmite one byte using my TX /Rx ......
    can you specify what these factor to make this thing work.

    1- Do I need another chip or assistance in addition to PIC16f84A (or just I connect the module directly to pic).
    2- Is it a programing (code) problem.
    3-Even when I send 170 decimal which is 0101 0101 in binary (easy for reciver to detect) I'm not receiving any thing.

    by the way I try also to use HT12E /HT12D encoder decoder but it didn't work.

  12. #12
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Cool

    Hi Mario, check your digital output on your receiver with a scope, if there is an output and if the polarity is the same as the input of the transmitter, if I had your E-mail addy then I can send you some schematics with sample code or if you can get to my site, I have some samples there, ask Melanie how to get there (sorry for the poor English)

  13. #13
    Mario's Avatar
    Mario Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ChrisMicro
    Hi Mario, check your digital output on your receiver with a scope, if there is an output and if the polarity is the same as the input of the transmitter, if I had your E-mail addy then I can send you some schematics with sample code or if you can get to my site, I have some samples there, ask Melanie how to get there (sorry for the poor English)

    my e-mail address ( [email protected] ) thanks alot

  14. #14
    smeet's Avatar
    smeet Guest


    Did you find this post helpful? Yes | No

    Default same problem.. pls help

    Hi I am trying to send packets of data using HSErout instead of SErout......The reason being when I try to use serout .. my A/d conversion is not as responsive as in Hserout.


    This is the code I am trying to use.. Pls tell me if this is the right approach or not...

    hserout ["SYNC",B2] using UART and I have also tried software using
    serout2 PORTB.6,T1200,["SYNC",B2]

    here B2 stores the A/d results...

    for serin :

    the hardware code is

    HSERIN 1,Main,[wait ("SYNC"),B0]
    and software is SERIN2 PORTB.4,T1200,10,Main,[wait ("SYNC"),B0]


    Pls reply as I need to get it done today thanks

  15. #15
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Smile Pic 2 Pic

    Hi smeet
    What chip are you using? I believe you are doing an a/d conversion and try to send the conversion.
    How many bites are you trying to send at a time? you can put your bites in an array var. and then send it, if you let me have your Email then I can send you a sample or two and do you realy need to use the UART?
    Here is a 20 bite array sample:
    First define the array as folow:
    L1 VAR BYTE[20]
    SerOut PORTA.6,N1200,["A",L1[0],L1[1],L1[2],L1[3],L1[4],L1[5],L1[6],L1[7],L1[8],L1[9],L1[10],L1[11],L1[12],L1[13],L1[14],L1[15],L1[16],L1[17],L1[18],L1[19]]
    SerIn PORTA.5,N1200,3000,label,["A"],L1[0],L1[1],L1[2],L1[3],L1[4],L1[5],L1[6],L1[7],L1[8],L1[9],L1[10],L1[11],L1[12],L1[13],L1[14],L1[15],L1[16],L1[17],L1[18],L1[19]
    Last edited by ChrisMicro; - 27th April 2006 at 00:59.

  16. #16
    smeet's Avatar
    smeet Guest


    Did you find this post helpful? Yes | No

    Default Re:

    Hi ,

    i am using PIC 16F877A... Ill attach my code hre... Im basically trying to send my A/d bits using a 418 Mhz transmitter... If I do not use HEROUt it really slows down my code as I am not using interrupts... I have not used interrupts bfore and need to get this code working in a day.. I d really appreciate your help... Im attaching my transmission and reception code here... Im trying Manchester encoding here and then transmit those 16 bits... I understand that I can send only 8 bits at a time so do u suggest I serout 2 array byte and serin two at the other end... I noticed you have added N1200 instead of T1200... CAn i use T1200..

    My email is [email protected]

    Part of the Code for serout :

    A: Pause 5
    If ADCON0.2 = 1 Then A

    B0 = ADRESH>>4
    B0=B0<<4
    ADRESH = 0
    ' PORTD=B0

    ADCON0 = %00111001
    Pause 5
    ADCON0.2 = 1

    B: pause 5
    if ADCON0.2 = 1 Then B

    B1 = ADRESH >> 4

    ByteIn = B0+B1

    PORTD = ByteIn

    GOSUB Encode

    'hserout [B2]
    hserout ["A",Manch] // I guess I went wrong here... Can I split Manch as 2 bytes c0 and c1 and use Hserout
    'serout2 PORTB.6,N1200,["A",B2]
    PAUSE 5

    GOTO Main

    Encode:
    for Index = 0 to 7
    if ByteIn.0[Index] = 0 then
    Manch.0[Index*2] = 0
    Manch.0[Index*2+1] = 1
    else
    Manch.0[Index*2] = 1
    Manch.0[Index*2+1] = 0
    endif
    next Index
    For Index = 0 to 7
    Manch.0[(Index*2)] = ~ByteIn.0[Index]
    Manch.0[(Index*2)+1] = ByteIn.0[Index]
    'Next Index
    'Return

  17. #17
    smeet's Avatar
    smeet Guest


    Did you find this post helpful? Yes | No

    Default Re:

    I have shown Next Index and Return as commented.. They are not commented though...

Similar Threads

  1. communication of pic 18f4520 and cell phone
    By Alisha in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 11:47
  2. Replies: 11
    Last Post: - 12th July 2008, 02:36
  3. pic to pic communication pic2pic
    By aftab in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th October 2007, 17:16
  4. USB communication with pic
    By Shamir in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th August 2006, 23:43
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts