Xn on/off/cont, Xnpgm statement, Xkey versus fkey – Rockwell Automation 1398-PDM-xxx IQ Master Version 3.2.4 for IA-2000 and IQ-5000 Positioning Drive Modules, IQ-55 User Manual

Page 171: Xkey instruction summary, Tutorial, X n on/off/cont

Advertising
background image

IQ Programming Structure • Xkey (Xn) Functions

149

Publication 1398-PM601A-EN-P — October 2000

TUTORIAL

programs and may be active even when no program is running.

The program statements in an Xkey routine can be any legal program statement except motion state-
ments or subroutine calls. Motion statements include MOVD, MOVP, DV, DIF, DELAY, and DWELL.
JUMP commands in an Xkey routine must be to a label contained in that Xkey routine; jumps outside
the Xkey routine are not allowed. PRINT and READ commands for the Operator Terminal are allowed.

The Xn statement is used to mark the beginning of a routine for an Operator Terminal Xkey, where n is
1 through 4. XEND marks the end of the Xkey routine. Xkey routines must be placed before the main
body of a program and after any TITLE, ASSIGN, or Sn: statements.

If more than one Xkey is enabled, and an Xkey is pressed while the first Xkey routine is still executing,
the first Xkey routine will be aborted and execution of the second will begin. Xn ON, Xn OFF, and Xn
CONT statements can be used within an Xkey routine to avoid this situation. The following is a code
fragment that shows the use of the Xn ON/OFF instructions to prevent the X1 program from being
interrupted.

X1:

;Beginning of the X1 key routine

CLEAR

;Clear the Operator Terminal Screen

X4 OFF

;Disable X4 while in

X1 routine

READ “Enter speed ” ,SHOW G42

X4 ON

;Re-enable X4 key

XEND

;End of X1 key routine

Xn ON/OFF/CONT

The Xn ON or Xn CONT statements are used to enable the Xkey program. After Xn ON is executed,
one Xkey press will be recognized and then the Xkey will be disabled. Another Xn ON statement must
be executed to re-enable the Xkey. As an alternative, the Xn CONT statement allows a key to be recog-
nized continuously, without waiting for the program to re-enable the Xkey.

XNPGM Statement

The XNPGM statement simulates pressing an Xkey from within a program. If the Xkey program has
been enabled previously with an Xn ON or Xn CONT statement, the Xkey program will execute. The
syntax is XNPGM = number where number can be any of the Xkey program numbers 1 to 4. Only one
Xkey program can be running at a time. If an Xkey program is running when the XNPGM statement is
executed, the current Xkey program ends and the new Xkey program is started, if the second Xkey pro-
gram was enabled.

Xkey Versus Fkey

You can accomplish the same task using Xkeys or Fkeys. The difference is in how the routines are pro-
grammed and executed. Xkey routines are defined right in the application program header. This means
that each application program may define the Xkey differently. Fkey programs are stored as system pro-
grams. Fkey programs are assigned to the Fkeys through the Parameter menu Fkey Set Up dialog box.

Xkey programs are defined in an application program and therefore can only be executed while a pro-
gram is executing. Fkey programs are defined separately and can execute without application programs
running.

Xkey Instruction Summary

The following table contains a summary of instructions that relate to Xkeys Refer to Part 5

Language

Reference for more detailed information.

Name

Description

XEND

Marks the end of an Xkey routine

Xn

Marks the beginning of an Xkey routine

Xn ON/OFF/CONT

Enables and disables an Xkey routine

XNACTIVE

ON if an Xkey is pressed, OFF otherwise

Advertising