Multiple PICs on usart network


+ Reply to Thread
Results 1 to 40 of 52

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    Thank you.

    Your replies sent me on search for "rs232 multidrop" and that gave important note.

    "One Master PIC can talk to multiple slaves, but only 1 slave can connect back to Master RX."

    I had missed that fact if it was mentionned in the PBP manual, or anywhere else.

    I've since switched to an alternate solution.

    Thanks!

    Robert

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    This post is for the next guy that tries to do this. A few things I learned:

    - you can put a basic MAX232 on the TX and RX lines and "watch" what is being sent around your network.
    - 4K7 pull-up resistors are good for master and slave RX pins (supposedly only necessary in case PIC is disconnected).
    - a structured approach to communication helps, ie: a PIC address, a command, data and checksum.
    - slaves then look at the PIC address and decide if it applies to them, a "calling all slaves" address is also useful.
    - a local command can help support various processing.
    - data can be as big as you need it.
    - and checksum can be as simple as addition of every byte sent, a word variable has more room.
    - RS232 is great for Master to multiple Slaves, as long as only 1 slave replies back UNLESS:


    Code:
    ...
    TXSTA.5 = 1                                 ' Enable USART TX function
    
    HSEROUT (slave sends reply only when spoken to by master)
    
    TXSTA.5 = 0                                 ' Disable USART TX function
    ...
    There's more than one way to skin a cat, but this was by far the easiest to have more than 1 slave on the MASTER RX line. There may still be an issue with this solution, but I have 6 slaves sharing a master RX line right now and they're all purring nicely.

    Thanks to all that helped me work through this (don't even want to count how many days it took to get this working).

    Robert

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

    Default Re: Multiple PICs on usart network

    The MAX3322E & MAX3323E are designed for this, as well, if using an RS232 transceiver.
    http://www.maximintegrated.com/datas...ce=supplyFrame

  4. #4

    Default Re: Multiple PICs on usart network

    Hi,
    I am assembling this circuit. 1 Week ago i am suffering of the same situation that you have.
    I am conecting 5 PIC 16F690, 1 as master (Tx conected to 4 Rx) and 4 slaves (all tx in parallel with other slaves...)

    If I only conected 2 pics (P2P) all works fine, but adding 1 more, the Tx from 1 slave to master is corrupted.

    I have the solution, can you reply what did you do to solve?


    /jose p

  5. #5

    Default Re: Multiple PICs on usart network

    this is my mail:
    [email protected]

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    Quote Originally Posted by JoseJimenez View Post
    Hi,
    ...can you reply what did you do to solve?
    I have only 1 slave enable the TX line at one time:
    http://www.picbasic.co.uk/forum/show...809#post116809

    Robert

  7. #7
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Default Re: Multiple PICs on usart network

    1. Two Schottky diodes on TX lines could be one solution. This way, one TX line does not effect the other.

    or if not using diodes,

    2. After each Transmit, you may disable USART and make TX pin input pin. When you need to send again, make TX pin an output pin and enable USART, then transmit.
    If one TX line is an input pin, it will not effect the network during the transmission of other TX line.

    These two are only suggestions and are not tested.
    Last edited by sayzer; - 21st February 2013 at 14:12.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    Can't comment on the diodes, but disabling USART also turns off receive. That's why I disabled only transmit.

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    Nope, not my video. That's Jose's and he uses transistors. I preferred a software solution, no extra parts involved.

    All Slaves keep their TX line disabled until they are spoken to by the Master and have to send back a reply.


    Quote Originally Posted by Demon View Post
    This post is for the next guy that tries to do this. A few things I learned:

    - you can put a basic MAX232 on the TX and RX lines and "watch" what is being sent around your network.
    - 4K7 pull-up resistors are good for master and slave RX pins (supposedly only necessary in case PIC is disconnected).
    - a structured approach to communication helps, ie: a PIC address, a command, data and checksum.
    - slaves then look at the PIC address and decide if it applies to them, a "calling all slaves" address is also useful.
    - a local command can help support various processing.
    - data can be as big as you need it.
    - and checksum can be as simple as addition of every byte sent, a word variable has more room.
    - RS232 is great for Master to multiple Slaves, as long as only 1 slave replies back UNLESS:


    Code:
    ...
    TXSTA.5 = 1                                 ' Enable USART TX function
    
    HSEROUT (slave sends reply only when spoken to by master)
    
    TXSTA.5 = 0                                 ' Disable USART TX function
    ...
    There's more than one way to skin a cat, but this was by far the easiest to have more than 1 slave on the MASTER RX line. There may still be an issue with this solution, but I have 6 slaves sharing a master RX line right now and they're all purring nicely.
    ...
    The only addition I would add to my list is using a MAX232 on each PICs for stability when using very long cables. It's not known at this point how "long" a network has to be for USART to become "less reliable".

    My project will communicate underground between the house, garage and shed (at least 100' end to end). I plan on using MAX232 chips; it's not like they are expensive.

    Robert


    EDIT: The existing "fried" commercial alarm system has a MAX232, so it's a known solution.
    Last edited by Demon; - 2nd January 2015 at 16:00.

  10. #10
    Join Date
    Aug 2011
    Posts
    453

    Default Re: Multiple PICs on usart network

    You can't have multiple MAX232's sharing TX and RX lines... the TX signals will conflict.

    Even one output to multiple inputs can easily exceed the device specs since each input has about 5K ohm input resistor.

  11. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604

    Default Re: Multiple PICs on usart network

    Hi,
    This....
    Code:
    TXSTA.5 = 1                                 ' Enable USART TX function
    HSEROUT (slave sends reply only when spoken to by master)
    TXSTA.5 = 0                                 ' Disable USART TX function
    ...is also a bad idea.

    The HSEROUT will load TXREG with the last byte to be sent, then the program continues. If the next line turns off the transmitter the last byte won't be sent properly.

    Poll TXIF to determine when you can turn off the transmitter.

    If this is for anything more than messing around, use RS485 or something designed for the purpose.

    /Henrik.

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    Quote Originally Posted by HenrikOlsson View Post
    ...
    The HSEROUT will load TXREG with the last byte to be sent, then the program continues. If the next line turns off the transmitter the last byte won't be sent properly.
    ...
    Weird, nothing unusual came up when I was doing my tests back then; no bytes lost, no data loss. I'm going to have to test this with a higher volume of data transfer and add the polling of TXIF as you suggest.

    I just read a RS485 app note and my head hurts.
    http://www.analog.com/static/importe...tes/AN-960.pdf

    Robert
    Last edited by Demon; - 2nd January 2015 at 22:59.

  13. #13
    Join Date
    Aug 2011
    Posts
    453

    Default Re: Multiple PICs on usart network

    TXIF only means that you can load the TXREG.

    You need to poll TRMT to know when the byte has been shifted out of the TSR (Transmit Shift Register) and you can disable the output. TRMT gets set halfway into the STOP bit.

Similar Threads

  1. PICs in a RS-485 network?
    By atomski in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 12th November 2011, 09:52
  2. Multiple PICS from Same Crystal?
    By WOZZY-2010 in forum General
    Replies: 2
    Last Post: - 6th February 2010, 15:18
  3. Problems controlling multiple pics
    By gandora in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 29th May 2007, 08:59
  4. Multiple Pics to One serial port
    By Rleonard in forum Serial
    Replies: 1
    Last Post: - 18th January 2007, 18:30
  5. Multiple Data on to USART RX pin
    By Squibcakes in forum Serial
    Replies: 2
    Last Post: - 20th July 2006, 00:37

Members who have read this thread : 13

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