Welcome, Guest
Username: Password: Remember me

TOPIC: Modbus tcp with arduino

Re: Modbus tcp with arduino 5 years 11 months ago #9664

  • ceccon
  • ceccon's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 46
  • Karma: 0
Hello Ben ,
I got it working by changing FunctionCode from ReadCoil to ReadDiscreteInput, I do not know why, may be you can explain for me and future beginners guys.

Other question is... In your example after (ChanDi9 number = 0... beginning message 2) you wrote that next ChanDi in this case ChanDi10 number = 1 again, is that correct? should not be number = 8?

Now I am able only to read Arduino pins from number 0 to number 7, not more, do you know why?

Please observe that I change my arduino sketch to try to read more pins

Thanks
BR
/Ceccon
Attachments:
Last Edit: 5 years 11 months ago by ceccon. Reason: Complement question
The administrator has disabled public write access.

Re: Modbus tcp with arduino 5 years 11 months ago #9666

  • benoit
  • benoit's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 180
  • Thank you received: 1
  • Karma: 0
Hi Ceccon,

About ChanDi...
> with 'Bit8 representation
---ChanDi1 to ChanDi8, 'number' from 0 to 7,
---ChanDi9 to ChanDi16, 'number' from 0 to 7,
...etc
> with 'Bit16' representation
---ChanDi1 to ChanDi16, 'number' from 0 to 15,
---ChanDi17 to ChanDi32, 'number' from 0 to 15,
...etc

I am not an Arduino expert but after some research on the web, I have note that is Mb.C[x] used to read Coils (with function code 'ReadCoils'). But in your Arduino sketch you use Mb.I[x].
Maybe you can try Mb.C[x] and FC01 (ReadCoils)?

If I understand Arduino Mudbus specifications (last release):
Mb.C[x]...0x.......Coils...............FC01 (ReadCoils) FC05 (WriteCoils)
Mb.I[x]...1x.......Digital Inputs......FC02 (ReadDiscretInputs)
Mb.IR[x]..3x.......Input Register......FC04 (ReadInputRegisters)
Mb.R[x]...4x.......Holding Registers...FC03 (ReadHoldingRegisters) FC16 (WriteMultipleRegisters)

/Ben
The administrator has disabled public write access.
The following user(s) said Thank You: ceccon

Re: Modbus tcp with arduino 5 years 11 months ago #9668

  • ceccon
  • ceccon's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 46
  • Karma: 0
Hello Ben

Just to confirm that by changing in Arduino sketch MB.I[x] to MB.C[x] the function code ReadCoil works as you inform.

Other information for the beginners (like myself) you always need to connect the ChanDi to DI signal,
I did a mistake to note connect ChanDi9 with one Di signal and the Arduino pin 8 in my case ChanDi10 did not work it only start after I connect ChanDi9 with Di channel. please see example bellow.

> with 'Bit8 representation
---ChanDi1 'number'= 0 ----> Connected to Di1, to read Arduino pin 0
---ChanDi2 'number'= 1 ----> Connected to Di2, to read Arduino pin 1
---ChanDi9 'number'= 0 ----> Connected to Di3, if you do not connect with a Di signal it will not work
---ChanDi10 'number'= 1 ----> Connected to Di4,to read Arduino pin 8
...etc

Please Ben confirm that I always need to connect Channel with Signals in order to make Proview able to read or write to any device port connected to them, that was my conclusion

I need to say thank you a lot for your support end help

Best Regards

/Ceccon
The administrator has disabled public write access.

Re: Modbus tcp with arduino 5 years 6 months ago #9829

  • ceccon
  • ceccon's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 46
  • Karma: 0
Hello Guys, here I am with Mudbus TCP and Arduino again.

I need to improve my system turning more robust in terms of confidence, may be some one with more experience can help me.

My question is how to keep Proview running when for some reason one of my 2 Arduino stop to communicate by some reason. What I see is if one stop the system run in random mode I mean, run for 10 min, stop for other 5, come back to run again, works intermittent, and after some time stop and don’t come alive any more.

So, how to turn my Proview system my robust in case of fail in part of my ethernet?
I also note that ErrorCont from my ethernet node 192.168.1.155 is quite big compared with the other node 192,168,1,154 can be a ethernet issue?.

Thanks
Best Regards
The administrator has disabled public write access.

Re: Modbus tcp with arduino 5 years 6 months ago #9832

  • FoxMan
  • FoxMan's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 23
  • Thank you received: 10
  • Karma: 3
Hi Ceccon,

can you please give some more details about the instability of your ProviewR setup with the two Modbus TCP-Arduinos. What is the behavior of the stations (ProviewR runtime, Arduino)

1. I guess your ProviewR system does not stop working when one or both of the Modbus Arduinos fail? I only know one constellation, where the ProviewR plc process will crash, when a modbus tcp communication fails. But in this case you won’t see the behavior you described (works - works not – works).

2. In all other cases that I know (and I have some Arduino UNO/MEGA and ESP8266 modbus tcp systems running), the problem is related to the Arduino and the related sketches/libraries. A question is: can you ping the Arduinos, when the modbus slave stopped working? When yes, this means, your sketch is hanging (for what reason ever) and the problem is not related to ProviewR. I’ve never used the mudbus library, but instead the msgmodbus library from Marco Gerritse. With this library I’ve seen similar behavior as you described, on cable reinsertion or on start of the Arduino, when the peers network connection was down. I tried to find the reason, but without success.
At the end I changed to the Modbus/ModbusIP-library from André Sarmento Barbosa. I have to watch it for a while till I know whether it brings more stability. In general I must state, that the Ethernet Shields do not work with any switch without problems (as they normally should). So I had to look around to find switches, I could use with the Ethernet Shields.

The error counter does not really count errors (like hardware errors on the network), but counts the unsuccessful attempts to communicate with the modbus slave. Higher counter just means that the communication was lost earlier. After successful reconnection to the slave, the counter is set to zero again.

Kind Regards
Martin
The administrator has disabled public write access.

Re: Modbus tcp with arduino 5 years 6 months ago #9833

  • ceccon
  • ceccon's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 46
  • Karma: 0
Hello Martin and thanks for your help

Yes I can ping the Arduinos when modbus slave stop

I am using library from Dee Wykoff (2011), if I understood your notes you are using the library from Andre Sarmento Barbosa that is working without problem, is that the case?

I just jump from USB connection to use ModBus TCP to make the system more stable but until now unfortunately I am failing. I really need help to do that due critical process operation.

More information: I spend time monitoring Modbus Slave Status it change between "Normal operating state" and "Disable" even I don’t touch the computers, any reason for that?

Can you please add your Arduino Sketch to have a look?

Thanks
Best Regards
/Ceccon
Last Edit: 5 years 6 months ago by ceccon. Reason: Complemante informations
The administrator has disabled public write access.
Time to create page: 8.070 seconds