Hello to all,
this is my first message.
I have a problem with modbus TCP.
I have 2 moxa modules Moxa E1210 with 16 inputs and 1 Moxa E1212 with 8in and 8out.
I want to read the state of digital inputs using modbus tcp.
In the moxa manuals i've to read DI-all_statusFromDI-00,
Start Address (decimal): 0048 witch FC code 04:INPUT REGISTER and the moxa adapter replies me with 1 word data.
I tried to read al teast 1 module, but when i execute the sketch the call of requestFrom gives me the reply: invalid argument.
I've written this code:
arduino-modbus-tcp-forum.ino (2.5 KB)
Pleas help me!
Thank a lot.
pylon
March 15, 2022, 3:03pm
2
if (!slave.connected()) {
slave.stop();
slave.connect(slaveIp, slavePort);
}
You shouldn't handle the TCP connection yourself, the Modbus library should do that. Take a look at the corresponding examples!
Thanks for your reply!
I've always the same problem: invalid argument on the modbus request
:((((((
pylon
March 16, 2022, 5:08pm
4
I know, my last response tells you why you have these errors.
I've already removed the code
if (!slave.connected()) { slave.stop(); slave.connect(slaveIp, slavePort); }
But It doesn't work fine
pylon
March 16, 2022, 5:36pm
6
Removing the code isn't all you have to do. You must call the corresponding code in the Modbus library.
Did you have a look at the examples of your library?
Hi pylon,
i've seen the example better as you tell and i resolved the problem.
What changes now if i want to add the other servers?
Can i poll in the same sketch to modbus rtu devices (having the Arduino interface)?
Thanks a lot.
pylon
March 17, 2022, 7:17pm
8
Create one modbus client object per server.
Theoretically, yes. What Arduino board are you using? What RS485 hardware do you intend to use?
system
Closed
September 13, 2022, 7:17pm
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.