Connecting DATA input parameter to TCP_SEND FB
Hallo,
I would like to send TCP commandos via FB. I got the TCP_SOCKET connected but somehow I am not able to set the DATA input of the TCP_SEND FB.
In the help section it says DATA has datatype "ANY". I have tried to set a string and an buffer as DATA input (also tried to connect it to the DATA output).
But I always get the error message: "FBDP0001 Objekt ist nicht verbunden" -> Object is not connected
Clicking on the error highlights the DATA input port of the TCP_SEND FB.
Connecting one String as input and an other String as output to the DATA parameter the following error is thrown:
"FBDP0012 VAR_IN_OUT-Parameter ist nicht korrekt verbunden" -> parameter is not connected correctly
How do i connect the String i want to send via TCP to the DATA parameter of TCP_SEND?
Edit:
Ok. With a second FB-link to my String variable I was able to bind the String to the in- and outport of the TCP_SEND FB.
Now I´m able to compile.
Greetings,
Jimmy Pesto
Comments
Hi Jimmy,
sorry for the delay.
In the last week we were more or less all busy on an the PLC/Drives in Nuremberg.
We will come back to you asap.
cu
Frank
Hello Jimmy,
I assume the cause of error is the not connected IN/OUT Variable from the "TCP_Send" / "TCP_Receive" FB or the wrong datatypes. Please find below the screenshot of working application and the used datatypes. I have downloaded the PCWorxEngineer program on two AXCF2152 controller (for transmit and receive of TCP IP telegrams). If you have additionally questions, please don't hesitate to ask !
First AXC2152 Controller: The application receives the TCP-Telegram
Second AXC2152 Controller: The application sends the TCP-Telegram
Used datatypes:
Best Regards
Eduard
Thanks for your help. Using datatype "PND_IO_512" and connecting two instances of the same variable as "in" and "out" port solved my problem!
May I ask you an other quick question?
I need to poll some web inputs via these TCP-Requests. Therefore I want to send the request as often as possible.
How can I trigger sending the request everytime the last request was finished?
I tried to use some Flipflops and the TCP-SEND "busy" and "done" outputs but this somehow gets stuck sometimes.
Thanks a lot for your advice!
Greetings,
Jimmy
Hi Jimmy,
Using Eduard's example (above) as a reference, you should be able to use something like this before the call to the TCP_SEND function block ...
xRequest := TCP_SOCKET_1.ACTIVE AND NOT TCP_SEND_1.BUSY;
This will toggle the REQ input every time the BUSY output goes low.
It's always worth putting in a timeout in situations like this, just in case things get stuck for any unforseen reason. For example, you could use a TON timer to reset the REQ input in cases where the BUSY output never appears, or is missed for some reason:
TIMEOUT(IN:=xRequest, PT:=T#10S);
xRequest := TCP_SOCKET_1.ACTIVE AND NOT TCP_SEND_1.BUSY AND NOT TIMEOUT.Q;
I haven't tested the above code, but something like this should help.
- Martin.