Q: Can I get the version of a library in TwinCAT3?
A: Yes.
For Beckhoff system libraries, we can double-click on any library in the reference (taking Tc2_Utilities as an example here). On the right side, we will find a "Version" folder in the specific description information of the library. By expanding it, we can see a description named "Global_Version"; selecting it will display the version variable corresponding to this library, which is a structure.
In the program, we can directly call this variable for assignment and find that the last element of the structure is a string variable containing the current version of the library. The code is shown in the following figure.
Libraries created in TwinCAT3 also have corresponding versions, and the method of obtaining them is the same as mentioned above.
Q: PLC: Error no more ads instances available (8191 are in use) run time stopped
A:
- First, try restarting to see if the error persists.
The error is typically caused by illegal usage of loops, arrays, or other instructions, and can only be identified through careful examination of the code.
A customer encountered this issue when using ADS to write servo stiffness, resulting from an inconsistency between arrays and for loops, causing an overflow.
For example, continuous rising edge triggering of the logical instruction mc_camtableselect
can also lead to data overflow.
- If you have modified the program, please download the original program back.
Q: How to disable the 200ms delay in TCP communication for network cards?
A: TCP is inherently a connection-oriented communication protocol. Every send and receive action between the communicating parties requires a properly functioning communication link. Therefore, TCP protocol internally provides a default ACK verification mechanism.
The ACK verification method is also related to the operating system. In TCP, data acknowledgment is often delayed. Under normal conditions, two TCP data packets correspond to one acknowledgment. If the delay timer overflows, an acknowledgment packet will be sent naturally.
However, in some systems, TCP data can only be sent after an ACK packet is received for every packet. This can lead to the following issue: Assuming a TCP connection is established between Server A and Client B. At a certain moment, A sends data to B for the first time and waits for B's ACK packet in return. However, B waits for the second TCP data packet to send the ACK flag. After approximately 200ms, when the delay timer in B overflows, B sends an ACK confirmation packet of length 1 to A. Consequently, when B receives data for the second time, it will inexplicably experience a delay of about 200ms—this delay is precisely the default send delay for ACK packets.
When testing a self-developed server communication framework, if it broadcasts, the receiving client may experience this phenomenon due to uneven send and receive between the communication parties—this is not due to the substandard performance of your server communication framework, but rather due to TCP's internal mechanism.
So, how can we avoid this situation? Here is a simple and easy-to-implement method—modify the registry to increase the default sending frequency of ACK packets on the client, thereby reducing the sending delay of ACK packets:
First, click the "Start" menu in the lower left corner of your computer screen, open "Run," and type "regedit" to open your registry.
Navigate through HKEY_LOCAL_MACHINE and continue drilling down until you reach:
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/services/Tcpip/Parameters/Interfaces
Here are data related to your network card. There are many entries, and they all have names similar to {5F26EBBD-9CA6-4219-9DBD-54852364EA17}. However, the correct one will display network settings including your IP address and server IP address on the right side of the window. Find the entry with an IPAddress that matches your local IP address; this is the setting for the network card you are connected to. Our goal is to modify it to increase the sending frequency of ACK packets on the client.
Next, right-click on the blank space on the right side of the window, select "New" -> "DWORD Value," and rename it to "TcpAckFrequency." Then, right-click on it, select "Modify," and fill in "1" in the blank space for "Value data" (it doesn't matter if it's hexadecimal or decimal).
Finally, close the registry, restart your computer, and the modification is complete.
Additional notes on TcpAckFrequency:
The TcpAckFrequency value determines the frequency at which Windows sends acknowledgment messages using TCP/IP, i.e., how many data packets it will wait for before sending a "command correct acknowledgment."
The default value is 2, meaning that TCP/IP will send an acknowledgment after receiving 2 segments or after receiving 1 segment but not receiving any other segments within 200 milliseconds.
If the value is 3, TCP/IP will send an acknowledgment after receiving 3 segments or after receiving 1 or 2 segments but not receiving any other segments within 200 milliseconds, and so on.
If you need to reduce response time by eliminating TCP/IP acknowledgment delays, set this value to 1. In this case, Windows will send a "command correct acknowledgment" for every TCP data packet received.
The valid range for this value is 0 to 255, where 0 indicates the use of the default value (2).
With the Delayed ACK mechanism, the client usually acknowledges after the server sends 2 data packets, significantly reducing unnecessary ACK packets while improving access speed and reducing bandwidth waste.
Modification method:
Add a key value in the registry for modification;
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/TcpipParameters/InterfacesAdapter/ GUID
Value Name: TcpDelAckTicks (Note that the name of this value may vary depending on the operating system)
Data Type: REG_DWORD
Value Data: Set this value to a number between 0 and 6
By default, the delayed ACK timer is set to 200 milliseconds. If you set the TcpDelAckTicks value to 0, delayed acknowledgment will be disabled.
Of course, the above solution can resolve the issue. However, since we know the cause, we can modify the TCP data transmission implementation on the board to transmit two packets to the PC at once, thus avoiding the need to set the default registry value.