Assignment Of Array Entries - Galil Motion Control DMC-1000 User Manual

Table of Contents

Advertisement

Instruction
DM POSX[7]
DM SPEED[100]
DM POSX[0]
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.
Instruction
DM SPEED[10]
SPEED[1]=7650.2
SPEED[1]=
POSX[10]=_TPX
CON[2]=@COS[POS]*2
TIMER[1]=TIME
An array element number can also be a variable. This allows array entries to be assigned sequentially
using a counter. For example;
Instruction
#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.
106 • Chapter 7 Application Programming
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
Example - USING THE COMMAND, DM
Interpretation
Defines an array names POSX with seven entries
Defines an array named speed with 100 entries
Frees array space

Assignment of Array Entries

Examples - assigning values to array entries
Interpretation
Dimension Speed Array
Assigns the first element of the array, SPEED the value 7650.2
Returns array element value
Assigns the 10th element of the array POSX the returned value from the tell
position command.
Assigns the second element of the array CON the cosine of the variable POS
multiplied by 2.
Assigns the first element of the array timer the returned value of the TIME
keyword.
Using a Variable to Address Array Elements
Interpretation
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
DMC-1000

Advertisement

Table of Contents
loading

Table of Contents