215
MG.10.J8.02 – VLT is a registered Danfoss trade mark
Programmable SyncPos motion controller
■
■
■
■
■
COM_OPT
/* Program for sending and reveiving 8 bytes of */
/* data via a communication option using */
/* PPO type 2 */
/* Definition of arrays */
DIM send [4]
DIM receive [4]
/* Definition of user parameters */
LINKGPAR 133 710 “DATA WORD 1” 0 255 0
LINKGPAR 134 711 “DATA WORD 2” 0 255 0
LINKGPAR 135 712 “DATA WORD 3” 0 255 0
LINKGPAR 136 713 “DATA WORD 4” 0 255 0
/* Initialize arrays (all elements = 0) */
i = 1
WHILE (i<=4) DO
receive [i] = 0
i = i+1
E N D W H I L E
j = 1
WHILE (j<=4) DO
send [j] = 0
j = j+1
E N D W H I L E
/* Main program loop */
main:
send [1] = GET 133
/*
send
array, element 1 = value of par. 710 */
send [2] = GET 134
/*
send
array, element 2 = value of par. 711 */
send [3] = GET 135
/*
send
array, element 3 = value of par. 712 */
send [4] = GET 136
/*
send
array, element 4 = value of par. 713 */
COMOPTGET 4 receive
/* Copy 4 words from comm. option */
/* to
receive
array */
COMOPTSEND 4 send
/* Copy 4 words from
send
array to */
/* communication option */
/* Print data of
receive
array */
print “RECEIVED(4 WORDS)”,” “,receive [1],”
“,receive [2],” “,receive [3],” “,receive [4]
GOTO main
/* End of program */
Program samples
■
■
■
■
■
Marker count
/* Measurement of marker distance in */
/* connection with SYNCM */
/* Master and slave must run when this program */
/* is executed */
DIM test[4] /* Definition of array with 4 elements */
/* Definition of variables */
dones = 0
donem = 0
/* Save last marker position for slave and master */
test [1] = IPOS
test [2] = MIPOS
/* Start of main program loop */
main:
/* Monitor the next slave marker and */
/* save it’s position */
IF (IPOS != test [1] AND dones == 0) THEN
test [3] = IPOS
dones = 1
res = test [3] - test [1]
/* Calculate distance between 2 consecutive */
/* slave markers */
PRINT “Slave distance “, res
/* Print result */
E N D I F
/* Monitor the next master marker and */
/* save it’s position */
IF (MIPOS != test [2] AND donem == 0) THEN
test [4] = MIPOS
donem = 1
res = test [4] - test [2]
/* Calculate distance between 2 consecutive */
/* master markers */
PRINT “Master distance “, res
/* Print result */
E N D I F
GOTO main