Table Of ContentPC Interfacing and Data Acquisition
This Page Intentionally Left Blank
PC Interfacing and Data Acquisition:
Techniques for Measurement,
Instrumentation and Control
Kevin James
Newnes
OXFORD AUCKLAND BOSTON JOHANNESBURG MELBOURNE NEWDELHI
Newnes
AnimprintofButterworth-Heinemann
LinacreHouse,JordanHill,OxfordOX28DP
225WildwoodAvenue,Woburn,MA01801-2041
AdivisionofReedEducationalandProfessionalPublishingLtd
Firstpublished2000
©KevinJames2000
Allrightsreserved.Nopartofthispublicationmaybereproducedin
anymaterialform(includingphotocopyingorstoringinanymediumby
electronicmeansandwhetherornottransientlyorincidentallytosome
otheruseofthispublication)withoutthewrittenpermissionofthe
copyrightholderexceptinaccordancewiththeprovisionsoftheCopyright,
DesignsandPatentsAct1988orunderthetermsofalicenceissuedbythe
CopyrightLicensingAgencyLtd,90TottenhamCourtRoad,London,
EnglandW1P9HE.Applicationsforthecopyrightholder’swritten
permissiontoreproduceanypartofthispublicationshouldbeaddressed
tothepublishers
BritishLibraryCataloguinginPublicationData
AcataloguerecordforthisbookisavailablefromtheBritishLibrary
ISBN0750646241
TypesetbyLaserWords,Madras,India
PrintedandboundinGreatBritain
Contents
Preface ix
Anoteonsoftwareexamples x
Part1:IntroductiontoDataAcquisitiononthePC
1 ThePCasaplatformfordataacquisition 3
1.1 TypesofPC 4
1.2 Theprocessor 5
1.3 Memory 11
1.4 Input/outputports 15
1.5 Busesandadaptorcardslots 17
2 Softwareconsiderations 26
2.1 AnoverviewofDA&Csoftware 26
2.2 Dataacquisitionandcontrolinrealtime 30
2.3 Implementingreal-timesystemsonthePC 45
2.4 Robustness,reliabilityandsafety 61
Part2:SamplingFundamentals
3 Sensorsandinterfacing 71
3.1 Introduction 71
3.2 DigitalI/O 76
3.3 Sensorsforanaloguesignals 81
3.4 Handlinganaloguesignals 95
3.5 Digitizationandsignalconversion 103
3.6 Analoguemeasurements 124
3.7 Timersandpacing 128
4 Sampling,noiseandfiltering 131
4.1 Samplingandaliasing 131
4.2 Noiseandfiltering 142
vi Contents
Part3:I/OTechniquesandBuses
5 Theinterruptsystem 163
5.1 Interruptvectors 164
5.2 Hardwareinterrupts 169
5.3 Softwareinterruptsandprocessorexceptions 185
5.4 Interruptpriorities 189
5.5 Writinginterrupthandlers 190
5.6 Re-entrancyandaccessingsharedresources 199
5.7 Interruptresponsetimes 200
6 Datatransfer 205
6.1 Data-acquisitioninterfacedevices 205
6.2 Datatransfertechniquesandprotocols 211
6.3 BuffersandbufferedI/O 244
7 Parallelbuses 251
7.1 Introduction 252
7.2 Dataacquisitionusingaparallelbus 253
7.3 ThePC’sparallelport 254
7.4 TheIEEE-488(GPIB)bus 270
8 Serialcommunications 284
8.1 Somecommonterms 284
8.2 Introductiontoasynchronouscommunication 286
8.3 Dataacquisitionviaaseriallink 291
8.4 Serialinterfacestandards 296
8.5 AsynchronousserialI/OonthePC 308
Part4:InterpretingandUsingAcquiredData
9 Scalingandlinearization 345
9.1 Scalingoflinearresponsecurves 346
9.2 Linearization 356
9.3 Polynomiallinearization 357
9.4 Interpolationbetweenpointsinalook-uptable 373
9.5 Interpolationvs.power-seriespolynomials 381
9.6 Interactivecalibrationprograms 381
9.7 Practicalissues 383
10 Basiccontroltechniques 387
10.1 Terminology 387
10.2 Anoverviewofcontrolsystems 388
10.3 Programmablelogiccontrollers 390
10.4 Safetyandreliabilityofcontrolsystems 391
10.5 Discontinuouscontrolsystems 392
10.6 Continuouscontrolsystems 396
Contents vii
Part5:Examples
11 Exampleprojects 411
11.1 Dimensionalgaugingofrailwaycarriagewheels 411
11.2 In-situsensorcalibrationonatube-straightening
machine 413
11.3 Dimensionalgaugingofturbineblades 416
11.4 Torsionalrigiditytestingofcarbodies 420
11.5 Winchtestingsystem 423
11.6 Brakeactuatortestsystem 426
11.7 Monitoringofbush-insertionload 429
11.8 Laboratoryfurnacetemperaturecontrol 432
11.9 Thermoluminescencespectrometry 434
Part6:Appendices
AppendixA Adaptorinstallationreference 441
AppendixB Charactercodes 447
References 453
Index 457
This Page Intentionally Left Blank
Preface
Untilfairlyrecentlymostscientificdata-gatheringsystemsandindus-
trial control procedures were based on electromechanical devices
such as chart recorders and analogue gauges. The capability to
processandanalysedatawasratherlimited(andinsomecaseserror
prone) unless one had access to a minicomputer or mainframe.
Today,thatsituation haschangedconsiderably.I amsurethatmost
potential readers of this book will be aware of the profound effect
thePChashadonthewayinwhichengineersandscientistsareable
toapproachdata-gatheringtasks.
Despite the now widespread use of various types of PC for
automated data capture, there has been only a small number of
publications on PC-based DA&C. Most if not all of these texts have
concentrated on the hardware aspects of interfacing and measure-
ment. A book emphasizing the design of DA&C software is long
overdue.
One of the reasons for this has become increasingly apparent
to me during the course of writing the present text. The subject
spans numerous conventional disciplines and no single book can
really do full justice to every aspect of this interdisciplinary subject.
DA&C programming tends to require skills in (or at least a basic
knowledge of) a range of subjects and, for this reason, the book
draws together elements of programming, PC architecture, oper-
ating systems, interfacing, communications, sampling theory and
processcontrol.
My task has been complicated because of the wide range of
backgrounds from which DA&C programmers tend to originate.
Amongst the readership there will, no doubt, be fairly experienced
programmers as well as engineers and scientists whose main area
of expertise lies in fields other than computer programming. Some
readerswillalreadyhaveasoundknowledgeofdataacquisition,while
for others the principles of interfacing, measurement and control
will be relatively new. With such a broad spectrum of potential