89
MG.10.J8.02 – VLT is a registered Danfoss trade mark
Programmable SyncPos motion controller
■
■
■
■
■
Programming with SyncPos
■
■
■
■
■
Fundamental Program Layout
••••• Definitions: Arrays, Interrupts, User
parameters
••••• Initializing: Setting parameters, flags and
variables
••••• Main program loop
main
:
–
GOTO
main
••••• Sub program area
SU B MAI N PROG
SUBPROG
name
–
R ETU R N
E N D PROG
Definitions
Array
DIM send[12], receive[12]
Interrupt
ON ERROR GOSUB errhandle
ON INT –1 GOSUB stopprog
ON PERIOD 500 GOSUB calc
ON TIME 10000 GOSUB break
User parameters
LIN KAXPAR SYNCACCURACY 710
"ACCURACY [qc]" 0 100000 0
LINKGPAR 133 716 "Offset [qc]" 0
100000 0
Initializing
Parameters
SET POSERR 100000000
SET 133 10000
SETVLT 205 50
Flags/variables
offset = 0
sync_flag = 0
System parameters VEL 100
ACC 100
DEC 100
Main program
main:
IF (IN 3 == 1) THEN
/* Go into synchronizing mode, if input 3 = 1 */
GOSUB syncprog
E LS E
GOSUB speedprog
/* If input 3 not = 1, run in speed mode */
GOTO main
Sub programs
SU BMAIN PROG:
SUBPROG syncprog
IF (sync_flag ==0) THEN
/* synchronize, if not already synchronized */
SYNCP
sync_flag = 1
E N D I F
RETURN
SUBPROG errhandle
WAITI 18 on
/* waiting for digital input 18, clear the error */
sync_flag = 0
ERRCLR
R ETU R N
E N D PROG
Sequential command processing
In general a command is processed to the end
before a new command is begun. This means that
for position commands the program waits until the
target position has been reached.
Exception: If NOWAIT has been set to ON.
■
■
■
■
■
Fundamental Command Structure
All instructions consist of: COMMAND WORD +
possible
Parameter
Parameter
Parameter
Parameter
Parameter
.
.
.
.
. A variable can also be used
as parameter instead of an absolute number.
Example
POSA 10000
or
pos = 10000
POSA pos
Command run times
If the command execution times are critical in an
application it is possible to measure the run times
of a command sequence under the different ope-
rating conditions using the command TIME.
Tips for Increasing Program Readability
•••••
Use of capital and small initial letters (i.e. all
commands capital letters, all variables small).
•
•
•
•
•
Placement of spacing between command
parts.
•
•
•
•
•
Place comments in your program. The com-
ments are between
/* … */ or after //…
/* Begin COMMENT End */
// Begin COMMENT End
Inadmissible is nesting comments (/* ...
...
...
...
... /*...
...
...
...
...*/)
•
•
•
•
•
Use of line identification within the loop.
Programming with SyncPos