beautypg.com

Delta RMC151 User Manual

Page 349

background image

5 Programming

REAL[20]

array with the index 4. This is

actually the fifth element

because the indices are zero-

based.

MyArray as

REAL[10]
Myindex as DINT

MyArray[MyIndex]

The value of 'Myindex' specifies

the element in 'MyArray'.

MyArray as

DINT[5]
MyVar as REAL

MyArray[ REAL_TO_DINT

(MyVar +5.0) ]

If you wish to use a REAL value

as an index, you can convert it

to a DINT as illustrated here.

_VarTbl.CurVal[2]

You can index variables as

shown here, but it is much

better to first assign a tag

name to a variable, then use

the tag name, as shown in the

MyArray example above.

_Axis[0]

Specifies the first axis. Note

that '_Axis[0]' is not a valid

data type by itself. You must

specify a tag, such as

_Axis[0].ActPos.

i as DINT

_Axis[i+2]

An index can be an expression,

but must evaluate to a DINT.

Special Case: _Axis[] with no specified element
In the user programs, the "_Axis[]" tag can be used without any value in the brackets. In

this case, the default axis of the task that is running the user program will be used. This

is for advanced users only. See the Default Axis section of the Tasks topic for details.
Special Case: _Task[] with no specified element
In the user programs, the "_Task[]" tag can be used without any value in the brackets. In

this case, the task that is running that user program will be used. This is for advanced

users only.
For example, you can use _Task[].CurAxis to change the default axis of the task.

Using Variable Arrays

Many types of data in the RMC are already in the form of arrays, such as axes, tasks, and

variables. In addition, you can declare arrays in the Variable Table Editor.
Variable arrays are useful for storing data that needs to be used sequentially. Using

arrays can make user programs shorter and easier to read. For example, if your

application requires sequentially moving to a number of positions, you can store those

positions in an array. You can then create a loop in a user program to move to each

position. You can increment an index variable each loop to specify which position to move

to.
Declaring Variable Arrays
To declare an array in the variable table:

1. Open the Variable Table Editor.
2. On the Edit tab, click the Type cell for some variable, then click the ellipsis button (

).

3. Choose the Data Type and the Size of the array, then click OK.
4. For each element in the array, you can set the initial value in the same manner as for

any variable.

deltamotion.com

329

This manual is related to the following products: