Pic To Pic Serial Communication?


Closed Thread
Results 1 to 20 of 20
  1. #1
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Cool Pic To Pic Serial Communication?

    HELLO BOYS!!
    I AM NIKOS FROM GREECE!!!

    I AM A NEW USER OF THE PICBASIC PRO LANGUAGE SO I DO NOT KNOW A LOT ABOUT IT.I USED TO PROGRAM PIC WITH ASSEMPLY.I HAVE READ THE PICBASIC PRO COMPILER BOOK.
    WHAT I AM LOOKING FOR IS A CONSTRUCTION WITH A MASTER PIC 16F84A AND 16 OTHER SLAVES PICS.THE MASTER SHOULD SEND FIRST AN ADDRESS(SERIALLY).ALL SLAVES PIC SEARCH FOR THE RIGHT ADDRESS .ONLY ONE HAS THE RIGHT ADDRESS.AFTER THAT THE MASTER STARTS TO SEND THE INFORMATION TO THE CORECT PIC.


    PLEASE I NEED YOUR HELP!!!!!

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    In the FAQ, there is a section on serial communication with pics.

    Step 1 is getting communication between 2 chips.
    Step 2 is easy too.
    With communication established, you can use SERin and SERout to control which chips receive what. The "Code" string can be 2 charactors chosen specifically for a certain chip. and the data following the code string is your info being sent to the chip.

    So lets start with Step 1 ok? Have you got communication between two chips? Where one will send data, and the other will put the data on a LCD? If you do not have this communication between two chips, you are wasting your time.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    Hello my friend Dwayne,

    NO,I DO NOT HAVE COMMUNICATION BETWEEN THE TWO PICS. A AM LOOKING THE WAY FOR STEP-1&2!! I AM GOING TO USE PIC 16F84A!!I DO NOT THING THAT IS HARD BUT IT IS TOO HARD FOR ME WHO READ THE MANUAL FOR PICBASIC PRO TWO DAYS AGO!!
    I KNOW ONLY ASSEMPLY.

    I AM WAITING YOUR REPLY

  4. #4
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Ngeron,

    Ok Ngeron, First go to the following link, and get a communication link going.

    http://www.picbasic.co.uk/forum/show...=&threadid=579


    The above link is step 1. Attempting step 2 is worthless, unless you have step 1 complete and operating.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  5. #5
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    Hello,

    I read the above link,i make the program as it says,but i have a problem.The pbp find a problem in my program.

    This is:
    'SERout MASTER

    B0 = %00000001
    loop: Serout POTB.0,T2400,[B0] <--- it finds error here
    Pause 100
    goto loop


    ----------------------------------------

    ' SERin slave
    DataRec Var byte
    loop: Serin A0,T2400,DataRec <--- it finds error here
    Serout B0,T2400,DataRec <--- it findserror here
    goto loop



    Where is the fult?
    I want to say also that i use the pbp demo version.

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


    Did you find this post helpful? Yes | No

    Default

    Can be because you don't have do some definessssss

    Code:
    This is:
    'SERout MASTER
    include "modedefs.bas"
    TRISB.0=0
    B0 var byte
    
    B0 = %00000001 
    
    loop: 
         Serout PORTB.0,T2400,[B0]
         Pause 100
         goto loop 
    
    
    ----------------------------------------
    
    ' SERin slave
    include "modedefs.bas"
    
    TRISB.1=1
    A0 var PORTB.1
    
    TRISB.0=0
    B0 var PORTB.0
    
    DataRec Var byte
    
    loop: 
         Serin A0,T2400,DataRec 
         Serout B0,T2400,DataRec  
    
         goto loop
    i don't like to say that but, look into your PBP book in the SERIN/SEROUT section... and do a search within this forum, and on the Melabs website in the code example section.
    Steve

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

  7. #7
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Lightbulb

    I can not use <<include>> in my programm. I use pbp demo and I do not have this permittion!!!


    Can someone help me with the eerors i find?




    This is:
    'SERout MASTER

    B0 = %00000001
    loop: Serout POTB.0,T2400,[B0] <--- it finds error here
    Pause 100
    goto loop


    ----------------------------------------

    ' SERin slave
    DataRec Var byte
    loop: Serin A0,T2400,DataRec <--- it finds error here
    Serout B0,T2400,DataRec <--- it findserror here
    goto loop

  8. #8
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Unhappy

    I mean I can not USE the <<include>>

  9. #9
    badrad's Avatar
    badrad Guest


    Did you find this post helpful? Yes | No

    Default

    did you include the modedefs.bas file? you need that for your serial communications.

    include "modedefs.bas"

  10. #10
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Exclamation

    WHERE IS THE ERROR?THE PBP DEMO VERSION SAID THAT I HAVE A DAD EXPRESION.

    HELP MEEEEEEEEEEEEEE





    TRISB.0=0
    B0 var byte
    B0 = %00000001

    loop:
    Serout PORTB.0,T2400,[B0] <--DAD EXPRESION
    Pause 100
    goto loop

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


    Did you find this post helpful? Yes | No

    Default

    Serout PORTB.0,0,[B0]

    what about now ?!?
    Steve

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

  12. #12
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    hello steve


    what is mean the second 0.this or not the baud rate?

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


    Did you find this post helpful? Yes | No

    Default

    If you don't include "modedefs.bas" the second "0" will refer to T2400 bauds.

    Since you're using the demo, i'm not sure if they include this "modedefs.bas" file. BTW i never place this include, i use specific VAR or i let it like that and i place comment at the right edge of the line.

    Code:
    TRISB.0=0 ' set PORTB.0 as output
    SerPin var PORTB.0 'alias to PORTB.0
    T2400 con 0 ' Alias to 2400 baudrate mode true 
                ' for SEROUT
    
    start:
          serout serpin,t2400,["hello"] ' send hello @2400 bauds
          pause 1000 ' wait 1 second
          goto start
    Steve

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

  14. #14
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    ---------------master pic------------------
    TRISB.0=0

    start:
    serout Potrb.0,0,[1]
    pause 1000
    goto start


    -----------------slave pic---------------------
    DataRec Var byte

    loop:
    Serin PortA.0,0,DataRec
    Serout portB.0,0,[DataRec]

    goto loop


    do you think that is correct?do you thnik that slave pic will recognize the 1?

    thnks for all

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


    Did you find this post helpful? Yes | No

    Default

    Close to be good. The only thing you have to add to the slave PIC, for safety sake, is the TRIS setting.

    Code:
    TRISA.0=1 ' set PORTA.0 as input
    TRISB.0=0 ' set PORTB.0 as output
    
    DataRec Var byte
    
    loop: 
         Serin PortA.0,0,DataRec 
         Serout portB.0,0,[DataRec] 
    
         goto loop
    it can also work without the TRIS setting since SERIN/SEROUT are *suppose* to set TRIS direction... what is to add 2 line to be sure ?!?

    In the Master PIC...
    serout Potrb.0,0,[1]
    typo error PORTB.0

    So if you monitor it at the end you'll send the ASCII 1.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    just a add on to be sure. If you want to test a specific character, the slave can be something like this.

    Code:
    TRISA.0=1 ' set PORTA.0 as input
    TRISB.0=0 ' set PORTB.0 as output
    
    DataRec Var byte
    
    loop: 
         Serin PortA.0,0,[1]
         Serout portB.0,0,["I've receive 1.. yeah!!!"] 
    
         goto loop
    OR

    Code:
    TRISA.0=1 ' set PORTA.0 as input
    TRISB.0=0 ' set PORTB.0 as output
    
    DataRec Var byte
    
    loop: 
         Serin PortA.0,0,DataRec
         if DataRec = 1 then
              Serout portB.0,0,["I've receive 1.. yeah!!!"] 
         else
              Serout portB.0,0,["Bad :-("]
         endif
         goto loop
    Steve

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

  17. #17
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    Dear Dwayne,

    I manage to make a simply conection between two pics!!!!
    That ws the step1.

    Please advise me with the step2.

    many thanks
    Last edited by ngeronikolos; - 4th February 2005 at 17:01.

  18. #18
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    thank you Steve.


    The only problem I face is with the PicBasic Pro Comiler.It is Demo Version.

  19. #19
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Nikilos,

    N>>I manage to make a simply conection between two pics!!!!
    That ws the step1.

    Please advise me with the step2.<<

    Ok, now that you have a simple verifyable connection using SERIN and SERout, lets expand on your SERin and SERout, and use another function of SERin and SERout.

    USE YOUR WORKING PROGRAM that works for you. Steve has helped you remendously. When I talk to you, I will be talking in GENERALIZATION. I do not have a compiler here where I am at right now, so my programs are PSUEDO examples. Use the working example you got from Steve. He have you a couple of working examples, all varied just a little, but still worked.

    ******the following is PSUEDO**********
    Serout PinNumber,Baudrate,["test"],"A";

    Serin PinNumber,Baudrate,["test"], Variable
    LCDout Variable.

    Something like this: (this is very close to the example in the book.)

    SERIN 1,N2400,[“test”],Variable
    ************************************




    What this does, is read pin number "1", and until it receives the filter letters "test" (completely reads *all* the letters test), it will NOT put a character into Variable

    So, if you want to send the word "Hello", your transmitter must send the following data:
    testH
    teste
    testl
    testl
    test0

    The 'test' will be ignored, and the letter following test will be placed in the "Variable".


    With this information, The Master Chip can send any data to any slave chip, by sending the correct "test", or "Code" that corrisponds to the slave chip.

    Slave Chip #1, could have SERIN 1,N2400,[“Slave1”],Variable
    Slave Chip #2, could have SERIN 1,N2400,[“Slave2”],Variable
    Slave Chip #3, could have SERIN 1,N2400,[“Slave3”],Variable

    That way None of the other slaves will respond to any of the other slave chips, as the data is being sent back and forth to the master slave.

    Step 2, is getting the receiver to respond and print only the character after the "filter characters". (In the above case SlaveX is the filter Character, and the letter following the filter characters is what you want to see).

    Since you already have communication between the two chips with the Serin/Serout, you need to use the same command, and make sure you can use the "Filter"

    Remember... 1 step at a time...You have communication, and you can verify it. This is also part of step 1...Changing the program (just a small bit) to enable "Filters" to work.




    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

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


    Did you find this post helpful? Yes | No

    Default

    I just make a new thread in the code example section.

    click here
    Steve

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

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. Replies: 11
    Last Post: - 12th July 2008, 02:36
  3. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  4. Replies: 5
    Last Post: - 20th March 2006, 01:34
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45

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