Variables, If/else statement, assign, block structure – 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 144

Advertising
background image

122

• Variables

Publication 1398-PM601A-EN-P — October 2000

TUTORIAL

Variables

Programming the limits for the Programmable Limit Switch and compiling probably is not the most
convenient way to “program” the limit switch. The ULTRA Plus or IQ has many variables that may be
used in programs: G1..G64, V1..V64 number variables and F1..F64 and B1..B8 flag variables. The G
and B variables retain their values even after power is removed from the ULTRA Plus or IQ. We will
now use two variables to “program” the limits in the Programmable Limit Switch. Modify the Scanned
Events in the last program like this:

S1: IF POSN >= G1 IF POSN <= G2 O1 = ON;Scanned Events

S2: IF POSN < G1 O1 = OFF

S3: IF POSN > G2 O1 = OFF

Notice that the minimum value, 3, has been replaced by G1 and the maximum value, 6, has been
replaced by G2. Compile and save this program. Display the Variables dialog box from the Parameters
menu (shown below). The value of G1 should be displayed. Set the value of G1 to 3 by typing 3 in the
Value box. Select the Update button to accept this value. Select G2 from the Variable List and change
it's value to 6. Select the OK button to accept this last value and close the dialog box.

Run the modified program. Does it run the same as the old one? Try changing the values of G1 and G2
by displaying the Variables dialog box again, even while the program is running. The behavior of the
Programmable Limit Switch should change.

IF/ELSE Statement, ASSIGN, Block Structure { }

Three scanned events are a lot of program code to control just one output. By rewriting the program,
only one Scanned Event is needed.

It might be difficult to remember that G1 is the minimum value and G2 is the maximum value later on.
The ASSIGN statement lets a programmer assign a meaningful name to a variable.

The new program looks like this:

TITLE "scanpgm2"

ASSIGN MindistG1 ;The min. position the axis can be at for INBAND to be on

ASSIGN MaxdistG2 ;The max. position the axis can be at for INBAND to be on

ASSIGN INBANDO1 ;INBAND is output 1

S1:IF F1 = F1 {

IF POSN < Mindist

INBAND = OFF

ELSE

Advertising