Frequently Asked Questions on Beckhoff TwinCAT(Part1)

 Q:How to cancel breakpoint debugging in TwinCAT2

 A:When debugging online in TwinCAT2, you can click on the line number of the program code to set a breakpoint. However, if you accidentally click on it when you don't need breakpoint debugging, it can cause the PLC program to stop running. The symptoms are as follows (the line number turns red, and the BP in the status bar lights up):

To prevent this from happening, you can disable the breakpoint debugging feature (uncheck the corresponding option in the Project-Options-TwinCAT tab, note that you need to logout first):


Q:After checking "Remember my answer and don't ask again." for saving Scope projects in TwinCAT 3, how can I restore the ability to choose a save path each time the file is automatically saved?


A:When you've recorded data in the Scope View and need to save it, you might use the Save Data function in the toolbar.


By default, a pop-up window will appear, asking if you want to save directly in the project path. After clicking "NO," you can customize the save path. Often, the checkbox "Remember my answer and don't ask again." is also checked to save the previous setting, but if you accidentally select the wrong option, the pop-up window will no longer appear. 


The solution: Click on the Scope option in the toolbar, find Scope Messages, and check the box for Append SVDX Message in the list on the right. This will bring back the pop-up window. Note: Check the box highlighted in the image below, not the text area to the right.

Q: Clear Function Code

A:Encapsulating memset to zero out a memory region makes the code more concise.

Notes:

  1. This code is intended for TC3 only. If you plan to use it with TC2, please be aware that the size of memset differs between BC and X86 architectures.

  2. Please do not misuse the Clear function. Avoid using it for boolean variables. It can be used to clear byte arrays, but not for data types like strings, as strings have terminating characters. Typically, to clear a structure, you would declare an empty instance of the structure and assign it.

  3. Functions in the mem series directly operate on memory, which can improve efficiency. However, please be cautious of memory leaks and use them with care.

Function Definition:

Clear(yourVariable);

Q:After the controller's single network interface is used simultaneously for ADS and EtherNet/IP (TF6281), the TwinCAT status changes to "Stop".

A:In addition to installing the real-time Ethernet driver on the controller's network card, an exclusive task also needs to be allocated.


Q:After executing FB_CreateDir, an error code 1804 is returned.

A:FB_CreateDir is used to create a new directory under an existing path, so it can only create one level of directory at a time:

For example, from C:\ to C:\PRJDATA

https://infosys.beckhoff.com/content/1033/tcplclib_tc2_system/30988299.html?id=2667162487971609572

However, if you attempt to create multiple levels of directories in one execution, it will result in an error code 1804. You must execute the command multiple times, adding one level of directory at a time, before proceeding to the next level.

To go from C:\ to C:\PRJDATA\Data, you would first execute FB_CreateDir to create C:\PRJDATA, and then execute it again to create C:\PRJDATA\Data.

Q:Error "AliasDeviceType not supported" occurs when opening the project

A:Others had no issues opening the project, but when I tried to open the same project, I encountered the error message shown in the image. After confirming that the TwinCAT3 and TwinSAFE versions were identical to those used by others, I ultimately resolved the issue by updating the EtherCAT description file. The root cause seems to be that some newer safety modules in the project were not recognized by TwinCAT, leading to the aforementioned error.

Like my work? Consider a donation! 👇