Yiwei Automation: Methods for Creating Complex Data Types in UDT and Modifying UDT Interfaces
2026-04-06 05:17:10··#1
User-defined data types (UDTs) are a special data structure that users only need to define once, and then use as a data type in their programs. The first step in creating a complex UDT (using the control of three motors as an example)is to create the UDT and define the relevant interfaces:Step 2: Create DB (DB1 below), and select the UDT you just created in the interface type of DB1.Step 3: Create FB (FB1 below), define the interface, and write the relevant motor control program:Open FB1 and define the interface variables in FB1.Write the following motor start/stop program in FB1:Step 4: Create a new FB (FB2 will be created below), and make FB2 into multiple background data:Open FB2 and define the interface variables in FB2 (to provide background data for starting and stopping the three motors):Step 5: Create an FC (FC1 below), and write a program to assign values to the data in DB1:Write the program in the FC:Step 6: In OB1, call FB2 and FC1:OK, this is complete.In actual device debugging, because we need to debug the functions, depending on the actual debugging situation, we may need to add or remove interfaces. Below is a demonstration of how to add an interface in UDT:First, add an interface variable in UDT1:The second step is to modify the DB1 source files:because the interface has changed, we need to check and update the interface of each block.The third step is to modify the relevant procedures in FB1:Because the interface has changed, we need to check and update the interfaces of each block (forwarding code: Yiwei: Focus on core control).Fourth step: Define parameters for the new interface in FB2, and define the actual parameters for the newly added interface in FC1.Welcome to follow Yiwei's WeChat subscription account (unimat2004) to learn more about industrial control technology anytime!