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

Introduction to DAQ with LabVIEW - Overviewhome.hit.no/~hansha/documents/labview/course/daq/powerpoint... · Introduction to DAQ with LabVIEW Hans-Petter Halvorsen, M.Sc. ... Thermocouple

Embed Size (px)

Citation preview

IntroductiontoDAQwithLabVIEW

Hans-PetterHalvorsen,M.Sc.

TC-01Thermocouple

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

withSelf-pacedStep-by-StepExercises

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

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

AdditionalLabVIEWResources

• LabVIEWTrainingforStudents(NationalInstruments):

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

Hereyouwillfind lotsofVideos,TutorialsandExercises

Itisrecommendedthatyouwatchsomeofthevideosbeforeyoureadfurter

Learning byDoing!

Hardware

cRIO

ZigBeeVisionSystem

Arduino

USB-6008Wi-FiDAQ

TC-01

NOxSensor

Pt-100

AirHeater

WaterTank

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

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

Hans-PetterHalvorsen,M.Sc.

DAQ

DAQHardwareExamplesNITC-01ThermocoupleTemperatureMeasurements

NIUSB-6008I/OModule

Note!TheDAQmxDriverisneededinordertousetheminsideLabVIEW!!

Analog/Digital Inputs/Outputs

Wewillusethisdevice

DAQ– DataAcquisition

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

NIDAQmxDriver

YourAppcreatedwithLabVIEW

NITC-01ThermocoupleDeviceor

NIUSB6008DAQDevice

Sensors,etc.

UsingTC-01inLabVIEW

Hans-PetterHalvorsen,M.Sc.

TC-01

Hans-PetterHalvorsen,M.Sc.

How-TouseTC-01withLabVIEW

USB

ConnectdevicetoPCusingUSB

NITC-01

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

UsedtologTemperatureDatausing theLabVIEWsoftware

Temperature(Thermocouple) Device

DAQmx Driverneeded!

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

Students:PluginthedeviceintoyourUSBportandseeifthiswindowappears

NITC-01Built-inTemperatureLoggerBuilt-inTemperatureLogger(NoDriverorprogrammingneeded)

Students:TesttheBuilt-inTemperatureLogger, LogDatatoFile,etc.

MAX– Measurement&AutomationExplorer

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

DataAcquisitionPaletteinLabVIEWFormore“advanced”DAQweusethesefunctions

ForbasicDAQweusetheDAQAssistant

Students:Makesurethatyouhavethispaletteinstalled.Ifnot, installthelatestDAQmx driver!

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

LabVIEWDAQAssistant

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

LabVIEWDAQAssistant

SelectInput/Output Type

SelectChannel

SetProperties

ReadDatafromTC-01Device

Students:CreatethisExampleandRuntheProgram

YoucreatetheNumericIndicatorontheFrontPanel

Plotting

Hans-PetterHalvorsen,M.Sc.

PlottingTemperature

Data

Students:CreatethisExampleandruntheprogram

PlotConfiguration

Inmostcasesitisrecommendedthat you turnoff ”Autoscaling”

Click on the axis toset MinandMaxvalues

Students:Trythis.

ClearPlotContents

Students:Trythis.

Right-Click

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.

UsingPropertyNodes

HerewewilllearntosetPropertiesfromLabVIEWCodeinsteadofsettingtheminthePropertyWindow, etc.Thisisveryuseful!

Herewehaveused“PropertyNodes”inordertosetproperscalingonX-AxisandcleartheChart

Students:Trythis.

MultiplePlottingandusingSubVIs

Students:CreatethisExampleandrunit

SubVI

Input Output

(Control) (Indicator)

IconthatmakesiteasiertounderstandwhattheSubVIisdoing

ASubVIisthesameasafunctionoramethodusedinotherlanguages

SelectInputsandOutputsSubVI

Datalogging

Hans-PetterHalvorsen,M.Sc.

SaveDatatoFile(Datalogging)Right-click-Properties

RecommendedSettings

RecommendedSettings

DataloggingExample

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

DataloggingExample– BlockDiagram

ReadfromMeasurementFile- Example

Right-click-Properties

BlockDiagram

RecommendedSettings

RecommendedSettings

UsingaLowpass FiltertoreduceNoise

Students:CreatethisExample.ThenIncludetheFilterinyourLogging Application

Functions palette:Express->SignalAnalysis->SimulateSignal

Functions palette:Express->SignalAnalysis->Filter

Properties

MeasurementFilter

Hans-PetterHalvorsen,M.Sc.

(Youmayskipthispart)

fromScratch

LowpassFilter/MeasurementFilterThedifferentialequationforaMeasurement filtermaybegivenas:

SinceweshallimplementtheMeasurementFilterinacomputer,weneedtomakeadicrete versionofthefilter.WeusetheEulerBackwarddiscretizationmethod:

WhereTsistheSamplingTimeThenweget:

Or:

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

Themeasuredsignalscontainsnoise,soweshouldremovethenoiseusingaFilter

LabVIEWFormulaNode

Example:

FormulaNode:CreateanduseCcodewithinLabVIEW

Students:UsetheLabVIEWFormulaNode.inordertoimplement theMeasurementFilter.

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

TestingtheFilterInthisexampleweaddnoise toaSinefunction.WethenusetheMeasurementFiltertoseeifwecanremovethenoiseafterwards.

Asyoucanseethisgivesagoodresults.Thefilterremovesthenoisefromthesignal.

Students: TrythisExample.Next:UsetheFilteronyour Datalogging System

AdditionalLabVIEWResources

• LabVIEWTrainingforStudents(NationalInstruments):

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

Hereyouwillfind lotsofVideos,TutorialsandExercises

Itisrecommendedthatyouwatchsomeofthevideosbeforeyoureadfurter

Learning byDoing!

Hans-PetterHalvorsen,M.Sc.

DoyouneedmorePractice?- Select aChallenge

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

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

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