PLCs

Math Functions for PLCs 325

This class overviews how to program mathematical functions in PLCs. PLCs often need to perform calculations with numbers provided by input devices. Input and output numbers for math functions must each be stored as data files. Data files for numbers must be tagged with the correct data type, and the data type for the inputs of a math function must be the same. Common math functions include add, subtract, multiply, and divide. Common comparison functions include equal, not equal, greater than, and less than. PLC software also typically includes several additional math functions that perform more advanced operations.

After taking this class, learners will understand how numbers are stored in PLCs, be familiar with common PLC data types, and know how math functions are programmed in ladder logic. They will also be familiar with common math and comparison functions used in PLCs. Understanding math functions in PLCs is essential for creating and troubleshooting PLC programs.

  • Difficulty Advanced

  • Format Online

  • Number of Lessons 13

  • Language English

Take the Next Step in Workforce Training

Talk with a Tooling U-SME specialist about class options and pricing.

1.866.706.8665

Contact Form

Course Outline
  • Math Functions for PLCs
  • File Addresses
  • Number Storage
  • Data Types: Integers
  • Data Types: Floating-Point Numbers
  • Converting Data Types
  • Review: Numbers and Data Types
  • Add and Subtract
  • Multiply and Divide
  • Equal and Not Equal
  • Greater Than and Less Than
  • Additional Math Functions
  • Review: Math Functions
Objectives
  • Describe mathematical functions in PLC programs.
  • Describe how to select file addresses in PLCs.
  • Describe how PLCs store numbers.
  • Distinguish between integer data types for PLCs.
  • Describe floating-point data types for PLCs.
  • Describe how data types are converted.
  • Describe the add and subtract functions.
  • Describe the multiply and divide functions.
  • Describe the equal and not equal functions.
  • Describe greater and less than comparison functions.
  • Describe additional common math functions.
Glossary
Vocabulary Term
Definition

Add

ADD. A set of instructions that tells a PLC to add two input numbers. Add functions must have an output data type with a large enough range.

Address

The unique location of a data file in a PLC’s memory. Addresses for PLC data files may be user-created names or predefined memory register codes.

Base 10

A notation that uses combinations of the numbers 0 to 9 to represent all numerical quantities. In the base 10 system, or decimal system, each successive place value column from right to left is 10 times greater than the previous place value column.

Billion

A number equal to one thousand million. One billion can be written as 1,000,000,000.

Binary digits

The smallest unit of information on a computer. Binary digits, also known as bits, consist of 1s and 0s.

Bits

The smallest unit of information on a computer. Bits, also known as binary digits, consist of 1s and 0s.

Boolean

BOOL. A single-bit data type that uses 1 for true and 0 for false. Boolean data is the output data type for comparison functions.

byte

A group of eight binary bits. The signed and unsigned short integer data types use one byte of storage each.

Calculate

A specialized function block that allows users to enter a mathematical expression. Calculate functions may be called compute functions depending on the PLC software.

Compute

A specialized function block that allows users to enter a mathematical expression. Compute functions may be called calculate functions depending on the PLC software.

Constants

A value or number that does not change. Constants are used in PLC math functions for numbers that are always the same, such as the value of pi.

Convert

A set of instructions that tells a PLC to change the data type of a stored number. Convert functions may create inaccurate results in some cases.

Conveyor belts

A moveable belt used in industry to transport materials over a distance. Conveyor belt motors can be controlled by PLCs.

Cosine

COS. A set of instructions that tells a PLC to find the cosine of an angle equal to the input number. The cosine of a right triangle is the ratio of the length of the side adjacent to the angle and the hypotenuse.

Counter

A set of program instructions that allows a PLC to keep a tally of actions or events in a process. Counter instructions can be programmed to count up or down to a preset value.

Count-up

CTU. A counter instruction that increases the current count by one each time the input logic transitions from false to true on a rung. Count-up counters typically start counting from zero until the accumulated value matches the preset value.

CTU

Count-up. A counter instruction that increases the current count by one each time the input logic transitions from false to true on a rung. CTU functions typically start counting from zero until the accumulated value matches the preset value.

Data files

The area of a PLC’s memory that contains the status of input devices, output devices, and other program instructions. Data files store information as a series of binary digits.

Data type

A definition that specifies both the bit size of a data file and how the data is interpreted by the PLC. Data types for numbers include INT, DINT, and REAL.

Decimal points

The period between whole numbers and parts of whole numbers. The higher the number of places to the right of the decimal point, the more precise the value.

Decimal system

A notation that uses combinations of the numbers 0 to 9 to represent all numerical quantities. In the decimal system, or base 10 system, each successive place value column from right to left is 10 times greater than the previous place value column.

DINT

Signed double integer. A 32-bit data type that can store positive and negative whole numbers. DINT data has a range of under -2 billion to over 2 billion.

Divide

DIV. A set of instructions that tells a PLC to divide one input number by another. Divide functions can only produce fractions of numbers if the output data type is floating-point.

EQU

Equal. A set of instructions that tells a PLC to determine whether two input numbers are equal. EQU functions have a true output if the inputs are equal and a false output if they are not equal.

Equal

EQU. A set of instructions that tells a PLC to determine whether two input numbers are equal. Equal functions have a true output if the inputs are equal and a false output if they are not equal.

Exponent

EXPT. A set of instructions that tells a PLC to raise one input number to the power of the other input number. Exponent functions must have an output data type with a large enough range.

Exponential

A quantity that increases or decreases at a rate proportional to its current size. Exponential functions are commonly used in electrical, nuclear, chemical, and financial applications.

Expression

A mathematical calculation or formula that includes numbers and/or variables using mathematical operations. In some PLC software, expressions can be entered directly into function blocks.

Floating-point

A method for efficiently storing fractions of numbers as a series of bits. Floating-point data types can store numbers with significant digits after a decimal point.

Fractions

A number that indicates parts of a whole number. Fractions can be written as a decimal point followed by a series of numbers.

Function blocks

A box-shaped element that contains program instructions. Function blocks contain instructions for processing input data and generating output data.

Greater than

GTR. A set of instructions that tells a PLC to determine whether one input number is greater than the other. Greater than functions have an output of true if the first input number is larger than the second input number.

Greater than or equal

GEQ. A set of instructions that tells a PLC to determine whether one input number is greater than or equal to the other. Greater than or equal functions have an output of true if the first input number is larger than or equal to the second input number.

Hexadecimal system

A notation that uses combinations of the numbers 0 to 9 and letters A to F to represent all numerical quantities. In the hexadecimal system, each successive place value column from right to left is 16 times greater than the previous place value column.

IEC 61131-3

A standard of the International Electrotechnical Commission that defines software for PLCs. IEC 61131-3 describes standardized programming languages, data types, and functions.

Input devices

A type of field device connected to a PLC that responds to a condition and sends an electrical signal to the input module. Input devices include components such as limit switches, sensors, and pushbuttons.

INT

Signed integer. A 16-bit data type that can store positive and negative whole numbers. INT data has a range of -32,768 to 32,767.

Integer

A whole number or its negative equivalent. Integer data types can store whole numbers but not fractions of numbers.

International Electrotechnical Commission

IEC. An international organization that prepares and publishes all standards for electrical, electronic, and related technologies. The International Electrotechnical Commission develops standards for PLC hardware and software.

Ladder logic

A widely used graphical programming language for PLCs. Ladder logic uses simple symbols to indicate the status of input and output devices.

Lathes

A machine tool commonly used to create cylindrical forms. A lathe holds a cylindrical workpiece on one or both ends while the cutting tool is gradually passed along the surface of the rotating part.

Less than

LES. A set of instructions that tells a PLC to determine whether one input number is less than the other. Less than functions have an output of true if the first input number is smaller than the second input number.

Less than or equal

LEQ. A set of instructions that tells a PLC to determine whether one input number is less than or equal to the other. Less than or equal functions have an output of true if the first input number is smaller than or equal to the second input number.

Long real

LREAL. A 64-bit data type that can store up to 15 significant digits after a decimal point. Long real data uses large amounts of storage space, but it is very precise.

Mathematical functions

A set of instructions that tells a PLC to perform calculations with numbers. Mathematical functions include add, subtract, multiply, and divide.

Millionth

A fraction that is one million times smaller than a whole number. One millionth can be written as 0.000001.

Mills

A machine that uses a rotating multi-point tool to remove metal from the surface of a workpiece. Mills may be operated either manually or by computer numerical control (CNC).

modulo

MOD. A set of instructions that tells a PLC to divide one input number by another, then calculate the remainder. The modulo function is often used when dividing integers.

Multiply

MUL. A set of instructions that tells a PLC to multiply two input numbers together. Multiply functions must have an output data type with a large enough range.

NEQ

Not equal. A set of instructions that tells a PLC to determine whether two input numbers are not equal. NEQ functions have a true output if the inputs are not equal and a false output if they are equal.

Not equal

NEQ. A set of instructions that tells a PLC to determine whether two input numbers are not equal. Not equal functions have a true output if the inputs are not equal and a false output if they are equal.

Octal system

A notation that uses combinations of the numbers 0 to 7 to represent all numerical quantities. In the octal system, each number placement right to left is 8 times greater than the previous number placement.

Operation

A mathematical action or process such as addition or subtraction. Each PLC math function performs a specific operation with the input data.

Output devices

A type of field device connected to a PLC that performs a desired action after receiving an electrical signal from the output module. Output devices include components such as motor starters, relays, and heaters.

PLC

Programmable logic controller. A processor-driven device that uses logic-based software to control machines and processes. Programmable logic controllers are used in industrial automation.

Power

A number that indicates how many times a given number is multiplied by itself. Powers are also known as exponents.

Programmable logic controllers

PLC. A processor-driven device that uses logic-based software to control machines and processes. Programmable logic controllers are used in industrial automation.

Programming languages

A set of symbols and rules used to present information to a processor. Programming languages for PLCs include ladder logic, structured text, function block diagrams, and sequential function charts.

Programs

The set of instructions entered into a CPU's memory that directs the PLC to control field devices. Programs for PLCs are often written in ladder logic.

Proximity sensor

A device that uses an electronic sensing field to detect the presence of an object. Proximity sensors are common PLC input devices.

Quadrillionth

A fraction that is one quadrillion times smaller than a whole number. One quadrillionth can be written as 0.000000000000001.

REAL

A 32-bit data type that can store up to 6 significant digits after a decimal point. REAL is a signed data type that can store positive or negative numbers.

Registers

An addressing method in older PLC software that stores data in files of predetermined bit lengths. Register addresses are written as a series of numbers, letters, and symbols.

remainder

The fraction of a number left over after dividing one integer by another integer. For example, the remainder of 9 divided by 4 is 0.25, because 9 ÷ 4 = 2.25.

Sensor

A device that detects a change in physical and environmental conditions. Sensors can detect the presence or absence of an object or person and can monitor environmental conditions such as temperature and humidity.

Sequential function charts

A graphical programming language for PLCs. Sequential function charts are useful for processes where many complex steps happen in sequence.

Signed

Using the leftmost bit in a data type to indicate whether a number is positive or negative. Signed data types include SINT, DINT, and REAL.

Signed double integer

DINT. A 32-bit data type that can store positive and negative whole numbers. Signed double integer data has a range of under -2 billion to over 2 billion.

Signed integer

INT. A 16-bit data type that can store positive and negative whole numbers. Signed integer data has a range of -32,768 to 32,767.

Signed short integer

SINT. An 8-bit data type that can store positive and negative whole numbers. Signed short integer data has a range of -128 to 127

Significant digits

The number of digits to the right of a decimal point. Numbers with more significant digits often represent more precise and accurate measurements.

Sine

SIN. A set of instructions that tells a PLC to find the sine of an angle equal to the input number. The sine of a right triangle is the ratio of the length of the side opposite the angle and the hypotenuse.

SINT

Signed short integer. An 8-bit data type that can store positive and negative whole numbers. SINT data has a range of -128 to 127

Square root

SQRT. A set of instructions that tells a PLC to find the square root of an input number. The square root is the number that, when multiplied by itself one time, results in the input number.

Structured text

A textual programming language for PLCs. Structured text is one of four standard programming languages defined by IEC 61131-3.

SUB

Subtract. A set of instructions that tells a PLC to subtract one input number from another. SUB functions can only produce negative numbers if the output data type is signed.

Subtract

SUB. A set of instructions that tells a PLC to subtract one input number from another. Subtract functions can only produce negative numbers if the output data type is signed.

Tag-based

An addressing method for PLC data files in modern PLC software. Tag-based systems allow users to create tags for data files that include a name, data type, and other information.

Tangent

TAN. A set of instructions that tells a PLC to find the tangent of an angle equal to the input number. The tangent of a right triangle is the ratio of the length of the side opposite the angle and the side adjacent to the angle.

Timer

A set of program instructions that allows a PLC to control and monitor time-dependent aspects of machines and processes. Timer instructions can delay an output from turning off or on for a preset amount of time.

Trigonometry

A branch of mathematics that addresses the measurements and relationships of triangles and their components. Trigonometry is often used in milling calculations.

UINT

Unsigned integer. A 16-bit data type that can store only positive whole numbers. UINT data has a range of 0 to 65,535.

Unsigned

Only able to store positive numbers in a data type. Unsigned data types lack a sign bit and include USINT, UINT, and UDINT.

Unsigned double integer

UDINT. A 32-bit data type that can store only positive whole numbers. Unsigned double integer data has a range of 0 to over 4 billion.

Unsigned integer

UINT. A 16-bit data type that can store only positive whole numbers. Unsigned integer data has a range of 0 to 65,535.

Unsigned short integer

USINT. An 8-bit data type that can store only positive whole numbers. Unsigned short integer data has a range of 0 to 255.

Variables

A value or number that changes. Variables for PLC math functions may come from input devices or other programming functions.