I have an application which has uses the function block TCP_Server3 from WagoLibEthernet_01.lib. I'm using the Wago 750-881.
When I login and start the program in Codesys, TCP communication works.
After I created and transferred the bootproject while logged in, I log out and disconnect power from the PLC and reconnect power after a few seconds. I see that my program works because I'm increasing and decreasing an analog output every second. But if I try to send a TCP message (using Packet Sender), the PLC does not respond on this message.
I find it very weird that my program only works partially when using the boot program.
Is there anything I forgot to do?
Edit: I just figured out that my bootproject only works fully when I connect power when the Mode Selector Switch is in the center position (stop program processing) and I move it to the top position (start program processing) while powered on. When I connect power if the switch is in the top position, my program does not work 100%.
Any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For weeks I haven't been able to solve my issue and would really appreciate your help. Ich looked into it further and changed my PLC, but no succes. I'm now working with Function Block TCP_Server from WagoLibEthernet_01.lib with the Wago 750-880. When I load my project with Online -> Login and start afterwards, everything works fine. However, when I create this program as bootproject, I have the following results:
1)
PLC is booted with 24V and the Mode Selector Switch is in the middle position (STOP). After the PLC has booted (all LEDs are or blink green), I move the Mode Selector Switch in the upper position (RUN). If I perform these steps, I have no issues and I can communicate perfectly via TCP.
2)
PLC is booted with 24V and the Mode Selector Switch is in the upper position (RUN). All functionality of my code seems to works, except TCP communication. For debug puposes I wrote the error codes from TCP_Server in a CSV file. TCP_Server always returns error 16#8001 (No socket descriptor available). If i change the Mode Selector Switch to the STOP position and back to RUN, this doesn't effect the result. I keep getting error 16#8001.
At the end you will find my code.
I've tried multiple solutions, but somehow I'm unable to fix this... I assume I'm doing something wrong or that I have to wait until the PLC has initialized something before I may call TCP_Server?
I really hope you can help me.
FUNCTION_BLOCKTCPServer_FBVAR_INPUTEND_VARVAR_OUTPUTEND_VARVARÂ Â tcpServ:TCP_Server;Â Â receivedData:ARRAY[0..MAX_RECEIVE_TCP_SERVER]OFBYTE;Â Â transmitData:ARRAY[0..MAX_SEND_TCP_SERVER]OFBYTE;Â Â startSend:BOOL;Â Â transmitCount:WORD;Â Â receiveCount:DINT;Â Â dataWrite:STRING;Â Â index:DINT;Â Â result:BOOL;END_VAR
tcpServ(xEnable := TRUE,
wPortNumber :=2455,
ptSendData :=ADR(transmitData),
diSendCount :=transmitCount,
xStartSend :=startSend,
aReceiveBuffer :=receivedData,
diReceiveCount :=receiveCount);IFtcpServ.diError>1THEN
  dataWrite :='Error';
  dataWrite :=CONCAT(dataWrite, DINT_TO_STRING(tcpServ.diError));
  dataWrite :=CONCAT(dataWrite,ASCIIBYTE_TO_STRING(13)); (*CR*)
  dataWrite :=CONCAT(dataWrite,ASCIIBYTE_TO_STRING(10)); (*LF*)
  CSV_writeData('S:\Logging\EthernetError.csv', LEN(dataWrite), ADR(dataWrite));END_IFIFreceiveCount>=10ANDtcpServ.xClientConnected=TRUETHEN
  (*Atleast6bytesneedtobereceived(minimumofLemnatecCommunicationProtocol*)
  dataWrite :='Received Data: ';
  dataWrite :=DINT_TO_STRING(receiveCount);
  dataWrite :=CONCAT(dataWrite,ASCIIBYTE_TO_STRING(13)); (*CR*)
  dataWrite :=CONCAT(dataWrite,ASCIIBYTE_TO_STRING(10)); (*LF*)
  CSV_writeData('S:\Logging\EthernetLog.csv', LEN(dataWrite), ADR(dataWrite));
  IFreceivedData[0] =cStartHeaderANDreceivedData[receiveCount-2] =cEndMessage THEN
    (*Validmessageheader, processdata*)
    result :=processCommand((receivedData[1] +receivedData[2]*256), receivedData[3], (receivedData[6] +receivedData[7]*256), ADR(receivedData[8]));
    processResponse((receivedData[1] +receivedData[2]*256), receivedData[3], ADR(transmitData[0]), ADR(transmitCount), BOOL_TO_BYTE(result));
    startSend :=TRUE;
  END_IFEND_IFIFreceiveCount>0THEN
  (*Clearreceivebuffer*)
  dataWrite :='Buffer clear';
  dataWrite :=CONCAT(dataWrite,ASCIIBYTE_TO_STRING(13)); (*CR*)
  dataWrite :=CONCAT(dataWrite,ASCIIBYTE_TO_STRING(10)); (*LF*)
  CSV_writeData('S:\Logging\EthernetLog.csv', LEN(dataWrite), ADR(dataWrite));
  FORindex :=0TOreceiveCountBY1DO
    receivedData[index] :=0;
  END_FOR
  receiveCount :=0;END_IF
And my PLC_PRG
PROGRAMPLC_PRGVARÂ Â test:Â Â TCPServer_FB;END_VAR
Hi all,
I have an application which has uses the function block TCP_Server3 from WagoLibEthernet_01.lib. I'm using the Wago 750-881.
When I login and start the program in Codesys, TCP communication works.
After I created and transferred the bootproject while logged in, I log out and disconnect power from the PLC and reconnect power after a few seconds. I see that my program works because I'm increasing and decreasing an analog output every second. But if I try to send a TCP message (using Packet Sender), the PLC does not respond on this message.
I find it very weird that my program only works partially when using the boot program.
Is there anything I forgot to do?
Edit: I just figured out that my bootproject only works fully when I connect power when the Mode Selector Switch is in the center position (stop program processing) and I move it to the top position (start program processing) while powered on. When I connect power if the switch is in the top position, my program does not work 100%.
Any ideas?
Hi all,
For weeks I haven't been able to solve my issue and would really appreciate your help. Ich looked into it further and changed my PLC, but no succes. I'm now working with Function Block TCP_Server from WagoLibEthernet_01.lib with the Wago 750-880. When I load my project with Online -> Login and start afterwards, everything works fine. However, when I create this program as bootproject, I have the following results:
1)
PLC is booted with 24V and the Mode Selector Switch is in the middle position (STOP). After the PLC has booted (all LEDs are or blink green), I move the Mode Selector Switch in the upper position (RUN). If I perform these steps, I have no issues and I can communicate perfectly via TCP.
2)
PLC is booted with 24V and the Mode Selector Switch is in the upper position (RUN). All functionality of my code seems to works, except TCP communication. For debug puposes I wrote the error codes from TCP_Server in a CSV file. TCP_Server always returns error 16#8001 (No socket descriptor available). If i change the Mode Selector Switch to the STOP position and back to RUN, this doesn't effect the result. I keep getting error 16#8001.
At the end you will find my code.
I've tried multiple solutions, but somehow I'm unable to fix this... I assume I'm doing something wrong or that I have to wait until the PLC has initialized something before I may call TCP_Server?
I really hope you can help me.
And my PLC_PRG
Related
Talk.ru: 1
Talk.ru: 2
Talk.ru: 3
Talk.ru: 7
Talk.ru: 8
Solved. I added a TON of 5 seconds on the beginning. When timer was finished, I started to call TCP Server. This works for me.