K
K
kvaks2020-05-09 00:47:15
Arduino
kvaks, 2020-05-09 00:47:15

How to transfer modbus from arduino through the interface?

I'm trying to send arduino data via modbus (485 over 2 wires) a bunch
of arduino -- XY-017 -- moxa to ETH and then process them.

I tried to use the ModbusRtu.h library, but I see with an oscilloscope that data is not being sent and TxRX does not blink on moxa or on arduino.

XY-017 is connected to pins 0 and 1. (Changed in places does not help)

Moxa is of course a master. instead of moxa, I connected the Uport1130 and read it "Modbus Poll" from the com port of the arduino, the data is coming, and silence from the converter.

#include "ModbusRtu.h"
#define ID   1      // адрес ведомого
//Задаём ведомому адрес, последовательный порт, выход управления TX
Modbus modbus(ID, 0, 1);
uint16_t MBdata[11]; // массив данных modbus

void setup() {
  modbus.begin( 9600 );
}
 
void loop() {
  float current = 55;
  modbus.poll( MBdata, 11);  // обработка сообщений
  MBdata[0] = current;
  MBdata[8] = modbus.getInCnt();
  MBdata[9] = modbus.getOutCnt();
  MBdata[10] = modbus.getErrCnt();
 }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
VT100, 2020-05-09
@kvaks

modbus(485 over 2 wires)

It is desirable - on three wires, including the "ground" (GND).
Is there a schematic for XY-017? It looks like there is an extra U2 IC, which makes you think that this is a USB-RS485 converter, which is not suitable here.
What arduino is used? According to the Nano scheme, I see that the UART mega328 lines are not separated from the FT232 in any way, which can cause a conflict when XY-017 is connected in parallel.

L
lonelymyp, 2020-05-09
@lonelymyp

You unhook this contraption and check that your arduin generally gives out something by uart on the given legs. When you achieve that the arduina will transmit and receive, you can connect this converter and look further.

P
Pujine, 2021-06-17
@Pujine

There, on the converter, the inscriptions on the contacts are mixed up, you need to connect TX - TX, RX - RX

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question