Author Topic: Controlling modbus TCP/IP slave devices  (Read 956 times)

0 Members and 1 Guest are viewing this topic.

Offline KemmeTopic starter

  • Contributor
  • Posts: 26
  • Country: pl
Controlling modbus TCP/IP slave devices
« on: May 25, 2018, 01:47:42 pm »
Hello guys

I'm planning to create some kind of master device which will control 30 slave devices through modbus TCP/IP. Basically each slave device will be a PLC which will be polled then the master will do some calculations and send commands to all the slaves. This sequence (polling-command) will be performed in a routine once a second. Also some data will be stored in a data base and some data will be displayed on a screen.
My idea is to set up an Apache server on Linux and run a PHP script (using some modbus libraries) each second to perform all the controlling tasks. For visualization I would use Javascript so all valid data would be displayed via web browser.
What do you think about that solution? Is it a proper way? Do you have any better ideas?
http://dot2pic.com - bitmap to data array online.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Controlling modbus TCP/IP slave devices
« Reply #1 on: May 25, 2018, 10:43:37 pm »
Well, that's doable - I have done something similar, but only with 3 devices on the network and using Node.js and C# (two different applications) instead of Apache/PHP (Javascript being a slightly more tolerable abomination of a language than PHP).

Just don't get tripped up by catastrophically bad implementations of Modbus - almost every single one I have seen has weird bugs and idiosyncrasies that will trip you up. Things such as Modbus working with 16bit words, not 8bit bytes making some operations "fun" to implement, "coils" and "registers" may or may not share the same memory space (both on the PLC and in the library), gems like relying on receiving replies in order (even though the spec explicitly says to not do that). Guess what happened when I tried to actually talk to a real PLC (and not just another copy of the library) using one them ...

Be prepared for some pretty low level debugging with a lot of bit manipulations and network sniffing. Also do get an actual PLC for development as soon as you can otherwise your code may work perfectly fine with a simulator and blow up spectacularly in random ways when you try to talk to the real hw.

Modbus is fun >:D Considering that this stuff is used to control things in nuclear plants and elsewhere is not something that makes one sleep well ...
« Last Edit: May 25, 2018, 10:49:39 pm by janoc »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf