Programmable SyncPos motion controller
MG.10.J8.02 – VLT is a registered Danfoss trade mark
92
■
■
■
■
■
Elements of the Programming Language
Constants
Constants can be used anywhere where parame-
ters or values are expected. Constants are usually
entered in integral numbers, for example:
value = 5000
Constants …
…
are integer number values between -2 to +2
billion,
…
are valid within the entire program (they are
global),
…
can be entered as a decimal, hexadecimal
(0x + hexadecimal number), octal (0 + octal
number) or in ASCII (between apostrophes), for
example:
value = 5000
= decimal 5000
value = 0x7F
= decimal 127
value = 0100
= decimal 64
value = ‘A’
= decimal 65
Hexadecimal and ASCII entries, in particular,
avoid many conversions and make the pro-
gram more readable, for example:
key = ‘A’
The advantage of constants is, that they don't
need own storage capacity.
Variables ...
…
can only be used for intermediate data
storage of inquiry and calculation results.
…
occur via the allocation of a value.
…
must not be defined separately.
…
are valid within the whole program, (i.e. they
are global)
…
contain integer number values between –2 to
+2 billion.
…
can be used within commands, instead of
constant values.
…
must be allocated a value before use in a
command.
Variable Identification Names
…
can be of any length
…
can consist of letters, numerals and underlines
…
must not contain any country-specifics, such
as “ä”, “é”
…
must begin with a letter
…
can be written in small or capital letters (no
difference!)
…
may not be identical to a command name
Special Variables
ERRNO = A system variable, which contains the
relevant error number
Arrays
Writing programs with dialog requires user input or
positions to be stored for a longer period of time,
for example, even after the VLT has been turned
off. Usually such input consists of several values
which are best stored in fields or arrays.
Arrays are stored in the memory area of the user
program and are defined globally, that means they
are independent of the current program. The user
can determine how many arrays are defined and
how large the individual arrays should be. This
determination is made with the DIM statement and
is then fixed and cannot be changed (except by
erasing memory). Each program that is intended to
use arrays must contain a corresponding DIM
statement which corresponds to the original defini-
tion. Otherwise an error will be indicated.
DI M Statement
The DIM statement has to be the first statement in
the program and must appear before the
subroutine area.
The DIM statement specifies the arrays to be sub-
sequently used. If no arrays have been previously
created then they will be created now. If arrays had
been previously defined then it is important that
the information corresponds with the original
definition.
Example
DIM target1[20], target2[20], target3[20], plant_offset[50]
DIM parameter[10]
With these commands a total of 5 arrays have
been defined with their corresponding sizes. If this
program is executed once then the arrays listed
above will be created in the SyncPos option. If,
when the program is re-started, it is determined
that the definition of the arrays differs from the
arrays in the SyncPos option, then this is indicated
as an error. However, it is correct if a second pro-
gram only contains the following line:
Example
DIM target1[20], target2[20], target3[20]
Programming with SyncPos