DRAFT

Tutorial 1:
Create a component

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.

Now let's start with VIGO6

What you need to build - THE 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 - THE 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 "Temperature_regulator_simple".

SEE THE INTRO

Play Video

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 descendant of 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 "Temperature_regulator_simple".

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

 

SEE HOW IT WORKS

Play Video

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.

SEE HOW IT WORKS

Play Video

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.

Click to enlarge!

Add registers

1. Add a register
a. Right-click on the subcomponent section of your component and select:
b. Add>>, Register>> click on PD_4050 Register.

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

3. Assign data to the register
a. Right-click on the register and click: "Assign data field to the register subcomponent".
b. 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. Add the next register
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, and nobody car write the data from a visualization.
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 usage for a Timer_subcomponent, by selecting the methods and reading the documentation to the right of the VIGO6 navigation tree.

SEE HOW IT WORKS

Play Video

Step 4 - Add connectors - CONNECTION TO OTHER COMPONENTS

Click to enlarge!

Your temperature regulator component will need to interface to the orange temperature input component and to the blue digital output component.

Therefore in this case two connectors are needed.
One for the temperature and one for the output.

Create a connection to the output component

1. Under the section "Connection to external components" in your component:
Add Connector to component of type: Digital output base PD 2824, which is a basis for more output types.

2. Rename it to Output.

3. Create a connection to a temperature component:Add Connector to component of type: Temperature Input Base PD 2854.

4. Rename it to Temperature.

SEE HOW IT WORKS

Play Video

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.

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

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

5. In all other cases close the output.

Here is what your code should look like:

SEE HOW IT WORKS

Play Video

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. Where to insert your program
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

SEE HOW IT WORKS

Play Video

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. ‘Override’ the After_init method in your Temperature_regulator_simple component

2. Call the Timermethod after ‘Inherited

What your code should look like:

SEE HOW IT WORKS

Play Video

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 “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_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 play button.

You now see your empty view.

6a. Instead of adjusting the size in 4., it is also possible to adjust the size, by right-click on the shown view, and adjust the size here.

7. Add the values to show
a. Right-click on the view list and pick “add”- “view for control instance”.
b. Click on the plus sign next to ” 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:

SEE HOW IT WORKS

Play Video

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.