Jump to content

TCP/IP client not reconnecting as intended


benS

Recommended Posts

So this may just be something we have to work around, but we are using USC-B10-T24 PLCs to operate an automated test stand for a product running with a bespoke embedded controller. The Unistream will connect via a CPU TCP client over ethernet to send and receive data from this device during the test. However, once the test is completed, we disconnect the device and send it on its merry way, then get another device and repeat the process. This isn't a common use case for PLCs, which usually are set up once and never disconnected or touched again, but it doesn't seem to be working properly.

Up until now, this was all handled over a serial connection, but I'm trying to have it run over ethernet due to the improved speed and stability.  However, now that we are trying to have it run on ethernet, I have noticed some extremely odd behavior. 

The PLC will check if it is disconnected, attempt to connect to a static IP that has previously been input into the device under test, and if it doesn't connect, it will force a disconnect (thinking it would go through some type of reinitialize process), then wait 5 seconds, then try again. On the first test of the day, after power up, this connects with no issues at all. We can send and recieve data from the network stream and it works perfectly. However, once the device is disconnected, the Unistream will no longer to connect to anything on the same IP, even if we plug the same device back in. What seems to work is if I change the IP every test, then it will connect just fine. However, until the unit is power cycled, the previous IP is then useless and the PLC will refuse to connect. It will ping fine and I can connect to the device with my laptop, but the TCP connect block in ladder gets hung up on waiting for SYN and eventually times out.  

I only have a block of 4 IPs to use, so every 4 tests I would have to power cycle the PLC to run more. I've tried alternating target (device) IPs between one and another, multiple clients on different ports, etc., but nothing seems to work except for a hard reset. Any tips? Is there a way to reinitialize a TCP Client within the ladder? 

Link to comment
Share on other sites

I cannot due to IP reasons. However, I have posted screenshots of the relevant rung - I can try to make a small program later that exhibits the issue and let you check it.  I Am using Unilogic version 1.32.98.

This is the connection rung - once connected everything works just fine, but getting it to connect only works once on startup and never again until we cycle power. 

image.thumb.png.bd5e0c3e63d805ac02d4174fb0b79416.png

 

Basically, UseEthernet just a setting set elsewhere. If it's active, the client is initialized and disconnected (based off of the bit and the socket status integer), we toggle a 5 second timer that tries to connect every 5 seconds. It reads the IP address out of an IP to String HMI element, saves it into an IPAddress tag and then tries to connect. When the connection is terminated, I have a block in there that triggers whatever disconnect routine happens under the hood, assuming that this would make it so that the client can be used again. It seemed to work ok on the Unistream HMIs, so i left it in this code on the USC PLCs. 

Link to comment
Share on other sites

  • 3 months later...

Hello,

Sorry for the long delay, I hope your issue got solved in the meanwhile.

If not, I would be interested in knowing what are the values of the TCP client struct members when the issue occurs:.

Can you please post a print screen of the struct's values?

Best regards,

Rivka

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...