147
MG.10.J8.02 – VLT is a registered Danfoss trade mark
Programmable SyncPos motion controller
■
■
■
■
■
SUBPROG name .. RETURN
The instruction SUBPROG identifies the beginning of
a subroutine. The name of the subroutine must
directly follow SUBPROG code word. The name can
be made up of one or more characters, and must be
unique, i.e. only one subroutine may have that name.
A subroutine can be called up and executed at any
time by use of the GOSUB instruction.
A subroutine can have any number of command
lines and can refer to all program variables. The
last command in each subroutine must be the
RETURN instruction, which permits exiting the sub-
routine and continuing the program with the
command following the GOSUB instruction.
Summary
Subroutine definition
Syntax
SUBPROG name
RETURN
Parameter
name = subroutine name
NB!
All subroutines must be contained within the
SUBMAINPROG and ENDPROG defined
areas. It is not admissible to declare a second sub-
routine within an existing subroutine.
Command group
CON
Cross Index
SUBMAINPROG … ENDPROG,
GOSUB, ON ERROR GOSUB, ON INT n GOSUB
Syntax-Example
SUB MAI N P ROG
/* begin SP-section * /
SUBPROG sp1
/* begin sp1
* /
command line 1
command line n
R ETU R N
/* end sp1
* /
E N D P RO G
/* end SP-section
* /
Program sample
GOSUB_01.M, AXEN D_01.M, ER ROR_01.M,
IF_01.M, STAT_01.M
■
■
■
■
■
SWAPMENC
This command allows swapping of the master and
slave encoders. This is particularly meaningful if one
wishes to alternately use two motors with one
control.
Prior to the command SWAPMENC ON/OFF, a
MOTOR OFF must always be executed in order to
avoid a tolerated position error exceeded. Also, the
controller parameters or axis parameters must be
changed if both motors are different.
The motor leads could be switched via relay.
Summary
Swap master and slave encoder internally.
Syntax
SWAPMENC s
Parameter
s = condition
ON = master encoder input is feedback input
OFF = slave encoder input is feedback input
NB!
In this changeover, no positions are lost, even if
the motors are moved by hand while the other
motor is controlled. It is possible to always access the
uncontrolled motor through MAPOS as well.
Command group
I N I
Cross Index
MAPOS
Syntax Example
SWAPMENC ON // Swap slave encoder internally
// with master encoder
Sample
MOTOR OFF
OUT 1 1
// Switch motor leads
SET KPROP ...
// Change axis parameters
SWAPMENC ON
// Swap encoder internally
MOTOR ON
// Turn on control again
POSA 10000
// Move the motor which is
// connected to master encoder
MOTOR OFF
OUT 1 0
// Switch motor leads
SET KPROP ...
// Change axis parameters
SWAPMENC OFF // Swapencoder
MOTOR ON
// Turn on control again
POSA 0
// Move the motor again which is
// connected to the slave encoder
Software Reference