Jump to content

MODBUS TCP Observation


Recommended Posts

  • MVP 2023

I just completed a project and noticed something odd. The project is as follows:

Chemical blender controlled by a V1210 PLC. This machine blends 4 different chemicals to the customer's specification into 4 different tanks (each with a different mix of the 4 chemicals). The chemical flow is controlled by 4 Entegris flow controller/flow meters (analog I/O).

A remote panel (V700) is located 50ft. (of Ethernet cable) away. This remote panel can control the operation identical to the main panel. Blending and tank filling can be started or stopped at either location.

Communication between the two PLCs is by MODBUS TCP with the V1210 as the Master and the V700 as the Slave.

Since all blending operation and control occurs at the main (V1210) panel, but operation of the system will generally occur at the remote (V700) panel, I wanted the best user experience I could obtain at the remote panel. If you've ever had remote control via MODBUS, you've noticed that there can be a bit of a lag to get a button response on the HMI screen (i.e. you usually have to hold the button down for a short time to get it picked up by the MODBUS polling). I usually run polling by either a timer or use SB 15 (100ms transition). The shortest timer possible is 10ms, which improved things considerably, but I checked the scan time on the V1210 and saw it was between 6 & 7 ms, which might improve things further. I was using the Unitronics R/W MIX FB to transfer data and hung that directly on the left rail (with SB 150 and the "function in progress" bit, but no timer). This caused the data transfer on every scan and dramatically improved the user interface at the remote panel. It was nearly as responsive as the main panel. Checking the TXD / RXD counters, there were no dropped packets at all - very good result, and I'm quite happy.

However, I did notice a minor oddity. Also on every scan, I am performing the necessary integration of the flow rate to total volume and display it on the screen. My normal method of integration in this type of circumstance is to time slice the rate using SB15, perform the necessary math to convert mL/min to mL/100ms, then sum to obtain total mL. On the main panel where all the calculations are performed you can see the flow rate is constant and the total volume increments up very smoothly. However, on the remote panel where that number is transferred over on every PLC scan (of the V1210), the total volume does not increase smoothly. It has a halting appearance, not smooth at all, that totally mystified me for awhile.

I think I now know why (though I could be wrong). Anyone want to take a stab at solving this mystery?

Link to comment
Share on other sites

  • MVP 2023

In real ModbusLand, there is no such function as an R/W MIX.  Unitronics is doing some thread spooling under the hood with multiple separate operations for each line defined in the block.

Also, it's not doing one Modbus operation per scan.  You wisely put a Function in Progress bit in front of the block which keeps the operation from barfing and it will run as fast as its little legs will carry it,  but that bit comes on and stays on until each Modbus operation in the block completes.

That's what you're seeing on the remote screen.  I am very tempted to set up a similar configuration in the Cigar Lab and look at the actual timestamped Modbus transactions using Wireshark, which will give me 0.001 sec resolution.

If you want to play with Wireshark yourself, it is a free program but you need an old school Ethernet hub (not a switch) to plug your monitoring computer into along with both PLCs.  The hub re-broadcasts all traffic out all ports, while the switch is aware of the IP address plugged into each port and will direct traffic accordingly.

Joe T. 

Link to comment
Share on other sites

  • MVP 2023

@Ausman is correct - you need a hub, not a switch (I misread @Joe Tauser's post), which I don't have. However, I did some other experiments.  I increment a DW on every scan and divided the R/W Mix Acknowledgements count by the scan count. The result seemed to vary a bit from startup, ranging from 82% to 97%, but mostly hung around 95-96% and was remarkably stable there. The PLCs connect through a switch, along with my desktop PC. The rest of my network is wifi through a router and so the PLC network is independent of other devices. The scan time of the Master PLC (V1210) is 7ms and the Slave PLC (V700) is 3ms. Since these are nice prime numbers, I expected to see a lot of aliasing to cause dropped packets, but that doesn't seem to be the case.

With very consistent >95% communications success rate on every scan, I'd say the Unitronics PLC is indeed completing the entire MODBUS R/W Mix function in a single scan. I could see no effect even when online with the PLC using Ethernet (on a different Port & Socket, of course).

Many of my projects that involve MODBUS TCP communications are on an isolated network. When that is the case I plan to always execute the comm FB on every scan rather than try to run a timer to slow it down. It makes the Slave PLC as responsive (to button presses, etc) as being at the Master. I wish I had realized that you could communicate on every scan years ago.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...