Copyright Elektor International Media BV
Contents
About the author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 About this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 What is measurement?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Components of a measurement system . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Standards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Traceability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Measurement for HMI purposes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Measurement for feedback control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Real time and historical data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Instrumentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2
Measured data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Specification of the measurement system. . . . . . . . . . . . . . . . . . . . . . . . . 29 Accuracy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Repeatability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Sensitivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Resolution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Linearity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Range. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Frequency components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Harmonics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3
Book 001.indb 3
16-10-13 11:16
Copyright Elektor International Media BV Fourier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Uncertainty. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3
Sampling and data acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 The Sampling theorem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Zero-order hold. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Analogue to Digital conversion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Resolution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Conversion rate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Anti-alias filtering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Data acquisition systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4
Post Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Highest and lowest values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Acceptance band. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Prediction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Compression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Distributions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Algorithm versus lookup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Real Time versus offline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5
Data management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Storage types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Data formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Single Sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Lists and linked lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4
Book 001.indb 4
16-10-13 11:16
Copyright Elektor International Media BV Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 File formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Data warehousing, storage and recovery . . . . . . . . . . . . . . . . . . . . . . . . . 83 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 6
Statistical Process Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 SPC applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Control charts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Upper and lower control limits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Out-of-range prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Process Distribution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Six-sigma methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Process capability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Real Time SPC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Key Process Indicators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7
Process and Industrial Measurement Systems . . . . . . . . . . . . . . . . . . . . . 95 Application Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Example 1 - Manufacturing Plant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Example 2 - Mining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Example 3 - Water Distribution Utility . . . . . . . . . . . . . . . . . . . . . . . . . 99 Measurement Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Remote Telemetry Units (RTU). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Distributed Control Systems (DCS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 SCADA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Process Dashboard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
5
Book 001.indb 5
16-10-13 11:16
Copyright Elektor International Media BV 8
Process Modelling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Linear, Continuous and Batch Systems. . . . . . . . . . . . . . . . . . . . . . . . . . 108 Linear System Modelling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Batch System Modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9
Introduction to Z Transforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
115
Transform Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 The Z transform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Z Transform representation of a system. . . . . . . . . . . . . . . . . . . . . . . . . 120 Numerical Solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Further Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 10
Sample C# Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
125
Program example 1, “Error Sum” filter. . . . . . . . . . . . . . . . . . . . . . . . . . 125 Program example 2, “Moving Average” filter. . . . . . . . . . . . . . . . . . . . . . 126 Spreadsheet example, “Data Smoothing”. . . . . . . . . . . . . . . . . . . . . . . . 126 Program example 3, Square law linearisation by algorithm. . . . . . . . . . . . 127 Program example 4, Energy determination from speed measurement . . . . 127 Program example 5, Process mean and distribution. . . . . . . . . . . . . . . . . 127 Program example 6, Arrays and structures. . . . . . . . . . . . . . . . . . . . . . . 129 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 11
Further Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
131
Related textbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Useful Web resources, recognised sites. . . . . . . . . . . . . . . . . . . . . . . . . . 132 Web search keywords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Measured Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Sampling and data Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Post Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Data management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
6
Book 001.indb 6
16-10-13 11:16
Copyright Elektor International Media BV Statistical process Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Industrial and Process measurement Systems. . . . . . . . . . . . . . . . . . . 133 Process Modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Z Transforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Appendix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
135
Instrument Interfacing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Hardware definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Serial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 USB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 “Fire-wire� IEEE1394. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Parallel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Ethernet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 CANbus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Wireless. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
2
Notes on C#. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 C#. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3
Glossary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
7
Book 001.indb 7
16-10-13 11:16
Copyright Elektor International Media BV
About this book
This book is aimed at engineers, students and hobbyists. It is intended as a source of reference for hardware and software associated with process control measurements, and is a companion text to the title “Introduction to Control Engineering� by the same author. The material presented is intended as an introduction to the use of PC based measurement systems and software tools, for those who need to understand the underlying principles or apply such techniques. Measurement of physical variables and other process output variables is an essential factor in all aspects of industry, especially in manufacturing and process industries. For any variable to be controlled, it must be measured accurately, with due regard to influencing factors and sources of error. The early chapters present the basis for measurement, with definitions and reference to measurement techniques. The difference between continuous and discrete data is noted, with explanations of sampling and associated measurement techniques. There is reference to electronic processing and capture techniques, typical of common measurement and data acquisition systems. Later chapters consider how captured data may be processed and analysed, with emphasis on data storage, filtering and presentation. The last part of the book is focussed on the use of measured data as feedback for process control, and as information for process modelling. Throughout the book, computer programs in the C# language are presented, illustrating some of the methodologies discussed. In this manner, the reader is able to have immediate practical desktop involvement, gaining further insight into the techniques and methods described. C# was chosen due to the wide support and ready availability, being a popular choice for engineering solutions, often used in real time and embedded systems. The language has found popularity with professional programmers as well as with amateur and hobbyist users. It is therefore well supported and documented, with a wide following. The book is not filled out with software listings, since it is supported by a web page with all program examples available for download. The pertinent sections of each program are listed for explanation in the text, without the clutter of supporting headers.
10
Book 001.indb 10
16-10-13 11:16
Copyright Elektor International Media BV
1
Introduction
What is measurement? From the beginning, we have sought to assess and quantify, to count, to assign value and to trade. Measurement has developed as a discipline as a means of quantification and assignation of value, to goods, manufactured products and physical variables. Developments in measurement have delivered deeper scientific knowledge and have significantly assisted the progress of our modern economies. Measurement seeks to answer the questions “how many”, “how much” or “how often”, essentially by detection of the presence of the items or variable, followed by quantisation and therefore assignment of value. Measurements have developed from observation of physical phenomenon (e.g. in temperature measurement, using the expansion of liquid in a thermometer tube, or the use of thermocouples where dissimilar metals produce a voltage indicative of the junction temperature), to a point where sophisticated sensors are available with electronic interfaces, capable of operating in the most arduous conditions. In this chapter, we shall consider the basis of measurement technology, and consider how a value is assigned to the item of interest.
Components of a measurement system A measurement system consists of three main components, • Sensor: a device, which is sensitive to the variable to be measured, producing an output representative of the quantity of that variable • Processing: a device accepting the output from the sensor and operating on that output for the purpose of scaling, conversion, filtering or transmission • Display: the final component of the system, where the value may be displayed in meaningful terms In many cases, a fourth component is desirable, • Storage: a means of recording measured data for the purposes of archiving, comparison with past values, observation of trends, and hence prediction of future behaviour
15
Book 001.indb 15
16-10-13 11:16
1
INTRODUCTION
Copyright Elektor International Media BV
Such measurement systems may be realised using mechanical components only, for example, • A pressure gauge using a Bourdon tube to drive a pointer indicator against a scale • A car speedometer (cable take-off from the gearbox driving a dashboard pointer) • A mercury-in-glass thermometer
For the purposes of this book, we will consider cases where the measurement system is electronic, i.e. • The sensor produces an electrical output signal to represent the measured variable, which will be an industrial standard, typically 0 – 10 V or 4 – 20 mA • The processing system will be electronic, with appropriate hardware for amplification, filtering, scaling, transmission etc. It may also include computer interface hardware, with further processing in software • The display will be either a simple numeric readout or computer HMI screen • Storage will be to a data record in computer or PLC program memory, eventually saving to a file on computer disc Figure 1.1 shows the basic measurement system.
Measured variable
Sensor
Processing
Display
Storage
Trends
Figure 1.1 The basic measurement system
16
Book 001.indb 16
16-10-13 11:16
Copyright Elektor International Media BV
2
Measured data
Specification of the measurement system In the last chapter, we considered the basis of measurement systems, with consideration of standard units and applications. We found that it is possible to express physically occurring variables as a measured quantity, but noted that there are issues to be aware of when taking measurements and when using the results of measurement tests. This chapter focuses on the measurement process, and the resulting data. Initially, there are several definitions relating to the measurement process, followed by consideration of other factors, which affect the integrity of data obtained. Given an understanding of the measurement process, we will be able to specify an instrumentation system, and appreciate any inherent limitations.
Accuracy When taking a measurement, our first concern is whether the value obtained is indeed correct, or otherwise. The word “accuracy” means “closeness to the truth” – in the case of instrumentation, a reading is said to be accurate if it is a correct indication of the actual value of the measured variable. We shall investigate and qualify our understanding of accuracy within the following sections.
Repeatability If we were to use an instrument to measure a variable on different occasions, we would expect to obtain consistent results. In particular, if the variable had not changed since it was last measured, we would expect the same instrument to obtain the same value. In some cases, it can be difficult to be consistent due to changing factors in the measurement environment, or other phenomena, such as noise and interference, which might adversely affect the instrument.
29
Book 001.indb 29
16-10-13 11:16
Copyright Elektor International Media BV
3
Sampling and data acquisition
In this chapter, we shall concern ourselves with the capture of data from a measurement. We have considered a basic measurement system as consisting of a sensor, followed by appropriate processing and display. All terms and definitions so far have applied to all types of measurement, whether by electronic instruments or by traditional “mechanical” indicator. The later focus of this book is upon the handling and processing of measured data by computer application, so we shall now venture somewhat deeper into the technology of the modern electronic measurement system. The chapter will focus on the operation of electronic systems and how sensor data is converted for transfer to computer storage. We shall begin by consideration of the sampling process, the point at which a value is taken, and then progress to the conversion of the sample to a digital representation.
Sampling The term “sampling” has different connotations depending upon application, but is essentially the means of obtaining relevant data. For example, within the measurement application, sampling may be considered to be, • Removal of a single item from a batch of manufactured components, for the purpose of measurement of its physical attributes (e.g. a critical dimension) • The taking of a single measurement of a time-varying signal (e.g. measurement of a process temperature)
In general terms, a sample must be “representative of the whole”, i.e. a single item is typical of the rest of the batch, or a single measurement is a true indication of the observed variable.
Initially, we shall concern ourselves with the taking of a single sample - assuming that we shall then wish to take regular samples for the purpose of trending, analysis and control, (i.e. to take a sample manufactured component out of every batch, or to take readings continuously from a process).
41
Book 001.indb 41
16-10-13 11:16
Copyright Elektor International Media BV
6
Statistical Process Control
In earlier chapters, we have considered how data from a process might be captured, stored and archived, in order to provide a history of process variables or process output. We have also investigated various statistical methods which may be usefully applied to that data. In this chapter, we shall look more closely at the application of statistical methods, and consider how process performance might be improved by the use of feedback or the implementation of tighter control of process variables. The focus will be on batch processing or component manufacture, where significant variables are to be observed. Statistical Process Control has seen widespread application in manufacturing and process industries, especially with the ability to store and handle data on personal computers, and produce meaningful visual results rapidly. Initially, this chapter is concerned with the basis of statistical methods through example, moving on to present methods of data analysis and process performance indication. The examples show how such techniques might be programmed, giving scope for modification and ready application.
SPC applications Consider a process producing cut length of tube as a component for a manufactured product, as shown in figure 6.1. For the component to be acceptable, it must satisfy three constraints in order to assemble correctly,
Wall thickness
Outer diameter
Length
Figure 6.1 Tubular component
85
Book 001.indb 85
16-10-13 11:16
6
Copyright Elektor STATISTICAL PROCESS CONTROL
International Media BV
The three variables are referred to as “attributes”, since they provide a description of the component. They form part of the larger, complete set of attributes for the component, which might include material, supplier, colour, hardness etc. The measured dimensions however, might be regarded as “critical variables”, since they must be within an acceptable band. In specification of the component, the three variables would be given dimension, qualified by an acceptable tolerance. If any of the three dimensions fall outside the acceptable tolerance, the component would be classed as “non-conforming”, requiring rework or rejection (scrap). In production of the component, samples are taken at regular intervals and the three variables measured. It would be expected that due to normal process variation, all three variables would exhibit a mean value with variance.
Control charts The simplest form of presentation for measured data is the “control chart”, showing trend and limits for one variable. Figure 6.2 shows an example of a control chart. The chart merely presents the measurement result of a single critical variable. This measurement could be taken from either, • a single item sampled from a batch, • the average of a batch of items, or • an item removed from a continuous process line at regular intervals
Upper control limit
Process mean
Lower control limit
1
2
3
4
5
6
7
8
Sample Figure 6.2 Single variable control chart
86
Book 001.indb 86
16-10-13 11:16
Copyright Elektor International Media BV CONTROL LIMITS UPPER AND LOWER
The x-axis of the graph will be the sample number or the sample interval, as applied to batch or continuous processing respectively.
Upper and lower control limits Having graphed the measured variable, a useful addition is to show tolerance limits called the “Upper Control Limit” and the “Lower Control Limit”. This produces a chart where process trends and possible drift towards a limit are easily recognised, Such methods of measurement and representation can be applied to all the critical dimensions of a component, and indeed applied to all components required to produce the final product. The objective is to minimise the quantity of rejected components by early detection of trends towards tolerance limits. Appropriate alarm and correction procedures may then be implemented to maintain continuous production of good product, and hence yield maximum productivity.
Out-of-range prediction In an earlier chapter we observed how past data could be used to predict future values, bearing in mind process noise, measurement error and sampling period. For statistical process control application, such prediction would give early warning of possible future out-of-tolerance product, as shown in figure 6.3.
Potential future out-of-range
1
2
3
4
5
6
7
8
Figure 6.3 Out-of-range prediction
87
Book 001.indb 87
16-10-13 11:16
Copyright Elektor International Media BV
9
Introduction to Z Transforms
We have seen in an earlier chapter how a continuous signal may be sampled to produce a digital representation of that signal. In that chapter, we noted • The sampling process • The sampling theorem • The concept of a “hold” Figures 3.1 and 3.2, repeated here as figures 9.1 and 9.2 illustrate the sampling process, where a continuous signal x(t) is sampled at intervals of T second.
Signal x(t)
m(kT)
Sample
y(kT)
Hold
Figure 9.1 Sample and hold
The sampled signal m(kT) is essentially a series of impulses, the amplitude (value) of which is the instantaneous value of the input signal.
T
2T
3T
4T
5T
T
Figure 9.2(a) sampler output pulses
2T
3T
4T
5T
Figure 9.2(b) sample and hold
Figure 9.2 Sampling
115
Book 001.indb 115
16-10-13 11:16
9
Copyright Elektor INTRODUCTION TO Z TRANSFORMS
International Media BV
The sample number is represented by the integer k, beginning at 1 (i.e. the first sample) and increasing in whole numbers, representing the point at which the sample is taken, hence the sample at time t = kT . The output of the hold is represented as y(kT), again being a sequence of numbers defining the original signal, but held at the past value. Other preceding chapters and C# programs have shown how we may operate on the data samples to produce practical, meaningful results. In this chapter, we shall consider how the data may be represented in the discrete time domain, and how we may convert between the discrete and continuous time domains using the “Z transform”.
Transform Basics In a single chapter of this text, it is not possible to completely cover all aspects of the Z transform and its related applications, but merely to provide a background. The following sections in this chapter therefore call upon several topic areas to which the reader may wish to refer for a deeper understanding. The chapter on “Further Reading” presents both text and web sources, suggesting mathematical support and engineering application topic areas, including, • Sequences and series • Differential equations and difference equations • Laplace transforms • System modelling We are generally most familiar with systems in the time domain, where we can describe a signal or the behaviour of a process as a function of time. In this case, we determine a relationship between the input and output of a system (the “transfer function”), and can then determine the output from the system as a result of a known input using standard mathematical techniques. Examples Example 1 An amplifier having a voltage gain of 100 is used to amplify a measured signal from a strain gauge. For an input signal of 10mV, the amplifier would produce an output of 1V. Since we are not interested in frequency components, the dc gain is used as a simple multiplier.
116
Book 001.indb 116
16-10-13 11:16
Copyright Elektor International Media BV TRANSFORM BASICS Example 2 An RC filter has a time constant of 1 second, used to remove high frequency noise from a temperature measurement signal. To observe the output from the filter, we could either Assume that the temperature is varying very slowly compared to the filter time constant, and use a filter gain of 1 as a multiplier or Describe the filter using a differential equation, express the input signal as a function of time and determine the output by numerical solution (i.e. solution in the time domain) or Describe the filter and the input signal in the Laplace domain (by taking Laplace transforms), multiply the two to determine the output signal and then convert back to the time domain
For most process control systems described by linear differential equations, the Laplace transform would be the preferred method of solution. Useful insight may be gained into the behaviour, response and stability of such systems by analysis in the Laplace domain. The Z transform is a mathematical tool which allows us to handle sampled data and discrete time systems easily, and gives us access to a range of analytical tools and techniques in much the same way as the Laplace transform handles differential systems. Useful insight may be gained into the behaviour, response and stability of discrete time systems by analysis in the Z domain. Z transform techniques are required where • The system is described by difference equations • The system is computer controlled, where a program loop takes samples from an analogue input, processes that signal and then updates an output at a fixed time interval • Digital processing is used (suggesting a regular clock signal with sequencing logic) • A signal is represented as a numerical sequence
117
Book 001.indb 117
16-10-13 11:16
9
Copyright Elektor INTRODUCTION TO Z TRANSFORMS
International Media BV
The Z transform We denote the process of converting into the z domain (i.e. taking the z transform) by the capital letter “Z”. If we have a sequence, Xk we show conversion into the z domain thus,
Z [ X k ] = X[ Z ]
Note that, • the original sequence, Xk, is already discontinuous, it is a sequence of numbers (such as obtained from an analogue-to-digital converter), the subscript “k” referring to the sample number. • In the resulting expression, X[z], the subscript “z” indicates that it is a z domain representation • The original letter used for the variable (i.e., “X”) is retained, since it is essentially the same signal, just in a different form
The z transform for a sequence Xk is defined as,
Z [ Xk ] =
∞
∑ Xk z− k
k =0
Or, to obtain the z transform of a sequence, • Multiply each term in the sequence by (z raised to an increasing negative power), then sum all terms
Examples To illustrate the process, we will consider the two most common signals used in control system analysis, the impulse and the step, and will then consider a simple sequence of numbers. Example 1
Z Transform of an impulse
An impulse is a signal of magnitude 1, occurring at t = 0. Expressed as a sequence of numbers, this is
118
Book 001.indb 118
16-10-13 11:16
Copyright Elektor International Media BV
THE Z TRANSFORM
X k = {1, 0, 0, 0, 0,..} (Noting that the “1” is the 0th sample, at t = 0, or k = 0) Applying the transform as above, we have
Z[X k ] = 1.z –0 + 0.z –1 + 0.z –2 + 0.z –3 ........
Example 2
= 1
Z Transform of a step
A step is a signal of magnitude 1, starting at t = 0. Expressed as a sequence of numbers, this is
X k = {1, 1, 1, 1,..} Applying the transform as above, we have
Z[X k ] = 1.z –0 + 1.z –1 + 1.z –2 + 1.z –3 ...... Referring to our mathematics for summation of infinite series, we recognise this as a summation of a power series, hence
Z [ Xk ] =
1 1 − z −1
Or
Z [ Xk ] =
Example 3
z z −1
Z Transform of a sequence
Let us now consider a simple sequence of numbers and take the transform in the same way. Suppose,
X k = {1, 0.5, 0.25, 0.125, 0.0625.....}
Applying the transform as above, we have
119
Book 001.indb 119
16-10-13 11:16
Copyright Elektor International Media BV
10
Sample C# Programs
This chapter presents C# programs to demonstrate implementation of the techniques presented throughout the text. The programs are not intended to be the most ideal solution, since the purpose is two-fold, Firstly,
to show how the measurement techniques covered in the text may be applied in a modern programming language, either for real time or offline application
Secondly
to introduce the C# language as a means of “desktop engineering”, providing an easy path to problem solution
The reader will note that all the C# programs presented are relatively easily coded, and that there will be more than one means by which the desired objective may be met, (and typically, the use of built-in functions reduces programming effort). The example programs presented serve as an introduction to the popular “C#” language, chosen for its high functionality combined with speed of execution - not necessarily because C# might be the best option. Any of the C# examples may be executed as part of a real time measurement system, or may be stand-alone utilities for post processing. Only the relevant code is described here since the complete programs are available for download from the supporting web site. The reader is referred to the web site for the full program listing, and to the section on further reading. There are also supportive texts on the C# and other variations of the C language listed.
Program example 1, “Error Sum” filter This filter is the simplest to implement, achieved in only two lines of code, Last_Output = Current_Output; Current_Output = Last_Output + ((Current_Input - Last_Output) / Filter_Weight);
125
Book 001.indb 125
16-10-13 11:17
10
Copyright SAMPLE C# PROGRAMS
Elektor International Media BV
In this example, since only one past value is used, a single instruction stores the previous output. The current output is then derived from the previous output and current input. This filter is particularly simple but effective, and therefore lends itself for use in real time application, requiring comparatively little processor power or storage.
Program example 2, “Moving Average” filter This filter uses an array to store sampled values. Upon each sample interval, previous sample values are shifted down one position, to make way for the new sample to be inserted. The oldest sample is therefore lost, and the filter output is determined from the average of the remaining values in the array. In the program example, the average of 5 samples is taken. A loop is used to shuffle the buffer, and another loop is used for the summation. // shuffle buffer for (Index=0; Index < 4; Index++) { Samples[Index] = Samples[Index+1]; } // add new value Samples[4] = Next_Input; // determine new output Sample_Sum = 0; for (Index = 0; Index < 5; Index++) { Sample_Sum = Sample_Sum + Samples[Index]; } Filter_Output = Sample_Sum / 5;
Spreadsheet example, “Data Smoothing” The web support also includes a spreadsheet used in the creation of figure 4.4. A fixed data set is used as an example, showing how the data smoothing algorithm operates.
126
Book 001.indb 126
16-10-13 11:17