introduction to daq with labview - overview - …€¦ · introduction to daq with labview...

50
Introduction to DAQ with LabVIEW Hans-Petter Halvorsen, M.Sc. TC-01 Thermocouple http://home.hit.no/~hansha/?page=labview with Self-paced Step-by-Step Exercises

Upload: trantuyen

Post on 05-Jul-2018

264 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

IntroductiontoDAQwithLabVIEW

Hans-PetterHalvorsen,M.Sc.

TC-01Thermocouple

http://home.hit.no/~hansha/?page=labview

withSelf-pacedStep-by-StepExercises

Page 2: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Contents• LabVIEW• WhatisDAQ?• UsingTC-01ThermocoupleDeviceinLabVIEW• Plotting• Datalogging• MeasurementFilter

Page 3: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

LabVIEWInstallationDownloadthesoftwarehere:

http://home.hit.no/~hansha/?page=labviewThesearethemainmodulesweuseinthedifferentcoursesatTelemark UniversityCollege:

• LabVIEW (LabVIEWProfessionalDevelopmentSystem32-Bit:English)

• NI-DAQmx (HardwareDriverforNIUSB-6008,NITC-01,etc.)• LabVIEWControlDesignandSimulationModule• LabVIEWMathScript RTModuleNote!Thesepackagesareseparate downloads!

Note!YougettheSerialNumberfromyourTeacher,butthesoftwarecanbeusedfor30daysbeforeyouneedtoenteravalidSerialNumber.

AllLabVIEWSoftwarecanbedownloadedhere:www.ni.com/download

Page 4: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

AdditionalLabVIEWResources

• LabVIEWTrainingforStudents(NationalInstruments):

http://ni.com/students/learnlabview• LabVIEWCourse:http://home.hit.no/~hansha/?training=labview

Hereyouwillfind lotsofVideos,TutorialsandExercises

Itisrecommendedthatyouwatchsomeofthevideosbeforeyoureadfurter

Learning byDoing!

Page 5: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the
Page 6: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Hardware

cRIO

ZigBeeVisionSystem

Arduino

USB-6008Wi-FiDAQ

TC-01

NOxSensor

Pt-100

AirHeater

WaterTank

Page 7: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

DAQmx istheHardwareDriverneededinordertousehardwaredeviceslikeNIUSB-6008,NITC-01,etc.insideLabVIEW.Themoduleisavailableasapaletteonyourblockdiagram.

LabVIEWThisisthecoreLabVIEWinstallationthatinstallstheLabVIEWProgramming Environment.

Thismoduleisatext-basedtoolthatisverysimilartoMATLAB.ThesyntaxissimilartoMATLAB,youcancreateandrunso-calledmfiles,etc.ThemoduleisavailablefromtheToolsmenuinsideLabVIEW.

LabVIEWMathScript RTModule

LabVIEWControlDesignandSimulationModuleThismoduleisusedforcreatingControlandSimulationapplicationswithLabVIEW. HereyouwillfindPIDcontrollers,etc.Themoduleisavailableasapaletteonyourblockdiagram.

NI-DAQmx

Page 8: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

http://www.ni.com/pdf/manuals/376039a.pdf

Page 9: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Hans-PetterHalvorsen,M.Sc.

DAQ

Page 10: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

DAQHardwareExamplesNITC-01ThermocoupleTemperatureMeasurements

NIUSB-6008I/OModule

Note!TheDAQmxDriverisneededinordertousetheminsideLabVIEW!!

Analog/Digital Inputs/Outputs

Wewillusethisdevice

Page 11: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

DAQ– DataAcquisition

ADAQSystemconsistsof4parts:1. Physicalinput/output signals, sensors2. DAQdevice/hardware3. Driversoftware4. Yoursoftwareapplication(Application software)

NIDAQmxDriver

YourAppcreatedwithLabVIEW

NITC-01ThermocoupleDeviceor

NIUSB6008DAQDevice

Sensors,etc.

Page 12: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

UsingTC-01inLabVIEW

Hans-PetterHalvorsen,M.Sc.

Page 13: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

TC-01

Hans-PetterHalvorsen,M.Sc.

How-TouseTC-01withLabVIEW

USB

ConnectdevicetoPCusingUSB

Page 14: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

NITC-01

TheNIUSB-TC01providesconnections foronethermocouple.Thermocouple typesJ,K,R,S,T,N,E,andBaresupported. AtTUCwewillusetheJtype.

UsedtologTemperatureDatausing theLabVIEWsoftware

Temperature(Thermocouple) Device

DAQmx Driverneeded!

Page 15: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

GettingStartedwithTC-01Thefollowing windowshould popupautomaticallywhenyouplug inyourNIUSB-TC01deviceinyourUSBport(ifnot,select“TC01Launcher.exe”):

Students:PluginthedeviceintoyourUSBportandseeifthiswindowappears

Page 16: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

NITC-01Built-inTemperatureLoggerBuilt-inTemperatureLogger(NoDriverorprogrammingneeded)

Students:TesttheBuilt-inTemperatureLogger, LogDatatoFile,etc.

Page 17: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

MAX– Measurement&AutomationExplorer

Students:MakesurethatyourdevicecanbelocatedinMAX.Runa“Self-Test”andusethe“TestPanels”tomakesurethedeviceworksproperly.

Page 18: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

DataAcquisitionPaletteinLabVIEWFormore“advanced”DAQweusethesefunctions

ForbasicDAQweusetheDAQAssistant

Students:Makesurethatyouhavethispaletteinstalled.Ifnot, installthelatestDAQmx driver!

FunctionsPalette:“MeasurementI/O”->“NIDAQmx”

Page 19: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

LabVIEWDAQAssistant

WhenyouplacetheDAQAssistantontheBlockDiagram,aWizardautomaticallypopsupwhereyouconfigurewhatyouwanttodo, i.e.,ifyouwanttoReadorWriteData,AnalogorDigitalsignals,whichchannelyouwanttouse,etc.

Page 20: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

LabVIEWDAQAssistant

SelectInput/Output Type

SelectChannel

SetProperties

Page 21: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

ReadDatafromTC-01Device

Students:CreatethisExampleandRuntheProgram

YoucreatetheNumericIndicatorontheFrontPanel

Page 22: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Plotting

Hans-PetterHalvorsen,M.Sc.

Page 23: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

PlottingTemperature

Data

Students:CreatethisExampleandruntheprogram

Page 24: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

PlotConfiguration

Inmostcasesitisrecommendedthat you turnoff ”Autoscaling”

Click on the axis toset MinandMaxvalues

Students:Trythis.

Page 25: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

ClearPlotContents

Students:Trythis.

Right-Click

Page 26: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Makethe xScale showRealTime

Note!Thisisinmilliseconds

Note!ThisisinSeconds

Note!ForTC-01:Max4samplespersecond(seeDataSheet)

X-AxisScaling

Right-clickandselectProperties

How-ToShow”Real-Time”on X-Axis

Students:Trythis.

Page 27: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

UsingPropertyNodes

HerewewilllearntosetPropertiesfromLabVIEWCodeinsteadofsettingtheminthePropertyWindow, etc.Thisisveryuseful!

Page 28: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Herewehaveused“PropertyNodes”inordertosetproperscalingonX-AxisandcleartheChart

Students:Trythis.

Page 29: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

MultiplePlottingandusingSubVIs

Students:CreatethisExampleandrunit

SubVI

Page 30: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Input Output

(Control) (Indicator)

IconthatmakesiteasiertounderstandwhattheSubVIisdoing

ASubVIisthesameasafunctionoramethodusedinotherlanguages

SelectInputsandOutputsSubVI

Page 31: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Datalogging

Hans-PetterHalvorsen,M.Sc.

Page 32: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

SaveDatatoFile(Datalogging)Right-click-Properties

RecommendedSettings

Page 33: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

RecommendedSettings

Page 34: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

DataloggingExample

Page 35: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Students: (1) LogTemperatureData,bothCelsiusandFahrenheit (useSubVI)toa“MeasurementFile”.(2) ThenPlottheDataintheFileinExcel.(3) YoushouldalsocreateanewVIinLabVIEWwhereyouplot thedatafromtheFileinaGraphandinanArray.

DataloggingExample– BlockDiagram

Page 36: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

ReadfromMeasurementFile- Example

Right-click-Properties

BlockDiagram

RecommendedSettings

Page 37: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

RecommendedSettings

Page 38: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

UsingaLowpass FiltertoreduceNoise

Students:CreatethisExample.ThenIncludetheFilterinyourLogging Application

Functions palette:Express->SignalAnalysis->SimulateSignal

Functions palette:Express->SignalAnalysis->Filter

Page 39: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Properties

Page 40: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

MeasurementFilter

Hans-PetterHalvorsen,M.Sc.

(Youmayskipthispart)

fromScratch

Page 41: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

LowpassFilter/MeasurementFilterThedifferentialequationforaMeasurement filtermaybegivenas:

SinceweshallimplementtheMeasurementFilterinacomputer,weneedtomakeadicrete versionofthefilter.WeusetheEulerBackwarddiscretizationmethod:

WhereTsistheSamplingTimeThenweget:

Or:

whereThisdiscreteMeasurementFiltercanbeeasilyimplementedinacomputerusinge.g.,LabVIEW,C#,etc.

Themeasuredsignalscontainsnoise,soweshouldremovethenoiseusingaFilter

Page 42: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

LabVIEWFormulaNode

Example:

FormulaNode:CreateanduseCcodewithinLabVIEW

Students:UsetheLabVIEWFormulaNode.inordertoimplement theMeasurementFilter.

Page 43: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

LowpassFilter/MeasurementFilter- ExampleStudents: ImplementthisExampleusingaLabVIEWFormulaNode.Whenfinished, trytologdatafromyoursensorwithandwithouttheMeasurementFilter.Comparetheresults.

Page 44: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the
Page 45: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

TestingtheFilterInthisexampleweaddnoise toaSinefunction.WethenusetheMeasurementFiltertoseeifwecanremovethenoiseafterwards.

Asyoucanseethisgivesagoodresults.Thefilterremovesthenoisefromthesignal.

Students: TrythisExample.Next:UsetheFilteronyour Datalogging System

Page 46: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the
Page 47: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

AdditionalLabVIEWResources

• LabVIEWTrainingforStudents(NationalInstruments):

http://ni.com/students/learnlabview• LabVIEWCourse:http://home.hit.no/~hansha/?training=labview

Hereyouwillfind lotsofVideos,TutorialsandExercises

Itisrecommendedthatyouwatchsomeofthevideosbeforeyoureadfurter

Learning byDoing!

Page 48: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Hans-PetterHalvorsen,M.Sc.

DoyouneedmorePractice?- Select aChallenge

Page 49: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

TemperatureLogging1.CreateLoggingApp:• Logthetemperatureinyourhousee.g.,during thenightusing theTC-01

Thermocouple device.• PlotthetemperatureinaChart• LogthetemperaturetoaFile2.CreateAnalysisApp:• ReadthetemperaturedatafromthefileintoLabVIEW• FindMaxtemperatureandMintemperatureusingbuilt-in functions inLabVIEW• FindalsotheAverage/MeantemperatureandtheStandarddeviationusingbuilt-in

functions inLabVIEW3.DoAnalysisinExcel:• ImportthedataintoExcelandcreateaPlot• FindMax,Min,Mean/AVG, SDusingExcel• Comparetheresults

Page 50: Introduction to DAQ with LabVIEW - Overview - …€¦ · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen ... with Self-paced Step-by-Step Exercises. Contents ... This is the

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

E-mail:[email protected]:http://home.hit.no/~hansha/