You get a bonus - 1 coin for daily activity. Now you have 1 coin

floating point operations on the contact plan

Lecture



Overview

You can use floating-point arithmetic commands to perform the following operations on two 32-bit floating-point IEEE numbers:

  • addition
  • subtraction
  • multiplication
  • division

IEEE 32-bit floating point numbers are of type REAL. Using floating point arithmetic, you can perform the following operations with a single 32 – bit IEEE floating point number:

  • square (SQR) and square root (SQRT) floating point numbers
  • formation of the natural logarithm (LN) of a floating point number
  • formation of exponential value (EXP) with base e (= 2.71828 ...)
  • the formation of the following trigonometric functions of the angle, represented as a 32-bit IEEE floating point number:
    • the formation of sine (SIN) floating-point numbers and the formation of arcsine (ASIN) floating-point numbers
    • cosine formation (COS) floating point numbers and arc cosine (ACOS) floating point numbers
    • the formation of tangent (TAN) floating-point numbers and the formation of arctangent (ATAN) floating-point numbers

Adding floating point numbers

The state of signal 1 at the enable input (EN) activates the command Addition of floating-point numbers. This command adds inputs IN1 and IN2. The result can be queried at the output OUT. If the result is outside the acceptable range for floating-point numbers (overflow or underflow), then the OV and OS bits of the status word are 1, and ENO is 0. For information on evaluating these indicators in the status word, see section 7.6.

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN1 REAL I, Q, M, D, L First term
IN2 REAL I, Q, M, D, L Second term
Out REAL I, Q, M, D, L Amount

Example and bits of the word of the state of addition of floating-point numbers

  floating point operations on the contact plan The state of signal 1 at input I 0.0 activates the ADD_R block. The result of the addition of MD0 + MD4 is placed in the double word of memory MD10. If the result falls outside the permissible range for real numbers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x x one x x
Example and bits of the word of the state of addition of floating-point numbers

Floating point subtraction

This command is identical to the previous one, the difference is that the command subtracts the input IN2 from IN1. Information on evaluating these indicators in the status word can be found in section 7.6.

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN1 REAL I, Q, M, D, L Minuend
IN2 REAL I, Q, M, D, L Subtrahend
Out REAL I, Q, M, D, L Difference

Example and bits of the state word of the subtraction of floating-point numbers

  floating point operations on the contact plan The state of signal 1 at input I 0.0 activates the SUB_R block. The result of the subtraction MD0 - MD4 is placed in the memory double word MD10. If the result falls outside the permissible range for real numbers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x x one x x
Example and bits of the state word of the subtraction of floating-point numbers

Floating point multiplication

The multiply floating-point command multiplies the input IN1 by IN2. In all other respects, the command is identical to the previous one. Information on evaluating these indicators in the status word can be found in section 7.6.

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN1 REAL I, Q, M, D, L First factor
IN2 REAL I, Q, M, D, L Second factor
Out REAL I, Q, M, D, L Composition

Example and bits of the floating point multiplication state word

  floating point operations on the contact plan The state of signal 1 at input I 0.0 activates the MUL_R block. The result of the multiplication MD0 x MD4 is placed in the memory double word MD10. If the result is outside the acceptable range for integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x x one x x
Example and bits of the floating point multiplication state word

Floating point division

This command divides IN1 input to IN2. In all other respects, the command is identical to the previous one. Information on evaluating these indicators in the status word can be found in section 7.6.

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN1 REAL I, Q, M, D, L Dividend
IN2 REAL I, Q, M, D, L Divider
Out REAL I, Q, M, D, L Private

Example and bits of the floating point division state word

  floating point operations on the contact plan The state of signal 1 at input I 0.0 activates the DIV_R block. The result of dividing MD0 by MD4 is placed in the double word of memory MD10. If the result falls outside the permissible range for real numbers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x x one x x
Example and bits of the floating point division state word

Estimation of state word bits after performing floating point operations

Mathematical operations affect the following bits of the status word:

  • CC 1 and CC 0
  • Ov
  • OS

A dash (-) in the bit column of the table means that the corresponding bit is not affected by the result of the operation.

The state signal of the status word bits for floating point results that are within the allowable range of values

The valid range for the result of the operation on floating-point numbers (32 bits) Status word bits
CC1 CC0 Ov OS
+0, -0 (zero) 0 0 0 -
–3.402823E + 38 <result <–1.175494E – 38
(a negative number)
0 one 0 -
+ 1.175494E-38 <result <3.402823E + 38
(positive number)
one 0 0 -

The status signal of the status word bits for floating point results that are outside the allowable range of values

Invalid range for floating-point operation result (32 bits) Status word bits
CC1 CC0 Ov OS
–1.175494E – 38 <result <–1.401298E – 45
(negative number) loss of significance
0 0 one one
+ 1.401298E – 45 <result <+ 1.175494E – 38
(positive number) loss of significance
0 0 one one
Result <–3.402823E + 38
(negative number) overflow
0 one one one
result> 3.402823E + 38
(positive number) overflow
one 0 one one
Result <–3.402823E + 38
or result> + 3.402823E + 38
not a floating point number
one one one one

Formation of the absolute value of a floating point number

Using the command Generate absolute value of a floating-point number, you can get the absolute value of a floating-point number.

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Input: Real Number
Out REAL I, Q, M, D, L Output: the absolute value of a real number

Example and bits of the floating-point absolute value state word

  floating point operations on the contact plan If I 0.0 = 1, then the absolute value of MD8 is output to MD12.
MD8 = +6.234 x 10-3 results in MD12 = 6.234 x 10-3. Output Q 4.0 is "1" if no conversion is performed (ENO = EN = 0).
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x - - - - 0 x x one
Example and bits of the floating-point absolute value state word

Formation of a square and / or square root of a floating point number

With the help of the Square command for a floating-point number, you can square a floating-point number. Using the command Square root of a floating point number, you can extract the square root of a floating point number. This command outputs a positive result if the operand is greater than “0”. The only exception: the square root of - 0 is –0. Information on evaluating these indicators in the status word can be found in section 7.6.

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Square number

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Square root number

Example and bits of the word of the formation of a square or square root

  floating point operations on the contact plan The SQRT block is activated when I 0.0 = 1. The result of the SQRT (MD0) is stored in the memory double word MD10. If MD0 <0, or if the result is outside the acceptable range for floating-point numbers, or the state of the signal at input I 0.0 = 0, then the output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x 0 x x one
Example and bits of the word of the formation of a square or square root

Formation of the natural logarithm of a floating point number

With this command you can form the natural logarithm of a floating point number.

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L The natural logarithm of a number

Example and bits of the state word of the formation of the natural logarithm

  floating point operations on the contact plan The LN block is activated when I 0.0 = 1. The result of LN (MD0) is stored in the memory double word MD10. If MD0 <0, or if the result is out of range for floating-point numbers, or if the state output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x 0 x x one
Example and bits of the state word of the formation of the natural logarithm

The formation of the exponential value of a floating-point number

Using the Formation of the exponential value of a floating-point number command, you can form the exponential value of a floating-point number with base e (= 2.71828 ...).

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Exponent number

Example and bits of the word of the state of formation of an exponential value

  floating point operations on the contact plan The EXP block is activated when I 0.0 = 1. EXP (MD0) is stored in the memory double word MD10. If MD0 <0, or if the result is outside the acceptable range for floating-point numbers, or if the signal state I 0.0 = 0, the output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x 0 x x one
Example and bits of the floating point state exponential value word

The formation of trigonometric functions of angles in the form of floating point numbers

With the following commands you can form trigonometric functions of angles represented as floating point numbers (32 bits, IEEE).

Team Explanation
Sin To form the sine of the angle given in radians.
ASIN Form arcsine floating point numbers. The result is an angle given in radians. This value is in the following range:
-¶ / 2 = <arcsine = <+ ¶ / 2, where ¶ = 3.14 ...
Cos To form the cosine of a floating-point number representing the angle given in radians.
ACOS Form arc cosine floating point numbers. The result is an angle given in radians. This value is in the following range:
0 = <arc cosine = <+ ¶, where ¶ = 3.14 ...
TAN To form the tangent of a floating-point number representing the angle specified in radians.
ATAN To form the arctangent of a floating point number. The result is an angle given in radians. This value is in the following range:
-¶ / 2 = <arctangent = <+ ¶ / 2, where¶ = 3.14 ...
LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Sine number

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Arcsine numbers

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Cosine number

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Arccosine number

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Tangent of number

LAD block Options Data type Memory area Description
  floating point operations on the contact plan En Bool I, Q, M, D, L Permissive entry
ENO Bool I, Q, M, D, L Permissive exit
IN REAL I, Q, M, D, L Number
Out REAL I, Q, M, D, L Arctangent of number

Example and bits of the word of the state of trigonometric functions

  floating point operations on the contact plan The SIN block is activated when I 0.0 = 1. The result of the SIN (MD0) is stored in the Dual Word of the MD10 memory. If the result is outside the allowable range for floating-point numbers or I 0.0 = 0, then the output Q 4.0 is set.
Status word bits
BR CC 1 CC 0 Ov OS OR Sta Rlo FC
Record x x x x x 0 x x one
Example and bits of the word of the state of trigonometric functions

Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Contact Programming / LAD

Terms: Contact Programming / LAD