0
\$\begingroup\$

Pictured below is a simple arrangement used to read the Temperature sensor from the PC. Standard/Protocol is MODBUS RTU RS-485 Half-Duplex.

RS-485 to USB

I've used this arrangement with both modpoll.exe and Chipkin CASModbusScanner software. Both work fine and report correct readings.

Now, the next arrangement uses the regular CP-2102 USB-to-TTL dongle with XY-K485 Transceiver module (Max3485, automatic direction control) to connect to the sensor:

cp2102 to max3485

This arrangement produces the "Reply timeout" error on modpoll, and "Invalid length: short" error on the CAS Modbus scanner.

Now, if I understand correctly, the method the data is sent over the RS-485 is the same as with the RX/TX plain serial: baudrate, parity, start/stop bits etc. except RS-485 uses differential voltage to represent bits, not absolute +5v or +3v3.

So theoretically communicating to the rs485 transceiver using serial from cp2102 to send MODBUS data should work, but it does not. Is my understanding of these principles correct, and why do you thing the second arrangement does not work?

PS: a diagram below shows how I currently understand the communications pipeline:

enter image description here

\$\endgroup\$
10
  • 3
    \$\begingroup\$ Where is the ground? You need a common ground to enable any form of data communication over copper wires. \$\endgroup\$
    – Lundin
    Commented May 9, 2023 at 9:51
  • 2
    \$\begingroup\$ Differential signals work up to a certain voltage potential difference as specified in the datasheet. Go beyond that and nothing will work. As soon as you have a voltage in electronics, it is relative to another voltage potential. You can't have signal levels with variable potential and no ground, that's not how electronics work. Optical signals is another story but that's not what you have here. \$\endgroup\$
    – Lundin
    Commented May 9, 2023 at 9:57
  • 2
    \$\begingroup\$ Data communication with differential signals but without a ground is a lottery. With some bad luck, the potentials are in range. But note that in that case they are using your supply ground as reference, which is dirty, may pick up noise, may be subject to ground current surges and so on. All electronics needs a voltage and a ground and differential transceivers aren't able to magically change the laws of physics. \$\endgroup\$
    – Lundin
    Commented May 9, 2023 at 10:03
  • 3
    \$\begingroup\$ Besides the missing ground, there is no transmit enable. Unless your RS485 handles that automatically, which then does not guarantee it is doing it properly. Oh right you say it has auto transmit enable. Unless you know it works, use a scope to measure it, or just use a proper enable control from USB UART chip (whichever you use, CP2102 or CH340). \$\endgroup\$
    – Justme
    Commented May 9, 2023 at 10:28
  • 3
    \$\begingroup\$ TX and RX in UART follow Murphy's Law: no matter how much thought you spend in advance at getting these right in theory, they always end up in the wrong place anyway :) It's a signal naming problem really, we never have this problem with SPI MOSI/MISO. \$\endgroup\$
    – Lundin
    Commented May 9, 2023 at 10:57

1 Answer 1

1
\$\begingroup\$

As Lundin had pointed out, the mistake was in the connection of RX/TX pins. Unlike the "classic" arrangement of connecting RX to TX and TX to RX like you would do when interfacing with an MCU, this particular case called for connecting RX to RX adn TX to TX. Quoting Lundin:

Please note that it matters if the device is a "terminal" at the end or a "modem" in the middle - the signals may change meaning depending on this.

The RS485 transmitter module is that "modem", therefore its RX/TX pins have to be connected to the respective RX/TX pins of the USB-to-TTL. The RS485 transceiver is merely a converter, so it is supposed to receive RX and TX as they are, unchanged without decoding or serializing like a recipient device would so it can pass them as differential signals.

The correct schematic would be: enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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