Ladder logic 401: Data acquisition and analysis

A programmable logic controller (PLC) is designed to not only provide information on signal levels, but it can also capture data and it can be analyzed, but there are a number of challenges the user faces from a software and logistical standpoint.

03/22/2016


A programmable logic controller (PLC) is designed to not only provide information on signal levels, but it can also capture data and it can be analyzed. The methods, however, can vary a great deal depending on the platform so this will focus on a generic level.

First, capturing the signal levels: These assume a signed integer signal from an analog card, unknown resolution.

Example of capturing the signal levels from a signed integer signal from an analog card, unknown resolution. Courtesy: Frank Lamb, Automation Primer

The image above shows a random sampling of values collected from a typical analog card. Since analog/device (AD) converters don't change values very quickly, it can be difficult to see the spikes that may occur in the signal.

Example of capturing the signal levels from a signed integer signal from an analog card, unknown resolution, with corrected values. Courtesy: Frank Lamb, Automation Primer

If values can be sampled at a higher rate than a typical proportional-integral-derivative (PID) control scheme might require, it might show some data like this. The spikes in these images illustrate what you can do if you do some simple limiting of values based on averaging.

It is important to note that any modification of data collected will require a delay of the signal. After all, it takes time to process the signals and improve them.

This is one method of creating sampling pulses that will work on pretty much any PLC platform, a free-running timer. One problem with it is that it is not going to be particularly precise since it operates within the scan. If it is necessary to improve pr

This is one method of creating sampling pulses that will work on pretty much any PLC platform, a free-running timer. One problem with it is that it is not going to be particularly precise since it operates within the scan. If it is necessary to improve precision, a cyclic routine or interrupt can be used.

This is a method of capturing ten values into an array and uses a first in, first out (FIFO) instruction. Courtesy: Frank Lamb, Automation Primer

This is a method of capturing ten values into an array. It uses a first in, first out (FIFO) instruction, which is available in most of the more expensive processors. If the user wants to capture more values, increase the size of the array.

This method bypasses first in, first out (FIFO) instruction. Courtesy: Frank Lamb, Automation Primer

Here is another method for a user who doesn't have or doesn't want to use a FIFO instruction. Array and file movement capabilities are still needed, however. The first instruction moves nine elements, leaving room for the current signal value to be copied into the first, most recent element.

This example takes about 20 instructions for movement of 10 values. Courtesy: Frank Lamb, Automation Primer

This example takes about 20 instructions for movement of 10 values. Courtesy: Frank Lamb, Automation Primer

This takes about 20 instructions for movement of 10 values. The MOV instructions would each need to be replaced with a LD Vxxx and an OUT Vxxx where the V's are your desired data locations; sensor value and storage location. These are 16-bit accumulators.

Here is an instruction that averages all of the elements in an array. Courtesy: Frank Lamb, Automation Primer

Here is an instruction that averages all of the elements in an array. Again, this is available on higher-end PLCs.

This is the method needed if the user don't have arrays or an average instruction. Courtesy: Frank Lamb, Automation Primer

This is the method needed if the user don't have arrays or an average instruction. Courtesy: Frank Lamb, Automation Primer

This is the method needed if the user doesn't have arrays or an average instruction. Sum up all of the values and divide by the number of values. The user can keep a running average of values this way for two or three values at a time. This could in turn be read back into another array for a running record of averages for smoothing.

This rung calculates the rate of change or Delta between consecutive captures and it works on any platform. Courtesy: Frank Lamb, Automation Primer

This rung calculates the rate of change or Delta between consecutive captures and it works on any platform. Again, this could be read back into an array for analysis. It is useful for determining the direction of change as well as its amplitude. For filtering, the user can capture "spike" values.

When analyzing signals it can be useful to capture signals as quickly or frequently as possible, unlike control and filtering. The limit will be how often the card actually posts a new value to its register. By capturing lots of values in an array, you can determine the update rate of your analog card, or A-D converter. If the user has an average of five identical values in a row at a capture rate of 5ms, your card updates every 25ms. Also, the faster you capture signals, the more likely you are to record a "spike" or out of tolerance value.

The next post on ladder logic will focus on data manipulation once the data has been captured from the analog card.

Frank Lamb is the founder of Automation Consulting Services Inc. This article originally appeared on the Automation Primer blog. Automation Primer is a CFE Media content partner. Edited by Chris Vavra, production editor, Control Engineering, CFE Media, cvavra@cfemedia.com.

ONLINE extra

For more articles on PLCs and programming, see related articles below.



WILLIAM , CA, United States, 04/06/16 10:28 AM:

Speed depends on the PLC system you use. We have systems acquiring data at 10,000 Sps, using Beckhoff Automation's EtherCAT and they have modules that allow 100,000 Sps. For timing, you can count PLC cycles (simple) or make calls to the CPU clock.
Anonymous , 06/14/16 10:05 AM:

Great information is provided mostly as a review but could be very beneficial to those who are new to the industry. Keep these brief tutorials coming. Thanks
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by...
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
The Engineering Leaders Under 40 program identifies and gives recognition to young engineers who...
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
Sensor-to-cloud interoperability; PID and digital control efficiency; Alarm management system design; Automotive industry advances
Make Big Data and Industrial Internet of Things work for you, 2017 Engineers' Choice Finalists, Avoid control design pitfalls, Managing IIoT processes
Engineering Leaders Under 40; System integration improving packaging operation; Process sensing; PID velocity; Cybersecurity and functional safety
This article collection contains several articles on the Industrial Internet of Things (IIoT) and how it is transforming manufacturing.

Find and connect with the most suitable service provider for your unique application. Start searching the Global System Integrator Database Now!

SCADA at the junction, Managing risk through maintenance, Moving at the speed of data
Flexible offshore fire protection; Big Data's impact on operations; Bridging the skills gap; Identifying security risks
The digital oilfield: Utilizing Big Data can yield big savings; Virtualization a real solution; Tracking SIS performance
click me