Chapter 7 Application Programming 128 USER MANUAL
SPEED Z ; Cannot have spaces in the name
Assigning Values to Variables:
Assigned values can be numbers, internal variables and keywords, functions, controller parameters and
strings;
The range for numeric variable values is 4 bytes of integer (231) followed by two bytes of fraction
(+/-2,147,483,647.9999).
Numeric values can be assigned to programmable variables using the equal sign.
Any valid DMC-13X8 function can be used to assign a value to a variable. For example,
V1=@ABS[V2] or V2=@IN[1]. Arithmetic operations are also permitted.
To assign a string value, the string must be in quotations. String variables can contain up to six
characters which must be in quotation.
Examples:
POSX=_TPX Assigns returned value from TPX command to variable POSX.
SPEED=5.75 Assigns value 5.75 to variable SPEED
INPUT=@IN[2] Assigns logical value of input 2 to variable INPUT
V2=V1+V3*V4 Assigns the value of V1 plus V3 times V4 to the variable V2.
VAR="CAT" Assign the string, CAT, to VAR
Assigning Variable Values to Controller Parameters
Variable values may be assigned to controller parameters such as GN or PR.
PR V1 Assign V1 to PR command
SP VS*2000 Assign VS*2000 to SP command
Displaying the value of variables at the terminal
Variables may be sent to the screen using the format, variable=. For example, V1= , returns the value
of the variable V1.
Example - Using Variables for Joystick
The example below reads the voltage of an X-Y joystick and assigns it to variables VX and VY to
drive the motors at proportional velocities, where
10 Volts = 3000 rpm = 200000 c/sec
Speed/Analog input = 200000/10 = 20000
#JOYSTIK Label
JG 0,0 Set in Jog mode
BGXY Begin Motion
#LOOP Loop
VX=@AN[1]*20000 Read joystick X
VY=@AN[2]*20000 Read joystick Y
JG VX,VY Jog at variable VX,VY
JP#LOOP Repeat
EN End