You are on page 1of 83

6/3/2014 12.

CALCA - Advanced Calculator Block

B0193AX, Rev J

12. CALCA - Advanced Calculator Block

12.1 Overview
The Advanced Calculator (CALCA) block provides both logical functions and arithmetic computational
capability within one integrated environment.

This block provides dual-operand efficiency in several mathematical and logical instructions, resulting in as much
as a three-to-one reduction in the length of your program relative to the same calculations performed in a CALC
block program.

The CALCA block does not support the clamping of real outputs, whereas the CALC block does. With this
exception, programs written for the CALC, MATH, or LOGIC blocks will execute in the CALCA block
without change.

The configuration process allows you to program the block by entering a series of up to 50 programming steps.
Each program step is represented by a parameter string of up to 16 characters.

The CALCA block inputs and outputs are shown in Figure 12-1.

Figure 12-1.
CALCA Block I/O Diagram

The differences between the CALCA, CALC, MATH, and LOGIC blocks are summarized in Table 12-1.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 1/83
6/3/2014 12. CALCA - Advanced Calculator Block

Table 12-1. Block Comparison


CALCA CALC MATH LOGIC

Dual Operands X --- X X

Output Clamping --- X --- ---

Boolean Instructions X X --- X

Packed Boolean Instructions X X ---

Mathematical Instructions X X X ---

Cascade Instruction X X X ---

Steps 50 50 20 15

Memory Registers 24 24 5 5

Boolean Inputs 16 16 0 16

Boolean Outputs 8 8 0 4

Integer Inputs 2 2 0 0

Integer Outputs 6 6 0 0

Long Integer Inputs 2 2 0 1

Long Integer Outputs 2 2 0 1

Real Inputs 8 8 8 2

Real Outputs 4 4 4 0

12.2 Basic Operation


The CALCA block operates like most programmable pocket calculators. The block's input/output modularity
and programming capacity provides a level of functionality that complements the standard block set offering.

The program which you enter is executed once each time the CALCA block executes. A single execution of the
program is defined as a single consecutive execution of each program step in turn. It is, however, possible to
specify conditional execution of steps or groups of steps.

Every program step contains an opcode, which identifies the operation to be performed, and up to two
command line arguments. The command line arguments consist of the actual operands for the step, the location
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 2/83
6/3/2014 12. CALCA - Advanced Calculator Block

of the operands, a specification of details which further refine the opcode, or some combination of these factors.
The syntax of each individual instruction is provided in Section 12.6.3.

The CALCA block can operate in Auto or Manual mode. The operation of the block in Manual is identical to
the operation in Auto, except that any output parameters involved in the steps are not modified by the block
logic. They are released, and can be set only by user action. Manual mode is described in Section 12.6.1.2.

12.3 Features
Provides 8 real inputs, 2 long integer inputs, 2 integer inputs, 16 Boolean inputs, 4 real outputs, 2 long
integer outputs, 8 Boolean outputs, and 6 integer outputs.
Provides 24 floating point memory data storage registers that are preserved between execution cycles.
Uses a stack of 24 floating point values for storage of intermediate computational results.
Provides 50 programming steps of up to 16 characters, allowing dual operands in all appropriate
instructions.
Clamping of outputs is not supported.
Accepts any CALC, MATH, or LOGIC block instruction without change; outputs are not clamped in the
CALCA block, however.
Allows arithmetic calculations to be conditionally executed, depending on arithmetic or logic conditions
detected under program control.
Provides a complete mix and interchangeability between the results of Boolean, integer, and real
operations.
Lets your algorithm read the status bits of input/output parameters and directly control the status bits of
output parameters (for example, Bad, Out-of-Service, Error).
Allows you to propagate the cascade acknowledgment from an upstream to a downstream block.
Checks correctness of all programming steps following block installation and reconfiguration, and marks
the block as undefined if an error is detected.
Provides the ability to detect run-time errors.
Supports Auto/Manual capability for all block outputs; in Manual, all functions are performed normally
except for changes of output values.
Allows forward branching of program control. However, backward branching is not allowed, to prevent
endless loops.
Lets you initialize all timers and memory registers.
Permits effectively unlimited time delays and pulse widths in the timer instructions.

12.4 Parameters

Table 12-2. CALCA Block Parameters

Name Description Type Accessibility Default Units/Range

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 3/83
6/3/2014 12. CALCA - Advanced Calculator Block

Configurable Parameters

INPUTS

NAME block name string no-con/no-set blank 1 to 12 chars

TYPE block type integer no-con/no-set 75 CALCA

DESCRP descriptor string no-con/no-set blank 1 to 32 chars

PERIOD block sample time short no-con/no-set 1 0 to 10

PHASE block execute phase integer no-con/no-set 0 ---

LOOPID loop identifier string no-con/no-set blank 1 to 32 chars

RI01 to RI08 real input 1 to 8 real con/set 0.0 ---

BI01-BI16 Boolean input 1 to 16 Boolean con/set 0 0 to 1

II01 to II02 integer input 1 to 2 integer con/set 0 ---

LI01 to LI02 long int input 1 to 2 long con/set 0 ---

MA manual/auto Boolean con/set 0 0 to 1

INITMA initialize MA short no-con/no-set 1 0 to 2

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 4/83
6/3/2014 12. CALCA - Advanced Calculator Block

TIMINI timer initialize option Boolean no-con/set 0 0 to 1

M01 to M24 memory 1 to 24 real no-con/no-set 0.0 1 to 24

STEP01 to STEP50 program steps 1 to 50 char[16] no-con/no-set blank 1 to 8 chars

Non-Configurable Parameters

OUTPUTS

BO01 to BO08 Boolean output 1 to 8 Boolean con/no-set 0 0 to 1

IO01 to IO06 integer output 1 to 6 integer con/no-set 0 ---

LO01 to LO02 long int output 1 to 2 long con/no-set 0 ---

PERROR program error integer con/no-set 0 ---

RO01 to RO04 real output 1 to 4 real con/no-set 0.0 ---

STERR step error number integer con/no-set 0 ---

DATA STORES

ACHNGE alternate change integer con/no-set 0 -32768 to 32767

BLKSTA block status pack_l con/no-set 0 bit map

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 5/83
6/3/2014 12. CALCA - Advanced Calculator Block

DEFINE no config errors Boolean no-con/no-set 1 0 to1

ERCODE configuration error string no-con/no-set blank 1 to 43 chars

LOCKID lock identifier string no-con/no-set blank 8 to 13 chars

LOCKRQ lock request Boolean no-con/set 0 0 to 1

NR_INP number of inputs short no-con/no-set 0 0 to 255

NR_OUT number of outputs short no-con/no-set 0 0 to 255

OF_INP offset to inputs integer no-con/no-set 0 0 to 255

OF_OUT offset of outputs integer no-con/no-set 0 0 to 255

OWNER owner name string no-con/set blank 1 to 32 chars

12.4.1 Parameter Definitions

ACHNGE

Alternate Change is an integer output which is incremented each time a block parameter is changed via a
Set command.

BI01 to BI16

Boolean Inputs 1 through 16 are inputs to the block calculations which can be configured, linked to
upstream blocks, or set when unlinked.

BLKSTA
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 6/83
6/3/2014 12. CALCA - Advanced Calculator Block

Block Status is a 32-bit output, bit-mapped to indicate various block operational states. For the CALCA
block, only the following bits are used:

Bit Boolean
Number* Description When Connection
(0 to 31) Name True (B32 to B1)

11 MA Manual = 0, Auto = 1 BLKSTA.B21

14 UDEF Block Undefined BLKSTA.B18

15 ON Block ON BLKSTA.B17

20 WLCK Access Locked BLKSTA.B12

* Bit 0 is the least significant bit (starting from the right).

BO01 to BO08

Boolean Outputs 1 through 8 are outputs from the block calculations. They can be set when the block is in
Manual.

DEFINE

Define is a data store which indicates the presence or absence of configuration errors. The default is 1 (no
configuration errors). When the block initializes, DEFINE is set to 0 if any configured parameters fail
validation testing. (See ERCODE for the list of all possible validation errors in this block.) In that case, no
further processing of the block occurs, including further validation of remaining parameters. To return
DEFINE to a true value, correct all configuration errors and re-install the block. If DEFINE = 0, the bit
BLKSTA.UDEF = 1.

DESCRP

Description is a user-defined string of up to 32 characters that describe the block's function (for example,
"PLT 3 FURNACE 2 HEATER CONTROL").

ERCODE

Error Code is a string data store which indicates the type of configuration error which caused the block's
DEFINE parameter to be set false. Validation of configuration errors does not proceed past the first error
encountered by the block logic. For the CALCA block, the following is the only possible error value of
ERCODE. (More specific information as to the type of syntax error encountered can be found in
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 7/83
6/3/2014 12. CALCA - Advanced Calculator Block

PERROR and STERR.)


"W45 - CONFIGURATION ERROR IN STEP nn"

II01 to II02

Integer Inputs 1 and 2 are inputs to the block calculations which can be configured, linked to upstream
blocks, or set when unlinked.

INITMA

Initialize Manual/Auto specifies the desired state of the MA input during initialization, where:
0 = Manual
1 = Auto
2 = The MA state as specified in the checkpoint file.
The block asserts this initial M/A state whenever:

It is installed into the Control Processor database.


The Control Processor undergoes a reboot operation.
The compound in which it resides is turned on.
The INITMA parameter itself is modified via the control configurator. (The block does not assert
INITMA on ordinary reconfiguration.)

INITMA is ignored if MA has an established linkage.

IO01 to IO06

Integer Outputs 1 through 6 are outputs from the block calculations. They can be set when the block is in
Manual.

LI01 to LI02

Long Integer Inputs 1 and 2 are inputs to the block calculations which can be configured, linked to
upstream blocks, or set when unlinked. In addition, the individual bits of LI01 can only be accessed in the
calculation as I1 (or I01) through I32. I1 is the most significant bit of LI01, and I32 is the least significant
bit.

LO01 to LO02

Long Integer Outputs 1 and 2 are outputs from the block calculations. They can be linked to downstream
blocks, or set when the block is in Manual. In addition, the individual bits of LO01 can only be accessed
in the calculation as O1 (or O01) through O32. O1 is the most significant bit of LO01, and O32 is the
least significant bit.

LOCKID
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 8/83
6/3/2014 12. CALCA - Advanced Calculator Block

Lock Identifier is a string identifying the workstation which has locked access to the block via a successful
setting of LOCKRQ. LOCKID has the format LETTERBUG:DEVNAME, where LETTERBUG is the
6-character letterbug of the workstation and DEVNAME is the 1 to 6 character logical device name of
the Display Manager task.

LOCKRQ

Lock Request is a Boolean input which can be set True or False only by a SETVAL command from the
LOCK U/L toggle key on workstation displays. When LOCKRQ is set True in this fashion a workstation
identifier accompanying the SETVAL command is entered into the LOCKID parameter of the block.
Thereafter, set requests to any of the block's parameters are honored (subject to the usual access rules)
only from the workstation whose identifier matches the contents of LOCKID. LOCKRQ can be set False
by any workstation at any time, whereupon a new LOCKRQ is accepted, and a new ownership
workstation identifier written to LOCKID.

LOOPID

Loop Identifier is a configurable string of up to 32 characters which identifies the loop or process with
which the block is associated. It is displayed on the detail display of the block, immediately below the
faceplate.

M01 to M24

Memory elements 1 through 24 are memory registers. These provide temporary storage for the result of
any operation in the up-to-50-step CALCA block program. The values you configure are initial values for
M01 to M24. The CALCA block program can overwrite this value with an STM command.

MA

Manual/Auto is a Boolean input that controls the block's operating state:


0 = False = Manual
1 = True = Auto
When in Manual, all block outputs are released and can only be updated manually. In Auto the outputs
are secured and only updated based on the programmed step operations.

NAME

Name is a user-defined string of up to 12 characters used to access the block and its parameters.

NR_INP

Number of Inputs is a short value representing the number of inputs in the block. It is used internally.

NR_OUT

Number of Outputs is a short value representing the number of outputs in the block. It is used internally.

OF_INP

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 9/83
6/3/2014 12. CALCA - Advanced Calculator Block

Offset to Inputs is the zero-based offset, in bytes, of the first block input from the head of the block. It is
used internally.

OF_OUT

Offset to Outputs is the zero-based offset, in bytes, of the first block output from the head of the block. It
is used internally.

OWNER

Owner is a settable string of up to 32 ASCII characters which are used to allocate control blocks to
applications. Attempts to set OWNER are successful only if the present value of OWNER is the null
string, an all-blank string, or identical to the value in the set request. Otherwise the request is rejected with
a LOCKED_ACCESS error. OWNER can be cleared by any application by setting it to the null string;
this value is always accepted, regardless of the current value of OWNER. Once set to the null string, the
value can then be set as desired.

PERIOD

Period is an indexed input that dictates the block's execution time base and allowable PHASE values. For
stations other than Integrators and Gateways, PERIOD values range from 0 to 13 and map to the
following period time lengths. (Integrator and Gateway blocks have different period values than shown
here.

Period Length Period Length

0 0.1 sec 7 10 min

1 0.5 sec* 8 60 min

2 1.0 sec 9 0.2 sec

3 2.0 sec 10 5.0 sec**

4 10 sec 11 0.6 sec***

5 30 sec 12 6.0 sec****

6 1 min 13 0.05 sec*****

* If the BPC is 0.2 sec., this period is treated internally as 0.6 sec., but the PERIOD parameter remains
1.
** If the BPC is 2.0 sec., this period is treated internally as 6.0 sec., but the PERIOD parameter remains
10.
*** If the BPC is 0.5 sec., this period is treated internally as 0.5 sec., but the PERIOD parameter
remains 11.
**** If the BPC is not 2.0 sec., this period is treated internally as 5.0 sec., but the PERIOD parameter
remains 12.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 10/83
6/3/2014 12. CALCA - Advanced Calculator Block

***** Available in CP 40 only.

PERROR

Program Error is a coded integer output that indicates the type of instruction syntax error or program run-
time error that occurred in the step specified by the STERR parameter. See Section 12.7 for tables of the
PERROR values.

PHASE

Phase is an integer input that causes the block to execute at a specific BPC within the time determined by
the PERIOD. For instance, a block with PERIOD of 3 (2.0 sec) can execute within the first, second,
third, or fourth BPC of the 2-second time period, assuming the BPC of the Control Processor is 0.5 sec.
See Integrated Control Software Concepts document.

RI01 to RI08

Real Inputs 1 through 8 are inputs to the block calculations which can be configured, linked to upstream
blocks, or set when unlinked. The CALCA block does not have change delta parameters; therefore,
when one of the parameters RI01 to RI08 is the sink of a peer-to-peer connection, it will be updated
based on any change in the source of the connection.

RO01 to RO04

Real Outputs 1 through 4 are outputs from the block calculations. They can be set when the block is in
Manual.

STEP01 to STEP50

Steps 1 through 50 are string inputs of up to 16 characters. They are the 50 executable commands that
make up the CALCA block program.

STERR

Step Error is an integer output that indicates which program step is exhibiting the error defined by
PERROR.

TIMINI

Timer Initialize determines the state of each DON, DOFF, or OSP element in the program at the time the
block initializes. For DON and DOFF timers, TIMINI acts as follows:

TIMINI True: Each DON or DOFF element is set to the expired state at initialization time, that is,
the timer acts as if its target time has been reached.
TIMINI False: The DON and DOFF elements initialize in the inactive state, that is, the accumulated
time is zero.

For OSP elements, TIMINI acts as follows:

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 11/83
6/3/2014 12. CALCA - Advanced Calculator Block

TIMINI True: The OSP elements act as if they had been pulsing at initialization time.
TIMINI False: The OSP elements act as if they had been inactive.

TYPE

When you enter "CALCA" or select it from a configurator list, an identifying integer is created specifying
this block type.

12.5 Functions
The CALCA block provides 114 program instructions, consisting of the following general types:

32 Arithmetic instructions, which perform mathematical calculations.


13 Boolean instructions, which provide various Boolean and packed Boolean operations.
27 Input/Output instructions, which perform the input or output of data or status bits.
2 Cascade and Propagation instructions for error propagation and downstream cascade
acknowledgments.
10 Memory and Stack Reference instructions for reading and writing the memory registers, or directly
manipulating the stack.
10 Program Control instructions for conditional and unconditional branching, and program termination.
9 Clear/Set instructions, which provide for conditional or unconditional clearing or setting of parameters,
sometimes with simultaneous program control action.
6 Timing instructions which control the operation of program timers.
2 Logic instructions which emulate the operation of flip-flops.
3 Error Control instructions which provide access to the run-time error flag.

12.5.1 Arithmetic Instructions

Most CALCA block operations center about a 25-position push-down stack of real data type values. The top
position of this stack is referred to as the accumulator.

All arithmetic instructions involve the accumulator value, frequently in conjunction with various block parameters.
No arithmetic operations contribute rounding errors beyond one unit of the least significant decimal digit of a real,
single precision, floating point value.

To minimize the number of arithmetic instructions, all arithmetic operations are performed in the floating point
domain.

Data is always stored as a real value. If an integer operation is defined, the operation strips the decimal portion
from the input real value(s), and converts the result to a real value again by adding a zero after the decimal point.
If a Boolean operation is specified, the operation interprets any non-zero value to be a logical one, and a zero
value to be a logical zero, in keeping with the usual C language convention.

The range of integer values is -32,768 to 32,767, except for the range of integer values for ADD RIxx n and
DIV RIxx n, which is -64 to 63.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 12/83
6/3/2014 12. CALCA - Advanced Calculator Block

The range of real values is 10-38 to 1038 for positive and negative numbers.

Each of the arithmetic operations (and Boolean operations) utilize one or more inputs to the calculation,
generically referred to as operands. These inputs are obtained from various block parameters, the push-down
stack, and/or the command line arguments of the instruction syntax. Regardless of the origin of the inputs,
instructions using one input are designated unary, those utilizing two inputs are designated diadic, and those
utilizing a variable number of inputs are designated polyadic.

Table 12-3. Arithmetic Instructions

Name Function Instruction Type

ABS Absolute Value Unary

ACOS Arc Cosine Unary

ADD Add Diadic or Polyadic

ALN Natural Antilog Unary

ALOG Common Antilog Unary

ASIN Arc Sine Unary

ATAN Arc Tangent Unary

AVE Average Diadic or Polyadic

CHS Change Sign Unary

COS Cosine Unary

DEC Decrement Unary

DIV Divide Diadic

EXP Exponent Diadic

IDIV Integer Division Diadic

IMOD Integer Modulus Diadic

INC Increment Unary

LN Natural Logarithm Unary

LOG Common Logarithm Unary

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 13/83
6/3/2014 12. CALCA - Advanced Calculator Block

MAX Maximum Diadic or Polyadic

MAXO (Same as MAX)

MIN Minimum Diadic or Polyadic

MEDN Median Polyadic

MUL Multiply Diadic or Polyadic

RAND Generate Random Number Unary

RANG Generate Random Number, Gaussian Unary

RND Round Unary

SEED Seed Random Number Generator Unary

SIN Sine Unary

SQR Square Unary

SQRT Square Root Unary

SUB Subtract Diadic

TAN Tangent Unary

TRC Truncate Unary

12.5.2 Boolean Instructions

All Boolean instructions involve the accumulator value, frequently in conjunction with various block parameters.
The Boolean value of logical zero is stored on the stack or in memory registers as real value 0.0, and logical one
is stored as 1.0. When operands are fetched from the stack or memory registers, the operation interprets any
non-zero value to be a logical one, and a real zero value to be a logical zero, in keeping with the usual C
language convention.

In addition to ordinary Boolean operations, a group of bitwise logical operations on packed Boolean values is
supported.

Table 12-4. Boolean Instructions

Name Function Instruction Type

AND Logical And Diadic or Polyadic


https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 14/83
6/3/2014 12. CALCA - Advanced Calculator Block

ANDX Packed Logical And Polyadic

NAN Logical Not And Diadic or Polyadic

NAND (Same as NAN)

NOR Logical Not Or Diadic or Polyadic

NORX Packed Logical Nor Or Polyadic. Packed Boolean

NOT Not Unary

NOTX Packed Logical Not Unary, Packed Boolean

NXO Logical Not Exclusive Or Diadic or Polyadic, Packed


Boolean

NXOR (Same as NXO)

NXOX Packed Logical Not Exclusive Polyadic, Packed Boolean


Or

OR Logical Or Diadic or Polyadic

ORX Packed Logical Or Polyadic, Packed Boolean

XOR Logical Exclusive Or Diadic or Polyadic

XORX Packed Logical Exclusive Or Polyadic, Packed Boolean

12.5.3 Input/Output Reference Instructions

Input/Output reference instructions provide access to status bits of I/O parameters and permit data transfer
between a specific input or output parameter and the accumulator (top of stack). Instructions referencing a
specific input or output include an operand specifying the particular I/O parameter.

Instructions only modify the values of output parameters when the CALCA block is in Auto. If an instruction
performs several actions, one of which is modification of output values, the portions of the instruction which do
not relate to output modification are carried out even if the block is in Manual. Modification of the status of
output parameters is be carried out in Auto or Manual.

Table 12-5. Input/Output Reference Instructions

Name Function Instruction Type

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 15/83
6/3/2014 12. CALCA - Advanced Calculator Block

CBD Clear Bad Status Output Status

CE Clear Error Status Output Status

COO Clear Out-of-Service Status Output Status

IN Input Input Value

INB Input Indexed Boolean Input Value

INH Input High Order Input Value

INL Input Low Order Input Value

INR Input Indexed Real Input Value

INS Input Status Input Status

OUT Output Output Value

RBD Read Bad and OOS Bits Input Status

RCL Read and Clear Input Value/Unconditional Clear

RCN Read Connect Status Input Linkage Type

RE Read Error Bit Input Status

REL Clear Secure Status Output Status

RON Read In-Service Status Input Status

ROO Read OOS Bit Input Status

RQE Read Quality Including Error Input Status

RQL Read Quality Input Status

SAC Store Accumulator in Output Output Value

SBD Set Bad Status Output Status

SE Set Error Status Output Status

SEC Set Secure Status Output Status

SOO Set Out-of-Service Status Output Status

STH Store High Order Output Value

STL Store Low Order Output Value

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 16/83
6/3/2014 12. CALCA - Advanced Calculator Block

SWP Swap Input Value/Output Value

12.5.4 Cascade and Propagation Instructions

Cascade and propagation instructions pass various status bits of specified real inputs to specified real outputs.
They are used for error propagation and downstream cascade acknowledgment.

Table 12-6. Cascade and Propagation Instructions

Name Function Instruction Type

PRI Propagate Upstream Cascade/Propagation

PRO Propagate Downstream Cascade

PRP Propagate Errors Propagation

12.5.5 Memory and Stack Reference Instructions

The CALCA block provides 24 memory data storage elements to store the result of any operation. Data is
stored as a real value but can represent either integer, real, or Boolean results.

All memory elements are preserved between execution cycles.

The letter M followed by an integer between 01 and 24 (or 1 and 24) designates the specific register to be
accessed by a memory referencing instruction.

Table 12-7. Memory and Stack Reference Instructions

Name Function Instruction Type

CLA Clear All Memory Registers Memory

CLM Clear Memory Register Memory

CST Clear Stack Stack

DUP Duplicate Stack

LAC Load Accumulator Memory/Stack


https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 17/83
6/3/2014 12. CALCA - Advanced Calculator Block

LACI Load Accumulator Indirect Memory/Stack

POP Pop Stack Stack

STM Store Memory Memory/Stack

STMI Store Memory Indirect Memory/Stack

TSTB Test Packed Boolean Stack

12.5.6 Program Control Instructions

The following instructions provide conditional or unconditional branching to a program step number as well direct
termination of the program. A step number less than or equal to the present program step or greater than 50
invalidates or terminates the program.

Table 12-8. Program Control Instructions

Name Function Instruction Type

BIF Branch If False Conditional Branch

BII Branch If Initializing Conditional Branch

BIN Branch If Negative Conditional Branch

BIP Branch If Positive or Zero Conditional Branch

BIT Branch If True Conditional Branch

BIZ Branch If Zero Conditional Branch

END End Program Program Termination

EXIT Exit Program Program Termination

GTI Go To Indirect Unconditional Branch

GTO Go To Unconditional Branch

NOP No Operation Unconditional Branch

12.5.7 Clear/Set Instructions


https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 18/83
6/3/2014 12. CALCA - Advanced Calculator Block

The following instructions allow you to clear or set a parameter value unconditionally, or set it conditionally,
depending on the accumulator value or the block initialization state.

Table 12-9. Clear/Set Instructions

Name Function Instruction Type

CLL (Unused - NOP)

CLR Clear Unconditional Clear

CLRB Clear Packed Boolean Unconditional Clear

SET Set Unconditional Set

SETB Set Packed Boolean Unconditional Set

SSF Set and Skip if False Conditional Set

SSI Set and Skip if Initializing Conditional Set

SSN Set and Skip if Negative Conditional Set

SSP Set and Skip if Positive Conditional Set

SST Set and Skip if True Conditional Set

SSZ Set and Skip if Zero Conditional Set

12.5.8 Timing Instructions

The operands of the following instructions (except for TIM) specify a time constant or a number of block cycles
as the duration of the timing function involved. If a time constant in seconds is specified, the duration of the timing
function is rounded up to the next block execution following the specified number of seconds. (In other words,
timing functions do not reach their target values between block executions.)

Table 12-10. Timing Instructions

Name Function Instruction Type

CHI Clear History Timing

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 19/83
6/3/2014 12. CALCA - Advanced Calculator Block

CHN Clear Step History Timing

DOFF Delayed OFF Timing

DON Delayed ON Timing

OSP One-Shot Pulse Timing

TIM Time Since Midnight Time Reporting

12.5.9 Logic Instructions

The following higher-level logic functions are supported. They emulate the functions of a traditional set-reset flip-
flop and a reset-dominant flip-flop, respectively.

Table 12-11. Logic Instructions

Name Function Instruction Type

FF Flip-Flop Logic

MRS Master Reset Flip-Flop Logic

12.5.10 Error Control Instructions

Error control instructions give your program the ability to detect, report, and clear errors during run-time. An
internal error flag (parameter PERROR) records the first run-time error event. The following instructions test and
clear this flag, but do not in themselves handle the error condition.

Table 12-12. Error Control Instructions

Name Function Instruction Type

CLE Clear Error Error Control

RER Read Error Error Control

SIEC Skip if Error Clear Error Control

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 20/83
6/3/2014 12. CALCA - Advanced Calculator Block

12.6 Instructions
12.6.1 Instruction Processing

12.6.1.1 Auto Mode

Each block processing cycle, the CALCA block executes each programmed step in sequence, except for those
bypassed because of branch conditions. When the program has been executed a single time, the block execution
is complete, and control is passed to the next block in the compound processor list.

Program execution is complete when an END or EXIT statement is reached in the program flow, or Step 50 has
been executed, whichever occurs first in time.

Between instructions, the block stores intermediate results on a 24-position internal stack. You can use stack
values as arguments to subsequent instructions. The stack is cleared at the start of each block execution cycle.
You can use the 24 internal memory registers (Mxx) to store data between block execution cycles. These
memory registers can be pre-configured to contain constants needed by the various instructions, or they can be
used to store instruction arguments and/or results.

12.6.1.2 Manual Mode

When the block is in Manual mode, it processes the steps the same way, except that the output actions are
ignored. When an instruction (such as RCL) involves both the writing of outputs and other actions, the other
actions are performed; only the output portions are ignored.

The actions carried out by the instruction RCL RO01 in Auto and Manual mode are shown in Figure 12-2. The
read portion, shown in part 1of Figure 12-2, occurs unconditionally. Then the clear action shown in part 2 of
Figure 12-2, which depends on the Auto/Manual mode, follows.

Figure 12-2.
Manual Mode

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 21/83
6/3/2014 12. CALCA - Advanced Calculator Block

It should be noted that instructions which modify the memory registers M01 to M24 continue to execute
normally while in Manual mode. If, for example, your program ramps a value in M01, then the ramping continues
throughout the Manual mode, and M01 contains an indeterminate value when the block is returned to Auto.

12.6.2 Instruction Syntax

The CALCA block program is entered through the Control Configurator. A program consists of a series of
string-type entries configured in parameters STEP01 through STEP50, each of which defines a single program
instruction.

Each CALCA block instruction consists of a string of alphanumeric characters, optionally followed by a
comment. The comment must follow a semi-colon character, and can contain any alphanumeric or punctuation
characters. The comments are ignored by the block logic, but you may find them useful when writing, debugging,
or reading a CALCA program.

As noted in Section 12.2, the instruction string comprises the opcode, followed by up to two command line
arguments. You may use leading blanks before the opcode of a program step, between the opcode and the first
argument, between the first argument and the second argument, and between the arguments and any comment
you include.

Blank steps can be inserted anywhere in a CALCA block program prior to the END statement. This makes it
easier to make minor modifications in the block program without reconfiguring each step in the program. When a
blank step is found in the program, the block logic skips to the next step without taking any action.

The action of each of the 114 defined instructions is specified in Section 12.6.3. The following comments are
general principles used by most of the instructions, but are not intended to override any of the detailed
specifications in Section 12.6.3.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 22/83
6/3/2014 12. CALCA - Advanced Calculator Block

The unary arithmetic and Boolean operations take their single input from the contents of the accumulator (located
at the top of the stack). They always store the result of the operation into the accumulator, overwriting the
original accumulator value. The stack pointer remains unchanged.

Diadic arithmetic and Boolean operations obtain their two inputs from a variety of places. When there are no
command line arguments specified, the two inputs are obtained from the two top locations of the stack, having
typically been placed there by the two instructions immediately preceding the diadic instruction. The block
decrements the stack pointer as the operation is being performed and stores the result in the new accumulator
location, overwriting the first of the two operands. (The term first, when used in describing the location of stack
operands, refers to the one which had been pushed earlier. Since the stack "grows toward high memory," an
earlier operand has a lower stack pointer value.) The second operand is also lost because it now resides in an
inaccessible position one location above the top of the stack.

If a single operand (for example, RIxx) is specified in the command line, the other operand is obtained from the
top of the stack, and the result is stored at the top of the stack, overwriting the operand there.

If two operands (for example, RIxx and Mxx) are specified in the command line, they are used to perform the
operation. The result is pushed onto the stack.

A polyadic arithmetic or Boolean instruction operates on a variable number of operands, and all of them are on
the stack.

When there are no command line arguments, the polyadic instructions operate on all values on the stack. When
the command line argument is a constant (c), they operate on the "c" operands at the highest stack positions.
These are the most recently-pushed values before the polyadic instruction is executed.

The block decrements the stack pointer as the operation is being performed and stores the result in the new
accumulator location (the new top of the stack location determined by the decremented stack pointer),
overwriting the first operand. All other operands are also lost because they now reside in inaccessible registers
located above the top of the stack. When fewer than all values on the stack are used, those stack values
remaining after the execution of the statement are not lost.

Some instructions allow a constant value as a command line argument. The instruction definitions of
Section 12.6.3. Use different letters to represent this constant, depending on the semantic meaning of the
constant, as follows:

s represents a step number


t represents a time constant
b represents a bit number
c represents a count of the number of stack values involved
n represents an arithmetic operand

In all cases, the constant is expected to be an integer. If you enter a non-integer value for the constant, it is
automatically truncated to an integer before it is used. There is no warning message when this truncation occurs.
Certain instructions permit a zero or negative integer value, and this is indicated in the individual instruction
descriptions. (Truncation of negative real values involves dropping the decimal portion and retaining the negative
sign.)

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 23/83
6/3/2014 12. CALCA - Advanced Calculator Block

If your program requires the use of a constant operand of real type, you should store it in one of the memory
registers M01 to M24 at configuration time.

Section 12.6.3 uses a notational convention to describe the syntactical options available for an instruction, as
illustrated below for the Add instruction:

ADD
ADD c
ADD {RIxx, ROxx, Mxx}
ADD {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Add)
[Descriptions and examples appear here.]
This means that the Add instruction has the following four possible command line syntaxes:

The opcode ADDalone.


The opcode ADDwith integer constant c as the only command line argument.
The opcode ADDwith exactly one of the operands RIxx, ROxx, or Mxx. Note that when operands
are enclosed in curly brackets, you must select exactly one from the group.
The opcode ADDwith exactly one operand from the group {RIxx, ROxx, Mxx} followed by
exactly one operand from the group {n, RIxx, ROxx, Mxx}, as for example ADD RO01 M02.
Note that there is no comma between the two operands. Except within comment fields, commas
are never valid in command lines.

Following the syntax specifications, are the English-language meaning of the opcode, for example, (Add),
and the description and examples for the instruction's use.
The location of the stack pointer after the execution of an instruction is indicated by an italicized
expression such as the following: sptr(after) = sptr(before) + 1. This means that the stack pointer after
the instruction has executed is one higher than it was before. Since the stack grows toward high memory,
this means that a value has been pushed onto the stack by the instruction.
Similarly, the expression sptr(after) = sptr(before) - 1 means that one value has been popped off the
stack by the instruction. The polyadic instructions finish with the spack pointer in the first position of the
stack, which is referred to as stackbottom.
One instruction, CST, finishes with the stack pointer one position lower than stackbottom, with the pointer
waiting for the first push. After CST, sptr(after) = stackbottom -1.

12.6.3 Instruction Definitions

The complete group of instructions you may use in a CALCA block program are defined in the following
alphabetical list:

ABS

(Absolute Value)
ABSreads the contents of the accumulator and returns the absolute value to the accumulator, overwriting
the original contents. sptr(after) = sptr(before).
Example:
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 24/83
6/3/2014 12. CALCA - Advanced Calculator Block

Accumulator = -.7853983 or +.7853983

17 ABS Compute absolute value of accumulator.

Accumulator = +.7853983

ACOS

(Arc Cosine)
ACOSreads the value (cosine function value) in the accumulator and computes the value, in radians, of the
first or second quadrant angle that has this cosine value. It then stores the angle value into the accumulator,
overwriting the original cosine value, which must have an absolute value equal to or less than one.
sptr(after) = sptr(before).
An attempt to ACOSa value > 1 or < -1 causes the instruction to be skipped and writes a "3" (ACOS run-
time error) to the PERROR parameter.
Example 1:

Accumulator = 0.7071

17 ACOS Compute arc cosine of accumulator.

Accumulator = +0.7853983 (Pi/4) radians. (Pi/4 radians =


45 degrees)

Example 2:

Accumulator = -0.5000

27 ACOS Compute arc cosine of accumulator.

Accumulator = 2.0944 (2*Pi/3) radians. (2*Pi/3 radians =


120 degrees)

ADD
ADD c
ADD {RIxx, ROxx, Mxx}
ADD {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Add)
ADD(or ADD c)reads the values from the top two stack locations (or a specified number c of stack
values), adds them, decrements the stack pointer, and writes the sum into the new accumulator location
(the new top of stack location). This overwrites the first operand and isolates the second and any later
operands from any further access. For ADD, sptr(after) = sptr(before) - 1. For ADD c, sptr(after) =
sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter. The same action occurs if ADDhas no operand and there is only one value on the

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 25/83
6/3/2014 12. CALCA - Advanced Calculator Block

stack.
ADD RIxxreads the value stored in RIxx (the CALCA's Real Input parameter xx), adds it to the value
that it pops from the stack, then pushes the result back onto the stack. ADD ROxxand ADD Mxxdo the
same for the values stored at ROxx and memory location xx, respectively. sptr(after) = sptr(before).
ADD RIxx nreads the RIxx value and a specified integer constant (n), adds them and stores the result on
the stack. If the first operand is ROxx or Mxx, the operation is similar. sptr(after) = sptr(before) + 1.
The range of n is -64 to 63.

NOTE: Values outside of this range will be accepted but the results are based on the rightmost 6 bits of n.

ADD RIxx Mxxreads the values stored in RIxx and Mxx, adds them, and stores the result on the stack.
Similarly when ROxx or Mxx is the first operand or RIxx or ROxx is the second operand. sptr(after) =
sptr(before) + 1.
Example:

RI01 = 12.3485
M01 = 3.73182

12 ADD RI01 M01 Adds RI01 to M01 and stores the result on the
stack.

Accumulator = 16.08032

ALN

(Natural Antilog)
ALNreads the value in the accumulator, computes the natural antilogarithm (base e) of the value, and
writes the result to the accumulator, overwriting the original contents. sptr(after) = sptr(before).
Example:

Accumulator = +0.69347

17 ALN Compute natural antilogarithm of accumulator.

Accumulator = +2.0000

ALOG

(Common Antilog)
ALOGreads the value in the accumulator, computes the base 10 antilogarithm of the value, and writes it to
the accumulator, overwriting the original contents. sptr(after) = sptr(before).
Example 1:

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 26/83
6/3/2014 12. CALCA - Advanced Calculator Block

Accumulator = +1.30103

17 ALOG Compute common antilog of accumulator.

Accumulator = +20.0000

Example 2:

Accumulator = -3.00000

27 ALOG Compute common antilog of accumulator.

Accumulator = +0.00100

AND
AND c
AND {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}
AND {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx} {BIxx, BOxx, Ixx,
Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Logical And)
ANDperforms a logical "and" of the contents of the specified operands and stack locations.
If blank is specified, all stack locations are ANDed together, and the result is written into the accumulator
(the new top of stack location). This overwrites the first operand and isolates the other operands from any
further access. sptr(after) = stackbottom.
If c is specified, the last c stack locations are ANDed together, removed from the stack, and the result
stored in the accumulator. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
If only one operand is specified, the operand is ANDed with the accumulator, and the result replaces the
accumulator. sptr(after) = sptr(before).
If both operands are specified, the operands are ANDed together and the result is stored in the
accumulator. sptr(after) = sptr(before) + 1.
If ~ is specified, the operand value is inverted prior to being used.
Before the operand Mxx is used in the calculation, its value is truncated to an integer; if the result is 0 the
operand value is considered False, otherwise it is True.
Example 1:

11 CST Clears the stack.

BI01 = True
BI07 = False
BO03 = True
BI14 = True

12 IN BI01 Puts BI01 into accumulator.

13 IN BI07 Puts BI07 into accumulator. The prior value is pushed down
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 27/83
6/3/2014 12. CALCA - Advanced Calculator Block

one stack location.

14 IN BO03 Puts BO03 into accumulator. The prior values are pushed
down one stack location.

15 IN BI14 Puts BI14 into accumulator. The prior values are pushed
down one stack location.

16 AND Performs the logical AND function on the 4 stack locations,


overwriting the True value loaded in from BI01. The other
values are inaccessible.

Accumulator = 0 (False)

Example 2:

11 IN BI02 Puts BI02 into accumulator.

BI03 = False
BO01 = True

12 AND BI03 BO01 Performs the logical AND of BI03 and BO01 and
stores the result on the stack.

Accumulator = False

ANDX
ANDX c

(Packed Logical And)


ANDXreads all the values or a specified number (c) of values from the stack, performs a 16-bit bitwise
logical "and" function on them, and stores the result into the new accumulator location (the new top of
stack). This overwrites the first operand and isolates the other operands from any further access.
For ANDX, sptr(after) = stackbottom. For ANDX c, sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
Each operand is truncated from real to 16-bit integer type before it is used in the calculation. The final
result is stored on the stack.
Example:

11 CST Clears the stack.

BI01 = True (0000000000000001)


II01 = 5 (0000000000000101)
II02 = 7 (0000000000000111)

12 IN BI01 Puts BI01 into accumulator. Stored as 1.0.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 28/83
6/3/2014 12. CALCA - Advanced Calculator Block

13 IN II01 Puts II01 into accumulator. The prior value is pushed down
one stack location.

14 IN II02 Puts II02 into accumulator. The prior values are pushed down
one stack location.

15 ANDX Performs the packed logical AND function and stores the
result into the accumulator overwriting the value loaded in
from BI01. The other values are inaccessible.

Accumulator = 0000000000000001 (stored as 1.0)

ASIN

(Arc Sine)
ASINreads the value (sine function value) in the accumulator and computes the value, in radians, of the
first or fourth quadrant angle that has this sine value. It then stores the angle value into the accumulator,
overwriting the original sine value, which must have an absolute value equal to or less than one. sptr(after)
= sptr(before).
An attempt to ASINa value > 1 or < -1 causes the instruction to be skipped and writes a "2" (ASIN run-
time error) to the PERROR parameter.
Example 1:

Accumulator = 0.7071

17 ASIN Compute arc sine of accumulator.

Accumulator = +0.7853983 (Pi/4) radians. (Pi/4 radians =


45 degrees)

Example 2:

Accumulator = -0.5000

27 ASIN Compute arc sine of accumulator.

Accumulator = -0.5236 (-Pi/6) radians. (-Pi/6 radians =


-30 degrees)

ATAN

(Arc Tangent)
ATANreads the value (tangent function value) in the accumulator, computes the value, in radians, of the
first or fourth quadrant angle that has this tangent value. It then stores the angle value into the accumulator,
overwriting the original tangent value. sptr(after) = sptr(before).
Example 1:

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 29/83
6/3/2014 12. CALCA - Advanced Calculator Block

Accumulator = 1.000

17 ATAN Compute arc tangent of accumulator.

Accumulator = +.7853983 (Pi/4) radians. (Pi/4 radians =


45 degrees)

Example 2:

Accumulator = -0.5000

27 ATAN Compute arc tangent of accumulator.

Accumulator = -.4636476 radians

AVE
AVE c
AVE {RIxx, ROxx, Mxx}
AVE {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Average)
AVEreads all the values from the stack, computes the mean algebraic value, decrements the stack pointer,
and writes this value into the new accumulator location (the new top of stack location). This overwrites the
first operand and isolates the other operands from any further access. sptr(after) = stackbottom.
AVE creads the top c values from the stack, computes the mean algebraic value of the c topmost values
on the stack, writes this value into the c'th position from the top of the stack, and sets the new top of the
stack (the accumulator) to this position. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
AVE RIxxreads the value stored in RIxx (the CALCA's Real Input parameter xx), computes the mean
algebraic value of the RIxx value and the value that it pops from the stack, and then pushes the result onto
the stack. AVE ROxxand AVE Mxxdo the same for the values stored at ROxx and memory location xx,
respectively. sptr(after) = sptr(before).
AVE RIxx Mxxreads the values stored in RIxx and Mxx, computes the mean algebraic value of the RIxx
and Mxx values, and stores the result on the stack. Whenever both operands are specified, the mean
algebraic value of the first and second operand is computed. sptr(after) = sptr(before) + 1.
AVE RIxx nreads the value stored in RIxx and a specified integer constant (n), computes the mean
algebraic value of RIxx and n, and stores the result on the stack. If the first operand is ROxx or Mxx, the
operation is similar. sptr(after) = sptr(before) + 1.
Example 1:

11 CST Clears the stack.

RI01 = 12.3485
RI02 = 3,73182
RI03 = -2.0037
RI04 = -0.8369
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 30/83
6/3/2014 12. CALCA - Advanced Calculator Block

12 IN RI01 Places RI01 into accumulator.

13 IN RI02 Places RI02 into accumulator and pushes the RI01 value
down one stack location.

14 IN RI03 Places RI03 into accumulator and pushes the prior values
down one stack location.

15 IN RI04 Places RI04 into accumulator and pushes the prior values
down one stack location.

16 AVE Reads all the values from the stack, calculates the mean
algebraic value for the stack values, and stores the result into
the accumulator, overwriting the RI01 value. The other values
are inaccessible.

Accumulator = 3.30993

Example 2:

RI01 = 12.3485
M01 = 3.73182

11 AVE RI01 M01 Calculates the mean algebraic value for RI01 and
M01 and stores the result on the stack.

Accumulator = 8.04016

BIF s

(Branch If False)
BIFbranches to the step number designated by sif the value in the accumulator (the current top of stack
location) is 0.0. sptr(after) = sptr(before).
BIF is identical to BIZ

BII s

(Branch If Initializing)
BII sbranches to the step number designated by sif the CALCA block is initializing this execution
cycle. sptr(after) = sptr(before).
An attempt to branch to a step number less than or equal to the current step number or greater than the
step number containing the ENDstatement (50 if there is no ENDstep) writes a "-4" (invalid goto syntax
error) to the PERROR parameter.

BIN s

(Branch If Negative)
BIN sbranches to the step number designated by s if the value in the accumulator (the current top of
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 31/83
6/3/2014 12. CALCA - Advanced Calculator Block

stack location) is less than 0.0. sptr(after) = sptr(before).


An attempt to branch to a step number less than or equal to the current step number or greater than the
step number containing the ENDstatement (50 if there is no ENDstep) writes a "-4" (invalid goto syntax
error) to the PERROR parameter.

BIP s

(Branch If Positive or Zero)


BIP sbranches to the step number designated by sif the value in the accumulator (the current top of
stack location) is greater than or equal to 0.0. sptr(after) = sptr(before).
An attempt to branch to a step number less than or equal to the current step number or greater than the
step number containing the ENDstatement (50 if there is no ENDstep), writes a "-4" (invalid goto syntax
error) to the PERROR parameter.

BIT s

(Branch If True)
BIT sbranches to the step number designated by sif the value in the accumulator (the current top of
stack location) is non-zero. sptr(after) = sptr(before).
An attempt to branch to a step number less than or equal to the current step number or greater than the
step number containing the END statement (50 if there is no ENDstep), writes a "-4" (invalid goto syntax
error) to the PERROR parameter.

BIZ s

(Branch If Zero)
BIZ sbranches to the step number designated by sif the value in the accumulator (the current top of
stack location) is 0.0. sptr(after) = sptr(before).
An attempt to branch to a step number less than or equal to the current step number or greater than the
step number containing the ENDstatement (50 if there is no ENDstep), writes a "-4" (invalid goto syntax
error) to the PERROR parameter.

CBD {ROxx, BOxx, IOxx, LOxx}

(Clear Bad Status)


CBDclears the Bad status bit of the specified output parameter to False. Its effect is identical in Auto or
Manual mode. sptr(after) = sptr(before).

CE {ROxx, BOxx, IOxx, LOxx}

(Clear Error Status)


CEclears the Error status bit of the specified output parameter to False. Its effect is identical in Auto or
Manual mode. sptr(after) = sptr(before).

CHI

(Clear History)
CHIcauses all timer history to be cleared, thereby setting all DON, DOFF, and OSPelements in the program
to the inactive state with accumulated time of zero. sptr(after) = sptr(before).
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 32/83
6/3/2014 12. CALCA - Advanced Calculator Block
CHN s

(Clear Step History)


CHN scauses the history of any timer in Step s to be cleared, setting any DON, DOFF, or OSPelement in
Step s to the inactive state with accumulated time of zero. sptr(after) = sptr(before).
If s is less than 1 or greater than 50, a "-3" (out-of-range syntax error value, treated as a run-time error) is
written to the PERROR parameter.

CHS

(Change Sign)
CHSreads the value in the accumulator, changes the sign of the mantissa, and writes the result into the
accumulator, overwriting the original contents. sptr(after) = sptr(before).
Example 1:

Accumulator = -0.6734592

17 CHS Change sign of accumulator.

Accumulator = +0.6734592

Example 2:

Accumulator = +0.1086372

27 CHS Change sign of accumulator.

Accumulator = -0.1086372

CLA

(Clear All Memory Registers)


CLAclears all 24 memory registers. sptr(after) = sptr(before).

CLE

(Clear Error)
CLEclears the internal error flag (the PERROR parameter) during program execution. PERROR is
automatically reset prior to each block execution. Thereafter it retains the first run-time error encountered
during execution.
CLEalso clears the step error (STERR) parameter, which records the step in which the first run-time error
occurred. sptr(after) = sptr(before).

CLM {Mxx}

(Clear Memory Register)


CLM Mxxclears the memory register specified by the Mxx operand, where xx is an index from 01 to 24
(or 1 to 24). sptr(after) = sptr(before).

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 33/83
6/3/2014 12. CALCA - Advanced Calculator Block
CLR
CLR {ROxx, BOxx, IOxx, LOxx, Mxx}

(Clear)
CLRstores a "0" in the specified operand.
If blank is specified, a "0" is stored in the accumulator, overwriting the current contents.
If Mxx is specified, a "0" is stored in memory location Mxx.
If any other operand type is specified, a "0" is stored in the specified output, provided the block is in Auto;
otherwise the step is skipped. In all cases, sptr(after) = sptr(before).

CLRB
CLRB b

(Clear Packed Boolean)


CLRBclears to 0 a specified bit in the accumulator. If blank is specified the bit number is expected to be at
the top of the stack and this bit number is removed from the stack before the instruction is executed.
sptr(after) = sptr(before) - 1.
If the bit number is less than 1 or greater than 16 an "11" (bit error run-time error) is written to the
PERROR parameter.
If the operand b is specified it indicates a bit number between 1 and 16 in the accumulator. The stack is
not popped in this case. sptr(after) = sptr(before).
Bit 1 is the most significant bit of the accumulator, and bit 16 the least significant.

COO {ROxx, BOxx, IOxx, LOxx}

(Clear Out-of-Service Status)


COOclears the Out-of-Service status bit of the specified output parameter to False. Its effect is identical in
Auto or Manual mode. sptr(after) = sptr(before).

COS

(Cosine)
COSreads the value (value of the angle in radians) in the accumulator, computes the cosine of the angle,
and writes the result into the accumulator, overwriting the original contents. sptr(after) = sptr(before).
Example:

Accumulator = +1.0472 (Pi/3) radians. (Pi/3 radians =


60 degrees)

17 COS Compute cosine of accumulator.

Accumulator = +0.5000

CST

(Clear Stack)
CSTresets the stack pointer one position below the bottom of the stack, waiting for the first value to be
pushed onto the stack. Since the block implicitly executes a CSTprior to execution, it is not required to
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 34/83
6/3/2014 12. CALCA - Advanced Calculator Block

start a program with a CSTinstruction.


It is, however, recommended that you issue a CSTinstruction just before setting up operands for a
polyadic instruction, since polyadic instructions operate on all values currently pushed onto the stack.
sptr(after) = stackbottom -1.

DEC
DEC n
DEC {ROxx, IOxx, LOxx, Mxx}

(Decrement)
DECdecrements the accumulator or the specified operand.
If blank is specified, the value in the accumulator is read, algebraically decreased by 1.0, and returned to
the accumulator, overwriting the original contents. If an integer n is specified, the accumulator value is
algebraically decreased by n and returned to the accumulator.
If Mxx is specified, the value in memory location xx is algebraically decreased by 1.0.
If ROxx is specified and the block is in Auto, the indicated output is algebraically decreased by 1.0. If the
block is in Manual, the step is skipped.
If IOxx or LOxx is specified and the block is in Auto, the indicated output is decremented by 1 as an
integer subtraction without underflow. If the operand value before decrementation is equal to -32,768
(-2,147,483,648 in the case of LOxx) or the block is in Manual, the step is skipped.
The stack is unaffected when the operand is other than blank or n. In all cases, sptr(after) =
sptr(before).
Example 1:

RI01 = -5.23

10 IN RI01 Places RI01 into the accumulator.

11 DEC 2 Decrement accumulator by 2.

Accumulator = -7.23. (-5.23 - 2.0)

Example 2:

M02 = 11.2

11 DEC M02 Decrement M02.

M02 = 10.2

DIV
DIV {RIxx, ROxx, Mxx}
DIV {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Divide)
DIVreads the values from the top two stack locations, divides the second operand (divisor) into the first
operand (dividend), decrements the stack pointer, and writes the quotient into the new accumulator
location (the new top of stack location). This overwrites the first operand and isolates the second operand
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 35/83
6/3/2014 12. CALCA - Advanced Calculator Block

from any further access. sptr(after) = sptr(before) - 1.


DIV RIxxreads the value stored in RIxx (the CALCA's Real Input parameter xx) as the divisor, divides
the value (the dividend) that it pops from the stack, then pushes the result back onto the stack. DIV ROxx
and DIV Mxxdo the same for the values stored at ROxx and memory location xx, respectively.
sptr(after) = sptr(before).
DIV RIxx Mxxreads the values stored in RIxx and Mxx, divides the RIxx value by the Mxx value, and
stores the result on the stack. Whenever both operands are specified, the first operand is divided by the
second operand. sptr(after) = sptr(before) + 1.
DIV RIxx nreads the value stored in RIxx and a specified integer constant n, divides the RIxx value by
n, and stores the result on the stack. If the first operand is ROxx or Mxx, the operation is similar.
sptr(after) = sptr(before) + 1.
The range of n is -64 to 63.

NOTE: Values outside of this range will be accepted but the results are based on the rightmost 6 bits of n.

An attempt to DIVby zero (divisor = 0) causes the value of 0 to be written to the stack location at which
the result would ordinarily be stored. A "4" (DIV run-time error) is written to the PERROR parameter.
Example:

RI01 = 12.3485
M01 = 3.73182

12 DIV RI01 M01 Divides RI01 by M01, and stores the result on the
stack.

Accumulator = +3.30898

DOFF
DOFF t
DOFF Mxx

(Delayed OFF}
DOFFproduces a logical zero output if the input has been in the logical zero state for the consecutive length
of time specified by the operand. Once the timer has been activated by a zero value of the input, the
output is forced to logical one; and remains in this state during the time-out. Once the delay has been
completed and the output is at logical zero, the output returns to one as soon as the instruction reads a
logical one followed by a zero at the input. On each cycle, the input is found in the accumulator, and the
output is then written to the accumulator, overwriting the input after it has been used.
DOFFwith blank operand or with a 0 constant operand uses 0.5 seconds as its delay value. If the operand
is the integer t and greater than zero the value of t indicates the number of seconds in the delay. If the
operand is Mxx, then the delay is determined by the contents of memory location xx. A positive value in
Mxx is used as the delay in seconds, and a negative value is used as the delay in block execution cycles.
The maximum time delay with format DOFF tis 32,767 seconds, or approximately 9.1 hours. The
maximum delay with format DOFF Mxxcan be obtained by loading the maximum positive floating point
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 36/83
6/3/2014 12. CALCA - Advanced Calculator Block

value into Mxx, before the DOFF Mxxinstruction is reached in the program. Since the maximum floating
point value is 1038, the delay is 1038 seconds. If the block period is longer than 1.0 second, an even
longer delay can be obtained by loading Mxx with the value of -1038. (The delay times obtainable with this
instruction are effectively unlimited.)
The TIMINI parameter controls DOFFbehavior at block initialization time to avoid unexpected behavior
of the DOFFtimer and, possibly, unpredicted activation of the CALCA block's outputs. If the TIMINI
parameter is set (TIMINI = True), the timer is considered to have been in the expired state just before
initialization. A one-to-zero transition of the accumulator after initialization is required in order to start the
timer. If the TIMINI parameter is not set (TIMINI =False), the timer is considered to have been in the
inactive state just before initialization, and a zero in the accumulator at block initialization begins to time the
specified delay. The timer, therefore, begins to run.
In all cases, sptr(after) = sptr(before).
Example:

RI01 = 8.0

9 IN RI01 Places RI01 into accumulator.

10 STM M01 Copies accumulator value of 8.0 to M01.

11 IN BI01 Inputs to the accumulator the state of BI01at the


execution time of each cycle.

12 DOFF M01 Looks at BI01's input to the accumulator, uses it to


control the Step 12 DOFF timer, and writes the timer
result to the accumulator.

Accumulator = Step 12 timer output

13 OUT BO04 Outputs accumulator contents (the results of the DOFF


M01 instruction) to output BO04. Assume that the block
is in Auto.

BO04 = Step 12 timer output

Figure 12-3.
Timing Diagram for DOFF Example

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 37/83
6/3/2014 12. CALCA - Advanced Calculator Block
DON
DON t
DON Mxx

(Delayed ON)
DONproduces a logical one output if the input has been in the logical one state for the consecutive length of
time specified by the operand. The output returns to zero as soon as the instruction reads a zero in the
input. On each cycle, the input is found in the accumulator, and the output is then written to the
accumulator, overwriting the input after it has been used.
DONwith blank operand or with a 0 constant operand uses 0.5 seconds as its delay value. If the operand
is integer t and greater than zero the value of t indicates the number of seconds in the delay. If the operand
is Mxx, then the delay is determined by the contents of memory location xx. A positive value in Mxx is
used as the delay in seconds, and a negative value is used as the delay in block execution cycles.
The maximum time delay with format DON tis 32,767 seconds, or approximately 9.1 hours. The
maximum delay with format DON Mxxcan be obtained by loading the maximum positive floating point
value into Mxx, before the DON Mxxinstruction is reached in the program. Since the maximum floating
point value is 1038, the delay is 1038 seconds. If the block period is longer than 1.0 second, an even
longer delay can be obtained by loading Mxx with the value of -1038. (The delay times obtainable with this
instruction are effectively unlimited.)
The TIMINI parameter controls DONbehavior at block initialization time to avoid unexpected behavior of
the DONtimer and, possibly, unpredicted activation of the CALCA block's outputs. If the TIMINI
parameter is set (TIMINI = True), the timer is considered to have been in the expired state just before
initialization. A zero-to-one transition of the accumulator after initialization is required in order to start the
timer. If the TIMINI parameter is not set (TIMINI =False), the timer is considered to have been in the
inactive state just before initialization, and a logical one in the accumulator at block initialization begins to
time the specified delay. The timer, therefore, begins to run.
In all cases, sptr(after) = sptr(before).
Example:

11 IN BI01 Inputs to the accumulator the state of BI01 at the


execution time of each cycle.

12 DON 7 Looks at BI01's input to the accumulator, uses it to


control the Step 12 DON timer, and writes the timer
result to the accumulator.

13 OUT BO04 Outputs accumulator contents (the results of the DON 7


instruction) to output BO04. Assume that the block is in
Auto.

BO04 = Step 12 timer output

Figure 12-4.
Timing Diagram for DON Example

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 38/83
6/3/2014 12. CALCA - Advanced Calculator Block

DUP

(Duplicate)
DUPcopies the last stack operand back onto the stack. The stack pointer is advanced one position.
sptr(after) = sptr(before) + 1.

END

(End Program)
ENDterminates the program. Any and all statements (including any additional ENDstatements) following the
first ENDare never executed. If any skip statement skips over the first ENDstatement, the block program
terminates as if the ENDhad been executed.
The ENDinstruction is not required. If there is no ENDstatement, Step 50 (which may be any legal
instruction) is the last statement executed, unless the execution flow lands on an EXITstatement.
sptr(after) = sptr(before).

EXIT

(Exit Program)
EXITterminates the program at the current step number. It is useful for establishing multiple conditional
exit points in the program. The EXITinstruction is functionally equivalent to a GTOinstruction pointing to an
ENDstatement. You can use as many EXITstatements as you need. sptr(after) = sptr(before).

EXP
EXP {RIxx, ROxx, Mxx}
EXP {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Exponent)
EXPwith blank operand reads the values from the top two stack locations, raises the first operand (base)
to the power of the second operand (exponent), decrements the stack pointer, and writes the result into
the new accumulator location (the new top of stack location). This overwrites the first operand and
isolates the second operand from any further access. sptr(after) = sptr(before) - 1.
EXP RIxxreads the value stored in RIxx, raises the value that it pops from the stack to the power of RIxx
value, then pushes the result back onto the stack. EXP ROxxand EXP Mxxdo the same for the values
stored at ROxx and memory location xx, respectively. sptr(after) = sptr(before).
EXP RIxx ROxxreads the values stored in RIxx and ROxx, raises the RIxx value to the power of ROxx
value, and pushes the result on the stack. Similarly for the cases where the first operand is of type ROxx
or Mxx, or the second operand is of type RIxx or Mxx. sptr(after) = sptr(before) + 1.
EXP RIxx nreads the value stored in RIxx and the specified integer constant n, raises the RIxx value to

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 39/83
6/3/2014 12. CALCA - Advanced Calculator Block

the power of n, and pushes the result on the stack. If the first operand is ROxx or Mxx, the operation is
similar. sptr(after) = sptr(before) + 1.
Whenever both operands are specified, the first operand is raised to the power of the second operand.
An attempt to EXPa negative value (base less than 0) causes the value of the specified exponent to be
written to the stack location that would have contained the final result if the operation had been successful.
A "9" (EXP run-time error) is written to the PERROR parameter.
If the base is 0 and the exponent is less than or equal to 0, the result of the operation is 0.0. PERROR is
not set.
Example:

RI01 = 1.483
M01 = 3.10

12 EXP RI01 M01 Raises RI01 to the power of M01 and pushes the
result on the stack.

Accumulator = +3.392638

FF

(Flip-Flop)
FFemulates the function of a traditional set-reset flip-flop. It uses two operands on the stack as inputs.
The first operand is the "set" input and the second operand is the "reset" input.
This instruction writes the output, which corresponds to the "Q" output of a flip-flop, into the accumulator,
overwriting the first operand (the "set" value) and making the second operand (the "reset" value)
inaccessible.

Table 12-13. Truth Table for FF Instruction

S R Q

0 0 No Change

0 1 0

1 0 1

1 1 No Change

The "No Change" condition causes the value of the flip-flop after the previous execution cycle, which is
retained in a block data variable, to be written to the accumulator. sptr(after) = sptr(before) - 1.
Example:

BI01 = True
BI02 = False
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 40/83
6/3/2014 12. CALCA - Advanced Calculator Block

12 IN BI01 Puts BI01 into accumulator - has a True value for "set."

13 IN BI02 Puts BI02 into accumulator - has a False value for "reset."
The "set" input is pushed down one stack location.

14 FF Reads the two operands, determines the output according


to the truth table above (output = 1 for this example), and
writes it into the accumulator, overwriting "set" input. The
output (1) is also stored in the block data for use the next
execution cycle.

Accumulator = True

15 OUT BO01 Writes the accumulator contents (the FF output) to


BO01.

BO01 = True

GTI
GTI {RIxx, ROxx, IIxx, IOxx, Mxx}

(Go To Indirect)
GTIbranches to the step number contained in the accumulator. GTI RIxxbranches to the step number
specified by the current contents of RIxx. Similarly for the other operand types. When the destination is in
an operand of real data type (accumulator, RIxx, ROxx, or Mxx), the operand contents are truncated to
an integer before use. sptr(after) = sptr(before).
An attempt to branch to a step number less than or equal to the current step number or greater than the
step number containing the ENDstatement (50 if there is no ENDstep) writes a "10" (index run-time error)
to the PERROR parameter.

GTO s

(Go To)
GTO sbranches to the step number designated by s. sptr(after) = sptr(before).
An attempt to branch to a step number less than or equal to the current step number or greater than the
step number containing the ENDstatement (50 if there is no ENDstep) writes a "-4" (invalid goto syntax
error) to the PERROR parameter.

IDIV
IDIV Mxx

(Integer Division)
IDIV, with either blank or Mxx operand, reads the values from the top two stack locations, truncates
each into integer form, integer divides the second truncated operand (divisor) into the first truncated
operand (dividend), decrements the stack pointer, and writes the quotient into the new accumulator
location (the new top of stack location). This overwrites the first operand and isolates the second operand
from any further access.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 41/83
6/3/2014 12. CALCA - Advanced Calculator Block

The result of integer division is always truncated, so that the quotient returned to the stack is always a
whole number. When an operand Mxx is specified, the quotient is handled as above, and the integer
remainder (the integer modulus) is stored in memory location xx. The integer modulus is also always a
whole number. In all cases, sptr(after) = sptr(before) - 1.
If the truncated value of the divisor is 0, the value 0.0 is written into the stack location where the quotient
would have been placed. The value "4" (divide run-time error) is written to the PERROR parameter. The
value of Mxx (if specified as an operand) is unchanged.
Example:

RI01 = 19.713
RI02 = 5.9021

15 IN RI01 Places RI01 into accumulator.

16 IN RI02 Places RI02 into accumulator. The prior value is pushed


down one stack location.

17 IDIV M03 The quotient, which is 3.0, overwrites the value of 19.713.
The value of 5.9021 is inaccessible. The integer modulus,
which is 4.0, is in memory location M03.

Accumulator = 3.0
M03 = 4.0

IMOD

(Integer Modulus)
IMODreads the values from the top two stack locations, truncates each into integer form, decrements the
stack pointer, and writes the integer modulus of the first divided by the second truncated value into the
new accumulator location (the new top of stack location). This overwrites the first operand and isolates
the second operand from any further access. The integer modulus is defined as the remainder after an
integer division, and is always a whole number. sptr(after) = sptr(before) - 1.
If the truncated value of the divisor is 0, the value 0.0 is written into the stack location where the modulus
would have been placed. The value "4" (divide run-time error) is written to the PERROR parameter.
Example:

RI01 = 19.713
RI02 = 5.9021

15 IN RI01 Places RI01 into accumulator.

16 IN RI02 Places RI02 into accumulator. The prior value is pushed


down one stack location.

17 IMOD The integer modulus, which is 4.0, overwrites the value of


19.713. The value of 5.9021 is inaccessible.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 42/83
6/3/2014 12. CALCA - Advanced Calculator Block
IN
IN {n, RIxx, ROxx, IIxx, IOxx, BIxx, BOxx, Ixx, Oxx, Mxx, ~RIxx, ~ROxx, ~IIxx,
~IOxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Input)
INwith no operands pushes the value 0.0 onto the stack. INwith operand of type n (any integer), RIxx,
ROxx, or Mxx pushes the operand value onto the stack. INIIxxand IN IOxxconvert the operand
value to real data type and then push the result onto the stack. INwith one of the Boolean operands
(BIxx, BOxx, Ixx, or Oxx) pushes the value 1.0 when the operand value is True and 0.0 when it is False.
INwith inverted Boolean operand (~BIxx, ~BOxx, ~Ixx, or ~Oxx) pushes the value 0.0 onto the stack
when the parameter value is True and 1.0 when it is false. INwith inverted real or integer operand
(~RIxx, ~ROxx, ~IIxx, ~IOxx, or ~Mxx) pushes the value 0.0 when the parameter is non-zero, and 1.0
when the parameter value is 0.0. In all cases, sptr(after) = sptr(before) + 1.

INB
INB {IIxx, Mxx}

(Input Indexed Boolean)


INBwith blank operand reads the value in the accumulator, truncates it to an integer, and uses the result as
the index of the BIxx parameter to be read. The value of BIxx is then pushed onto the stack. INB IIxx
and INB Mxxoperate similarly, except that the index of the BIxx parameter is found in IIxx or Mxx. (If in
Mxx, the real contents of Mxx are first truncated to an integer.)
A value of True in the indexed Boolean is written to the stack as 1.0 and a value of False is written as 0.0.
sptr(after) = sptr(before) + 1.
If the value of the index (the contents of the accumulator, IIxx, or Mxx) is less than 1 or greater than 16, a
"10" (index run-time error) is written to the PERROR parameter.

INC
INC n
INC {ROxx, IOxx, LOxx, Mxx}

(Increment)
INCincrements the accumulator or the specified operand.
If blank is specified, the value in the accumulator is read, algebraically increased by 1.0, and returned to
the accumulator, overwriting the original contents. If an integer n is specified, the accumulator value is
algebraically increased by n and returned to the accumulator.
If Mxx is specified, the value in memory location xx is algebraically increased by 1.0. The stack is
unaffected.
If ROxx is specified and the block is in Auto, the indicated output is algebraically increased by 1.0. If the
block is in Manual, the step is skipped.
If IOxx or LOxx is specified and the block is in Auto, the indicated output is incremented by 1 as an
integer addition without overflow. If the operand value before incrementation is equal to 32,767
(2,147,483,647 in the case of LOxx) or the block is in Manual, the step is skipped.
The stack is unaffected when the operand is other than blank or n. In all cases, sptr(after) =
sptr(before).
Example 1:

RI01 = -5.23
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 43/83
6/3/2014 12. CALCA - Advanced Calculator Block

10 IN RI01 Places RI01 into the accumulator.

11 INC 2 Increments accumulator by 2.

Accumulator = -3.23 (-5.23 + 2.0)

Example 2:

M02 = 11.2

11 INC M02 Increments M02 by 1.

M02 = 12.2

INH {LIxx, LOxx}

(Input High Order)


INHreads the high order 16 bits of parameter LIxx or LOxx as an integer and pushes it onto the stack.
sptr(after) = sptr(before) + 1.

INL {LIxx, LOxx}

(Input Low Order)


INLreads the low order 16 bits of parameter LIxx or LOxx as an integer and pushes it onto the stack.
sptr(after) = sptr(before) + 1.

INR
INR {IIxx, Mxx}

(Input Indexed Real)


INRwith blank operand reads the value in the accumulator, truncates it to an integer, and uses the result as
the index of the RIxx parameter to be read. The value of RIxx is then pushed onto the stack. INR IIxx
and INR Mxxoperate similarly, except that the index of the RIxx parameter is found in IIxx or Mxx. (If in
Mxx, the real contents of Mxx are first truncated to an integer.) sptr(after) = sptr(before) + 1.
If the value of the index (the contents of the accumulator, IIxx, or Mxx) is less than 1 or greater than 8, a
"10" (index run-time error) is written to the PERROR parameter.

INS {RIxx, BIxx, IIxx, LIxx, ROxx, BOxx, IOxx, LOxx}

(Input Status)
INSpushes the 16-bit status of the specified input or output parameter onto the stack. The status value is
not modified. sptr(after) = sptr(before) + 1.
The status integer is made up of the following fields: (Bit 0 is the least significant bit; Bit 15 is most
significant.)

Bit Definition

0 to 4 Data Type
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 44/83
6/3/2014 12. CALCA - Advanced Calculator Block

5 to 7 OM Status

8 Bad

9 Secure/Release

10 Acknowledge

11 Out of Service

12 Shadow Parameter

13 Limited High

14 Limited Low

15 Propagated Error

LAC Mxx

(Load Accumulator)
LAC Mxxloads the accumulator with contents of memory location xx, where xx is a one or two digit
number, between 01 and 24 (or 1 and 24), that specifies the specific memory register whose contents are
to be loaded into the accumulator. sptr(after) = sptr(before) + 1.

LACI Mxx

(Load Accumulator Indirect)


LACI Mxxloads the accumulator with the contents of a memory register indexed by the contents of the
memory register specified by the Mxx operand, where xx is an index from 01 to 24 (or 1 to 24). Neither
memory register is affected.
If Mxx does not contain an integer value, the truncated contents are used as the index.
If the specified memory contents are less than 1 or greater than 24, a "10" (index run-time error) is written
to the PERROR parameter at run-time. sptr(after) = sptr(before) + 1.

10 IN 5 Loads accumulator with value 5.0.

11 STM M04 Places value 5.0 into M04.

12 IN 9 Loads accumulator with value 9.0.

13 STM M05 Places value 9.0 into M05.

14 LACI M04 Loads accumulator with contents of M05 (9.0).

15 OUT RO01 Outputs accumulator value of 9.0 to RO01.

LN
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 45/83
6/3/2014 12. CALCA - Advanced Calculator Block

(Natural Logarithm)
LNreads the value (which must be positive) in the accumulator, computes the natural (base e) logarithm of
the value, and writes the result to the accumulator, overwriting the original contents. sptr(after) =
sptr(before).
An attempt to execute this instruction with a zero or negative value in the accumulator causes the
instruction to be skipped and writes an "8" (LN run-time error) to the PERROR parameter.
Example 1:

Accumulator = +1000.00

17 LN Computes natural logarithm of accumulator

Accumulator = +6.907755

Example 2:

Accumulator = +0.130570

27 LN Computes natural logarithm of accumulator

Accumulator = 2.035846

LOG

(Common Logarithm)
LOGreads the value (which must be positive) in the accumulator, computes the common (base 10)
logarithm of the value, and writes the result to the accumulator, overwriting the original contents.
sptr(after) = sptr(before).
An attempt to execute this instruction with a zero or negative value in the accumulator causes the
instruction to be skipped and writes a "7" (LOG run-time error) to the PERROR parameter.
Example 1:

Accumulator = +2000.00

17 LOG Computes common logarithm of accumulator.

Accumulator = +3.30103

Example 2:

Accumulator = +0.02000

27 LOG Computes common logarithm of accumulator.

Accumulator = -1.69897

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 46/83
6/3/2014 12. CALCA - Advanced Calculator Block
MAX
MAX c
MAX {RIxx, ROxx, Mxx}
MAX {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Maximum)
MAXreads all the values from the stack, selects the maximum algebraic value, decrements the stack
pointer, and writes this value into the new accumulator location (the new top of stack location). This
overwrites the first operand and isolates other operands from any further access. sptr(after) =
stackbottom.
MAX creads the top c values from the stack, selects the maximum algebraic value from the c topmost
values on the stack, writes this value into the c'th position from the top of the stack, and sets the new top
of the stack (the accumulator) to this position. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
MAX RIxx reads the value stored in RIxx (the CALCA's Real Input parameter xx), selects the maximum
algebraic value from the RIxx value and the value that it pops from the stack, and then pushes the result
onto the stack. MAX ROxxand MAX Mxxdo the same for the values stored at ROxx and memory location
xx, respectively. sptr(after) = sptr(before).
MAX RIxx Mxxreads the values stored in RIxx and Mxx, selects the maximum algebraic value from the
RIxx and Mxx values, and stores the result on the stack. Whenever both operands are specified, the
maximum algebraic value is selected from the first and second operands. sptr(after) = sptr(before) + 1.
MAX RIxx nreads the value stored in RIxx and a specified integer constant (n), selects the maximum
algebraic value from RIxx and n, and stores the result on the stack. If the first operand is ROxx or Mxx,
the operation is similar. sptr(after) = sptr(before) + 1.
Example 1:

11 CST Clears the stack.

RI01 = 12.3485
RI02 = 3.73182
RI03 = -2.0037
RI04 = -0.8369

12 IN RI01 Places RI01 into accumulator.

13 IN RI02 Places RI02 into accumulator and pushes the RI01 value
down one stack location.

14 IN RI03 Places RI03 into accumulator and pushes the prior values
down one stack location.

15 IN RI04 Places RI04 into accumulator and pushes the prior values
down one stack location.

16 MAX Selects the maximum algebraic value (12.3485) and stores


this value into the accumulator, overwriting the RI01 value.
The other values are inaccessible.
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 47/83
6/3/2014 12. CALCA - Advanced Calculator Block

Accumulator = 12.3485

Example 2:

RI01 = 12.3485
M01 = 3.73182

11 MAX RI01 M01 Selects the maximum algebraic value from RI01 and
M01 and stores the result on the stack.

Accumulator = 12.3485

MAXO

Identical to MAX

MEDN

(Median)
MEDNreads all the values from the stack, determines the median value, decrements the stack pointer, and
writes this value into the new accumulator location (the new top of stack location). This overwrites the first
operand and isolates the other operands from any further access.
The median value is determined as follows: The stack values are arranged conceptually in ascending order;
then the median is the middle value if the number of operands is odd, or the average of the two middle
values if the number of operands is even. sptr(after) = stackbottom.
Example:

11 CST Clears the stack.

RI01 = 12.3485
RI02 = 3.73182
RI03 = -2.0037
RI04 = -0.8369

12 IN RI01 Places RI01 into accumulator.

13 IN RI02 Places RI02 into accumulator and pushes the RI01 value
down one stack location.

14 IN RI03 Places RI03 into accumulator and pushes the prior values
down one stack location.

15 IN RI04 Places RI04 into accumulator and pushes the prior values
down one stack location.

16 MEDN Computes the average of the two middle values (3.73182 and
-0.8369) and stores this value into the accumulator,
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 48/83
6/3/2014 12. CALCA - Advanced Calculator Block

overwriting the RI01 value. The other values are inaccessible.

Accumulator = 1.44746

MIN
MIN c
MIN {RIxx, ROxx, Mxx}
MIN {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Minimum)
MINreads all the values from the stack, selects the minimum algebraic value, decrements the stack pointer,
and writes this value into the new accumulator location (the new top of stack location). This overwrites the
first operand and isolates the other operands from any further access. sptr(after) = stackbottom.
MIN creads the top c values from the stack, selects the minimum algebraic value from the c topmost
values on the stack, writes this value into the c'th position from the top of the stack, and sets the new top
of the stack (the accumulator) to this position. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
MIN RIxxreads the value stored in RIxx (the CALCA's Real Input parameter xx), selects the minimum
algebraic value from the RIxx value and the value that it pops from the stack, and then pushes the result
onto the stack. MIN ROxxand MIN Mxxdo the same for the values stored at ROxx and memory location
xx, respectively. sptr(after) = sptr(before).
MIN RIxx Mxxreads the values stored in RIxx and Mxx, selects the minimum algebraic value from the
RIxx and Mxx values, and stores the result on the stack. Whenever both operands are specified, the
minimum algebraic value is selected from the first and second operands. sptr(after) = sptr(before) + 1.
MIN RIxx nreads the value stored in RIxx and a specified integer constant (n), selects the minimum
algebraic value from RIxx and n, and stores the result on the stack. If the first operand is ROxx or Mxx,
the operation is similar. sptr(after) = sptr(before) + 1.
Example 1:

11 CST Clears the stack.

RI01 = 12.3485
RI02 = 3.73182
RI03 = -2.0037
RI04 = -0.8369

12 IN RI01 Places RI01 into accumulator.

13 IN RI02 Places RI02 into accumulator and pushes the RI01 value
down one stack location.

14 IN RI03 Places RI03 into accumulator and pushes the prior values
down one stack location.

15 IN RI04 Places RI04 into accumulator and pushes the prior values
down one stack location.
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 49/83
6/3/2014 12. CALCA - Advanced Calculator Block

16 MIN Selects the minimum algebraic value and stores this value into
the accumulator, overwriting the RI01 value. The other values
are inaccessible.

Accumulator = -2.0037

Example 2:

RI01 = 12.3485
M01 = 3.73182

11 MIN RI01 M01 Selects the minimum algebraic value from RI01 and
M01 and stores the result on the stack.

Accumulator = 3.73182

MRS

(Master Reset Flip-Flop)


MRSemulates the function of a traditional reset-dominant flip-flop. It uses two operands on the stack as
inputs. The first operand is the "set" input and the second operand is the "reset" input.
This instruction writes the output, which corresponds to the "Q" output of a flip-flop, into the accumulator,
overwriting the first operand (the "set" value) and making the second operand (the "reset" value)
inaccessible.
Note that the MRSinstruction provides the same functionality as the FF, except that the reset input has
priority over the set input. If both inputs take on a logical one value, the flip-flop is forced to reset.

Table 12-14. Truth Table for MRS Instruction

S R Q

0 0 No Change

0 1 0

1 0 1

1 1 0

The "No Change" condition causes the value of the MRSflip-flop after the previous execution cycle, which
is retained in a block data variable, to be written to the accumulator. sptr(after) = sptr(before) - 1.
Example:

BI01 = True
BI02 = True
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 50/83
6/3/2014 12. CALCA - Advanced Calculator Block

12 IN BI01 Puts BI01 into accumulator - has a True value for "set."

13 IN BI02 Puts BI02 into accumulator - has a True value for "reset."
The "set" input is pushed down one stack location.

14 MRS Reads the two operands, determines the output according


to the truth table above (output = 0 for this example), and
writes it into the accumulator, overwriting "set" input. The
output (0) is also stored in the block data for use the next
execution cycle.

Accumulator = False

15 OUT BO01 Writes the accumulator contents (the MRS output) to


BO01.

BO01 = False

MUL
MUL c
MUL {RIxx, ROxx, Mxx}
MUL {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Multiply)
MUL(or MUL c), reads the values from the top two stack locations (or a specified number (c) of stack
locations), multiplies them, decrements the stack pointer, and writes the product into the new accumulator
location (the new top of stack location). This overwrites the first operand and isolates the second and any
later operand from any further access. For MUL, sptr(after) = sptr(before) - 1. For MUL c, sptr(after)
= sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter. The same action occurs if MULhas no operand and there is only one value on the
stack.
MUL RIxxreads the value stored in RIxx (the CALCA's Real Input parameter xx), multiplies it with the
value that it pops from the stack, then pushes the result back on the stack. MUL ROxxand MUL Mxxdo
the same for the values stored at ROxx and memory location xx, respectively. sptr(after) = sptr(before).
MUL RIxx Mxxreads the values stored in RIxx and Mxx, multiplies the RIxx value by the Mxx value, and
stores the result on the stack. Whenever both operands are specified, the first operand is multiplied by the
second operand. sptr(after) = sptr(before).
MUL RIxx nreads the value stored in RIxx and a specified integer constant (n), multiplies the RIxx value
by n, and stores the result on the stack. If the first operand is ROxx or Mxx, the operation is similar.
sptr(after) = sptr(before).
Example 1 - Calculate (RI01 * M01):

RI01 = 12.3485
M01 = 3.73182

12 MUL RI01 M01 Multiplies RI01 by M01 and stores the result on the
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 51/83
6/3/2014 12. CALCA - Advanced Calculator Block

stack.

Accumulator = 46.08238

Example 2 - Calculate (RI01 + RI02) * (RI03 - RI04):

RI01 = 12.3485
RI02 = 3.73182
RI03 = 8.919
RI04 = 5.199

12 ADD RI01 RI02 Adds RI01 to RI02 and stores (pushes) the result on
the stack.

Accumulator = 16.08032

15 SUB RI03 RI04 Subtracts RI04 from RI03 and stores (pushes) the
result on the stack.

Accumulator = 3.72

16 MUL Pops the top two values from the stack, multiplies
them, and pushes the result (16.08032 * 3.72 =
59.81879) on the stack.

Accumulator = 59.81879

17 OUT RO01 Writes the value (59.81879) in the accumulator (top


of the stack) to the RO01 parameter.

NAN

Identical to NAND

NAND
NAND c
NAND {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}
NAND {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx} {BIxx,
BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Logical Not And)


NANDperforms a logical "nand" (not and) of the contents of the specified operands and stack locations.
Logical Not And is defined as producing a False output if all of the inputs are True and a True output if
any one of the inputs is False.
If blank is specified, all stack locations are NANDed together, and the result is written into the
accumulator (the new top of stack location). This overwrites the first operand and isolates the other
operands from any further access. sptr(after) = stackbottom.
If c is specified, the last c stack locations are NANDed together, removed from the stack, and the result
stored in the accumulator. sptr(after) = sptr(before) - c + 1.
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 52/83
6/3/2014 12. CALCA - Advanced Calculator Block

If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
If only one operand is specified, the operand is NANDed with the accumulator, and the result replaces
the accumulator. sptr(after) = sptr(before).
If both operands are specified, the operands are NANDed together and the result is stored in the
accumulator. sptr(after) = sptr(before) + 1.
If ~ is specified, the operand value is inverted prior to being used.
Before the operand Mxx is used in the calculation, its value is truncated to an integer; if the result is 0 the
operand value is considered False, otherwise it is True.
Example 1:

11 CST Clears the stack.

BI01 = True
BI07 = False
BO03 = True
BI14 = True

12 IN BI01 Puts BI01 into accumulator.

13 IN BI07 Puts BI07 into accumulator. The prior value is pushed down
one stack location.

14 IN BO03 Puts BO03 into accumulator. The prior values are pushed
down one stack location.

15 IN BI14 Puts BI14 into accumulator. The prior values are pushed
down one stack location.

16 NAND Performs the logical NAND function, and stores result into
the accumulator, overwriting the True value loaded in from
BI01. The other values are inaccessible.

Accumulator = True

Example 2:

BI04 = False
BO01 = True

12 NAND BI04 BO01 Performs the logical NAND of BI04 and BO01
and stores the result on the stack.

Accumulator = True

NANX
NANX c

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 53/83
6/3/2014 12. CALCA - Advanced Calculator Block

(Packed Logical Not And)


NANXreads all the values or a specified number (c) of values from the stack, performs a 16-bit bitwise
logical "nand" function on them, and stores the result into the new accumulator location (the new top of
stack). This overwrites the first operand and isolates the other operands from any further access. Logical
Not And is defined as producing a False output if all of the inputs are True and a True output if any one of
the inputs is False.
For NANX, sptr(after) = stackbottom. For NANX c, sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
Each operand is truncated from real to 16-bit integer type before it is used in the calculation. The final
result is stored on the stack as a real value.
Example:

II01 = 5 (0000000000000101)
II02 = 1 (0000000000000001)
RI01 = 13.078 (0000000000001101)

13 IN II01 Puts II01 into accumulator. The prior value is pushed down
one stack location.

14 IN II02 Puts II02 into accumulator. The prior values are pushed
down one stack location.

15 IN RI01 Puts RI01 into accumulator. Value is truncated to 13 and


used as 0000000000001101 in the calculation. The prior
values are pushed down one stack location.

16 NANX 3 Performs the packed logical NANX function and stores the
result, 1111111111111110, into the accumulator,
overwriting the value of II01. The other values are
inaccessible.

Accumulator = -2.0

NOP

(No Operation)
This instruction causes the step to be ignored. The program continues with the next instruction. sptr(after)
= sptr(before).

NOR
NOR c
NOR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}
NOR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx} {BIxx,
BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Logical Not Or)


NORperforms a logical "nor" (not or) of the contents of the specified operands and stack locations. Logical
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 54/83
6/3/2014 12. CALCA - Advanced Calculator Block

Not Or is defined as producing a False output if any input is True and a True output if all of the inputs are
False.
If blank is specified, all stack locations are NORed together, and the result is written into the accumulator
(the new top of stack location). This overwrites the first operand and isolates the other operands from any
further access. sptr(after) = stackbottom.
If c is specified, the last c stack locations are NORed together, removed from the stack, and the result
stored in the accumulator. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
If only one operand is specified, the operand is NORed with the accumulator, and the result replaces the
accumulator. sptr(after) = sptr(before).
If both operands are specified, the operands are NORed together and the result is stored in the
accumulator. sptr(after) = sptr(before) + 1.
If ~ is specified, the operand value is inverted prior to being used.
Before the operand Mxx is used in the calculation, its value is truncated to an integer; if the result is 0 the
operand value is considered False, otherwise it is True.
Example 1:

11 CST Clears the stack.

BI01 = True
BI07 = False
BO03 = True
BI14 = True

12 IN BI01 Puts BI01 into accumulator.

13 IN BI07 Puts BI07 into accumulator. The prior value is pushed down
one stack location.

14 IN BO03 Puts BO03 into accumulator. The prior values are pushed
down one stack location.

15 IN BI14 Puts BI14 into accumulator. The prior values are pushed
down one stack location.

16 NOR Performs the logical NOR function, and stores the result into
the accumulator, overwriting the True value loaded in from
BI01. The other values are inaccessible.

Accumulator = False

Example 2:

BI04 = False
BO01 = True

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 55/83
6/3/2014 12. CALCA - Advanced Calculator Block

12 NOR BI04 BO01 Performs the logical NOR of BI04 and BO01 and
stores the result on the stack.

Accumulator = False

NORX
NORX c

(Packed Logical Not Or)


NORXreads all the values or a specified number (c) of values from the stack, performs a 16-bit bitwise
logical "nor" function on them, and stores the result into the new accumulator location (the new top of
stack). This overwrites the first operand and isolates the other operands from any further access. Logical
Not Or is defined as producing a False output if any input is True and a True output if all of the inputs are
False.
For NORX, sptr(after) = stackbottom. For NORX c, sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
Each operand is truncated from real to 16-bit integer type before it is used in the calculation. The final
result is stored on the stack as a real value.
Example:

II01 = 5 (0000000000000101)
II02 = 1 (0000000000000001)
RI01 = 13.078 (0000000000001101)

13 IN II01 Puts II01 into accumulator. The prior value is pushed down
one stack location.

14 IN II02 Puts II02 into accumulator. The prior values are pushed down
one stack location.

15 IN RI01 Puts RI01 into accumulator - assume value is 13.078. Value


is truncated to 13 and used as 0000000000001101 in the
calculation. The prior values are pushed down one stack
location.

16 NORX Performs the packed logical NORX function and stores the
3 result, 1111111111110010, into the accumulator, overwriting
the value of II01. The other values are inaccessible.

Accumulator = -14.0

NOT

(Not)
NOTreads the value (real, integer, or Boolean) in the accumulator (zero value = False, non-zero value =
True), logically negates the value, and writes the result into the accumulator, overwriting the original value.
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 56/83
6/3/2014 12. CALCA - Advanced Calculator Block

sptr(after) = sptr(before).
Example (AC = accumulator):

Accumulator = 0 after Step 16.

17 NOT Accumulator = 1 after Step 17.

Accumulator = 0.21 after Step 26.

27 NOT Accumulator = 0 after Step 27.

NOTX

(Packed Logical Not)


NOTXreads the value (real, integer, or Boolean) in the accumulator, performs a 16-bit logical complement
of the value, and writes the result into the accumulator, overwriting the original value. (The original value is
truncated to a 16-bit integer before complementing.) sptr(after) = sptr(before).
Example:

Accumulator = 12.0

17 NOTX Complement the accumulator.

Accumulator = -13.0. (Complement of 0000000000001100 is


1111111111110011, or -13.0.)

NXO

Identical to NXOR

NXOR
NXOR c
NXOR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}
NXOR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx} {BIxx,
BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Logical Not Exclusive Or)


NXORperforms a logical "nxor" of the contents of the specified operands and stack locations. Not
Exclusive Or is defined as producing a True output for an even number of True inputs, a False output for
an odd number of True inputs, and a True output if all inputs are False.
If blank is specified, all stack locations are NXORed together, and the result is written into the
accumulator (the new top of stack location). This overwrites the first operand and isolates the other
operands from any further access. sptr(after) = stackbottom.
If c is specified, the last c stack locations are NXORed together, removed from the stack, and the result
stored in the accumulator. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 57/83
6/3/2014 12. CALCA - Advanced Calculator Block

If only one operand is specified, the operand is NXORed with the accumulator, and the result replaces the
accumulator. sptr(after) = sptr(before).
If both operands are specified, the operands are NXORed together and the result is stored in the
accumulator. sptr(after) = sptr(before) + 1.
If ~ is specified, the operand value is inverted prior to being used.
Before the operand Mxx is used in the calculation, its value is truncated to an integer; if the result is 0 the
operand value is considered False, otherwise it is True.
Example 1:

11 CST Clears the stack.

BI01 = True
BI07 = False
BO03 = True
BI14 = True

12 IN BI01 Puts BI01 into accumulator.

13 IN BI07 Puts BI07 into accumulator. The prior value is pushed down
one stack location.

14 IN BO03 Puts BO03 into accumulator. The prior values are pushed
down one stack location.

15 IN BI14 Puts BI14 into accumulator. The prior values are pushed
down one stack location.

16 NXOR Performs the logical NXOR function, and stores result into
accumulator, overwriting the True value loaded in from
BI01. The other values are inaccessible.

Accumulator = False

Example 2:

BI04 = False
BO01 = True

12 NXOR BI04 BO01 Performs the logical NXOR of BI04 and BO01
and stores the result on the stack.

Accumulator = False

NXOX
NXOX c

(Packed Logical Not Exclusive Or)

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 58/83
6/3/2014 12. CALCA - Advanced Calculator Block

NXOXreads all the values or a specified number (c) of values from the stack, performs a 16-bit bitwise
logical "nxor" function on them, and stores the result into the new accumulator location (the new top of
stack). This overwrites the first operand and isolates the other operands from any further access. Not
Exclusive Or is defined as producing a True output for an even number of True inputs, a False output for
an odd number of True inputs, and a True output if all inputs are False.
For NXOX, sptr(after) = stackbottom. For NXOX c, sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
Each operand is truncated from real to 16-bit integer type before it is used in the calculation. The final
result is stored on the stack as a real value.
Example:

II01 = 5 (0000000000000101)
II02 = 7 (0000000000000111)
RI01 = 12.078 (0000000000001100)

13 IN II01 Puts II01 into accumulator. The prior value is pushed down
one stack location.

14 IN II02 Puts II02 into accumulator. The prior values are pushed
down one stack location.

15 IN RI01 Puts RI01 into accumulator. Value is truncated to 12 and


used as 0000000000001100 in the calculation. The prior
values are pushed down one stack location.

16 NXOX 3 Performs the packed logical NXOX function and stores the
result, 1111111111110001, into the accumulator,
overwriting the value loaded in from II01. The other values
are inaccessible.

Accumulator = -15.0

OR
OR c
OR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}
OR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx} {BIxx, BOxx,
Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Logical Or)
ORperforms a logical "or" of the contents of the specified operands and stack locations.
If blank is specified, all stack locations are ORed together, and the result is written into the accumulator
(the new top of stack location). This overwrites the first operand and isolates the other operands from any
further access. sptr(after) = stackbottom.
If c is specified, the last c stack locations are ORed together, removed from the stack, and the result
stored in the accumulator. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 59/83
6/3/2014 12. CALCA - Advanced Calculator Block

PERROR parameter.
If only one operand is specified, the operand is ORed with the accumulator, and the result replaces the
accumulator. sptr(after) = sptr(before).
If both operands are specified, the operands are ORed together and the result is stored in the
accumulator. sptr(after) = sptr(before) + 1.
If ~ is specified, the operand value is inverted prior to being used.
Before the operand Mxx is used in the calculation, its value is truncated to an integer; if the result is 0 the
operand value is considered False, otherwise it is True.
Example 1:

11 CST Clears the stack.

BI01 = True
BI07 = False
BO03 = True
BI14 = True

12 IN BI01 Puts BI01 into accumulator.

13 IN BI07 Puts BI07 into accumulator. The prior value is pushed down
one stack location.

14 IN BO03 Puts BO03 into accumulator. The prior values are pushed
down one stack location.

15 IN BI14 Puts BI14 into accumulator. The prior values are pushed
down one stack location.

16 OR Performs the logical OR function, and stores result into


accumulator, overwriting the True value loaded in from
BI01. The other values are inaccessible.

Accumulator = True

Example 2:

BI04 = False
BO01 = True

12 OR BI04 BO01 Performs the logical OR of BI04 and BO01 and


stores the result on the stack.

Accumulator = True

ORX
ORX c

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 60/83
6/3/2014 12. CALCA - Advanced Calculator Block

(Packed Logical Or)


ORXreads all the values or a specified number (c) of values from the stack, performs a 16-bit bitwise
logical "or" function on them, and stores the result into the new accumulator location (the new top of
stack). This overwrites the first operand and isolates the other operands from any further access.
For ORX, sptr(after) = stackbottom. For ORX c, sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
Each operand is truncated from real to 16-bit integer type before it is used in the calculation. The final
result is stored on the stack as a real value.
Example:

11 CST Clears the stack.

BI01 = True (0000000000000001)


II01 = 5 (0000000000000101)
II02 = 0 (0000000000000000)
RI01 = 12.078 (0000000000001100)

12 IN BI01 Puts BI01 into accumulator. Stored as 1.0 and used as


0000000000000001 in the calculation.

13 IN II01 Puts II01 into accumulator. The prior value is pushed down
one stack location.

14 IN II02 Puts II02 into accumulator. The prior values are pushed down
one stack location.

15 IN RI01 Puts RI01 into accumulator. Value is truncated to 12 and


used as 0000000000001100 in the calculation. The prior
values are pushed down one stack location.

16 ORX Performs the packed logical OR function and stores the


result, 0000000000001101, into the accumulator, overwriting
the value loaded in from BI01. The other values are
inaccessible.

Accumulator = 13.0

OSP
OSP t
OSP Mxx

(One-Shot Pulse)
OSPwith blank operand or with a 0 constant operand uses 0.5 seconds as its pulse width value. If the
operand is integer t and greater than zero the value of t indicates the number of seconds in the pulse width.
If the operand is Mxx, then the pulse width is determined by the contents of memory location xx. A
positive value in Mxx is used as the pulse width in seconds, and a negative value is used as the pulse width
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 61/83
6/3/2014 12. CALCA - Advanced Calculator Block

in block execution cycles.


The maximum pulse width with format OSP tis 32,767 seconds, or approximately 9.1 hours. The
maximum pulse width with format OSP Mxxcan be obtained by loading the maximum positive floating
point value into Mxx, before the OSP Mxxinstruction is reached in the program. Since the maximum
floating point value is 1038, the pulse width is 1038 seconds. If the block period is longer than 1.0 second,
an even longer pulse width can be obtained by loading Mxx with the value of -1038. (The pulse widths
obtainable with this instruction are effectively unlimited.)
OSPgenerates a non-retriggerable (triggering is disabled while the output is true) one-shot pulse when the
accumulator value makes a zero-to-one transition. The output remains true for a period specified by the
operand, after which the block resets the output to zero.
The TIMINI parameter controls OSPbehavior at block initialization time to avoid unexpected behavior of
the OSPelement and, possibly, unpredicted activation of the CALCA block's outputs. If the TIMINI
parameter is set (TIMINI = True), the pulse is considered to have been in progress just before
initialization. A zero-to-one transition of the accumulator after initialization is required in order to start the
pulse output. If the TIMINI parameter is not set (TIMINI =False), the pulse is considered to have been
off just before initialization, and a logical one in the accumulator at block initialization begins to output the
specified pulse.
In all cases, sptr(after) = sptr(before).
Example:

11 IN BI01 Inputs to the accumulator the state of BI01 at the


execution time of each cycle.

12 OSP 5 Looks at BI01's input to the accumulator, uses it to


control the Step 12 OSP element, and writes the result to
the accumulator.

13 OUT BO04 Outputs accumulator contents (the results of the OSP 5


instruction) to output BO04. Assume block is in Auto.

BO04 = Step 12 OSP output

Figure 12-5.
Timing Diagram for OSP Example

OUT {ROxx, BOxx, IOxx, Oxx, Mxx, ~BOxx, ~Oxx, ~Mxx}

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 62/83
6/3/2014 12. CALCA - Advanced Calculator Block

(Output)
OUTwrites the accumulator contents to the output parameter specified by the operand. When operating in
the Manual state, this instruction is skipped without changing the value of the output, unless the operand is
Mxx or ~Mxx, in which case the operation is executed.
The value of the accumulator is first clamped between 32,767 and -32,768 and then truncated to an
integer value before writing it to an operand of type IOxx.
Any non-zero value in the accumulator is converted to True in an operand of type BOxx or Oxx, and a
0.0 value is converted to False. If the operand is of type ~BOxx or ~Oxx a non-zero value in the
accumulator causes a False to be written and a 0.0 causes a True to be written.
If the operand is of type Mxx, the accumulator value is simply copied to the specified memory location. If
it is of type ~Mxx, any non-zero accumulator value is written to Mxx as the real value 0.0 and an
accumulator value of 0.0 is written to Mxx as real value 1.0.
OUT does not alter the contents or location of the accumulator. sptr(after) = sptr(before).
Example:

Accumulator = 3.1416

OUT IO02 Writes accumulator value to output IO02.

OUT RO02 Writes accumulator value to output RO02.

OUT ~BO01 Writes accumulator value to output BO01.

IO02 = 3
RO02 = 3.1416
BO01 = False

POP

(Pop Stack)
POPremoves the value at the top of the stack and discards it. The stack pointer is decremented to point to
the next value on the stack. sptr(after) = sptr(before) - 1.

PRI ROxx

(Propagate Upstream)
PRIallows you to propagate cascade status and bad status from a specified RInn input, to a specified
ROnn output. The RInn input index is loaded onto the stack by a prior instruction.
This instruction copies the LHI, LLO, INITU, INITC, FS, BAD, and OOS bits from the status field of
RInn to the status field of the ROnn output. If this operation causes any of these bits to be changed in the
status of ROnn, an immediate execution of the upstream block is requested. sptr(after) = sptr(before) -
1.
If the popped index value for RIxx is less than 1 or greater than 8, a "-3" (out-of-range syntax error value,
treated as a run-time error) is written to the PERROR parameter.
Example:

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 63/83
6/3/2014 12. CALCA - Advanced Calculator Block

31 IN 4 Loads "4" onto the stack to specify the RI04 will be used
by the PRI instruction.

32 PRI RO02 Propagates the LHI, LLO, INITU, INITC, FS, BAD and
OOS status bits, from RI04 to real output RO02.

PRO ROxx

(Propagate Downstream)
PROallows you to propagate the cascade acknowledgment from a specified RIxx input to the specified
ROxx output. The RIxx input index is loaded onto the stack by a prior instruction, and popped from the
stack when it is used. sptr(after) = sptr(before) - 1.
This instruction copies the PRIBLK initialization acknowledgment bit (the Acknowledge status bit) from
RIxx to ROxx.
If the popped index value for RIxx is less than 1 or greater than 8, a "-3" (out-of-range syntax error value,
treated as a run-time error) is written to the PERROR parameter.
Example:

41 IN 5 Loads "5" onto the stack to specify that RI05 will be used
by the PRO instruction.

42 PRO RO03 Propagates the PRIBLK initialization acknowledgment bit


in RI05 to real output RO03.

PRP ROxx

(Propagate Errors)
PRPallows you to propagate certain types of RIxx input errors to the specified ROxx output. The RIxx
inputs whose error conditions are to be propagated are specified by a mask on the stack, loaded by a
prior instruction. The mask is popped from the stack after it is used. sptr(after) = sptr(before) - 1.
This instruction sets the Error status bit of the specified output operand if any of the specified RIxx inputs
are in error. An RIxx input is considered to be in error when:

its Bad status bit is True, or


its Out-of-Service status bit is True, or
its Error status bit is True, or
its OM status field does not have the value "ON_SCAN".

Example:

12 IN H29 Puts Hexadecimal 29 into accumulator.

13 PRP RO02 Propagates any error in RI03 or RI05 or RI08 to the real
output RO02. Hexadecimal 29 is the mask 00101001.
The value "1" in the high order bit of the mask indicates
RI01, the next lower order bit indicates RI02, and so on.
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 64/83
6/3/2014 12. CALCA - Advanced Calculator Block

RAND

(Generate Random Number)


RANDgenerates a random number with uniform distribution and places it in the accumulator. The following
formula is used:
Seed = (Seed*125) modulo 2,796,203
Accumulator = Seed / 2,796,203
Seed is a CALCA block variable which is set to the value 100,001 when the block initializes, and is
changed each time a RANDinstruction is executed. You can re-initialize Seed with any desired value at any
time, by using the SEEDinstruction. sptr(after) = sptr(before) + 1.

RANG

(Generate Random Number, Gaussian)


RANGgenerates a random number with Gaussian distribution and places it in the accumulator. Two
consecutive implicit RANDexecutions are used, after which the following formula determines the value to
be set into the accumulator:
x = result of the first of two RAND iterations
y = result of the second of two RAND iterations
Accumulator = square root ((-2.0 ln (x)) * cos(2.0 y))
In this expression, "ln" represents the natural logarithm function. sptr(after) = sptr(before) + 1.

RBD {RIxx, IIxx, LIxx, BIxx, ROxx, IOxx, LOxx, BOxx}

(Read Bad and OOS Bits)


RBDreads both the Out-of-Service and Bad status bits of the specified parameter and writes the value 1
to the accumulator if either of the bits is set. If neither bit is set the value 0 is written to the accumulator.
sptr(after) = sptr(before) + 1.

RCL {RIxx, ROxx, IIxx, IOxx, BIxx, BOxx, Ixx, Oxx, Mxx, ~RIxx, ~ROxx, ~IIxx, ~IOxx,
~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Read and Clear)


RCL with RIxx, IIxx, BIxx, or Ixxoperand unconditionally pushes onto the stack the contents of the
operand. If the operand is unlinked (in the case of Ixx, if the LI01 operand is unlinked) a zero value is
written to the operand. Otherwise the operand is unchanged.
RCLwith ROxx, IOxx, BOxx, or Oxxoperand unconditionally pushes onto the stack the operand contents,
and, if the CALCA block is in Auto, writes a zero value to the operand. Otherwise the operand is
unchanged.
RCL Mxxalways pushes the Mxx value onto the stack and writes 0.0 to Mxx.
For real type operands, a written zero value is 0.0; for integer types it is 0; and for Boolean types it is
False. Values of integer operands are converted to real type when pushed on the stack. False Boolean
operands are pushed as 0.0, and true Boolean operands are pushed as 1.0.
RCLwith inverted operand follows the same rules as above, except that operand values are inverted
before they are pushed on the stack. Inverted real or integer operands are pushed as 0.0 when they are
non-zero and as 1.0 when they are zero.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 65/83
6/3/2014 12. CALCA - Advanced Calculator Block

In all cases, sptr(after) = sptr(before) + 1.

RCN {RIxx, IIxx. LIxx, Bxx}

(Read Connect Status)


RCNreads the linkage type of the specified input and stores the short integer result in the accumulator.
sptr(after) = sptr(before) + 1.

RE {RIxx, IIxx, LIxx, BIxx, ROxx, IOxx, LOxx, BOxx}

(Read Error Bit)


REreads the Error status bit of the specified parameter and writes its value to the accumulator. (1 = True
= error bit set, 0 = False = error bit not set.) sptr(after) = sptr(before) + 1.

REL {ROxx, BOxx, IOxx, LOxx}

(Clear Secure Status)


RELclears the Secure status bit of the specified output parameter to False, thereby releasing it and making
it settable. Its effect is identical in Auto or Manual mode. The effect of RELoverrides that of MA.
sptr(after) = sptr(before).

RER

(Read Error)
RERreads the internal error flag (the PERROR parameter) during program execution and stores the value
in the accumulator. PERROR retains the first run-time error encountered during each block execution, or
the first error encountered after a CLEinstruction. You can use this instruction to check for errors that may
have occurred since starting the current execution cycle. sptr(after) = sptr(before) + 1.

RND

(Round)
RNDreads the number in the accumulator, rounds off the value to the nearest integer, and writes the result
into the accumulator, overwriting the original value.
If the decimal portion is less than 0.5, the value is rounded down to the integer portion of the number. If
the decimal portion is 0.5 or greater, the value is rounded up to the next higher integer. In the case of
negative accumulator values, if the absolute value of the decimal portion is greater than 0.5, the value is
rounded down to the next lower integer. (See Example 2.) sptr(after) = sptr(before).
Example 1:

16... Assume that the accumulator has value of 43.499 after Step 16.

17 RND Accumulator has value of 43.0 after Step 17.

Example 2:

26... Assume that the accumulator has value of -1.68 after Step 26.

27 RND Accumulator has value of -2.0 after Step 27.


https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 66/83
6/3/2014 12. CALCA - Advanced Calculator Block

RON {RIxx, IIxx, LIxx, BIxx, ROxx, IOxx, LOxx, BOxx}

(Read In-Service Status)


RONreads the Out-of-Service status bit of the specified parameter and writes the inverse of its value to the
accumulator. (1 = True = OOS bit not set = parameter in service, 0 = False = OOS bit set = parameter
out-of-service).
The result of the RONinstruction is always the inverse of the result of the ROO instruction. sptr(after) =
sptr(before) + 1.

ROO {RIxx, IIxx, LIxx, BIxx, ROxx, IOxx, LOxx, BOxx}

(Read OOS Bit)


ROOreads the Out-of-Service status bit of the specified parameter and writes its value to the accumulator.
(1 = True = OOS bit set, 0 = False = OOS bit not set.)
The result of the ROOinstruction is always the inverse of the result of the RONinstruction. sptr(after) =
sptr(before) + 1.

RQE {RIxx, IIxx, LIxx, BIxx}

(Read Quality Including Error)


RQEreads the Bad, Out-of-Service, and Error status bits and the OM status field of the specified input. It
writes the value 1 to the accumulator if any of the three bits is set or if the OM status field does not have
the value "ON_SCAN". In any other case, it writes the value 0 to the accumulator. sptr(after) =
sptr(before) + 1.

RQL {RIxx, IIxx, LIxx, BIxx}

(Read Quality)
RQLreads the Bad and Out-of-Service status bits and the OM status field of the specified input. It writes
the value 1 to the accumulator if either of the two bits is set or if the OM status field does not have the
value "ON_SCAN". In any other case, it writes the value 0 to the accumulator. sptr(after) =
sptr(before) + 1.

SAC {ROxx, BOxx, IOxx, Mxx, ~BOxx, ~Mxx}

(Store Accumulator in Output)


SACis identical to OUT, except that outputs to the pseudo-parameters Oxx are not permitted. sptr(after)
= sptr(before).

SBD {ROxx, BOxx, IOxx, LOxx}

(Set Bad Status)


SBDsets the Bad status bit of the specified output parameter to True. Its effect is identical in Auto or
Manual mode. sptr(after) = sptr(before).

SE {ROxx, BOxx, IOxx, LOxx}

(Set Error Status)


https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 67/83
6/3/2014 12. CALCA - Advanced Calculator Block

SEsets the Error status bit of the specified output parameter to True. Its effect is identical in Auto or
Manual mode. sptr(after) = sptr(before).

SEC {ROxx, BOxx, IOxx, LOxx}

(Set Secure Status)


SECsets the Secure status bit of the specified output parameter to True, thereby making the parameter
non-settable. Its effect is identical in Auto or Manual mode. The effect of SECoverrides that of MA.
sptr(after) = sptr(before).

SEED

(Seed Random Number Generator)


SEEDstores the contents of the accumulator into the Seed value used by the RANDand RANGinstructions.
The initial Seed value is set, when the block initializes, at 100,001 and is changed by each iteration of the
RANDor RANGinstruction. If the accumulator value is less than zero or greater than 100,001 when the
SEEDinstruction is executed, the instruction is skipped. sptr(after) = sptr(before).

SET
SET {ROxx, BOxx, IOxx, LOxx, Mxx}

(Set)
SETstores a "1" in the specified operand.
If blank is specified, a "1" is stored in the accumulator. If Mxx is specified, a "1" is stored in memory
location Mxx.
If any other operand type is specified, a "1" is stored in the specified output, provided the block is in Auto;
otherwise the step is skipped. In all cases, sptr(after) = sptr(before).

SETB
SETB b

(Set Packed Boolean)


SETBsets to 1 a specified bit in the accumulator. If blank is specified the bit number is expected to be at
the top of the stack and this bit number is removed from the stack before the instruction is executed.
sptr(after) = sptr(before) - 1.
If the bit number is less than 1 or greater than 16 an "11" (bit error run-time error) is written to the
PERROR parameter.
If the operand b is specified it indicates a bit number between 1 and 16 in the accumulator. The stack is
not popped in this case. sptr(after) = sptr(before).
Bit 1 is the most significant bit of the accumulator, and bit 16 the least significant.

SIEC

(Skip if Error Clear)


SIECskips the next program step if the internal error flag (the PERROR parameter) is zero. PERROR
retains the first run-time error encountered during each block execution, or the first error encountered after
a CLEinstruction sptr(after) = sptr(before).

SIN

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 68/83
6/3/2014 12. CALCA - Advanced Calculator Block

(Sine)
SINreads the value (value of the angle in radians) in the accumulator, computes the sine of the angle, and
writes the result into the accumulator, overwriting the original contents. sptr(after) = sptr(before).
Example:

Accumulator = +0.5236 (Pi/6) radians. (Pi/6 radians =


30 degrees)

17 SIN Compute sine of accumulator.

Accumulator = +0.5000

SOO {ROxx, BOxx, IOxx, LOxx}

(Set Out-of-Service Status)


SOOsets the Out-of-Service status bit of the specified output parameter to True. Its effect is identical in
Auto or Manual mode. sptr(after) = sptr(before).

SQR

(Square)
SQRreads the value in the accumulator, computes the square of the value, and writes the result into the
accumulator, overwriting the original contents. sptr(after) = sptr(before).
Example:

Accumulator = -7.0 or +7.0

17 SQR Computes square of accumulator

Accumulator = +49.0000

SQRT

(Square Root)
SQRTreads the value (which must be 0) in the accumulator, computes the square root of the value, and
writes the positive root to the accumulator, writing over the original contents. sptr(after) = sptr(before).
An attempt to SQRTa value < 0 causes the instruction to be skipped and writes a "1" (SQRT run-time
error) to the PERROR parameter.
Example:

Accumulator = +49.0000

17 SQRT Computes square root of accumulator

Accumulator = +7.00000

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 69/83
6/3/2014 12. CALCA - Advanced Calculator Block
SSF {ROxx, BOxx, IOxx, LOxx, Mxx}

(Set and Skip if False)


SSFsets the specified operand to 1.0 (if ROxx or Mxx) or 1 (if IOxx or LOxx) or True (if BOxx) and
skips the next program step when the accumulator value is 0.0. Otherwise the instruction is ignored and
the next instruction in sequence is executed.
If this instruction is the last or next-to-last step in the CALCA block program and the accumulator is zero,
the operand is set and then the block program terminates.
When the block is in Manual, the outputs ROxx, BOxx, IOxx, and LOxx are unchanged, but the skip
action still occurs based on the value of the accumulator. sptr(after) = sptr(before). SSFis identical to
SSZ.

SSI {ROxx, BOxx, IOxx, LOxx, Mxx}

(Set and Skip if Initializing)


SSIsets the specified operand to 1.0 (if ROxx or Mxx) or 1 (if IOxx or LOxx) or True (if BOxx) and
skips the next program step if the CALCA block is initializing this execution cycle. Otherwise the
instruction is ignored and the next instruction in sequence is executed.
If this instruction is the last or next-to-last step in the CALCA block program and the block is initializing,
the operand is set and then the block program terminates.
When the block is in Manual, the outputs ROxx, BOxx, IOxx, and LOxx are unchanged, but the skip
action still occurs based on the value of the accumulator. sptr(after) = sptr(before).

SSN {ROxx, BOxx, IOxx, LOxx, Mxx}

(Set and Skip if Negative)


SSNsets the specified operand to 1.0 (if ROxx or Mxx) or 1 (if IOxx or LOxx) or True (if BOxx) and
skips the next program step when the accumulator is negative. Otherwise the instruction is ignored and the
next instruction in sequence is executed.
If this instruction is the last or next-to-last step in the CALCA block program and the accumulator is
negative, the operand is set and then the block program terminates.
When the block is in Manual, the outputs ROxx, BOxx, IOxx, and LOxx are unchanged, but the skip
action still occurs based on the value of the accumulator. sptr(after) = sptr(before).

SSP {ROxx, BOxx, IOxx, LOxx, Mxx}

(Set and Skip if Positive)


SSPsets the specified operand to 1.0 (if ROxx or Mxx) or 1 (if IOxx or LOxx) or True (if BOxx) and
skips the next program step when the accumulator is positive or zero. Otherwise the instruction is ignored
and the next instruction in sequence is executed.
If this instruction is the last or next-to-last step in the CALCA block program and the accumulator is
positive or zero, the operand is set and then the block program terminates.
When the block is in Manual, the outputs ROxx, BOxx, IOxx, and LOxx are unchanged, but the skip
action still occurs based on the value of the accumulator. sptr(after) = sptr(before).

SST {ROxx, BOxx, IOxx, LOxx, Mxx}

(Set and Skip if True)

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 70/83
6/3/2014 12. CALCA - Advanced Calculator Block

SSTsets the specified operand to 1.0 (if ROxx or Mxx) or 1 (if IOxx or LOxx) or True (if BOxx) and
skips the next program step when the accumulator is non-zero. Otherwise the instruction is ignored and
the next instruction in sequence is executed.
If this instruction is the last or next-to-last step in the CALCA block program and the accumulator is non-
zero, the operand is set and then the block program terminates.
When the block is in Manual, the outputs ROxx, BOxx, IOxx, and LOxx are unchanged, but the skip
action still occurs based on the value of the accumulator. sptr(after) = sptr(before).

SSZ {ROxx, BOxx, IOxx, LOxx, Mxx}

(Set and Skip if Zero)


SSZsets the specified operand to 1.0 (if ROxx or Mxx) or 1 (if IOxx or LOxx) or True (if BOxx) and
skips the next program step when the accumulator value is 0.0. Otherwise the instruction is ignored and
the next instruction in sequence is executed.
If this instruction is the last or next-to-last step in the CALCA block program and the accumulator is zero,
the operand is set and then the block program terminates.
When the block is in Manual, the outputs ROxx, BOxx, IOxx, and LOxx are unchanged, but the skip
action still occurs based on the value of the accumulator. sptr(after) = sptr(before).

STH LOxx

(Store High Order)


STHstores the last stack value into the high order integer of the specified long integer output (LOxx), after
type conversion into an unsigned integer. The output is changed only when the block is in Auto, otherwise
the instruction is skipped. sptr(after) = sptr(before).

STL LOxx

(Store Low Order)


STLstores the last stack value into the low order integer of the specified long integer output (LOxx), after
type conversion into an unsigned integer. The output is changed only when the block is in Auto, otherwise
the instruction is skipped. sptr(after) = sptr(before).

STM Mxx

(Store Memory)
STM Mxxstores the accumulator contents into the memory register specified by the Mxx operand, where
xx is an index from 01 to 24 (or 1 to 24). The accumulator is unaffected. sptr(after) = sptr(before).

STMI Mxx

(Store Memory Indirect)


STMI Mxxstores the accumulator contents into a specified memory register indexed by the contents of the
memory register specified by the Mxx operand, where xx is an index from 01 to 24 (or 1 to 24). The
accumulator is unaffected.
If Mxx does not contain an integer value, the truncated contents are used as the index. Mxx is unaffected.
sptr(after) = sptr(before).
If the specified memory contents are less than 1 or greater than 24, a "10" (index run-time error) is written

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 71/83
6/3/2014 12. CALCA - Advanced Calculator Block

to the PERROR parameter at run-time.

SUB
SUB {RIxx, ROxx, Mxx}
SUB {RIxx, ROxx, Mxx} {n, RIxx, ROxx, Mxx}

(Subtract)
SUBreads the values from the top two stack locations, subtracts the second operand (subtrahend) from
the first operand (minuend), decrements the stack pointer, and writes the difference into the new
accumulator location (the new top of stack location). This overwrites the first operand and isolates the
second operand from any further access. (The later stack value is subtracted from the earlier one.)
sptr(after) = sptr(before) - 1.
SUB RIxxreads the value stored in RIxx (the CALCA's Real Input parameter xx), subtracts it from the
value that it pops from the stack, then pushes the result back onto the stack. SUB ROxxand SUB Mxxdo
the same for the values stored at ROxx and memory location xx, respectively. sptr(after) = sptr(before).
SUB RIxx Mxxreads the values stored in RIxx and Mxx, subtracts the Mxx value from the RIxx value,
and stores the result on the stack. Whenever both operands are specified, the second operand is
subtracted from the first operand. sptr(after) = sptr(before) + 1.
SUB RIxx nreads the value stored in RIxx and a specified integer constant (n), substracts nfrom the
RIxx value, and stores the result on the stack. If the first operand is ROxx or Mxx, the operation is similar.
sptr(after) = sptr(before) + 1.
Example:

M01 = 3.73182
RI01 = 12.3485

12 SUB RI01 M01 Substracts M01 from RI01 and stores the result on
the stack

Accumulator = +8.61668

SWP
SWP {ROxx, BOxx, IOxx, Mxx}

(Swap)
SWPwith no argument causes the contents of the last two positions on the stack to be interchanged. The
stack pointer is not moved.
SWP ROxxswaps the contents of the last position on the stack with that of output ROxx. If the block is
not in Auto, the value of ROxx is copied to the stack, but the stack value is not copied to ROxx.
SWP BOxxswaps the contents of the last position on the stack with that of output BOxx. A True value in
BOxx is converted to 1.0 on the stack, and a False value is converted to 0.0 on the stack. Any non-zero
value on the stack is converted to True in BOxx, and a 0.0 value is converted to False in BOxx. If the
block is not in Auto, the swap is treated as in the ROxx case.
SWP IOxx swaps the contents of the last position on the stack with that of output IOxx. The accumulator
value is clamped between 32,767.0 and -32,768.0 before the swap. If the block is not in Auto, the swap
is treated as in the ROxx case.
SWP Mxxswaps the contents of the last position on the stack with that of memory location Mxx.
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 72/83
6/3/2014 12. CALCA - Advanced Calculator Block

In all cases, sptr(after) = sptr(before).

TAN

(Tangent)
TANreads the value (value of the angle in radians) in the accumulator, computes the tangent of the angle,
and writes the result into the accumulator, overwriting the original contents. sptr(after) = sptr(before).
Example:

Accumulator = +0.7853983 (Pi/4) radians. (Pi/4 radians =


45 degrees)

17 TAN Computes tangent of accumulator.

Accumulator = +1.0000

TIM

(Time Since Midnight)


TIMgets the time, in seconds since midnight, and pushes it onto the stack sptr(after) = sptr(before) + 1.

TRC

(Truncate)
TRCreads the number in the accumulator, truncates the mantissa, or decimal portion, and writes the result
into the accumulator as a floating point value, overwriting the original value. sptr(after) = sptr(before).
Example:

Accumulator = 43.999

17 TRC Truncates the accumulator

Accumulator = 43.0

TSTB
TSTB b

(Test Packed Boolean)


TSTBtests a specified bit in the accumulator. If blank is specified the bit number is expected to be at the
top of the stack and this bit number is removed from the stack before the instruction is executed.
sptr(after) = sptr(before) - 1.
If the bit number is less than 1 or greater than 16 an "11" (bit error run-time error) is written to the
PERROR parameter.
If the argument b is specified it indicates a bit number between 1 and 16 in the accumulator. The stack is
not popped in this case. sptr(after) = sptr(before).
Bit 1 is the most significant bit of the accumulator, and bit 16 the least significant.
If the tested bit is 0, the value False (0.0) replaces the accumulator; if it is 1, the value True (1.0) replaces
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 73/83
6/3/2014 12. CALCA - Advanced Calculator Block

the accumulator.

XOR
XOR c
XOR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}
XOR {BIxx, BOxx, Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx} {BIxx, BOxx,
Ixx, Oxx, Mxx, ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}

(Logical Exclusive Or)


XORperforms a logical "xor" of the contents of the specified operands and stack locations. Exclusive Or is
defined as producing a True output for an odd number of True inputs, a False output for an even number
of True inputs, and a False output if all inputs are False.
If blank is specified, all stack locations are XORed together, and the result is written into the accumulator
(the new top of stack location). This overwrites the first operand and isolates the other operands from any
further access. sptr(after) = stackbottom.
If c is specified, the last c stack locations are XORed together, removed from the stack, and the result
stored in the accumulator. sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
If only one operand is specified, the operand is XORed with the accumulator, and the result replaces the
accumulator. sptr(after) = sptr(before).
If both operands are specified, the operands are XORed together and the result is stored in the
accumulator. sptr(after) = sptr(before) + 1.
If ~ is specified, the operand value is inverted prior to being used.
Before the operand Mxx is used in the calculation, its value is truncated to an integer; if the result is 0 the
operand value is considered False, otherwise it is True.
Example 1:

11 CST Clears the stack.

BI01 = True
BI07 = False
BO03 = True
BI14 = True

12 IN BI01 Puts BI01 into accumulator.

13 IN BI07 Puts BI07 into accumulator. The prior value is pushed down
one stack location.

14 IN BO03 Puts BO03 into accumulator. The prior values are pushed
down one stack location.

15 IN BI14 Puts BI14 into accumulator. The prior values are pushed
down one stack location.

16 XOR Performs the logical XOR function, and stores result into
accumulator, overwriting the value loaded in from BI01. The
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 74/83
6/3/2014 12. CALCA - Advanced Calculator Block

other values are inaccessible.

Accumulator = True

Example 2:

BI04 = False
BO01 = True

12 XOR BI04 BO01 Performs the logical XOR of BI04 and BO01 and
stores the result on the stack.

Accumulator = True

XORX
XORX c

(Packed Logical Exclusive Or)


XORXreads all the values or a specified number (c) of values from the stack, performs a 16-bit bitwise
logical "xor" function on them, and stores the result into the new accumulator location (the new top of
stack). This overwrites the first operand and isolates the other operands from any further access.
Exclusive Or is defined as producing a True output for an odd number of True inputs, a False output for
an even number of True inputs, and a False output if all inputs are False.
For XORX, sptr(after) = stackbottom. For XORXc, sptr(after) = sptr(before) - c + 1.
If c exceeds the current number of stack operands, a "6" (stack underflow run-time error) is written to the
PERROR parameter.
Each operand is truncated from real to 16-bit integer type before it is used in the calculation. The final
result is stored on the stack as a real value.
Example:

II01 = 5 (0000000000000101)
II02 = 7 (0000000000000111)
RI01 = 12.078 (0000000000001100)

13 IN II01 Puts II01 into accumulator. The prior value is pushed down
one stack location.

14 IN II02 Puts II02 into accumulator. The prior values are pushed
down one stack location.

15 IN RI01 Puts RI01 into accumulator. Value is truncated to 12 and


used as 0000000000001100 in the calculation. The prior
values are pushed down one stack location.

16 XORX 3 Performs the packed logical XORX function and stores the
result, 0000000000001110, into the accumulator,
overwriting the loaded in from II01. The other values are
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 75/83
6/3/2014 12. CALCA - Advanced Calculator Block

inaccessible.

Accumulator = 14.0

12.7 Error Conditions


For each instruction, the specified operation code (for example, ADD or RCL) and operands, including the
index ranges of the operands (xx), are validated when the CALCA block is installed or modified by the Control
Configurator. An invalid operation code or operand causes the block to be undefined. An error message
indicating the type of syntax error and the step in error is sent to the Control Configurator and displayed on the
screen.

Two types of errors are detected by the CALCA block:

Syntax errors - those detected when the program is validated, as the block is installed or modified.
Run-time (dynamic) errors - those detected while the program is running. Note that these errors do not
cause the program to halt.

An integer code stored in the output parameter PERROR indicates the type of the first detected error.

The output parameter STERR indicates the number of the program step that experienced the first error.

Displaying the automatically-updated run-time values of PERROR and STERR at the display interface enables
you to monitor these parameters while in the debugging phase of the CALCA program development.

Syntax errors are detected when the CALCA block is installed or reconfigured, but not when the compound is
turned ON, or when the control processor is rebooted. This avoids control cycle overruns that might occur if
validation of complex CALCA blocks were to be done during ordinary block processing. Configuration errors
generate screen messages that you can view and act upon for correction while configuring the block, without
interrupting the configuration session.

A non-zero value for PERROR indicates an error. A negative value generally indicates a syntax error, and a
positive value generally indicates that an error occurred while executing the program (that is, a run-time error).
The only exceptions to this convention are described in the CHN and PRO instructions (q.v.).

The syntax error codes for the PERROR parameter are listed in Table 12-15.

Table 12-15. PERROR Syntax Error Codes

Code Definition

-1 Invalid operation code

-2 Invalid operand type

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 76/83
6/3/2014 12. CALCA - Advanced Calculator Block

-3 Out of range operand index

-4 Invalid go to step number

The run-time error codes for the PERROR parameter are listed in Table 12-16.

Table 12-16. PERROR Run-time Error Codes

Code Definition

1 SQRT error (accumulator < 0)

2 ASIN error (absolute value of accumulator > 1)

3 ACOS error (absolute value of accumulator > 1)

4 DIV error (divide by zero)

5 Stack overflow

6 Stack underflow

7 LOG error (accumulator 0)

8 LN error (accumulator 0)

9 EXP error (base < 0)

10 Index error

11 Bit error

12.8 Programming Concepts


The CALCA block operates in the same way as do most programmable pocket calculators. To specify program
operations, you type in a series of programming steps, which are analogous to "keystrokes" on a calculator. A
programming step can contain zero, one, or two command line arguments which serve to complete the
specification of the action to be performed. Each instruction performs a unique operation over a set of one or
more operands.

The block accepts programs entered through the Reverse Polish Notation (RPN) method, which is more efficient
than other methods of programming. In a simple example, you specify first the operands and then the action to be
performed, which terminates the operation. This convention works especially well with those instructions that
operate on more than two operands.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 77/83
6/3/2014 12. CALCA - Advanced Calculator Block

CALCA block instructions use the following types of operands:

1. Real Variables - Real variable values used in block calculations are either specified as command line
arguments (RIxx, ROxx, or Mxx) or obtained from the stack, where they were stored as the result of
earlier operations.
2. Integer Variables - Parameters IIxx, IOxx, LIxx, and LOxx or the constant command line argument "n."
3. Boolean Variables - Parameters BIxx and BOxx, and pseudo-parameters Ixx and Oxx. Boolean variables
can be optionally inverted before use.
4. Other Constants - In addition to arguments of type "n" used as integer variables in the calculation, constant
command line arguments are also used to represent a timer constant ("t"), a program step number ("s"), a
bit number ("b"), or the number of stack operands to be used ("c").

The opcode and any required arguments for a program step are entered in the STEPxx position of the Control
Configurator screen.

Arithmetic Examples:

Example 1 illustrates an instruction that uses two operands to compute the result. Example 2 shows an instruction
involving more than two operands.

Example 1 - Calculate (RI01 * RI02) and output the result to RO01:

STEP01 MUL RI01 Multiplies Real Input 1 by Real Input 2 and stores the
RI02 results on the stack.

STEP02 OUT RO01 Writes the product of RI01 and RI02 to RO01.

Example 2 - Calculate ((RI01 + RI02 + RI03 + RI04) / 4):

STEP01 CST Clears the stack.

STEP02 IN Places Real Input 1 into accumulator.


RI01

STEP03 IN Places Real Input 2 into accumulator and pushes Real Input 1
RI02 value down one stack location.

STEP04 IN Places Real Input 3 into accumulator and pushes the prior
RI03 values down one stack location.

STEP05 IN Places Real Input 4 into accumulator and pushes the prior
RI04 values down one stack location.

STEP06 AVE Reads all the values from the stack (values for Real Inputs 1
through 4), calculates the mean algebraic value for them, and
stores the result into the accumulator, overwriting the Real
Input 1 value. The other values are inaccessible.
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 78/83
6/3/2014 12. CALCA - Advanced Calculator Block

12.8.1 Execution Sequence

You can consider the sequencing of program steps to be under control of an internal program counter that
indicates the next program step to be processed. Instructions such as GTO that affect program control reference
the step number of the next step to be processed. Transfer of control is permissible only in a forward direction;
looping backwards or to the same step is not allowed. Your program can have up to 50 steps.

The CALCA block supports both conditional and unconditional means of altering the control of program
execution. Conditional transfer of control is dependent on various tests of the accumulator value, or on the block
initialization status.

The following example demonstrates this concept:

Branching Example:

Figure 12-6.
Program Branching Example

Example:

STEP01 IN RI01 Reads Real Input 1.

STEP02 BIP 04 Branches if value is positive.

STEP03 IN RI02 Reads Real Input 2.

STEP04 OUT RO01 Writes selected real input to output.

12.8.2 Arithmetic Chaining

An internal LIFO (last-in, first-out) stack preserves the results of prior, intermediate operations required for
calculation of the final result. You can chain arithmetic operations without using memory registers to store and
https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 79/83
6/3/2014 12. CALCA - Advanced Calculator Block

retrieve data. This approach greatly simplifies program entries and minimizes the number of programming steps.

12.8.2.1 Stack Push Operations

If the first instruction of the chained group has two operands, the operands are processed according to the
operator (add, subtract, multiply, divide, or exponentiation), and the result is stored in the first stack register (top
of stack).

If the next instruction of the group is also an arithmetic instruction with two operands, as in the example of this
section, the next operands are processed according to the operator and the new result is pushed onto the stack.
The result of the previous arithmetic operation is pushed down to the second stack register.

12.8.2.2 Stack Pop Operations

If an arithmetic instruction has no command line arguments, as in the fourth step of the example, both operands
are popped from the stack. If it has one command line argument, as in the seventh step of the example, the first
of the two operands is obtained by popping it from the stack. Any stack pop retrieves the most recently pushed
value from the stack to complete the current operation.

When instructions in the chain operate directly on the accumulator value, the stack pointer is not moved.

The operation sequence for an arithmetic chaining example is shown in Figure 12-7. It shows the stack
operations involved in the equation, working from the innermost parentheses outward. The actual program steps
which implement the procedures are shown in Figure 12-8.

Figure 12-7.
Arithmetic Chaining Example, Operation Sequence

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 80/83
6/3/2014 12. CALCA - Advanced Calculator Block

Programming steps to compute the following equation:

RO01 = RI05 * SQRT ((RI01 * RI02) / ((RI03 * RI04) - 1)

Figure 12-8.
Arithmetic Chaining Example, Program

Figure 12-9.
Arithmetic Chaining Example, Stack Operation

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 81/83
6/3/2014 12. CALCA - Advanced Calculator Block

12.9 Application Example


Figure 12-10.
Application Example

Example:

STEP01 SUB RI01 90 Substracts constant "90.0" from Real Input 1.

STEP02 BIN 5 Branches to Step 5 if difference is negative.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 82/83
6/3/2014 12. CALCA - Advanced Calculator Block

STEP03 IN 90 Reads constant "90.0" and pushes it onto stack.

STEP04 GTO 10 Branches to Step 10.

STEP05 SUB RI01 10 Substracts constant "10.0" from Real Input 1.

STEP06 BIP 10 Branches to Step 10 if difference is positive.

STEP07 IN 10 Reads constant "10.0" and pushes it onto stack.

STEP08 GTO 10 Branches to Step 10.

STEP09 IN RI01 Reads Real Input 1 and pushes it onto stack.

STEP10 OUT RO01 Writes limited measurement value to Real Output 1.

STEP11 END

By configuring the memory registers M01 to M24 with appropriate clamping values, the lack of output clamping
in the CALCA block can be overcome by the use of a program similar to the preceding one.

https://support.ips.invensys.com/Content/Documents/IASeries/foxdoc/FOXDOC/B0193/Ax1/ax_cal.htm?searchid=1401795708079 83/83

You might also like