RS485 or is "just" RS232 OK?

Discussion in 'The Projects Forum' started by stirling, Dec 24, 2011.

  1. stirling

    Thread Starter Member

    Mar 11, 2010
    52
    2
    I have a PC setup as a modbus master. I have ONE modbus slave. I'm using modbus RTU over RS232. All works just fine.

    I now want to add a second slave.

    I read the way to do this is to use RS485 - i.e. implement a single to multipoint "network".

    Having read up on RS485 it seems it's "thing" is it allows comms over longer distances than RS232. However, my TWO slaves and the master are physically within a few feet of each other so I had thought of implementing RS485 "in a box" i.e. 3 RS232 ports connected via a "foot long" RS485 but then thought - do I need to do this? - is this overkill? Can I not just connect the two RS232 slaves and the RS232 master "in parallel". There shouldn't be "bus" contention problems at the protocol level because modbus should handle this. BUT - can you do this at the "electrical" level?

    So I guess what I'm asking is can you do this:

    master(com1)(tx) -> RS232(rx)(slave1) -> RS232(rx)(slave2)
    master(com1)(rx) <- RS232(tx)(slave1) <- RS232(tx)(slave2)

    Thanks
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    You can connect RS232(rx)(slave1) and RS232(rx)(slave2) directly to master(com1)(tx).

    The RS232(tx)(slave1) and RS232(tx)(slave2) must be ORed together before sending to master(com1)(rx). This can be done through a diode from each slave tx connected to the master rx input.
     
  3. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    There are two troubles with the "diode or" approach. The first is that the two slaves might both transmit at the same time, and then neither will be heard. I suppose this can be dealt with if the slaves only transmit after being addressed by the master. The other problem is that with diodes in the line, the slaves can send the transmission line high (active, for RS232) but can't pull it low, so maybe you'd need a pulldown resistor to -12V.

    Would it be possible to set up the three units in a loop, so each of them transmits to its neighbor in the clockwise direction? It would mean each slave has to re-transmit data going to or from the master.
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    Yes, I agree with the need for a pull down resistor to -12V.

    If the slaves are properly implemented they should not respond unless they are specifically addressed. Hence there should be no contention so long as no broadcast command is sent.
     
  5. stirling

    Thread Starter Member

    Mar 11, 2010
    52
    2
    Thanks both

    Sounds straightforward enough. BTW you're quite right MrChips, there'll be no time when the two slaves should contend the line because I don't use modbus broadcast in my app.

    A question re: the -12V pulldown. In order to avoid complicating things by having to come up with a -12V rail would the following work? I use MAX232's for both my slave's RS232 to TTL and I use both RS232 inputs but only 1 of the RS232 outputs (tx, rx and DTR). So do you see any reason why I can't use this spare output for the -ve rail for the pulldown? i.e. neatly use the MAX232's on board charge pump.

    EDIT: Or even better - isn't the RTS from the PC's com port at -12(actually -10V) when not used - which I don't.

    Finally - how many slaves can I attach using the diode OR method? (4 would be nice)
     
    Last edited: Dec 24, 2011
  6. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    Ideally, one would hope that there is already a pulldown on the input of the RS-232 receiver at the master. Check the data sheets for this. Or you can install a passive resistor pulldown to -12V on the RS-232 board.
    A final option is to find a RS-232 control signal that is permanently at -12V and connect the pulldown resistor to this. You can also check to see if there is an unused RS-232 transmitter on the chip.

    Edit: I just reread your post. Yes. Use a spare driver and connect the TTL input of the inverting driver to HIGH. This will give you the -12V to which you can connect your pulldown resistor.

    Now we're getting complicated. The problem is not on the diode end of things. It is how many slave(rx) can the master(tx) drive. You would have to look at the loading requirements of each slave(rx) and your baud. What baud are you using?
     
  7. stirling

    Thread Starter Member

    Mar 11, 2010
    52
    2
    Thanks MrChips - this is all beginning to make sense to me. Re: your comment on the master "driving" capability I'm beginning to realize that's perhaps the other thing that RS485 brings to the party. Maybe the "RS485 in a box" IS actually the way to go.

    Anyway re: your question: I'd like the option of potentially going up to 115200 if pos - just so I don't limit my options - however at the moment I'm testing on 9600.

    I have to go and do the Christmas thing now but I'm most grateful for your help if we can continue in a couple of days or so.

    Meanwhile Merry Christmas to you.
     
Loading...