In this example, the message “Enter Length” is displayed on the computer screen. The controller
waits for the operator to enter a value. The operator enters the numeric value which is assigned to
the variable, LENX.
Cut-to-Length Example
In this example, a length of material is to be advanced a specified distance. When the motion is
complete, a cutting head is activated to cut the material. The length is variable, and the operator is
prompted to input it in inches. Motion starts with a start button which is connected to input 1.
The load is coupled with a 2 pitch lead screw. A 2000 count/rev encoder is on the motor, resulting
in a resolution of 4000 counts/inch. The program below uses the variable LEN, to length. The IN
command is used to prompt the operator to enter the length, and the entered value is assigned to
the variable LEN.
#BEGIN LABEL
AC 800000
Acceleration
DC 800000
Deceleration
SP 5000
Speed
LEN=3.4
Initial length in inches
#CUT Cut
routine
AI1
Wait for start signal
IN "enter Length(IN)", LEN
Prompt operator for length in inches
PR LEN *4000
Specify position in counts
BGX
Begin motion to move material
AMX
Wait for motion done
SB1
Set output to cut
WT100;CB1
Wait 100 msec, then turn off cutter
JP #CUT
Repeat process
EN End
program
Inputting String Variables
String variables with up to six characters may input using the specifier, {Sn} where n represents
the number of string characters to be input. If n is not specified, six characters will be accepted.
For example, IN "Enter X,Y or Z", V{S} specifies a string variable to be input.
Output of Data (Numeric and String)
Numerical and string data can be output from the controller using several methods. The message
command, MG, can output string and numerical data. Also, the controller can be commanded to
return the values of variables and arrays, as well as other information using the interrogation
commands (the interrogation commands are described in chapter 5).
Sending Messages
Messages may be sent to the bus using the message command, MG. This command sends
specified text and numerical or string data from variables or arrays to the screen.
Text strings are specified in quotes and variable or array data is designated by the name of the
variable or array. For example:
MG "The Final Value is", RESULT
144
•
Chapter 7 Application Programming
DMC-1600