PIC master slave howto


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Wow That seems like an Awesome Protocol!

    BrianT made a great Protocol! i have a project that could use this idea!

    It depends in wheter you will use several or just one Slave, if you will use several you would have to make a Data Path Access Control (to avoid collision), this is what BrianT made with the Attention pin. If on the other hand your are using just one slave you can do so many things!! I have even done it with Serout and Serin Commands! But i will definitively recommend you using serial port and interrupts.

    A nice protocol for communication is used in one of Microchips AppNotes, the one with the Serial Bootloader for 18F and 16F devices (dont remember the number right now, easy to find on their webpage), in that protocol you can find that they try to connect a uC with a PC in both ways, it uses CRC and even an autobaud function. Pay attention to the packet they form it is simple just 4 or 5 extrabytes.

    From my point of view if you really have a "Master" the master can and should control all the communication, slave should just answer to the Masters Request, otherwise it could get tricky (or just trickier).

    The simplest form i have used before was just sending 1byte data from Master to Slave, there you can have 255 orders , but you can get in trouble if the byte gets messed up and the slave ends up receiving garbage.

    Whats i think is better is for you to give us one of your ideas, that way we can tell you pros and cons we find on it.

  2. #2


    Did you find this post helpful? Yes | No

    Default re PIC master slave howto

    Thanks for the reply

    Well as i'm only heving a remote slave and a local master i'm not using any
    bus or adressing, so a 2 wire differential interface in halfduplex is fine

    Here is what I want to do in detail

    Slave site:

    16F88 with 7 AN channels, I use 6 AN channels for voltage measuring 10bit

    Outputs: 1 AN channel (AN6) and one PortB
    Inputs: 4 input pins to read there status
    Bidirectional: 1 1wire port with 1 DS1820 temperature sensor
    RS422 with SP485 level converter using 3 PortB pins: TXD,RXD,TX or RX select

    Master Site

    RS422 with SP485 level converter using 3 PortB pins: TXD,RXD,TX or RX select
    LCD
    Keypad

    The master polls the slave
    and request 6 AN variables in 10bit, requests the status of the 4 input pins,
    request the 1wire temperatur sensor raw value (2 words) or eventually a converted value

    The keyboard allows to toggle both outputs which are "bits" (portb.x)

    So my question is how can I handle this with serin2 at the slave side with the use of "WAIT" i guess ? and if possible with a CRC added
    Can I read all variables in a row or variable by variable , and what if i want to toggle the 2 outputs ?
    Do I need to use an interupt of the buildin uart ? (SP485 is connected to the hardware RXD/TXD)

    Speed will be 9600 8N1

    Thanks

  3. #3


    Did you find this post helpful? Yes | No

    Default

    re PIC master slave howto

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

    Thanks for the reply

    Well as i'm only heving a remote slave and a local master i'm not using any
    bus or adressing, so a 2 wire differential interface in halfduplex is fine

    Here is what I want to do in detail

    Slave site:

    16F88 with 7 AN channels, I use 6 AN channels for voltage measuring 10bit

    Outputs: 1 AN channel (AN6) and one PortB
    Inputs: 4 input pins to read there status
    Bidirectional: 1 1wire port with 1 DS1820 temperature sensor
    RS422 with SP485 level converter using 3 PortB pins: TXD,RXD,TX or RX select

    Master Site

    RS422 with SP485 level converter using 3 PortB pins: TXD,RXD,TX or RX select
    LCD
    Keypad

    The master polls the slave
    and request 6 AN variables in 10bit, requests the status of the 4 input pins,
    request the 1wire temperatur sensor raw value (2 words) or eventually a converted value

    The keyboard allows to toggle both outputs which are "bits" (portb.x)

    So my question is how can I handle this with serin2 at the slave side with the use of "WAIT" i guess ? and if possible with a CRC added
    Can I read all variables in a row or variable by variable , and what if i want to toggle the 2 outputs ?
    Do I need to use an interupt of the buildin uart ? (SP485 is connected to the hardware RXD/TXD)

    Speed will be 9600 8N1

    Thanks



    Quote Originally Posted by Josuetas View Post
    BrianT made a great Protocol! i have a project that could use this idea!

    It depends in wheter you will use several or just one Slave, if you will use several you would have to make a Data Path Access Control (to avoid collision), this is what BrianT made with the Attention pin. If on the other hand your are using just one slave you can do so many things!! I have even done it with Serout and Serin Commands! But i will definitively recommend you using serial port and interrupts.

    A nice protocol for communication is used in one of Microchips AppNotes, the one with the Serial Bootloader for 18F and 16F devices (dont remember the number right now, easy to find on their webpage), in that protocol you can find that they try to connect a uC with a PC in both ways, it uses CRC and even an autobaud function. Pay attention to the packet they form it is simple just 4 or 5 extrabytes.

    From my point of view if you really have a "Master" the master can and should control all the communication, slave should just answer to the Masters Request, otherwise it could get tricky (or just trickier).

    The simplest form i have used before was just sending 1byte data from Master to Slave, there you can have 255 orders , but you can get in trouble if the byte gets messed up and the slave ends up receiving garbage.

    Whats i think is better is for you to give us one of your ideas, that way we can tell you pros and cons we find on it.

Similar Threads

  1. Reading a slave USB with a pic
    By pcaccia in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th October 2008, 13:00
  2. Master to slave 16F767
    By sachymo in forum General
    Replies: 6
    Last Post: - 3rd June 2008, 21:22
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 20:33
  4. Replies: 2
    Last Post: - 10th June 2005, 03:34
  5. 256 Pics Communicate to 1 Master Pic
    By mazlan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th July 2004, 14:11

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