Assignment Of Array Entries - Galil Motion Control DMC-1600 Series User Manual

Table of Contents

Advertisement

Assignment of Array Entries

Like variables, each array element can be assigned a value. Assigned values can be numbers or
returned values from instructions, functions and keywords.
Array elements are addressed starting at count 0. For example the first element in the POSX array
(defined with the DM command, DM POSX[7]) would be specified as POSX[0].
Values are assigned to array entries using the equal sign. Assignments are made one element at a
time by specifying the element number with the associated array name.
NOTE: Arrays must be defined using the command, DM, before assigning entry values.
Examples:
DM SPEED[10]
SPEED[1]=7650.2
SPEED[1]=
POSX[10]=_TPX
CON[2]=@COS[POS]*2
TIMER[1]=TIME
Using a Variable to Address Array Elements
An array element number can also be a variable. This allows array entries to be assigned
sequentially using a counter.
For example:
#A
COUNT=0;DM POS[10]
#LOOP
WT 10
POS[COUNT]=_TPX
POS[COUNT]=
COUNT=COUNT+1
JP #LOOP,COUNT<10
EN
The above example records 10 position values at a rate of one value per 10 msec. The values are
stored in an array named POS. The variable, COUNT, is used to increment the array element
counter. The above example can also be executed with the automatic data capture feature
described below.
Uploading and Downloading Arrays to On Board Memory
Arrays may be uploaded and downloaded using the QU and QD commands.
where array is an array name such as A[].
Start is the first element of array (default=0)
End is the last element of array (default=last element)
DMC-1600
Dimension Speed Array
Assigns the second element of the array, SPEED the value 7650.2
Returns array element value
Assigns the 11th element of the array POSX the returned value from the tell
position command.
Assigns the third element of the array CON the cosine of the variable POS
multiplied by 2.
Assigns the second element of the array timer the returned value of the TIME
keyword.
Begin Program
Initialize counter and define array
Begin loop
Wait 10 msec
Record position into array element
Report position
Increment counter
Loop until 10 elements have been stored
End Program
QU array[],start,end,delim
QD array[],start,end
Chapter 7 Application Programming • 141

Advertisement

Table of Contents
loading

Table of Contents