declaring variables with AT qualifier for IO assignment - TwinCAT NE CODESYS

AlfredoQuintero

Lifetime Supporting Member
Join Date
Feb 2015
Location
Yokohama
Posts
1,551
Hello TwinCAT and CODESYS experts: kolyur, AustralIan, busarider29, et. al.
I will be once again very glad to get your expert advice on this one issue.
I have to develop a PLC program for a somehow sophisticated but very straight forward EtherCAT device: all the control and monitoring of the device takes place through the process data objects. No problem up to this point; I get the comms and so on. The ESI file describes in exhaustive detail the mapping of all the variables in the EtherCAT device. So I created in the PLC program user data types that mirror the description of the PDO structures, and one can copy paste the UDTs from CODESYS to TwinCAT and viceversa.

In CODESYS I can declare a variable of the user defined type and by means of the AT qualifier in the declaration, and by confirming the actual memory assignment for the EtherCAT device in one simple assignment all the variables that are defined in the user data type get automatically assigned to the correct offsets in the IO memory, in one line of code!

My question is whether it is possible to do the same in TwinCAT an based on the result of my attempts, it seems it is not possible, as TwinCAT only allows (or seems only allow, would love to be proven wrong here) basic data types like BOOL or INT to be linked as the TwinCAT program detects the different variables described in the ESI file.

In case the above is the cause for not being able to do one IO-to-PLC-variable link in TwinCAT, I wonder whether it would be possible to develop and ESI file that would describe a user defined data type and then the entries in the PDO would not be a collection of the different BOOL, INT, DINT, etc, but the defined user data types. I have never seen such an ESI file (there may be) but I am hypothesizing here that if the ESI file entry was say for the Tx PDO one single variable of the same SIZEOF as the user data type in the TwinCAT UDT definitions, then it may allow to assign just one variable. This would be very useful for the user-friendliness of this EtherCAT device, as I can foresee a use case in which one machine may require several of these devices.

Of course normally nobody should modify ESI files other than the manufacturer of the device, but this device is not yet released and we are developing this firmware, hence we are in this unique position in which we still can change the ESI file. Long e-mail, sorry about that, but thanks for reading down to this point.
 
I have remembered that I tried to use user defined types for the PDO and the EtherCAT conformance test tool gave a number of warnings. am not sure whether the EtherCAT specification forbids the use of UDTs. Will think about this later because it is late here, but will appreciate some guidance on the TwinCAT variable assignment
 
In Twincat 2 you can define variables so I think timecat3 would be the same ( they are both basically Shrinkwrapped Codesys anyway) with the @ but they can only be WOrd, DOuble Work and Bit types if I remember something like like

Input12 at %QW4.0
 
Can you declare a complex variable as AT %I* or AT %Q* and then link it to a matching type variable in the I/O tree? I think this is a default approach in TwinCAT anyway.
 

Similar Topics

Hello to Siemens experts of the forum. Yet another basic inquiry. I have been tasked with verifying that a program developed for S7-1200 with TIA...
Replies
10
Views
3,875
Hi everyone I hope someone would be so kind to help me with this issue, I have trouble finding the way to declare a value which I want to be my...
Replies
1
Views
1,289
Hi guys. I'm trying to create an add on instruction that will take up to 10 values and output the highest and lowest values. I would like to...
Replies
4
Views
2,616
Hi, we are using Rx3i CRU320 redundant PLC system and we noticed a discrepancy between Primary and Secondary controller. Couple of variables (DI)...
Replies
8
Views
284
Hi everyone, I was wondering how we declare Persistent Variables in Studio 5000 (main reason to keep the values during power cycle and program...
Replies
5
Views
247
Back
Top Bottom