give an address to pic on rs-485 network


Closed Thread
Results 1 to 3 of 3
  1. #1
    russellperry's Avatar
    russellperry Guest

    Default give an address to pic on rs-485 network

    I'm trying to figure out how to put an address in pic by Dip Switch. What I mean is I'm trying to teach pic to determine network address 485 by changing the state of dip Switchs.

    sample request:
    for address 001 - dip switch will be off off off on
    for address 002 - dip switch will be off off on on
    and so on.

    what i am missing is the true table and how to code it in picbasic.

    I sure like a snip of code to understand this issue.

    Does anyone have an idea?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517

    Default Re: give an address to pic on rs-485 network

    Hi,
    Lets say you have the four switches connected to PortB.0 thru PortB.3 and that they pull their respecitve pin high when 'on'. Then all you need to is
    Code:
    Adress VAR BYTE
    TRISB = %00001111    ' lower four bits as inputs, rest as outputs
    Adress = PortB & 15
    At this point the variable Adress will contain the the "value" of the dip switches as coded "in binary" and allows for a total of 16 adresses, 0-15.

    In your example, the first line would be adress 1 but the second would be adress 3 when using the above code.

    /Henrik.

  3. #3
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: give an address to pic on rs-485 network

    Normally rotary BCD selector switches are used.

    Name:  th[5].jpg
Views: 554
Size:  5.2 KB

    This save the user having to work out which dip switches to set to get the required binary value.

Similar Threads

  1. PICs in a RS-485 network?
    By atomski in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 12th November 2011, 10:52
  2. How to make your own PIC network
    By mister_e in forum Code Examples
    Replies: 3
    Last Post: - 22nd November 2009, 02:19
  3. RS 485 network
    By mychangl in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 25th November 2008, 10:35
  4. PIC network over AC 220V
    By boban in forum Schematics
    Replies: 9
    Last Post: - 6th June 2007, 11:31
  5. Slave Databuffer - RS-485 network
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st June 2005, 19: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