User variables and arithmetic, User variables, Scope – 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 149: Nonvolatile vs. volatile variables, Scope nonvolatile vs. volatile variables

Advertising
background image

User Variables and Arithmetic • User Variables

127

Publication 1398-PM601A-EN-P — October 2000

TUTORIAL

User Variables and Arithmetic

User Variables

IQ Basic supports a fixed set of variables that the programmer can use to store data and perform arith-
metic. There are four types of user variables: G, V, B, and F. There are 64 nonvolatile G variables, 64
volatile V variables, 64 volatile F flag variables and 8 nonvolatile B flag variables. In addition to the
user variables, system variables are also supported.

System variables are dedicated variables that contain particular values. For example, POS1 contains the
position of encoder 1. System variables are discussed later in Part 4.

Scope

IQ Basic variables are available system wide. Each of the variables can be read and set from any user
program, system program, or by a Host Language Command at any time. There are no provisions to
protect a variable from change. This is referred to as global scope.

Global scope variables permit you to segment your project into multiple programs, each with a particu-
lar task. The multiple programs then pass information through global variables. For example, one pro-
gram may initialize the machine, prompt the operator through a series of data entries, check that the data
is correct, and then set a flag indicating the setup program has been run successfully. Another program
in the system may run through the steps of making a part. First it ensures that the setup program has
been run by checking the flag. It then continues to make parts using the setup variables.

The disadvantage of global scope variables is that you must be careful to avoid inadvertent interaction
between your programs. For example, if one program expects a variable to be a certain value and
another program modifies the variable, the first program will not run correctly.

Nonvolatile vs. Volatile Variables

Nonvolatile variables are variables that do not change when power is removed from the ULTRA Plus or
IQ. G and B variables are nonvolatile variables. These variables maintain their values when power is
removed. Nonvolatile variables are primarily used to store data that does not change frequently. For
example, the maximum speed, the total number of cycles that have been run since installation, or part

Advertising