Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: plcnut on December 02, 2014, 11:36:17 AM
-
I have a system with 4 Datalogic Matrix 300 scanners. Each scanner is set up as a client with my H2-DM1E's IP as the server address. I set each of the scanners starting Modbus registers and lengths so that they are each dumping into blocks of MHR registers. This all works good.
The problem:
If the scanner is idle for more that 30-60 seconds (I have not put an actual timer on it), then I have to trigger the scanner three times before I get any data in the MHR register for that scanner. The serial connection is spitting out the data every time, and the Datalogic software sees the data every time, but the PLC gets nothing. I have come to the conclusion that it 'may' be on the PLC end.
I have not been able to find any way to view Modbus errors from the scanner end...
The PLC is set for:
-Enable Modbus/TCP server 'checked',
-Maximum Concurrent Sessions: '4',
-Client Inactivity Timeout: '60',
-TCP Port Number: '502'.
Any ideas?
-
Wireshark?
-
...and if it wasn't clear, by "Wireshark" I meant "Get me a Wireshark trace and I'll be happy to analyze it and tell you what might be going on". ;)
-
I spent a few hours with Wireshark trying to get a trace. It appears my switch (an un-managed Netgear) is cutting all the comms. I guess it is doing its job too well for tracing... I tried putting my PC's IP into the scanner, and then I can get an occasional call from the scanner, but nothing that seems helpful, because it can't get a response.
I have now installed a MODBUS Server on my PC, so hopefully tomorrow I can get you a trace.
-
Netgear has a switch family that you can configure for port mirroring. I think the 5-port version is a GS105E (if that number is correct, the "E" is important; there is a non-E version that's cheaper and doesn't mirror). I picked up one at Staples for under $80. That's what I use when I want to get a Wireshark and neither device is a PC.
-
Thanks CG.
I will ask IT if they have any managed switches that may allow mirroring.
-
I can't remember what the specific part number is, but several of us have mirroring switches as well. Critical for non-PC to non-PC Ethernet comms.
-
Here are 2 traces I gathered this morning with a Modbus Client on my PC (the client is not set up properly, but it does communicate).
The first trace is what happens when I scan something after the scanner has been idle for a couple of minutes.
The second trace is what happens when the scanner has not been idle.
I am going to try too get a mirroring switch today so I can get a trace with the scanner talking to DM.
BTW "AG108" is the barcode data.
-
We didn't have a switch, so I have one on the way...
-
It's kinda strange. The client sends the request and then immediately tries to freshen the socket, appears to succeed, but the DataLogic device doesn't return a response. A bit over two seconds later, the client opens a new connection, sends a new request, which is answered.
If I had to guess, the DataLogic device has dropped the phone without actually hanging it up...meaning...the server function has been shut down on the socket, but the socket hasn't been freed at the stack level.
-
The scanner is the Client (@ .26). The PC just has a Modbus Slave application running on it (@ .50).
-
The Datalogic setup screen:
-
Ah...so it it.
The behavior is still the same. The socket is stale and the server isn't responding. The DataLogic resets it, but doesn't issue a new request until two seconds later, and it does so on a new socket.
If there had been multiple minutes between comms to Do-more's Modbus/TCP server, we would have already timed out and dumped the connection. You can extend that, but the problem is still the same...the DataLogic device isn't doing anything to keep the connection fresh, it then sends a command, gets no response, and opens a new connection. I would think that for something like a scanner, which I would expect to have fairly infrequent comms, the preferred implementation would be to open the socket, transact business, then close the socket. Barring that, some form of keep alive would be prudent.
I have a nice little force-the-socket-closed hack in Do-more's stack to catch the condition where the remote connection gets closed unexpectedly. It wasn't pretty, but it was necessary to prevent this exact situation.
-
We have been doing more testing, and it appears that there are some problems with the way that Datalogic has implemented the protocol. Maybe I am doing something wrong in setup, but won't know until Datalogic calls me back.
-
Could be more than one problem.
Without seeing a trace of Do-more to DataLogic comms, all I can do is guess, but I know for certain that we will terminate the connection after 60 seconds of no comms. If they don't catch that and close the connection, and try again on the closed socket, it'll time out.
In your PC-based server, it appears that the server layer has checked out, probably due to inactivity, but the socket is still active. That may be a problem in it's own right. Reagrdless, it does appear to me that DataLogic is expecting the connection to still be active after minutes of silence, and many servers will have already dropped the connection by then.
-
Even when running the Modbus slave on my PC, it takes 2 scans before I can get a code into the client if the scanner has been idle.
Still can't get to tech support at Datalogic... :(
-
If you bump up the idle disconnect time on the DM1, does it still fail there?
-
I have attached one more trace just to show what is happening with a working Modbus slave.
There are 3 scans in this trace. One scan, and then a pause, and then 2 successive scans (AG108 is the data).
This is using a Matrix 300 that has been reset to factory defaults, and then the imaging calibrated, and the only other settings I changed was enabling the Modbus Client, and setting the Modbus addressing.
-
If you bump up the idle disconnect time on the DM1, does it still fail there?
The fail is directly tied to the DM1 timeout setting. I will see if I can figure out something with Datalogic. Their documentation for Modbus covers less than one page in the manual.
-
Not sure how the Datalogic side works, but what if you did something to keep the link active? Either read or write data that is constantly changing, like a heartbeat pulse?
-
Then I'd say it is what I suspected; DataLogic isn't handling the disconnect. Bad form, but I understand the issue having solved it for Do-more.
The biggest issue I see is that they don't appear to be making much of an effort to retry the operation when it fails. That might fly in the scanner world, but it would be sternly frowned upon in control.
-
Not sure how the Datalogic side works, but what if you did something to keep the link active? Either read or write data that is constantly changing, like a heartbeat pulse?
DataLogic is the master.
-
I know there is a heartbeat setting for the Datalogic, but I really don't want the overhead on my network if I can get by without it.
-
Most of those transmit once a second or maybe you can set it? I doubt it would affect anything and you can monitor it in the DoMore to check the integrity of the link. Keeping data going through the port may keep it open. Try it.
-
Spent all morning with Datalogic tech support. There is a problem with their implementation of Modbus TCP. Also, the heartbeat will not work on Modbus (it is supposed to, but it is broke). They do have a TCP Data Socket that I am going to try to use until they get me a Firmware update.
Thank you guys for the support!
-
Are their any monitoring bits/registers in DMD that I could look at to see the status of the Modbus server?
Also, what are the dangers in setting the Modbus server's timeout to 2 hours?
-
I got a new switch so I can mirror ports now ;D
Here is a sample trace between DMD and Datalogic. The barcode data that is being sent is 'AG108'.
-
I am learning to use Wireshark, and am trying to cut out the extraneous data in the trace files. Here is the latest that records everything to and from my H2-DM1E and the Datalogic from power-up until I make several scans (notice the first scan was a no-read).
-
Key parts of the trace:
1. DataLogic (DL) does an odd thing at the start. He sends out a gratuitous ARP, which essentially announces to the network that he 10.0.0.26. He then issues 4 ARP requests for the PLC in 2us. Not hurtful, but odd to burst off 4 requests without waiting for a reply.
2. Upon receiving the first response from the PLC, he opens a connection.
3. After about 1 minute, the PLC closes it due to inactivity, and DL ACKs him indicating that he at least saw the close request.
4. 15 seconds after that, DL sends a Modbus write.
5. DL immediately follows it with a connection close and a RST/ACK...doesn't wait for a response. It feels like the socket is goofed up at this point.
6. PLC says, huh? (resets the connection)
7. 6 seconds later, DL opens a new connection and successfully speaks Modbus.
Basically, he gets flustered when the server drops the line on him. He eventually recovers, but doesn't appear to retry the failed comm.
-
I have implemented Datalogic's Data Socket protocol instead of Modbus. It is working great!
THANK YOU Host for giving us these great protocol development tools!!!
I will continue to work with Datalogic on getting their Modbus protocol working, and will update this thread with the results.
-
Contemporary Controls also have this 5-port switch that doesn't learn what IP's are accessible via which port and just sends all traffic down all ports.
http://www.ccontrols.com/ctrlink/eiskd.php
To me, that's a hub, but Contemporary Controls still calls it a switch with that one exception. Not sure what the difference is.
Because of that, you can run NetEdit to a PLC on the other side of this switch. There are systems where you wouldn't want the message flooding, but in some systems it wouldn't hurt anything and allows you to NetEdit the PLC without temporarily rewiring.
-
The distinction is likely that unlike a hub, it caches and resends, allowing source and destination to be different speeds. Functionally speaking, it does sound like a hub...which is a very useful thing.
-
Yup. They call it a "diagnostic" switch, so they're targeting the kinds of things like troubleshooting protocols where neither device is a PC; same types of things we were talking about with the Netgear switch earlier up the thread. Difference being that this one is industrial style and quality. DIN rail, 24VAC/VDC power via terminals, etc.
-
Oops, thought my December post was about Contemporary Controls' EIPR router, so today's post was meant to supplement that. (I'll delete the December one, as I've actually tried NetEdit over the switch now and know it works) Their router is also a very cool product and likely applicable to what a lot of forum users do.
I've tested so I can leave the PLC and HMI addresses fixed and route through the plant network leaving the WAN side as a DHCP client, and the PLC can send emails and so on. Here's the router page:
http://www.ccontrols.com/ctrlink/eipr.php