In this first tutorial, we will show you some key ideas of VIGO6 that will help you build your first control component. The tutorial switch between theory and hands-on exercises with "how-to" videos as a help. You can spot the videos by this icon:

Now - let's start.

The VIGO6 editor

VIGO6 arranges the COPP types in a tree structure, like the navigation pane in Windows File Explorer.
 
Each type has a little icon, that lets you spot the types in the tree. For example, a component type has a C icon.
 
You can define data types, constants, and variables in the tree. When you change the name of a type, VIGO6 updates the program code for you. 
 
You can navigate with the four arrow keys or the mouse. You can open more than one type at the same time, with the use of tabs.

 

To the right is the properties section. Where you can see the properties for the types you select in the tree. You can also configure your type here. For a project, you can choose the language, color theme, and more. Another example is a device, where you can set the serial number from the project view.

The virtual tour of VIGO6

COPP Component

A COPP component is one of the types in VIGO6.

It is a blend of program code, data, and settings that defines a specific use. In addition, it has a memory with variables and constants, that uses various memory categories.

It also contains methods with program code. The method has access to the memory, and it can call other methods in the component, as well as in other components (through connectors).

GUID

VIGO6 creates a GUID (Global Unique Identifier) for all COPP types that follow this format:

<company identifier>_<ID number>-<version number>

An example of the format is “PD_2886-01”, where the type is 2886, version 1, from the company PD.

Inheritance

When you inherit from a component type, you create a new type with its own GUID. The new type is the descendant, while the other is the ancestor. You can add new elements to the new type. Further, the editor makes sure that it keeps all of its ancestor’s traits in order to stay compatible with its parent. However, you can't change the parameter type for the ancestor’s methods.

Version control and archive

An archive system is a part of VIGO6. VIGO6 stores all COPP types in the COPP archive and you can identify them by their GUID. Each type has COPP information and related documentation. When you change an archived type, it gets a new version by the editor and server.

Instance

When you define a type, you can use it again and again. For example, when you add a component in a project, you use an instance of the component type as is. Further, you can add as many instances as you need. In the case, where there is a new version of a type, you can decide if you want to update the instances of the type or not.

Now let's start with VIGO6

What you need to build - control logic

1. You need to build the light green component in the picture to the left. You specify a setpoint. When the temperature is below the setpoint, the component should turn on an output that is connected to a heating element. On the other hand, when the temperature is above the setpoint, the output should turn off.

2. You "measure" the temperature with a 4-20 mA temperature transmitter.

3. The regulation is a simple on/off controller with a temperature hysteresis. You control the regulating interval with a timer.

What you need to build - view

 

You need to be able to view both the setpoint and the current temperature and change the setpoint.

NB: A note on names. When you need to name a new type, we will present the name like this "XX_Temperature_regulator_simple". Please use two letters that make sense to you - like your initials - and use them instead of "XX".

Step 1 - Create a temperature regulator component

1. Open the component.

    a. Click on the "open type"-icon (or press "CTRL-O").

    b. Then select "COMPONENTS>>".

    c. You can now type any part of the name or GUID. Find "PD_7664 Process_component" - and double-click to open it. 

2. Create a new type.

    a. Right-click on the component name

    b. Select “Create new type”.

A new tab will open with the new type, where you are the writer. The component is inherited from PD_7664.

    c. Change the name. Double-click on the name of your component and change it to "XX_Temperature_regulator_simple".

NB: When you press space, you make an underscore.

Constants

 Constants are either type constants or instance constants. You define and set type constants at the type level. It means that you can't change them in instances of the type. On the other hand, you define instance constants at the type level but set them at the instance level.

 

Variables

Variables can be volatile or non-volatile. While volatile variables lose their value on power off, non-volatile will keep them. Both are local to the component or method where you declare them. If you want to set or view them outside of the component, for example, you need to connect the variable to a register.

Quantity types

Data instances can have a "quantity type". In effect, visualization is simpler, and it enables the compiler to prevent quantity errors in your program.

Examples of quantity types are:

  • Density
  • Pressure
  • Energy
  • Volume
  • Mass
  • Time

When you add variables of a floating-point type that represents a quantity, it is important to state the quantity type.
The compiler deduces the quantity type for the result of a calculation or expression. In effect, when you assign a value to the float, the compiler analyzes the quantity types and shows when there is an error such as Volume: = Density

Step 2 - Create variables and constants in your component

 

1. Add an instance constant
    a. Right-click on the section "INSTANCE CONSTANTS".

    b. Click on "Add constant".

    c. Choose PD_2003 Float32.

    d. Change the name to Regulating_interval.

    e. Right-click on the variable and press "Quantity type". Choose TimeDifference.

It defines how often the regulator runs.

2. Add a volatile variable
    a. Right-click on the section "VOLATILE VARIABLES".

    b. Click on "Add variable".

    c. Choose PD_2003 Float32.

    d. Change the name to Actual_temperature_value.

    e. Right-click on the variable and press "Quantity type". Choose AbsoluteTemperature.

It holds the actual temperature.

3. Add a non-volatile variable

    a. Right-click on the section "NON-VOLATILE VARIABLES"

    b. Click on "Add variable".

    c. Choose PD_2003 Float32.

    d. Change the name to Setpoint_value.

    e. Right-click on the variable and press "Quantity type". Choose AbsoluteTemperature.

    f. Set the default value to 25 [degrees celcius].

It holds the set-point for the regulator.

Local unit definitions

The system stores all data in a COPP component in SI-units. Human interfaces as display and editor convert from the SI units to the unit definition you select via the local unit table. The unit table defines a set of units. For example, there is a local unit table for Europe and another for the US. You may prefer to work with gallons and display it in liters in the view. This is not a problem when you use VIGO6.

Step 3 - Set the local unit table in the editor

1. Click on "Change editor setup" (the orange wheel).

2.

    a. Click on the combo box "Default Quantity Local unit relation table".

    b. Select: PD_5311 Europe_metric_system.

 

NB: You choose the units for the views in tutorial 2. For now, you have set the units that you use in the editor.

Subcomponents

A special type of component that you can add to another component (the parent). A subcomponent defines an interface, as well as data instances. It has methods with access to its declared data structures. By override, the methods can get access to the data in its parent. When a component as a parent adds a subcomponent, the parent has direct access to data in the subcomponent.
Examples areregister” and “timer”.

You can access the variable through the Set and Get methods.

You access the register like you would access a variable. For example "My_register:= 27", will call the register's Set method with 27 as a parameter. It will store the value "27" in the register's variable.

Step 4 - Add subcomponents - registers and timer

We want to make the variables Setpoint_value and Actual_temperature_value visible outside of the control component - for example for the view or for other components.

Add registers

1.

Right-click on the subcomponent section of your component and select:

Add>>, Register>> click on PD_4050 Register.

 

2. Change the name of the new register to "Setpoint".

 

3.

    a. Right-click on the register and click: "Assign data field to the register subcomponent". Select "Setpoint_value" as the register variable.

    b. Make sure that you enable "get" and "set" for all user types. To clarify, it tells the view that the variable is to read and write.

    c. Press "define value range". Set the maximum value to 40 and minimum value to 20. Do the same for alarm limit high and alarm limit low.

 

4.

    a. Then create a register with the name Actual_temperature for the variable Actual_temperature_value in the same way.

    b. Enable "get" and disable "set" for all user types. This tells the view that this variable is read-only.

    c. Press "define value range". Set the maximum value to 100 and the minimum value to 0. Do the same for alarm limit high and alarm limit low.

Add a timer

1.

Add a timer, so you can repeat your regulation at defined intervals:
    a. Add PD_4404 Timer_subcomponent to the Subcomponent section.

    b. Change the name to Timer.

    c. Click on the timer. Read the uses for a Timer_subcomponent, by selecting the methods and reading the documentation to the right of the VIGO6 navigation tree.

 

Connectors

A method in the (sub)component X is able to call a method in the component Y via a connector.
The connector is a "placeholder" for a connection to a component of a given type.

You don't make a choice about the hardware for the components at this point. As a result, you can use the same control component with many (compatible) types of hardware. This means, that you don't need to make new control code or views for each.

If for example, a specific hardware module for output control is out of production, you simply need to switch the physical module. Afterward, your plant can continue to run without writing new code or compiling your project again.

Step 5 - Add connectors

 
 

Your temperature regulator component will need to interface with already made components. First, for reading a temperature (the orange component on the drawing to the left), second for setting a digital output (the blue component on the drawing). Hence you need to add connectors.

 

Create a connection to the output component

1. Under the section "Connection to external components" in your component:

Add a connector to an instance of type: PD_2824 Digital_output_base, which is a basis for more output types.

2. Rename it to Output.

3. Create a connection to a temperature component:

Under section "Connection to external component": Add a connector to instance of type: PD_2854 Temperature_input_base rename it to Temperature.

Methods

Methods contain program code that only runs when you call the method. It is similar to a function in PROCESS-PASCAL, that can have parameters and a result.

Program code in a method has direct access to parameters, local variables, component variables, and constants. However, methods differ from functions, as you can call them via P-NET.

Assignment of a value to a variable

On the left of ’:=’ you write the name of the variable, you want to assign a value to. On the right side is the value. For example, a constant, variable, or method. When you have a variable with a specific quantity, you need to give it the correct local unit (SI unit).

For example: Weight_Setpoint: = 35 [kg]

The compiler checks that the types match. In addition, it checks the quantity type is correct.

Popup menu

When you right-click in the editor, a popup menu will appear. It shows the choices of correct program code at that spot. You can place the cursor at the start of a code line or just after the last text, In effect, you don't have to learn the whole syntax at once.

Further, the popup menu preloads control structures that you can use as code templates.

COPP Notation without Begin and End

A block in a COPP program doesn't use a BEGIN and an END. Instead of "BEGIN" you use an indentation, while a reverse indentation means "END". 

With indents, you create a tree-like structure where the indents show the level structure of the code. The editor inserts vertical lines and highlights the current block that makes it easier to read.

THEN and ELSE are sub-structures to IF and have the same indentation. Plus and minus icons are next to IF, THEN, and ELSE blocks. You can use them to show or hide the block.

Step 6 - Add a method and write your control code

Now you need to write the actual piece of code that will enable your component to make the wanted regulation.

Create a new method:

1. Right-click on the method section and select "Add Method". Name it Regulate.

Write code for your temperature control:
You can right-click and use "select identifier" and "code templates" instead of writing all the code yourself.
 

1. Read the temperature from the input component into the register "Actual_temperature" in the control component.

2. If the temperature is lower than the setpoint, then open the output.

3. In all other cases close the output.

Here is what your code should look like:

Method Call

When you define a method’s parameter and result type -you have to define the name, data type, and quantity type. It is the same as for a variable.

You have to include the individual parameters by name in a method call:
X: = Component Name. Method Name (Content: = delivered_amount, Number: = 7)

It makes the code easier to review. In addition, you don't have to know the order of method parameters, as this will be clear from the parameter names. As a result, it can reduce the number of errors. The pop-up menu only shows the identifiers for instances of the data and quantity types you can use.

 

The editor has template functionality, which writes the parameter names, for example:
Method Name (Content: =?, Number: =?)

Methods may have local variables that only exist as long as the method runs.
You can give local variables a name and maybe a quantity type.

When you call a method, the system sets a local variable to "invalid", and you have to initialize it in the code before you can use it. It makes your program more secure.

When a method makes a calculation, the data instance values and quality indications affect the outcome. It will be a part of the result of the calculation. In other words, if one or more is invalid, the result will also be invalid.

Step 7 - Repeat the regulation

You need to make sure that your regulation keeps running at specific intervals, and for this, you use the timer subcomponent that you added earlier.

1.

    a. Fold out the Timer subcomponent in your component and select the method "Timermethod".

    b. Right-click to Override and open "Program".

In the first line of the program, it says INHERITED. This shows that the method of the ancestor will run. Don't delete the INHERITED, unless you know what happens in the code from the whole ancestor chain.

 
2. Now create the program code that:

    a. Calls the Regulate method

    b. Runs the Timer again - in the time you have set in your constant Regulating_interval.

What your code should look like:

Step 8 - Handle the startup in Init

You need to be sure that your system is in a known state before you start your regulation.

1. ‘Overridethe Init method in your Temperature_regulator_simple component.

2. Call the Timermethod after ‘Inherited’.

What your code should look like:

NB: The editor inserts ‘Call_asynchronously’ when you call a method marked "Internal" from a method marked "External". See Task Manager for further information.

Visualization

In VIGO6 you decide at the component level what parts of the component to make available in a view. If you need to see or edit data outside of your component - you need a register. You did the same for setpoint and actual temperature.

You can create your own views or use and build upon views that others have made. 

Let us make a simple view of our temperature regulator component.

Step 9 - Create a view of the temperature regulator component.

Your component should be able to view and change the set-point and to view the current temperature.

1. Open your control component "XX_Temperature_regulator_simple".

2. Right-click and pick “create new view for this type based on” PD_11813 - Comp_view".

3. Rename the view to "Window_for_XX-temperature_regulator_simple".

4. Choose type constants, view_region, bottomRight and set y to 50[mm] and x to 100[mm].

5. Save your view.

6. Open your graphical editor by pressing the "Show view"-icon seen to the right. It is just above the VIGO6-navigation tree and looks like a boy. You now see your view that is empty for now.

7. 

    a. Right-click on the view list and pick "add"- "view for control instance".

    b. Click on the plus sign next to " XX_temperature_regulator_simple".   

    c. Pick register "Setpoint".

    d. Select view PD_2159 - Number_name_value_unit.

8. On your view, you now see the element and you can drag it where you want on the screen.

9. Add a similar view for register "Actual temperature".

Your view should look like this:

Congratulations. Finally, you have created your control component with control logic and a view. You can use it again and again.

 

And to recap, here is what you have built:

Now let us move to the next tutorial where you learn how to create assemblies, main assemblies, and projects. And you will set up your testbed and load your components into a hardware module.