NgoHoang

Communication Socket_TCP

2 posts in this topic

Dear all!

I have 2 program: Ladder and ST (I convert from Ladder to ST) to communicate by Socket TCP.

With Ladder program, I can open Port and Close port very good.

But in ST program, I open Port and Close Port at the firsrt time is OK. At the second time, after close Port I can not open.

Could you tell me the different between 2 Progam.

Thanks and best regard!

Ladder_123.gxw

ST_123.gxw

Share this post


Link to post
Share on other sites

You'll have to monitor what happens in your code. Where does it fail (which condition is not set TRUE to activate the "OPEN" sequence)? You'll probably need to do this while you have the card/system on your desk, it's hard for us to test this without a functioning system.

One advice though is to look if the last sequence (close) "overrides" the first sequence (open). Maybe you have a bit that is automatically reset when you sequence from the first to the last? What you can do is to add temporary bits/words only for testing purposes that shows the actual value of a given variable at a specific point in your code.

One example is:

IF(M16=TRUE) THEN
M20:=TRUE;
END_IF;

IF(M17=TRUE) THEN
M20:=FALSE;
END_IF;

In this case, if both M16 and M17 are TRUE, M20 will always be false since the last sequence resets it anyway. To "check" for this, you can add a variable for testing purposes:

IF(M16=TRUE) THEN
M20:=TRUE;
testVar:=M20;
END_IF;

IF(M17=TRUE) THEN
M20:=FALSE;
END_IF;

In this case, you will always know the status of M20 in the third line of the code (after the SET instruction, but before the RST instruction). You can do this as many places as you want. The point is that because of the sequence scan of the PLC, sometimes it might be difficult to see what status a bit/word actually has without using test variables (which you later remove). In event-driven programming there are breakpoints for this kind testing, but in scan-driven programming it's a bit harder...

If you're "lazy" you can start by just shifting places between open and close sequences (so that the close sequence comes before the open sequence). Maybe it will only open and never close?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now