PLC Analog Programming

PLC Analog Programming

Using PLCs to monitor and control analog signals takes their functionality to the next level but requires a little extra design effort.

Originally conceived for handling discrete logic, PLCs quickly evolved to do much more. As discussed in the previous article of this series, PLC discrete programming involves on/off signals, data and instructions.

PLC analog programming, on the other hand, introduces some new concepts to consider, along with some housekeeping tasks which must be performed to maintain best practices. The required tasks are generally common-sense, and PLCs provide the necessary features and instructions. However, users need to take the initiative to properly apply them.

Analog monitoring and logic are important needs for many automated processes and machines. Some critical equipment characteristics can only be expressed as analog signals. Even where active control of analog signals is not needed, analog values are useful for viewing on human machine interface screens and logging into a data historian where they can be used to trend and analyze parameters over varying time periods. This post will help new users understand the concepts associated with PLC analog programming.

What Exactly Does “Analog” Mean?Coolant warning light control analog programming range

For PLCs used in industrial automation applications, the term “analog” indicates a signal or logic that varies over a range instead of just existing as an off/on discrete value. This range must have pre-defined allowable limits, with a normal or “nominal” low (or minimum) and high (or maximum) value. Think of analog as the speedometer of a car, ranging from 0 to 100mph, instead of a discrete off/on warning light.

Analog values are handled with mathematical instructions and comparison instructions. As we will see, there are many more programming options with analog values than with discrete signals.

PLC Analog Inputs and Outputs

When it comes to PLC analog I/O, there are many types of field instruments that can provide or accept a signal. Many processes use some or all of the “big four” sensing parameters of flow, level, pressure and temperature. Some equipment might have sensors that can provide an analog value indicating the position of a gripper or valve. Electrical systems commonly indicate voltage, current, power and other factors as analog signals. Analyzers could return process values like pH or conductivity as analog inputs. For outputs, PLCs can command modulating valves to a desired position, variable frequency drives (VFDs) to a certain speed, vanes to a desired position or other components able to be continuously controlled.

Analog Data Types

Within a PLC, there are several ways to represent analog data. It is always important to consult the PLC documentation regarding available data types and associated handling. One basic format is a 16-bit WORD, also called an integer (INT). An unsigned integer ranges from 0 to 65,535, or if used as a signed integer, the value ranges from -32,768 to 32,767. Usually there are also double-integers (DINTs) which are 32-bit and provide a much larger range and the possibility for greater precision. Many PLCs can also handle floating-point numbers (those with decimal values) using a REAL data type. Floating-point values have an even wider range than DINTs.

Scaling Analog Signals

Most PLCs accept and generate analog signals for I/O as an integer of some sort, but sometimes at less than 16-bit resolution. For instance, a common format is 12-bit, which means the raw analog signal ranges from 0 to 4,095. This raw value is sometimes called “counts.”

Thoughtful programmers will scale the raw counts into easily human-readable engineering units, oftentimes translating the information to REAL in the process. For example, a 12-bit PLC analog input connected to a temperature transmitter indicating 0 to 200°F requires a mathematical instruction to convert the raw input of 0-4,095 to engineering units of 0.0-200.0 in a REAL variable.

Basic PLC code example for scaling

The PLC may provide an analog input configuration option to perform this scaling, it may provide a specific scaling instruction (above) or the user may choose to do this with simple math instructions. Some applications may call for bidirectional scaling ranging from a negative value to a positive value.

Analog Alarms

Analog values provide much more information than discrete values, and this information must be handled correctly. For instance, if the example temperature transmitter ever indicates an under-range condition below 0°F or an over-range condition above 200°F, these values indicate a signal problem. Best practices for design therefore include setting alarm under- and over-range values to protect math and other control logic from unintended operation.

Using comparison logic, programmers can monitor any number of alarm thresholds or conditions. The most common are low and high alarm conditions, low-low and high-high shutdown conditions and intermediate operating conditions.

Program Housekeeping for Analog Signals

Handling analog values in a program requires some other housekeeping considerations. In addition to monitoring values for bad quality, the values should be limited. Each can never go so far out-of-bounds as to cause an illegal computation (such as a “divide by zero” fault). Not only should analog outputs be limited in this way, but if the logic ever senses a failure or emergency stop condition, the analog output should be driven to the failsafe value, which is usually minimum. One more consideration for analog inputs is some sort of filtering, whether built-in to the PLC or added using math functions, to smooth out noisy analog input signals and provide a more usable indication.

When properly applied, programming PLCs to monitor and control analog values is a powerful capability useful for automating many types of systems. Care taken in design will result in successful and trouble-free operation for years to come.

How helpful was this article? Click a star to rate.
[4 votes so far. Average rating of 5]


Please enter your comment!
Please enter your name here