Serial Communication problem (read other topics but still have the problem)


Closed Thread
Results 1 to 9 of 9
  1. #1
    Jcee324's Avatar
    Jcee324 Guest

    Default Serial Communication problem (read other topics but still have the problem)

    Hello

    I have a problem with serial communication between two PIC-
    processors, one PIC16F84A and one PIC16F627. I uses the commands SerIn2 and SerOut2. One-way communication works fine, I can send a signal from one PIC to the other (SerIn2 on the 16F84A and SerOut2 on the 16F627) but when I tries to use both commands on both PIC's at the same time and so get a two-way communication everything stop working. Does anyone know what I can do to create a two-way serial communication between the processors?

    Another small question. Can a PIC and a BasicStamp communicate
    useing SerIn/SerOut? And has any of you used Parallax BOE-Bot? I am
    planing of maybe buying one, is it worth the money?

    Thanks for the help.
    \Jonas
    http://www.geocities.com/jcee324/eindex.htm

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


    Did you find this post helpful? Yes | No

    Default

    Hello Jcee,

    Jc>>I have a problem with serial communication between two PIC-
    processors, one PIC16F84A and one PIC16F627. I uses the commands SerIn2 and SerOut2. One-way communication works fine, I can send a signal from one PIC to the other (SerIn2 on the 16F84A and SerOut2 on the 16F627) but when I tries to use both commands on both PIC's at the same time and so get a two-way communication everything stop working.<<

    Well, you have step one going! This is important. communication in one direction. Yes, everything will stop working. One serial communication must be completed before the response is sent from the other chip. The Serin takes control of that one pin, and must finish its job before a Serout take place.

    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
    Jcee324's Avatar
    Jcee324 Guest


    Did you find this post helpful? Yes | No

    Default

    Hello

    Thanks Dwayne, I understand that you can't send in two directions at once on the same pin. But I want to communicate one way on one pin and the other way on another pin. Is that possible?

    \Jonas
    http://www.geocities.com/jcee324/eindex.htm

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


    Did you find this post helpful? Yes | No

    Default

    Hello Jcee,

    Jcee>>Thanks Dwayne, I understand that you can't send in two directions at once on the same pin. But I want to communicate one way on one pin and the other way on another pin. Is that possible?<<

    It certainly is, as long as it is not at the "exact" same time.

    In other words, there should be a "trigger" byte to tell the other chip to send or receive. That trigger byte can be on the "transmit pin", or be part of the receive pin. (Depending on how you want it.)
    thus it will talk back and forth just like a walkie talkie. (not like a cell phone).

    Serin2 has a timeout value thus both chips can be in a loop.

    tell us how you want it to work, maybe we can puts some code out there for you...

    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
    Jcee324's Avatar
    Jcee324 Guest


    Did you find this post helpful? Yes | No

    Default

    Hello

    Well Dwayne, for the moment I don't know exactly how I want it to work. But I you (or someone else) could put a code together that just makes it possible to send a byte between the PICs (one message and one answer) it would be great, I have tried myself now a couple of days but not geting it to work. I want a continual communication (not just one message and one answer and thats it but that the PICs communicate the whole time) if it's possible.

    Thanks alot!
    \Jonas
    http://www.geocities.com/jcee324/eindex.htm

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


    Did you find this post helpful? Yes | No

    Default

    Hello Jcee,

    JCee>>Well Dwayne, for the moment I don't know exactly how I want it to work. But I you (or someone else) could put a code together that just makes it possible to send a byte between the PICs (one message and one answer) it would be great, I have tried myself now a couple of days but not geting it to work. I want a continual communication (not just one message and one answer and thats it but that the PICs communicate the whole time) if it's possible.<<

    Ok, do you want one chip to be the master? The one that initiates all communication between both chips? (This is the easiest way) Or do you want both to be masters, where either one can initiate communication between each other? (this is harder).

    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...

  7. #7
    Jcee324's Avatar
    Jcee324 Guest


    Did you find this post helpful? Yes | No

    Default

    Hello Dwayne

    Well I think that it would work fine with one master and the other to be slave. Can you have several slaves? Not that I need it but it can be good to know in the future. What is the main difference between the programs if one or both is master?

    \Jonas
    http://www.geocities.com/jcee324/eindex.htm

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


    Did you find this post helpful? Yes | No

    Default

    Hello Jcee,

    L>>Well I think that it would work fine with one master and the other to be slave. Can you have several slaves? Not that I need it but it can be good to know in the future. What is the main difference between the programs if one or both is master?<<

    You can easily have several chips being slaves. the master "initiates" the communication, and then the communication starts.

    With only one master, all the other chips are "listening" . With Two masters, both chips must be listening, and be able to transmit too.

    masterchip. Psuedocode.

    TRISA = "%00000001"

    Tx Var Porta.0
    Rx Var Porta.1

    Loop:
    Tx=High 'initiate transmittion
    Pauseus 10 'give time for receiver to switch to receive mode
    Serout Tx, 2400, ["Slave1","T"] 'make sure only Slave1 chip recevies the "T"
    if Rx <> High then Loop 'Slave did not receive the "T";

    Serout Tx,2400,"Transmit all my data here"
    Tx=Low
    end of routine.


    Receiver.

    Same variable setup.
    RxData var byte

    Loop:
    while Rx <> "High" goto Loop;
    Serin Rx,2400,["Slave1",RxData];
    if RxData<>"T" then Loop;
    Serin Rx,2400,receive your data here.
    end routine.

    I am at work, so I can't write the "exact code" but this can give you a idea how to start it. I believe you only have to put the correct format and be running.

    If you notice, this was made for *many* slaves.

    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...

  9. #9
    Jcee324's Avatar
    Jcee324 Guest


    Did you find this post helpful? Yes | No

    Default

    Dwayne, thanks for the code.

    But I seen now that I must have misunderstood you. My program must have two masters. Both chips must be "listening" and be able to transmit as well as receive.

    Thanks again for all help!
    \Jonas

Similar Threads

  1. serial communication problem
    By kindaichi in forum Serial
    Replies: 13
    Last Post: - 11th March 2010, 16:37
  2. Wireless serial communication question
    By Ahmadabuomar in forum Serial
    Replies: 3
    Last Post: - 21st December 2009, 03:49
  3. Serial communication problem
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th July 2004, 14:32
  4. serial communication problem
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th July 2004, 17:41
  5. 16F877, DS18S20 and Serial Comm Problem
    By YellowTang in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2004, 10:36

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