TRN (Truncate) Ladder Logic Instruction

Definition

The Truncate instruction removes the fractional part of a number stored in a Real data type and places the truncated value in the destination. The Source data remains unchanged.

Example

  •             Source data =              357.06
  •             Destination data =      357      (After truncate)

List of possible arguments

SOURCE can be one of the following data types.

  • CONSTANT
  • REAL

DESTINATION can be any combination of the following data types.

  • SINT
  • INT
  • DINT
  • REAL

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.

TOD (To Binary-Coded Decimal BCD) Ladder Logic Instruction

Definition

The TOD instruction is a ladder logic rung output instruction that takes decimal value from the Source and places the Binary-Coded Decimal equivalent in the Destination.

The instruction is enabled when the preceding logic is true and disabled otherwise. The values can be constants, tags or any combination.

In BCD each byte represents a decimal numeral which is different than displaying decimal numbers in plain binary.

  •        Decimal                BCD
  •             0                      0000
  •             1                      0001
  •             2                      0010
  •             3                      0011
  •             4                      0100
  •             5                      0101
  •             6                      0110
  •             7                      0111
  •             8                      1000
  •             9                      1001

Before conversion:

The decimal number 99 displayed in Binary      0110_0011 (99)

After conversion:

The decimal number 99 displayed in BCD         1001_1001 (99)

The TOD instruction would convert the decimal 99 shown above into a BCD 99. Follow this link for a more detailed explanation of the Binary-Coded Decimal.

List of possible arguments

SOURCE and DESTINATION can be any combination of the following data types.

  • CONSTANT             Can’t be the DESTINATION obviously
  • SINT              
  • INT
  • DINT

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.

 

FRD (From Binary-Coded Decimal BCD) Ladder Logic Instruction

Definition

The FRD instruction is a ladder logic rung output instruction that takes a binary coded decimal value from the Source and places the decimal equivalent in the Destination.

The instruction is enabled when the preceding logic is true and disabled otherwise. The values can be constants, tags or any combination.

In BCD each byte represents a decimal numeral which is different than displaying decimal numbers in plain binary.

  •        Decimal                BCD
  •             0                      0000
  •             1                      0001
  •             2                      0010
  •             3                      0011
  •             4                      0100
  •             5                      0101
  •             6                      0110
  •             7                      0111
  •             8                      1000
  •             9                      1001

Before conversion:

The decimal number 99 displayed in BCD          1001_1001 (99)

After conversion:

The decimal number 99 displayed in Binary      0110_0011 (99)

 

The FRD instruction would convert the BCD 99 shown above into a decimal 99. Follow this link for a more detailed explanation of the Binary-Coded Decimal.

List of possible arguments

SOURCE and DESTINATION can be any combination of the following data types.

  • CONSTANT             Can’t be the DESTINATION obviously
  • SINT              
  • INT
  • DINT

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.