DMC-2X00 Chapter 7 Application Programming y 103
con[2]=@COS[POS]*2 Assigns the 2nd element of the array the cosine of POS * 2.
timer[1]=TIME Assigns the 1st element of the array 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.
Instruction Interpretation
#A Begin Program
count=0;DM POS[10] Initialize counter and define array
#LOOP Begin loop
WT 10 Wait 10 msec
POS[count]=_TPA Record position into array element
POS[count]= Report position
count = count +1 Increment counter
JP #LOOP, count <10 Loop until 10 elements have been stored
EN End Program
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.
QU array[],start,end,delim
QD array[],start,end
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)
Delim specifies whether the array data is separated by a comma (delim=1) or a carriage return
(delim=0).
The file is terminated using <control>Z, <control>Q, <control>D or \.
Automatic Data Capture into Arrays
The DMC-2x00 provides a special feature for automatic capture of data such as position, position
error, inputs or torque. This is useful for teaching motion trajectories or observing system
performance. Up to four types of data can be captured and stored in four arrays. The capture rate or
time interval may be specified. Recording can be done as a one time event or as a circular continuous
recording.