MAX485 node address

Discussion in 'Embedded Systems and Microcontrollers' started by alex4evr, Apr 23, 2010.

  1. alex4evr

    Thread Starter New Member

    Apr 23, 2010
    6
    0
    Dear all;

    I need your help regarding an implementation into an embedded system of an RS485 communication port using the MAX485 microchip. This chip will transmit binary signal (TTL) to a master controller. The network will have multiple slaves with a Max485 for each.

    I need to know how can I assign an address for each slave so the master can identify the slave? Shall I add a PIC (with jumpers for address selection) to each slave in which I will program this address?

    Any ideas/samples please?
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,793
    There are at least two ways to do it.

    1. Use DIP switches. They are easy to identify visually but may not fit on very small boards that need to go into tight spaces
    2. Use the non-volatile memory in the PIC
    You might ask how the non-volatile memory inside the PIC can be set to different node addresses and further how to detect and correct duplicate node addresses.

    Assume that node addresses must be in the range [0..31]
    If you can preload the non-volatile memory when you program the code into the PIC you can assign the node address at this time. You can also make each node default to node address 31. Then make a two node network with the PC and the node whose address you want to change, and change it. Lastly if you implement a duplicate node detection scheme and can identify duplicate nodes by some set of keys other than node address such as company ID, product code, and serial number you can use those keys to tell the node to change its address.

    For duplicate node detection, each node on power up should send out a "Duplicate Node ID Request" and listen for potential responses for some period of time. If it hears no "Duplicate Node ID Response" then it sends out another request and listens for a response. If after two requests with no response it concludes that the are no duplicate node ID's. If however it receives a "Duplicate Node ID Response" it means that some other node has claimed that node address and our node must take itself offline and declare a fault. Fault recovery may be either manual or automated as described above.

    Is that clear or do you require further elaboration?
     
    Last edited: Apr 23, 2010
  3. alex4evr

    Thread Starter New Member

    Apr 23, 2010
    6
    0
    Thank you for your prompt reply;

    Space is not a problem I can go with a DIP switch selectable address with no problem. Indeed what type of PIC shall I use to do all this stuff knowing that the ttl signals am supposed to read comes form an RFID reader. Can you please give more concrete info with sample code?

    Thanking you!
    Alex.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,793
    From the limited information that you have provided I'm not sure I can provide what you are asking for. Reading the switches and implementing the communication is only the tip of the iceberg.

    If you are doing this for yourself then I recommend jumping in with both feet by picking something and running with it. Don't worry about making a suboptimal initial choice; what you learn will prove invaluable as you adapt your plan to meet your requirements.

    If you are doing this for work and there is a "penalty" for a suboptimal choice then that is another matter. In this case you need to spend a considerable amount of time defining the requirements for two reasons:

    1. So we have a chance of helping you
    2. So we know what "DONE" means
    Think about it and get back to us.
     
  5. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    As well as an address, you need to work out a communications protocol so if more than one remote unit transmits at the same time, the PICs buffer the info and send it to the bus one at a time (ie. bus conflict sensing and resolution).

    You need to design a packet or 'frame' format to contain the unit address, data being sent and checksum or CRC to ensure you only use valid data.

    Would you be better off with a CAN based bus? The CAN controllers on the PICs that have them are designed to handle bus contention and some of the addressing part.
     
  6. alex4evr

    Thread Starter New Member

    Apr 23, 2010
    6
    0
    thanks for the suggestions; i will come back once i have the pic and the rs485 port. by the way the rfid module has its proper protocol that i need to buffer to the pic and add the node address to the syntax being buffered and a checksum. what pic do you suggest?

    Alex.
     
  7. alex4evr

    Thread Starter New Member

    Apr 23, 2010
    6
    0
    Hello Guys;

    Am thinking about the following circuit (basic schema). Whay do you think about? What PIC controllers do you suggest? Any programming ideas?

    Thanks in advance.
    AlexisXXX
     
  8. alex4evr

    Thread Starter New Member

    Apr 23, 2010
    6
    0
    Hi,

    I will give more details about the RFID reader. It accepts one byte command (0x52) and will send over its serial port (ttl level) a 6 bytes message corresponding to the transponder tag ID. The serial com parameters are 9600 baud, 8 bits, 1 stop, no parity. There is a CTS control on the RFID unit.

    Though this is a biderctional communication and there will be more than one RFID reader on the rs485 bus that should be identified by a unique address set by the DIP switch (as proposed into my basic circuit schema).

    The host will send a 2 bytes command [node ID][read command (0x52)] on the rs485 bus. The RFID reader that have the DIP switch configuration (jumpers) equal to the node ID will only send the read command byte to the RFID reader.

    The RFID reader will send back a 6 bytes message (which is the TAG ID of the transponder card (5 bytes) plus one acknowledge byte) to which I need to add the node ID in order to make sure that the response message comes from the correct RFID reader.

    Any suggestions or programming hints are wellcomed. I can give more details about the RFID characteristics.

    Thanks;
    AlexXXX.
     
  9. alex4evr

    Thread Starter New Member

    Apr 23, 2010
    6
    0
    Hello;

    Thanks for the suggestion, in fact I am looking for the easiest way to program the pic. I found the PIC18F662 with 2 UARTS, do you have any suggestions, tutorials, hints for programming the PIC? I appreciate your help!

    Thanks;
    AlexXXX
     
  10. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    I don't think you need two PICs. It's easy enough to program a software-based UART into a processor. At least, it's easy if the baud rate isn't too high (9600 is fine) and it's half duplex rather than full duplex. But in this case it seems as if you send one byte to trigger the RFID reader, and then it responds--there's no simultaneous receive and transmit.

    As for setting an address, DIP switches work. It's not an elegant design, but you'd have a visible way of checking what the address is--that can be useful!

    I'd look at the PIC16F690. Very versatile, quite inexpensive.

    By the way, if the RFID readers really operate on a "speak when spoken to" basis, one PIC should be able to interact with more than one of them at a time. If you did that it would reduce the hardware considerably, but the readers would have to be fairly close together to make it possible. With RS485 you have the ability to place the processors, and therefore the readers, a long way apart. So it depends on what you need.
     
Loading...