Beckhoff#Let’s Talk about DUT

This post I will explain a very important concept in OOP Programming – It is DUT(Data Unit Type).you can image that DUT is a tool to help you define servels variables as “One Variables;For Example, you have 10 different  process control parameters with Same Temperature and flow setpoint(I will call it as receiple), you can define as;

process1_temperature1

process1_flowvalue1

process2_temperature1

process2_flowvalue1

But it is very easy to make missmake and not easy to modify in the future.By this case, we can use DUT – to define a variable that includes different variables.

DUT_Process

temperature1

flowvalue1

that you just need to define your parameters just this:

Process:array[0..yourLength] of DUT_Process;

Then access your data like:

Process[0].temperature1

Structure

Let’s do some basics first.

Add DUT>Structure.

Basic

ExtendsのCheckboxがありますが、最初はこれをなしにします。

You can see there isExtend checkbox in here, just ignore it now.

Define 3 variables in this DUT_Basic.

Then Define a new variable with DUT_Baisc inside the GVL(Global variable list)

After you login to runtime, you can see the variables BasicStructureVariable with 3 variables – the variables that you define before.

Extends

Let’s Step into Extends options.

Create a new DUT and Check the Extends box.

The input Assistant popup is shown and choose DUT_Basic, press OK.

Create the new DUT like this.

Now, you can see the EXTENDS keyword. It means the  DUT_Extends_From_DUT_Basic includes all DUT_Basic variables that you defined , but also the new variables.

Let’s add 3 new variables again.

And then define the variable with type DUT_Extends_From_DUT_Basic .

After login to runtime, you can see that the ExtendStructVariable includes more variables than you see in the programming screen before.

The red mark is the part of DUT_Basic and the green mark is the part of DUT_Extends_From_DUT_Basic.

Enumeration

Enumeration is a DUT that allows you to allow different constants as a readable name but not just 1,2,3,4. 


Non-Textlist Support

In TwinCAT System or Codesys, Enumeration has Textlist Support options, it will affect the HMI display. Let;s try Non-TextList support first.

you can see this screen. As I mentioned before, different values of constant can be defined inside here as a readable name.

For example, enum_member:=0, It means that E_Reciple_No_TextList_Support.enum_member=0.

Let’s define some drinks and assign some values inside.


Support Text List

This time we define a Textlist support DUT.

Sure, you can change this option after the DUT is created.

If you want to remove the options, right click and press Remove text list support.

Also, if you want to add the options, right click and press Add text list support.

Now we defined 2 variables – with textlist support and without.

Example

You can directly access the Enum DUT by using the DUT name.

It is very common while you are using TwinCAT Function Block(E_XX Type).

While you go online, you can see the value of Beer and Wine is assigned. It is very readable for the programmer.

Also you can directly compare these values because they are just INT.

Here is an example to show when the recipe number is RedWine, that does something..


Use in Visualization

The main difference between the Support textlist or not, is the Visualization.

Let’s add a Visualization Screen.

Drop a Combo box Integer in the empty area.

And also places some label display.

We have configured a sample drop list screen now.

Click the Textlist support Drop List and go to the variable field.

Choose Reciple_TextSupport variables.

you can see there is a <E_Reciple_TextList_Support> after the variable.

Let’s choose Non TextList Support this time.

Then choose the Reciple_No_TextSupport variable.

There is no additional information like <> after the variable.

You can see the drop list that is assigned with the TextList Variables; all the selections are shown as the Euum Name.

But in the Non Textlist support variable, you can only choose the number format.

Alias

Alias is a tool to let you configure an array DUT easily.

Choose Alias and Array Wizard.

you can configure your 2D or 3D array in here.

For Example, you have an application with 10 small stations and each station has the same parameters.we can define the Dimension 1 to 0..9 and DImension to 0..3 .

Then in the Base Type field, click the input assistant.

I will choose Real or anytime that you want.

Press OK to finish your configuration.

And Then press open to create it.

The structure inside DUTAlias is auto defined as a 2D Array.

Define the DUTAlias variables in the GVL and test it.

You can access the variable like [0,3].or [1,2].

Finally ,Define a variables inside the POU.

you can access myData[x,y] like this.

UNION

UNION is a Special DUT and please reference the following post to get more information:

Beckhoff#Convert the byte array to variables in TwinCAT3 | (soup01.com)

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする