M O T I O N C O N T R O L P R O G R A M M I N G
106
Motion Control Programming
·
Galil Motion Control, Inc.
·
800-377-6329
Complex applications often require several independent tasks
to be executed at the same time. The DMC allows simulta-
neous execution of up to four independent applications pro-
grams. This is an ideal feature for executing independent
operations or PLC tasks in the background.
Each separate task is defined as task 0 through 3. Any task
can be executed or halted from another task. For example,
XQ#POS1,0 begins Task 0. HX0 halts Task 0. All DMC
commands, including event triggers and conditionals, can be
used in each task. However, input interrupts and input
prompts are available only in Task 0.
Multitasking--Background PLC. Example:
The example below shows how four independent pro-
grams can be executed simultaneously from the DMC
memory. The main task #MAIN starts all the other tasks --
#PLC1, #PLC2, #MOVE -- after Input 1 is high. It halts
all tasks when Input 1 goes low. #PLC1 sets Output 2
only when Input 2 and Input 3 are high. #PLC2 generates
a waveform on Output 1 which is high for 10 msec and
low for 40 msec. #MOVE moves the X axis 100 counts,
repetitively.
Instruction
Interpretation
#MAIN
Main Program --Task 0
AI1
After Input 1 high
XQ#PLC1,1
Execute Task 1
XQ#PLC2,2
Execute Task 2
XQ#MOVE,3
Execute Task 3
AI-1
After Input 1 low
HX
Halt all tasks
EN
End program
#PLC1
#PCL1 -- Task 1
OB2,@IN[2]&@IN[3] Set Output 2 if Input 2 and 3 high
JP#PLC1
Loop
EN
End Task 1
#PLC2
#PLC2 -- Task 2
AT0
Set reference time
#LOOP
Loop label
SB1;AT10
Set Output 1; wait 10 msec
CB1;AT-50
Clear Output 1; at 50 msec; reset timer
JP#LOOP
Loop
EN
End Task 2
#MOVE
#MOVE -- Task 3
PR100;BGX;AMX
Move 100 counts
WT20;JP#MOVE
Wait 20 msec and repeat
EN
End Task 3
Arrays
Arrays are structured memories where data can be stored
and retrieved in a certain order. They are useful for storing
sequences of position points or output signals.
An array is characterized by a name and a size. Each ele-
ment in the array is identified by its index. For example, the
array XPOS may have a size of 100 units. As a consequence,
each point is identified as XPOS [N] where N varies between
0 and 99.
Multitasking
MULTITASKING &
ARRAYS
SET X-Y SPEED, ACCEL
AND DECEL
N=0
READ XPOS[N], YPOS[N]
COMMAND X-Y MOTION
WAIT FOR END OF MOTION
WAIT FOR REQUIRED TIME
N=N+1
LOOP
END
YES
NO
Flowchart for Array Program
N<4