3

I am trying to build a small device that will act as translator between two devices having two different RS-485 MODBUS protocols. This device will store 4 different values from "Device 1" through MODBUS protocol and then will gives these values to "Device 2" through another MODBUS protocol when Device 2 asks for these values. The distance between two devices is just 5 feet and communication would need to happen every 5 seconds.

What would be right low cost hardware for this? I was preferring to avoid Raspberry Pi mainly due to cost of full solution. I do not have enough familiarity with Arduino to understand what hardware components I would need to build this device. Hence looking for advice from experts.

Translator

SamGibson
  • 17,231
  • 5
  • 37
  • 58
Niks
  • 33
  • 4
  • 1
    Hello and welcome. A few questions: what baud rate(s) are in use? Are you using the ASCII or binary variety of MODBUS? Is device 1 on the same power supply as device 2? – jonathanjo Aug 14 '23 at 11:56
  • Niks - Welcome. (a) As you're new here, please read the [tour] & [help] for the main site rules, as they differ from typical forums. (b) FYI please note that requests for specific recommendations are [off-topic](/help/on-topic) as we don't know what specific devices are available to you, within your budget, with your required supply longevity and your other constraints / requirements etc. However the (so far only) [answer](/a/677568) you received gives useful & generally applicable advice. You will need to use that type of advice to choose a specific device, given your other requirements. – SamGibson Aug 14 '23 at 19:34
  • @jonathanjo Baud rate for first device is 19200 and baud rate for second device is 9600. Device 1 is 48V lithium battery and Device 2 is inverter I did find a two channel RS485 for RPI Pico. So perhaps that may be one option. SamGibson, Thanks for the feedback. Will take care of that in future. – Niks Aug 15 '23 at 07:00

2 Answers2

7

MODBUS over RS-485 is UART-based, so any small MCU with two UART ports would do the job. The only other thing you'll need is a couple of RS-485 level translators, like the MAX485 or equivalent.

Dave Tweed
  • 168,369
  • 17
  • 228
  • 393
1

"Lowest cost" really depends on how many you want to make, and other factors such as power supplies, connectors and so on.

There are two main ways of doing this:

  • Proxy mode Translator waits as a slave until device 2 asks for something. Then translator asks device 1 and returns answer. If this is quick enough, and the error behaviour is acceptable (what do you do if D1 doesn't answer quickly enough?), it is the simplest way.
  • Asynchromous mode Translator constantly polls device 1. Whenever it likes, device 2 asks for latest data. This is more complex as multiple things can be happening at once.

If your baud rates are fixed, they are slow enough you can do one of them (9600) in pure software (bitbanging). In which case any Arduino hardware would work -- and many, many, other devices. Many engineers dislike software serial because it's very resource-intensive, but for a very simple only-one-task-and-nothing-else-at-all system, it can be extremely reliable and simple. The proxy-type translator would be like this.

The main thing to think about is whether the grounds are sharable or whether you need isolation.

  • With isolation Use a ready-made module, perhaps from Digilent or Mikroe which are both excellent; many others are available.
  • Without isolation can use almost anything, my recommendation would be 75176-pinout transceiver on an 8-pin DIP so you can replace and test.

My recommendation would be to get it working with a Raspberry Pi, which is easiest, until you know exactly how you want the translation function to work. Or perhaps with an Arduino, which is a little harder.

Once you've done that, then you can code it appropriate to the level of engineering robustness you require, perhaps with AVR-GCC or another toolchain.

If you were making a lot of them, you might get down to an ATTiny type processor and two RS-485 chips (plus a few bypass capacitors and whatever biasing resistors you might want.) At 2 metres and 19,200-baud, almost anything will work and you don't have to get very clever.

jonathanjo
  • 12,049
  • 3
  • 27
  • 60