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.

Concepts

Throughout the tutorial, you need an understanding of the following concepts:

- COPP Component

- GUID

- Inheritance

- Archive

- Instance

- Constants

- Variables

- Quantity

- Subcomponents

- Connectors

- Methods

- Method call

You can find a description of each concept in the glossary. You can read it at once, or several times throughout the tutorial.

 

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 connected to a heating element. But, 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.

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.

Step 3 - 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.

Step 4 - 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.

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.

Step 5 - 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:

Step 6 - 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 7 - 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 8- 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 empty view.

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.