5

I have to build a sensor network which communicates over a single RS485 bus. The network could have tens of nodes. The problem is that I have to control access to the shared bus and find a way to address each node, similar to TCP/IP. Each sensor (when it is triggered) can send data asynchronously to the server.

Is there a protocol available for a RS485 network? If so, is it free? The protocol would be implemented in a microcontroller.

Can I use a controller with TCP/IP stack?

Has anybody designed such a network? I am curious if my approach is correct in order to know if it's OK to continue on this path or if I have to switch to a different techology.

Cristian M
  • 347
  • 2
  • 13
  • 1
    There are lots of protocols in use - grab a manual for something that speaks RS845 in a shared setting. Typically a master sends out the address of who it wants to talk to, and only that node may reply only then. But a more peer to peer scheme with collision detection and random backoff could be possible. – Chris Stratton Oct 18 '17 at 08:06
  • 2
    TCP/IP does not control shared bus access; this is done by a lower protocol. – CL. Oct 18 '17 at 08:37
  • @ChrisStratton I my case the sensors communicate with a server and each sensor (when it is triggered) can send data asynchronously to the server. – Cristian M Oct 18 '17 at 09:04
  • 1
    Go for modbus. 1234567890 –  Oct 18 '17 at 09:18
  • Collision detection can be difficult (not impossible) with RS485 as neither high nor low are dominant and a device monitoring the bus while transmitting may only see it's own transmission despite a collision with a device down the line. There was an answer here a year or few ago that showed a modification for collision detection. I'll pass on a link if I find it. I've used modbus and added polling based on address dependant timeslots to avoid collisions while determining what slaves were connected. – Tut Oct 18 '17 at 10:57
  • This answer by Dave Tweed may be what I was remembering: https://electronics.stackexchange.com/a/62380/25328 (I haven't tried this) – Tut Oct 18 '17 at 11:09
  • You might consider CAN as an alternative to RS485: https://electronics.stackexchange.com/q/304546/25328 – Tut Oct 18 '17 at 11:20
  • 1
    Many free-to-use protocols are listed at https://en.wikibooks.org/wiki/Embedded_Systems/Common_Protocols ; most of them would work on RS485 physical link hardware. – davidcary Feb 24 '18 at 18:35

1 Answers1

2

I have made a demo about transfer TCP/IP through RS485: https://github.com/dukelec/cdbus_doc

The protocol on RS485 is CDBUS, which could use a standalone controller to solve the collision problem, you can also implement CDBUS protocol by software, or simply don't take care about collision, re-sent packet when data lost was detected.
The CDBUS protocol: https://github.com/dukelec/cdbus_ip

The upon protocol is CDNET, is similar to UDP protocol, you can send UDP packet from MCU by only few line of codes and without any library, but need a gateway to translate CDNET to real TCP/IP protocol. Or you can define your own protocol, and translate them on the gateway.

dukelec
  • 21
  • 2