2
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Chris Stratton Oct 18 '17 at 8:06
  • 2
    \$\begingroup\$ TCP/IP does not control shared bus access; this is done by a lower protocol. \$\endgroup\$ – CL. Oct 18 '17 at 8:37
  • \$\begingroup\$ @ChrisStratton I my case the sensors communicate with a server and each sensor (when it is triggered) can send data asynchronously to the server. \$\endgroup\$ – Cristian M Oct 18 '17 at 9:04
  • 1
    \$\begingroup\$ Go for modbus. 1234567890 \$\endgroup\$ – Gregory Kornblum Oct 18 '17 at 9:18
  • \$\begingroup\$ 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. \$\endgroup\$ – Tut Oct 18 '17 at 10:57
1
\$\begingroup\$

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.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.