Introduction

Add to My manuals
704 Pages

advertisement

Introduction | Manualzz

Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS)

For relay ladder instructions, bold data types indicate optimal data types. An instruction executes faster and requires less memory if all the operands of the instruction use the same optimal data type, typically DINT or REAL.

Compute (CPT)

The CPT instruction performs the arithmetic operations you define in the expression.

Operands:

Relay Ladder

Operand Type

Destination SINT

INT

DINT

REAL

Format:

tag

Description

tag to store the result

Expression SINT

INT

DINT

REAL

immediate tag an expression consisting of tags and/or immediate values separated by operators

A SINT or INT tag converts to a DINT value by sign-extension.

Structured Text

Structured text does not have a CPT instruction, but you can achieve the same results using an assignment and expression. destination := numeric_expresion;

See Appendix C, Structured Text Programming for information on the syntax of assignments and expressions within structured text.

Description:

The CPT instruction performs the arithmetic operations you define in the expression. When enabled, the CPT instruction evaluates the expression and places the result in the Destination.

The execution of a CPT instruction is slightly slower and uses more memory than the execution of the other compute/math instructions. The advantage of the CPT instruction is that it allows you to enter complex expressions in one instruction.

TIP

There is no limit to the length of an expression.

Arithmetic Status Flags:

Arithmetic status flags are affected.

Fault Conditions:

none

248

Publication 1756-RM003K-EN-P - July 2008

Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 7

Execution:

Condition

prescan rung-condition-in is false rung-condition-in is true postscan

Relay Ladder Action

The rung-condition-out is set to false.

The rung-condition-out is set to false.

The instruction evaluates the Expression and places the result in the Destination.

The rung-condition-out is set to true.

The rung-condition-out is set to false.

Example 1:

When enabled, the CPT instruction evaluates value_1 multiplied by 5 and divides that result by the result of value_2 divided by 7 and places the final result in result_1.

Example 2:

When enabled, the CPT instruction truncates float_value_1 and float_value_2, raises the truncated float_value_2 to the power of two and divides the truncated

float_value_1 by that result, and stores the remainder after the division in

float_value_result_cpt.

Publication 1756-RM003K-EN-P - July 2008

Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

249

advertisement

Related manuals

advertisement

Table of contents