Understanding structs
Structs are special data structures that allow you to group logically related data into a single data structure. Structs in IEC 61131-3 work very similarly to a struct in a C-like language. They are custom data types that contain variables of different data types in a singular data structure. If you’ve never programmed in a C-like language, structs may seem a lot like classes, a concept that will be covered later.
Declaring a struct
Creating a struct is very similar to creating a GVL. Similar to a GVL, you create a struct with the following steps:
- Right-click Application.
- Hover over Add Object.
- Click DUT.
When you finish these steps, you should see a wizard that is very similar to the wizard used to create a GVL, except that it has a few more options. The wizard can be viewed in Figure 4.12. For now, the only thing that you will need to do is change DUT
in the Name field to motorStruct
and click Add. Once you click Add, a new...