Instrument Calculation

 

Instrument Calculation Menu

 

The Instrument Calculation menu allows programming code-like lines to be executed at a variable time interval per step.  Note – It is important to contact Super Systems at 513-772-0060 before creating or modifying any Instrument Calculation customization.

 

General Description

The Instrument Calculation allows for fifty (50) lines of program and fifty (50) program variables.  Program variables allow for storage on intermediate results of calculations.

A program variable is designated by a v followed by a number from 0 to the number of variables – 1.

 

A Lower or Upper case “V” is valid, as well as leading zeroes.  The following are all considered the same variable: V3, v3, v0003.

 

The 9220’s Modbus registers can be used as input variables in the equations without restriction.  To protect the instrument, Modbus registers are restricted as output registers.

 

Modbus registers are designated by an upper or lower case “M” followed by a number.

 

Note – The standard Modbus routine is called to retrieve the Modbus variable, therefore a 0x8000 (-32768) will be returned for an invalid register.

Note – Modbus registers are stored with integer values, so adjustments will need to be made for decimal values.

 

If the instrument can have external analog input boards, or the instrument is a Video Recorder or DAQ, these inputs can be accessed directly as A1 through A40.  By using the “A” designation, the Modbus register number is not needed and the variable is scaled to the correct value (decimals included) based on the input type specified.

 

In a Video Recorder, the Client instrument data slots can be defined as variables D1 through D32.  D31 and D32 are extra slots and have no restrictions as output variables.  D1 through D30 are shared with the first ten (10) Client instruments in groups of three (3) – PV, SP, PO – and caution should be used when assigning as outputs.

 

A line in the program of the instrument calculation must start with a variable or a keyword.

 

Variables must be followed by an equal sign (=) and then an expression.  The expression can be a simple assignment (V1 = 3) or a variable operation variable as described below (V1 = M225 * 0.1).

 

Keywords MUST be entered in capital letters only.

 

The list of valid keywords is: IF, ELSE, ENDIF, QUE, RLY, and END.

 

“IF” must be followed by an expression which is a variable, relationship operator, then variable.

 

The list of valid relationship operators is: > (Greater Than), < (Less Than). = (Equals), >= (Greater Than or Equal To), <= (Less Than or Equal To), != (Not Equal To), and == (Equal To). Note – The “=” and “==” relationship operators are identical.

 

The list of valid bitwise operators is: & (AND), | (OR), ^ (XOR), << (Left Shift), and >> (Right Shift).

 

The result of the “IF” relationship test determines if the lines following the “IF” statement will be executed or not.

 

The “ELSE” and “ENDIF” must be on a line by themselves.  “ELSE” will toggle the program based on the result of the “IF” test.  “ENDIF” will close out the “IF”.

 

Example:

IF V1 >= 30

V3 = V2 * 1.5

ELSE

V3 = 5

ENDIF

 

In this example, if the value in V1 is greater than or equal to 30, then the value of V3 will be the value of V2 multiplied by 1.5.  If the value in V1 is less than 30, the value of V3 will be 5.

 

EVERY “IF” must have a closing “ENDIF”.  However, the “ELSE” is optional.

 

The “QUE” is used to send data to a Client instrument and must have three (3) variables separated by spaces.  The first is the Client instrument number, the second is the register number, and the third is the data to send.

 

Example:

QUE 3 1129 V1

 

This example will send the value of V1 to register 1129 on instrument 3.

 

The “RLY” is used to control a relay if the relay assignment is 999.  The “RLY” must be followed by a variable which is the relay number (18) and a relationship expression.

 

Example:

RLY 5 M554 < 2

 

This example would turn Relay 5 ON if the communication status for instrument 5 was bad.

 

The “END” keyword will stop the lines from running, and start over from line 1.

 

There are a few functions that are available as well.  The list of valid functions is: FSIN (Sine), FCOS (Cosine), FEXP (Exponent), FLOG (Logarithm), FLN (Natural Logarithm), FSQRT (Square Root), FABS (Absolute Value), and FPOW (Power).  The Sine and Cosine functions need to have the parameter in radians.  A function must be in all caps and begin with an “F” and have a pair of parenthesis.  An undefined function returns the value of the expression in the parenthesis. 

Note – A pair of parenthesis by themselves is considered an undefined function.

 

The instrument calculation has limited parsing ability.  This is kept to variables, operation, variable – i.e. V1 = 12.25 * V2.  Another example is M128 = V1/100. 

 

A negative sign (-) in front of the number is considered part of the number – i.e. V1 = -2.55 + V2.

 

A variable to the parser is one of the following: a program variable (Vxx), a Modbus register (Mxxx), a number, or a function.

 

Example:

V1 = (V2 * 1.35) + (V3 * V4)

 

This example will multiple V2 by 1.35 and multiply V3 and V4 together, and add those two results and store that value in V1.

 

The maximum length of a program line is thirty-one (31) characters.

 

The following are the valid mathematical operators: + (Addition), - (Subtraction), * (Multiplication), / (Division), and % (Modulo Divide – integer only).

 

The difference between Division and Modulo Division is that Modulo will always return an integer value.

 

Example:

11 / 4 = 2.75

11 % 4 = 2 (The .75 will not be returned)

 

 

Calculation Time (0 = Disabled)

This is the calculation time for the calculations.  This will specify the delay between executing a line.  Each line has the same delay between them, even if they are blank.  A value of zero (0) will keep the calculations from being performed. The range is 010000.

 

Configure Instrument Calculations

This option will display the screen where the calculations can be entered.  There are two ways to enter the calculations, through the Instrument Calculation screen, or with the Button View screen.

Instrument Calculation Screen + Button View

The Button View screen will allow the user to use buttons to enter the program lines.  Only the buttons that can currently be used will be enabled.  On the Instrument Calculation screen, prompts will show up to help the user enter the program lines correctly.