PLC

How to use Different CONVERSION Instruction in Siemens TIA Portal 

This article will show different Conversion Instructions used in the Siemens TIA Portal. The Siemens TIA Portal Conversion blocks are:

S. NOTYPES OF BLOCKSFUNCTION
1CONVERTThe Convert instruction reads the IN, and converts it to the data types specified in the command. The converted value is output at OUT.
2ROUNDThe Round instruction rounds the value at input IN, to the nearest integer. The instruction interprets the value at input IN as a floating-point number and converts it to an integer of data type DINT. The even number is chosen if the input value is exactly between an even and an odd number. The instruction’s output is sent to the OUT.
3CEILThe CEIL Instruction generates the next higher integer from a floating-point number instruction to round the value at input IN, to the next higher integer. The instruction interprets the value at the IN input as a floating-point number and converts it to the next higher integer.  The output value can be greater than or equal to the input value.
4FLOORThe FLOOR Instruction generates the next lowest integer from a floating-point number instruction to round the value at input IN, to the next lowest integer. The instruction interprets the value at the IN input as a floating-point number and converts it to the next lowest integer. The value of the output can be less than or equal to the value of the input.
5TRUNCTRUNC is an instruction that converts a numerical value to an integer from the value at the IN input. The IN value is interpreted as a floating-point number. The instruction only sends the integer part of the floating-point number to the OUT, with no decimal places.
6NORM_XThe NORM_X instruction normalizes and maps the value to a linear scale. The MIN and MAX parameters can be used to define the limits of a value range that is applied to the scale. Depending on the location of the value to be normalized within this value range, the result at the OUT is calculated and stored as a floating-point number. If the value to be normalized equals the value at the MIN input, the OUT value is “0.0”. If the value to be normalized equals the value at input MAX, the value “1.0” is returned by OUT.
7SCALE_XThe Scale instruction scales the input value and maps it to a given value range. The floating-point value at the input is scaled to the value range defined by the MIN and MAX parameters when the “Scale” instruction is executed. The scaling produces an integer, which is stored in the OUT.
S. NoOperationInput/Output AddressInput AddressData type
1CONVERTInputM0.0Please refer to the below explanation for the data type of each block
OutputQ0.0
2ROUNDInputM0.1
OutputQ0.1
3CEILInputM0.2
OutputQ0.2
4FLOORInputM0.3
OutputQ0.3
5TRUNCInputM0.4
OutputQ0.4
6NORM_XInputM0.5
OutputQ0.5
7SCALE_XInputM0.6
OutputQ0.6

The PLC program is created using Siemens TIA Portal V16 software. As stated above, the following Sections explain the various PLC Conversion blocks.

  1. The CONV Instruction is used to convert the data from one type to another type directly or indirectly.
  2. The data type for input and output address can be declared based on the reader requirement.
  3. The CONV instruction has EN, IN, ENO, and OUT signals.
S. NoInstructionMeaning
1ENThis signal enables the CONV instruction.
2IN IN stands for Input data. The data type for IN is shown in the below table.
3ENOIt enables the other instruction connected to CONV instruction
4OUTOUT stands for transferred data from IN. The data type for IN is shown in the below table.
ENOConditionResult
1No errorAll of the COUNT elements were copied successfully.
0The source (IN) or destination (OUT) ranges both exceed the available memory area.Appropriate elements are copied. There are no partial elements copied.
  1. Once the %M0.0 input switch is ON the data from IN is transferred to the OUT.
  2. The OUT can be converted to corresponding data types.
  3. The data type for declaring the IN and OUT is shown below.
ParameterData typeDescription
INSInt, USInt, Int, UInt, DInt, UDInt, Real, LReal, BCD16, BCD32, Bit stringVarious data types of Input and Output
OUTSInt, USInt, Int, UInt, DInt, UDInt, Real, LReal, BCD16, BCD32, Bit string
  1. The ROUND instruction is used to round the given data to the next integer. 
  2. The data type for input and output data type can be declared based on the reader’s requirement.
  3. The ROUND instruction has EN, IN, ENO, and OUT signals.
S. NoInstructionMeaning
1ENThis signal enables the ROUND instruction.
2IN IN stands for Input signal, which is used to assign input data. The data type for IN is shown in the table below.
3ENOIt enables the other instruction connected to the ROUND instruction.
4OUTOUT refers to data that has been transferred from IN. The IN data type is shown in the table below.
  1. Once the %M0.1 input switch is ON the data from IN is converted to the OUT.
  2. The data type for declaring the IN and OUT is shown below
ParameterData typeDescription
INLReal, RealVarious data types of Input and Output
OUTSInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
  1. The CEIL instruction is used to round the next highest integer. 
  2. The data type for input and output data type can be declared based on the reader’s requirement.
  3. The CEIL instruction has EN, IN, ENO, and OUT signals.
S. NoInstructionMeaning
1ENThis signal enables the CEIL instruction.
2IN IN stands for Input signal, which is used to assign input data. The data type for IN is shown in the table below.
3ENOIt enables the other instruction connected to the CEIL instruction.
4OUTOUT refers to data that has been transferred from IN. The IN data type is shown in the table below.
  1. Once the %M0.2 input switch is ON the data from IN is converted to the OUT.
  2. The data type for declaring the IN and OUT is shown below
ParameterData typeDescription
INLReal, RealVarious data types of Input and Output
OUTSInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
  1. The FLOOR instruction is used to round the next LOWEST integer. 
  2. The data type for input and output data type can be declared based on the reader’s requirement.
  3. The FLOOR instruction has EN, IN, ENO, and OUT signals.
S. NoInstructionMeaning
1ENThis signal enables the FLOOR instruction.
2IN IN stands for Input signal, which is used to assign input data. The data type for IN is shown in the table below.
3ENOIt enables the other instruction connected to the FLOOR instruction.
4OUTOUT refers to data that has been transferred from IN. The IN data type is shown in the table below.
  1. Once the %M0.3 input switch is ON the data from IN is converted to the OUT.
  2. The data type for declaring the IN and OUT is shown below
ParameterData typeDescription
INLReal, RealSource start address
OUTSInt, Int, DInt, USInt, UInt, UDInt, Real, LRealDestination start address
  1. The TRUNC instruction is used to round the next LOWEST integer. It truncates all the values after the decimal. Similar, to Floor Instruction.
  2. The data type for input and output data type can be declared based on the reader’s requirement.
  3. The TRUNC instruction has EN, IN, ENO, and OUT signals.
S. NoInstructionMeaning
1ENThis signal enables the TRUNC instruction.
2IN IN stands for Input signal, which is used to assign input data. The data type for IN is shown in the table below.
3ENOIt enables the other instruction connected to the TRUNC instruction.
4OUTOUT refers to data that has been transferred from IN. The IN data type is shown in the table below.
  1. Once the %M0.4 input switch is ON the data from IN is converted to the OUT.
  2. The data type for declaring the IN and OUT is shown below
ParameterData typeDescription
INLReal, RealVarious data types of Input and Output
OUTSInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
  1. The NORM_X instruction normalizes the value between the min to max values.
  2. The input value is mapped between min to max and displayed at the output.
  3. The Formula to determine the OUT value of NORM_X instruction is
  4. OUT = (VALUE – MIN) / (MAX – MIN)
  5. The NORM_X instruction has EN, ENO, MIN, VALUE, MAX, and OUT signals.
S. NoInstructionMeaning
1ENThis signal enables the NORM_X instruction.
2MINMINsignal is used to assign minimum input data that OUT can be calculated. The MIN value is a fixed value.
3VALUEVALUE is variable input, using the above formula the OUT-value changes proportionately.
4MAXMAXsignal is used to assign maximum input data that OUT can be calculated. The MAX value is a fixed value.
5ENOIt enables the other instruction connected to the NORM_X instruction.
6OUTOUT refers to data that has been calculated from IN. The IN data type is shown in the table below.
  1. Once the %M0.5 input switch is ON the data from VALUE is calculated and displayed to the OUT.
  2. The data type for declaring the MIN, VALUE, MAXM, and OUT is shown below
ParameterData typeDescription
MININt, SInt, DInt,  UDInt, USInt, UInt, Real, LRealVarious data types of Input and Output
VALUE
MAX
OUTReal, LReal
  1. The SCALE_X instruction scales the value between the min to max values.
  2. The input value is mapped between min to max and displayed at the output.
  3. The Formula to determine the OUT value of NORM_X instruction is

OUT = [VALUE ∗ (MAX – MIN)] + MIN

  1. The SCALE_X instruction has EN, ENO, MIN, VALUE, MAX, and OUT signals.
S. NoInstructionMeaning
1ENThis signal enables the SCALE_X instruction.
2MINMINsignal is used to assign minimum input data that OUT can be calculated. The MIN value is a fixed value.
3VALUEVALUE is variable input, using the above formula the OUT-value changes proportionately.
4MAXMAXsignal is used to assign maximum input data that OUT can be calculated. The MAX value is a fixed value.
5ENOIt enables the other instruction connected to the SCALE_X instruction.
6OUTOUT refers to data that has been calculated from IN. The IN data type is shown in the table below.
  1. Once the %M0.6 input switch is ON the data from VALUE is calculated and displayed to the OUT.
  2. The data type for declaring the MIN, VALUE, MAXM, and OUT is shown below
ParameterData typeDescription
MINReal, LRealVarious data types of Input and Output
VALUE
MAX
OUTReal, LReal INt, SInt, DInt,  UDInt, USInt, UInt, 

The procedures for programming ladder logic on the SIEMENS TIA portal are listed below. (Simulation).

Note: Please see the preceding article for a detailed explanation of how to program ladder logic using the Siemens TIA Portal.

  1. The simulation result of the CONV block is shown below
  2. When the input switch is ON the data stored in the input is transferred to the output
  1. The input data is stored in the IN of the CONV block. The input and output address of the CONV Instruction can be declared here. The data declared to each instruction is single data (the data type can be defined by the reader). 
  2. In the CONV block corresponding data type is reflected in the output. This way the CONV instruction can be executed and the result can be viewed.  The CONV block after the final execution is shown below.
  1. The input and output data type for the CONV instruction is customizable. The reader can change any type of data on the input and output side. (Please refer to the above table for the input and output type). Before declaring the address on the input and output side, the reader should ensure what type of data can be declared on the input and output side.
  2. In the above example, Real is the input data type therefore the address declared on the IN is %MD, and OUT is Int data type the address declared as %MW.
  1. The simulation result of the ROUND Instruction is shown below
  1. When the input switch is ON the data in the input is transferred to the output to the next integer.
  2. The input data is stored in the ROUND Instruction. The input and output address of the ROUNDInstruction can be declared in the instruction. The data declared for each instruction is based on reader input. The data is declared as shown below
  3. The ROUND instruction can be executed and the result can be viewed.  The ROUNDblock after the final execution is shown below
  1. The simulation result of the CEIL block is shown below
  2. When the input switch is ON the data stored in the input is rounded off to the next HIGHEST integer and transferred to the output.
  1. The input and output address can be declared by the reader based on the data type on input and output.
  2. The CEIL instruction can be executed and the result can be viewed.  The CEIL block after the final execution is shown below
  1. The reader can see the above two images, the output of both cases is the same. This is due to the instruction CEIL, which always gives the next highest integer (i.e. the decimal value greater than 0.5 or less than 0.5).
  1. The simulation result of the FLOOR block is shown below
  2. When the input switch is ON the data stored in the input is rounded off to the next LOWEST integer and transferred to the output.
  1. The input and output address can be declared by the reader based on the data type on input and output.
  2. The FLOOR instruction can be executed and the result can be viewed.  The FLOOR block after the final execution is shown below
  1. The reader can see the above two images, the output of both cases is the same. This is due to the instruction FLOOR, which always gives the next LOWEST integer (i.e. the decimal value greater than 0.5 or less than 0
  1. The simulation result of the TRUNC block is shown below.
  2. When the input switch is ON the data stored in the input is rounded off to the next LOWEST integer and transferred to the output. The reader can change the data type on the input and output side and check for the TRUNC instruction.
  1. The input and output address can be declared by the reader based on the data type on input and output.
  2. The TRUNC instruction can be executed and the result can be viewed.  The TRUNC block after the final execution is shown below.
  1. The reader can see the above two images, the output of both cases is the same. This is due to the instruction TRUNC, which always gives the next LOWEST integer (i.e. the decimal value greater than 0.5 or less than 0.5).

NORM_X

  1. The simulation result of the NORM_X block is shown below.
  1. The MIN, MAX, and VALUE are the input of the NORM_X instruction.  The MIN & MAX are the fixed values, the data can be set by the reader based on the requirement of the output.
  2. The VALUE is the variable quantity, it can be changed by the reader during the run time (usually the VALUE will be sensor output).
  3. The input and output address can be declared by the reader based on the data type on input and output.
  4. The NORM_X instruction can be executed and the result can be viewed.  The NORM_X block after the final execution is shown below.

OUT = (VALUE – MIN) / (MAX-MIN)

Example: MIN = 10; MAX = 30; VALUE = 20

OUT = (20-10)/ (30-10) = 0.5

  1. The simulation result of the SCALE_X block is shown below.
  1. The MIN, MAX, and VALUE are the input of the SCALE_X instruction.  The MIN & MAX are the fixed values, the data can be set by the reader based on the requirement of the output.
  2. The VALUE is the variable quantity, it can be changed by the reader during the run time (usually the VALUE will be sensor output).
  3. The input and output address can be declared by the reader based on the data type on input and output.
  4. The SCALE_X instruction can be executed and the result can be viewed.  The SCALE_X block after the final execution is shown below.

OUT = [VALUE ∗ (MAX-MIN)] + MIN

Example: MIN = 5; MAX = 25; VALUE = 0.5

OUT = [0.5 * (25-5)] + 5 = 15

The above exercise will help readers understand how different CONVERSION Instruction work.

Sundareswaran Iyalunaidu

With over 24 years of dedicated experience, I am a seasoned professional specializing in the commissioning, maintenance, and installation of Electrical, Instrumentation and Control systems. My expertise extends across a spectrum of industries, including Power stations, Oil and Gas, Aluminium, Utilities, Steel and Continuous process industries. Tweet me @sundareshinfohe

Related Articles

Back to top button

Adblock Detected

We Noticed You're Using an Ad Blocker Hi there! We understand that ads can be annoying, but they help support our website and allow us to continue providing you with high-quality content. Please consider whitelisting our site or disabling your ad blocker while you visit. Your support means a lot to us! Thank you for understanding!