Q: Access to misaligned address. Access may lead to runtime exceptions. Please adapt the memory location.
A:
Access to misaligned address. Access may lead to runtime exceptions. Please adapt the memory location.
① Locate the "Project" in the taskbar and select "Clean All" followed by "Rebuild." (Note: After "Clean All," ensure to select "No" based on the prompts.)
② Check if the allocated address type and variable type are not corresponding.
Another possibility is that the TwinCAT2 version of the controller is very old (such as version 1302), while the TwinCAT2 version of the programming computer is very new (2304). The recommended solution is to uninstall the TwinCAT2 version on the programming computer and install a TwinCAT2 version that is the same or similar to the controller's version.
Q: How should I understand Action, method, Transition, and Properties?
A: Action can be seen as a subroutine, and its variables are defined within the POU (Program Organization Unit) it belongs to.Transition refers to the transition conditions used between steps in an SFC (Sequential Function Chart). To familiarize yourself with it, you can refer to tutorials on SFC programming. Method and Properties are concepts in OOP (Object-Oriented Programming), representing methods and attributes of objects. They can have their own variables, or the variables can be defined in the POU they belong to. If you are accustomed to procedural programming, you may not encounter these concepts frequently. To gain a deeper understanding, you can refer to tutorials on OOP programming.
Q: The logical test of modbusTCP in multi-ports 811, 821, 831 failed.
A: modbusTCP can only be used in the first port 801.
Q: The E-bus power of the first module after the coupler is displayed as a negative value.
A: When an EL module is directly connected to a CX embedded controller, the power supply wiring and voltage measurements are all normal, but the first module displays a negative E-bus power value as shown in the figure below. Additionally, the safety module cannot be added to the Safety project at this time.
It was surprisingly discovered that the coupler module was not displayed. The CX embedded system's built-in coupler should be displayed as EK1200, but it is not present here.
At this point, the best approach is to check if any EtherCAT description files, especially those provided by TwinCAT, have been deleted from the debugging PC. Update the description files to ensure that all built-in EtherCAT description files are present. After doing so, reopen the software and scan the IO to ensure it functions normally.
The storage path for TwinCAT3 description files is: C:\TwinCAT\3.1\Config\Io\EtherCAT
The storage path for TwinCAT2 description files is: C:\TwinCAT\Io\EtherCAT
Q: Can the CE system perform NTP clock synchronization?
A: Yes, it can.
Please refer to the following settings for the path:
Start -> CX Configuration -> Miscellaneous tab
If you need to set up a local area network without access to the internet, you will need to configure a clock manually and change the SNTP Server address to your own address.
Q: Error 1402 "unkown\components\xxxxx" encountered during TwinCAT installation
A: Solutions:
① Easiest Approach: Reinstall the Operating System
Install TwinCAT on a professional edition or higher of the operating system with administrative privileges.
② Modify Registry Permissions
Use the Win+R key combination to open the "Run" dialog box, enter
regedit
and press Enter (requires administrative privileges).Navigate to the key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData
Right-click "UserData" and select "Permissions..."
Click the "Advanced" button.
Select "Administrators...", check the box for "Replace all child object permissions with inheritable permissions from this object", and click "Apply". Change the owner to Administrators (not Administrstor).
Note: If you encounter an error stating "Registry Editor cannot set security on the selected key and some of its subkeys" at Step 5, after clicking Apply,
Here's how to resolve this issue (close the Registry Editor if it's still open):
Download "psexec" from the following link:
https://docs.microsoft.com/en-us/sysinternals/downloads/psexecExtract the downloaded file.
Open a Command Prompt with administrative privileges, navigate to the extracted folder, and execute
psexec -i -d -s regedit
.
To navigate to the extracted folder, assuming the folder is D:\ExtractedFolder, in the cmd window, type D:
(note the colon) and then cd ExtractedFolder
.
After that, enter the command psexec -i -d -s regedit
to enter the Registry Editor.
Follow the steps for modifying registry permissions again.
Note: Running the above command requires closing the Registry Editor to successfully modify permissions. Otherwise, you may encounter the error "Registry Editor cannot set security on the selected key and some of its subkeys".
Q: Where are the actual paths for TC_BOOTPRJPATH and TC_INSTALLPATH?
A:
Q: What does the asterisk (*) mean in array[*]
?
A: The asterisk (*) in array[*]
represents a variable-length array (dynamic array) used in functional blocks.
Q: Using Variable-Length Arrays
A: When programming the input pins of a functional block and we want to have a variable-length array, we can follow the example provided in the info section. The function showcased there allows for accepting different length arrays and calculates the sum of the array's contents.
Sample:
FUNCTION F_Sum : DINT;
VAR_IN_OUT
aSample: ARRAY [*] OF INT;
END_VAR
VAR
nI, nSum2 : DINT;
END_VAR
nSum2 := 0;
// LOWER_BOUND and UPPER_BOUND achieve fetching the lower and upper bounds of an array, and then iterate to accumulate each element's value
FOR nI:= LOWER_BOUND(aSample,1) TO UPPER_BOUND(aSample,1) DO
nSum2 := nSum2 + aSample[nI];
END_FOR;
F_Sum := nSum2;
Q: EL5101 cannot receive pulses, and the ABled light does not flash.
A: Check steps:
First, confirm if the run light is constantly on based on the LED indicators. If not, reconfigure and activate again.
After connecting a signal to one of the A+A_ inputs, use a multimeter to measure the voltage. For a single-ended signal, the voltage should be between 3.55.5v. For a differential signal, voltage variations of +- can be detected, with a range of 0.213v.
Confirm that the 24V voltage supply from the front-side ++-- IO load is providing power to the module. This can be verified by measuring the 24V and 0V pins on the module itself.
Q: Errors and Basic Usage Instructions for Python Communication with TwinCAT ADS
A:
First, here are the examples and documentation for Python communication with ADS on GitHub:
https://github.com/stlehmann/pyads
http://pyads.readthedocs.io/en/latest/index.html
Install Python: Download it from the official Python website.
Install Components for Python Communication with ADS (pyads): (Two installation methods)
From PyPi: (Recommended, run this command in CMD)
$ pip install pyads
From Github:
$ git clone https://github.com/MrLeeh/pyads.git --recursive $ cd pyads $ python setup.py install
- Test Python Communication with TwinCAT 3 via ADS:
- Add routes on both sides (must use TwinCAT's ADS version to add routes on Windows).
- TwinCAT 3 program:
- Declare an
int_val:int;
in MAIN.
- Declare an
- For Python, use IDLE and enter commands one by one:
- Errors and Solutions:
FileNotFoundError: Could not find module 'TcAdsDll'. Try using the full path with constructor syntax.
:
To resolve this, find the pyads_ex.py
file path, open it, locate line 51:
_adsDLL = ctypes.windll.TcAdsDll # type: ignore
Replace it with the absolute path to
TcAdsDll.dll
:_adsDLL = ctypes.windll.LoadLibrary("C:\\twincat\\AdsApi\\TcAdsDll\\TcAdsDll.dll")
(Note the path format.)
- Finally, here are examples of communication for various types of variables.
Q: Can I use the same variable to reset three Twinsafe function blocks?
A: Yes, you can. You can bind 3 variables to a single reset variable. However, this is only possible with version 4024 or above. It's not supported in versions below 4024.
Q: Error encountered when opening the pro program: "Error while loading download information for current target: login without download possible!"
A: In the TwinCAT PLC Control, use the "Clean Build" option in the project's toolbar at the top. After that, rebuild the project and save it.
Q: Modbus RTU error codes: MODBUSERROR_CRC, MODBUSERROR_NO_RESPONSE, MODBUSERROR_ILLEGAL_FUNCTION
A: For MODBUSERROR_ILLEGAL_FUNCTION:
① Check if the function block is correctly written. Ensure that writereg
and readreg
are used separately.
② Verify the license in the controller. Check if there's a mix of temporary and permanent licenses. You can temporarily remove the permanent license and use the temporary license instead.
A: For MODBUSERROR_NO_RESPONSE and MODBUSERROR_CRC, as well as MODBUSERROR_ILLEGAL_FUNCTION:
① First, use a Modbus debugging tool to communicate and check if the wiring is correct.
② If using 485 communication, modify the COE parameter settings as follows: Set enable half duplex
to true
and enable point to point connect
to false
.
Here is the list of error messages.
TYPE MODBUS_ERRORS :
( (* Modbus communication errors *)
MODBUSERROR_NO_ERROR, (* 0 *)
MODBUSERROR_ILLEGAL_FUNCTION, (* 1 *)
MODBUSERROR_ILLEGAL_DATA_ADDRESS, (* 2 *)
MODBUSERROR_ILLEGAL_DATA_VALUE, (* 3 *)
MODBUSERROR_SLAVE_DEVICE_FAILURE, (* 4 *)
MODBUSERROR_ACKNOWLEDGE, (* 5 *)
MODBUSERROR_SLAVE_DEVICE_BUSY, (* 6 *)
MODBUSERROR_NEGATIVE_ACKNOWLEDGE, (* 7 *)
MODBUSERROR_MEMORY_PARITY, (* 8 *)
MODBUSERROR_GATEWAY_PATH_UNAVAILABLE, (* A *)
MODBUSERROR_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND, (* B *) (* additional Modbus error definitions *)
MODBUSERROR_CHARREC_TIMEOUT := 16#20, (* 20 hex *)
MODBUSERROR_ILLEGAL_DATA_SIZE, (* 21 hex *)
MODBUSERROR_ILLEGAL_DEVICE_ADDRESS, (* 22 hex *)
MODBUSERROR_ILLEGAL_DESTINATION_ADDRESS, (* 23 hex *)
MODBUSERROR_ILLEGAL_DESTINATION_SIZE, (* 24 hex *)
MODBUSERROR_NO_RESPONSE, (* 25 hex *) (* Low level communication errors *)
MODBUSERROR_TXBUFFOVERRUN := 102, (* 102 *)
MODBUSERROR_SENDTIMEOUT := 103, (* 103 *)
MODBUSERROR_DATASIZEOVERRUN := 107, (* 107 *)
MODBUSERROR_STRINGOVERRUN := 110, (* 110 *)
MODBUSERROR_INVALIDPOINTER := 120, (* 120 *)
MODBUSERROR_CRC := 150, (* 150 *) (* High level PLC errors *)
MODBUSERROR_INVALIDMEMORYADDRESS := 232, (* 232 *)
MODBUSERROR_TRANSMITBUFFERTOOSMALL (* 233 *) ); END_TYPE
Q: How do I rotate a control in TwinCAT 3 PLC HMI?
A:
Adjust the "rotation" and "interior rotation" options in the "absolute movement." The former refers to the revolution around the black cross point, while the latter represents the rotation on its own axis. Please refer to the following for detailed instructions: