Programming Example
Project:
Assume
you want to calculate the mean value between two signals in the control
system and write
the result to a third signal.
What
to do:
We make
this application 3, so open App03 Command Window.
The
resulting picture will be like below:
Now at
the >> prompt, type
>>edit
TaskInit
and the
result will be the editor opening with TaskInit.m
Insert
how often the program should run in SYS.Ts=10. Meaning each 10 sec.
Save the
file.
Now open
the file TaskScheduler.m either by writing ‘edit TaskScheduler’ in the
command window
or press ‘file open’ and select the file. The result is shown
below:
Leave the
line with the command AppGetPointValues, because we here need to get values
from
the control system.
Add the
following lines to make the program:
And then
start the task:
You now
have the mean value written to the point ‘Z4M01L3’ every 10 seconds.
A short
explanation:
The
functions PVa(‘Z4M01L1’) and PVa(‘Z4M01L2’) gives you the present process
values.
The
signalmean is then the sum divided by 2.
The
function writeDPV(‘Z4M01L3’,signalmean) will write the value of signalmean
to the process value
with the tagname ‘Z4M01L3’.
Normally
the task is not programmed directly in TaskScheduler, but in a function,
which is then called
from TaskScheduler.
The
Workspace Browser, is used to monitor the variables in the present
workspace, but also the
editor has a good tiptool text giving the values of
most variables when you point them.
The
variable SYS contains all information from the underlying control system.
Functions like PVa(‘tagname’) is used to extract the information in an easy
way.
The
File Browser shows all files in the present directory.
Here you
can double click on one of the files in this application to open it in the
editor. The editor picture
is shown above, where we enter the program.
When a
file is in the editor, you can insert breakpoints, where the program
execution will stop so
you can inspect the values. You can then single step
the program, line by line, to check what happens
is what you expect.
And
finally, you have access to the excellent Matlab Help Browser:
During
development, you will often have all of the above windows open.
During
operation, the SIMEQ system is normally invisible.
SIMEQ - It’s a pleasure to
work with.
To the top
|