Calca
Calca
B0193AX, Rev J
  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
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
Real Inputs 8 8 8 2
Real Outputs 4 4 4 0
  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
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
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
Non-Configurable Parameters
OUTPUTS
DATA STORES
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
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)
15 ON Block ON BLKSTA.B17
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
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:
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
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.
           * 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
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.
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:
  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.
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
  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.
  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.
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
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
  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.
  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.
  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.
  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.
  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.
  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.)
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
  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.
FF Flip-Flop Logic
  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.
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
  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.
  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.
  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:
  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:
           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.
  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
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
Example 2:
Accumulator = -0.5000
  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
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
Accumulator = +20.0000
Example 2:
Accumulator = -3.00000
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:
                                 BI01 = True
                                 BI07 = False
                                 BO03 = True
                                 BI14 = True
             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
             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.
Accumulator = 0 (False)
Example 2:
                                             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
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.
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
Example 2:
Accumulator = -0.5000
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
Example 2:
Accumulator = -0.5000
  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:
                                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
             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
BIP s
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.
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
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
Accumulator = +0.6734592
Example 2:
Accumulator = +0.1086372
Accumulator = -0.1086372
CLA
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}
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
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 = +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
  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
Example 2:
M02 = 11.2
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
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
           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:
           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.
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.
Accumulator = True
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
             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
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}
  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
Example 2:
M02 = 11.2
M02 = 12.2
  INR
  INR {IIxx, Mxx}
           (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
  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
Accumulator = +6.907755
Example 2:
Accumulator = +0.130570
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
Accumulator = +3.30103
Example 2:
Accumulator = +0.02000
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:
                                RI01 = 12.3485
                                RI02 = 3.73182
                                RI03 = -2.0037
                                RI04 = -0.8369
             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.
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:
                                RI01 = 12.3485
                                RI02 = 3.73182
                                RI03 = -2.0037
                                RI04 = -0.8369
             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
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:
                                RI01 = 12.3485
                                RI02 = 3.73182
                                RI03 = -2.0037
                                RI04 = -0.8369
             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
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.
Accumulator = False
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
                                           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
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}
           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:
                                 BI01 = True
                                 BI07 = False
                                 BO03 = True
                                 BI14 = True
             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
                                 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.
             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}
           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:
                                 BI01 = True
                                 BI07 = False
                                 BO03 = True
                                 BI14 = True
             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
                                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.
             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):
NOTX
Accumulator = 12.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}
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:
                                 BI01 = True
                                 BI07 = False
                                 BO03 = True
                                 BI14 = True
             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
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.
             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:
                                 BI01 = True
                                 BI07 = False
                                 BO03 = True
                                 BI14 = True
             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.
Accumulator = True
Example 2:
                                          BI04 = False
                                          BO01 = True
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
             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.
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
           Figure 12-5.
           Timing Diagram for OSP Example
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
                                        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.
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:
Example:
             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
RANG
  RCL {RIxx, ROxx, IIxx, IOxx, BIxx, BOxx, Ixx, Oxx, Mxx, ~RIxx, ~ROxx, ~IIxx, ~IOxx,
  ~BIxx, ~BOxx, ~Ixx, ~Oxx, ~Mxx}
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
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.
Example 2:
26... Assume that the accumulator has value of -1.68 after Step 26.
           (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.
           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).
SEED
  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
SIEC
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.5000
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 = +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
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}
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).
STH LOxx
STL LOxx
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
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
  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
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 = +1.0000
TIM
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
Accumulator = 43.0
  TSTB
  TSTB b
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}
                                 BI01 = True
                                 BI07 = False
                                 BO03 = True
                                 BI14 = True
             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
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
                                 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.
             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
           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.
Code Definition
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
The run-time error codes for the PERROR parameter are listed in Table 12-16.
Code Definition
5 Stack overflow
6 Stack underflow
8 LN error (accumulator 0)
10 Index error
11 Bit error
  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
      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.
    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.
    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
  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.
Branching Example:
  Figure 12-6.
  Program Branching Example
Example:
  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.
  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.
  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
  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
Example:
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
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