Skip to main content
Arduino

Return to Answer

Commonmark migration
Source Link

[![RS485 wiring][1]][1]RS485 wiring

[![RS485 demo][2]][2]RS485 demo

[![RS485 moving master schematic][3]][3]RS485 moving master schematic

[![RS485 - one device][4]][4]RS485 - one device

[![RS485 - two devices][5]][5]RS485 - two devices

[![RS485 - three devices][6]][6]RS485 - three devices

This was with the boards still programmed to run at 19200 baud. [1]: https://i.sstatic.net/unAvv.png [2]: https://i.sstatic.net/7Kttu.jpg [3]: https://i.sstatic.net/IbHz8.png [4]: https://i.sstatic.net/3vqnR.png [5]: https://i.sstatic.net/4KZCZ.png [6]: https://i.sstatic.net/gPYau.png

[![RS485 wiring][1]][1]

[![RS485 demo][2]][2]

[![RS485 moving master schematic][3]][3]

[![RS485 - one device][4]][4]

[![RS485 - two devices][5]][5]

[![RS485 - three devices][6]][6]

This was with the boards still programmed to run at 19200 baud. [1]: https://i.sstatic.net/unAvv.png [2]: https://i.sstatic.net/7Kttu.jpg [3]: https://i.sstatic.net/IbHz8.png [4]: https://i.sstatic.net/3vqnR.png [5]: https://i.sstatic.net/4KZCZ.png [6]: https://i.sstatic.net/gPYau.png

Added notes about testing a long cable run.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125

RS485 wiring [![RS485 wiring][1]][1]

RS485 demo [![RS485 demo][2]][2]

RS485 moving master schematic [![RS485 moving master schematic][3]][3]

RS485 - one device [![RS485 - one device][4]][4]

RS485 - two devices [![RS485 - two devices][5]][5]

RS485 - three devices [![RS485 - three devices][6]][6]


Cable run test

For a proper hardware test, I connected the devices up to my in-house UTP cabling. I have cat-5 cable running from various rooms to a central plug-board. Going from one end of the house to another (a reasonable length run) it still works fine. There is 5 m cable between the Arduino and the wall socket, for a start. Plus another 5 m cable at the other end. Then there are about 2 x 15 m runs from the rooms to the switch room, and inside that there is a short bridging cable to connect them together.

This was with the boards still programmed to run at 19200 baud. [1]: https://i.sstatic.net/unAvv.png [2]: https://i.sstatic.net/7Kttu.jpg [3]: https://i.sstatic.net/IbHz8.png [4]: https://i.sstatic.net/3vqnR.png [5]: https://i.sstatic.net/4KZCZ.png [6]: https://i.sstatic.net/gPYau.png

[![RS485 wiring][1]][1]

[![RS485 demo][2]][2]

[![RS485 moving master schematic][3]][3]

[![RS485 - one device][4]][4]

[![RS485 - two devices][5]][5]

[![RS485 - three devices][6]][6]


Cable run test

For a proper hardware test, I connected the devices up to my in-house UTP cabling. I have cat-5 cable running from various rooms to a central plug-board. Going from one end of the house to another (a reasonable length run) it still works fine. There is 5 m cable between the Arduino and the wall socket, for a start. Plus another 5 m cable at the other end. Then there are about 2 x 15 m runs from the rooms to the switch room, and inside that there is a short bridging cable to connect them together.

This was with the boards still programmed to run at 19200 baud. [1]: https://i.sstatic.net/unAvv.png [2]: https://i.sstatic.net/7Kttu.jpg [3]: https://i.sstatic.net/IbHz8.png [4]: https://i.sstatic.net/3vqnR.png [5]: https://i.sstatic.net/4KZCZ.png [6]: https://i.sstatic.net/gPYau.png

Added scope shots.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125

Screen-shots of the code in action

These images show the code working. First, with only one device connected:

RS485 - one device

You can see from the pulses there that the device is broadcasting its data at randomly-varying intervals, to avoid continuing to clash with another device that powered up at the same moment.


RS485 - two devices

Now we see blocks of data from two devices, with roughly the same size gaps in the middle. I configured it for four devices, but only two are present, so we see two blocks of data, and two gaps.


RS485 - three devices

Now with three devices online, we see three blocks of data, and one gap, as the missing device is bypassed.


If you are checking the figures, these were taken with the baud rate doubled, as a test, to 19200 baud.


Screen-shots of the code in action

These images show the code working. First, with only one device connected:

RS485 - one device

You can see from the pulses there that the device is broadcasting its data at randomly-varying intervals, to avoid continuing to clash with another device that powered up at the same moment.


RS485 - two devices

Now we see blocks of data from two devices, with roughly the same size gaps in the middle. I configured it for four devices, but only two are present, so we see two blocks of data, and two gaps.


RS485 - three devices

Now with three devices online, we see three blocks of data, and one gap, as the missing device is bypassed.


If you are checking the figures, these were taken with the baud rate doubled, as a test, to 19200 baud.

Added new schematic which shows /RE and DE connected.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125
Loading
Added demonstration code for moving master concept.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125
Loading
Added suggestion for timeslots and rolling masters.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125
Loading
Responded to comments.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125
Loading
Added photo of demo.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125
Loading
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125
Loading

AltStyle によって変換されたページ (->オリジナル) /