Technical Reference
Motion Programming
www.galilmc.com
/
Galil Motion Control, Inc.
11
Arrays
Arrays are ordered structures in memory where data can be
stored and retrieved.They are useful for storing sequences of
position points or output signals.
An array is characterized by a name and a size. Each element
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.
To store data in the array, we use an instruction such as
XPOS [5] = _TPX which reads the current position of the X axis
and stores the value in the array.The value of the position may
be later retrieved with instructions of the form X = XPOS [5]
which transfers the position value to the variable X.
The use of arrays is illustrated by the following example.
One of the main uses of the array is for recording motion as
described in the following section.
The controller is required to move an XY table to four positions characterized by their coordinates.The values of the required points are stored in the
arrays XPOS and YPOS. Once the controller reaches the specified point, it must wait a certain amount of time before resuming the motion.The waiting
time in milliseconds is stored in the array WAIT.
The program is described in two parts.The first part, RUN, performs the moves according to the requirements.The second part, #STORE, defines the arrays.
INSTRUCTION
INTERPRETATION
#RUN
Label
JS #STORE
AC 200000,200000
Accelerations
DC 200000,200000
Decelerations
SP 50000,50000
Speeds
N = 0
Initial count
#LOOP
PA XPOS [N], YPOS [N]
Specify final position
BGXY
Start motion
AMXY
Wait for completion
WT WAIT [N]
Wait specified time interval
N = N+1
Increment index
JP#LOOP, N<4
Repeat 4 times
EN
End program
INSTRUCTION
INTERPRETATION
#STORE
Label
DM XPOS [4], YPOS [4], WAIT [4] Define arrays
XPOS [0] = 100
Set values
XPOS [1] = 320
XPOS [2] = 450
XPOS [3] = 500
YPOS [0] = -100
YPOS [1] = 20
YPOS [2] = 153
YPOS [3] = 200
WAIT [0] = 50
WAIT [1] = 100
WAIT [2] = 60
WAIT [3] = 120
EN
End program
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
N<4
Flowchart for Array Program
Example--Array