104
•
Chapter 7 Application Programming
DMC-1500
Example - Using the Command, DM
Instruction Interpretation
DM POSX[7]
Defines an array names POSX with seven entries
DM SPEED[100]
Defines an array named speed with 100 entries
DM POSX[0]
Frees array space
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 - Assigning Values to Array Entries
Instruction Interpretation
DM SPEED[10]
Dimension Speed Array
SPEED[1]=7650.2
Assigns the first element of the array, SPEED the value 7650.2
SPEED[1]=
Returns array element value
POSX[10]=_TPX
Assigns the 10th element of the array POSX the returned value from the tell
position command.
CON[2]=@COS[POS]*2
Assigns the second element of the array CON the cosine of the variable POS
multiplied by 2.
TIMER[1]=TIME
Assigns the first element of the array timer the returned value of the TIME
keyword.
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;
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]=_TPX
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.
Содержание DMC-1510
Страница 6: ......
Страница 18: ...6 Chapter 1 Overview DMC 1500 THIS PAGE LEFT BLANK INTENTIONALLY...
Страница 88: ...76 Chapter 6 Programming Motion DMC 1500 Figure 6 7 Motion intervals in the Home sequence...
Страница 90: ...78 Chapter 6 Programming Motion DMC 1500 THIS PAGE LEFT BLANK INTENTIONALLY...
Страница 137: ...DMC 1500 Chapter 7 Application Programming 125 THIS PAGE LEFT BLANK INTENTIONALLY...
Страница 157: ...DMC 1500 Chapter 10 Theory of Operation 145 THIS PAGE LEFT BLANK INTENTIONALLY...
Страница 160: ...148 Appendices DMC 1500 Card Level Layout...
Страница 178: ...166 Appendices DMC 1500 ICM 1100 Drawing 1 3 4 0 0 4 4 0 2 4 0 7 0 0 4 5 3 7 0 5 7 0 2 8 5 1 0 0 1 0 1 0 7 0 1 0 0...
Страница 180: ...168 Appendices DMC 1500...
Страница 198: ...186 Appendices DMC 1500 THIS PAGE LEFT BLANK INTENTIONALLY...