Introduction to DAQ with LabVIEW and USB-6008 - Overview · This is the core LabVIEW installation...

Post on 03-Nov-2018

245 views 7 download

Transcript of Introduction to DAQ with LabVIEW and USB-6008 - Overview · This is the core LabVIEW installation...

IntroductiontoDAQwithLabVIEW

Hans-PetterHalvorsen,M.Sc.

USB-6008

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

withSelf-pacedStep-by-StepExercises

Contents

• LabVIEW• WhatisDAQ?• UsingUSB-6008inLabVIEW• AnalogIn• AnalogOut• Datalogging

USB-6008I/OModule

LabVIEWInstallationDownloadthesoftwarehere:

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

• LabVIEW (LabVIEWProfessionalDevelopmentSystem32-Bit:English)

• NI-DAQmx (HardwareDriverforNIUSB-6008,NITC-01,etc.)• LabVIEWControlDesignandSimulationModule• LabVIEWMathScriptRTModuleNote!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

DAQmxistheHardwareDriverneededinordertousehardwaredeviceslikeNIUSB-6008,NITC-01,etc.insideLabVIEW.Themoduleisavailableasapaletteonyourblockdiagram.

LabVIEWThisisthecoreLabVIEWinstallationthatinstallstheLabVIEWProgramming Environment.

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

LabVIEWMathScriptRTModule

LabVIEWControlDesignandSimulationModuleThismoduleisusedforcreatingControlandSimulationapplicationswithLabVIEW. HereyouwillfindPIDcontrollers,etc.Themoduleisavailableasapaletteonyourblockdiagram.

NI-DAQmx

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

DAQ

Hans-PetterHalvorsen,M.Sc.

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.

ADConverter

DAConverter

MeasurementSignal

ControlSignalUSB

AD&DAConverters

AD – AnalogtoDigitalDA – DigitaltoAnalog

AllAnalogSignalsneedstobeconvertedtoDigitalSignalsbeforetheComputercanusethem(ADConverter).

ContinuousSignal

DiscreteSignal Acomputercanonlydealwithdiscretesignals

k=0,1,2,3,4,....

Ts=SamplingTimeWhenTs->0,wehaveacontinuoussignal,butinacomputerthatisnotpossible.

Continuousvs.

DiscreteSignals

SamplingandAliasingOriginalSignal Aliasing(“Nedfolding”)->TheSamplingRateistolow!

SamplingTimeSamplingFrequency

UsingUSB-6008inLabVIEW

Hans-PetterHalvorsen,M.Sc.

USB-6008

Hans-PetterHalvorsen,M.Sc.

How-TouseUSB-6008withLabVIEW

USB

Analog I/O

DigitalI/O

NIUSB-6008I/OModuleSpecifications:• 8analoginputs,AI(12-bit,10kS/s,-10-10V)• 2analogoutputs,AO(12-bit,150S/s,0-5V)• 12digitalI/O(DI/DO)• 32-bitcounter

Note!DAQmx Driverisneeded!!

4differenttypesofSignals:AO – AnalogOutputAI – AnalogInputDO – DigitalOutputDI – DigitalInput

USBConnection -10-10V

0-5V

MAX– Measurement&AutomationExplorer

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

NIUSB-6008“Dev1”

Youmaychangethename(“Dev1”)

DataAcquisitionPaletteinLabVIEWFormore“advanced”DAQweusethesefunctions

ForbasicDAQweusetheDAQAssistant

Students:Makesurethatyouhavethispaletteinstalled.Ifnot, installthelatestDAQmx driver!

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

LabVIEWDAQAssistant

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

AnalogIn

Hans-PetterHalvorsen,M.Sc.

AI SettingsinDAQAssistantProperties

Channel

TypeofSignals

Whatyouchooseheredependsonthevoltageyouwanttomeasure

ReadAnalogSignalswithUSB-6008

Students:UsetheUSB-6008DAQdeviceinordertoreadthevoltagefromdifferentbatteries.UseaMultimeter tocheckifyoureadthecorrectvalues.Measure5-10differentbatteries.UseLabVIEWtofind theaverage.

Multimeter

Analog Input(AI)

SamplingTime

AnalogOut

Hans-PetterHalvorsen,M.Sc.

AO SettingsinDAQAssistantTypeofSignals

Channel

Properties

WriteAnalogSignalsusingUSB-6008

Students:CreatethisVI.SetdifferentvaluesontheFrontPanel.UseaMultimeter toseeiftheDAQdevicesendsout thecorrectvoltagesignal.

AnalogOutput(AO)Multimeter

AnalogIn+AnalogOut

Hans-PetterHalvorsen,M.Sc.

Write/ReadDatausingUSB-6008

Students:Createthese2VIsandrunthemsimultaneously

ConnectthecablesfromAnalogOutputtothecablesforAnalogInput(so-called “Loopback Test”)

AnalogOutput(AO)

Analog Input(AI)

AO SettingsinDAQAssistantTypeofSignals

Channel

Properties

AI SettingsinDAQAssistantProperties

Channel

TypeofSignals

AnalogIn+AnalogOutinsameVI

Students:CreatethisExample

Note!Herewehaveusedlow-levelfunctions forbetterperformance

Datalogging

Hans-PetterHalvorsen,M.Sc.

(Youmayskipthispart)

Datalogging

USB-6008I/OModule

PT-100TemperatureSensor

HerewewillconnectaPT-100TemperatureSensortotheUSB-6008deviceinordertologtemperaturedata.WewillplotdataandsavedatatoaFile.

PT-100Sensor

Transducer/Transmitter

PowerSupply

1-5V

Multimeter

PT-100TemperatureSensor

1-5V

1-5V->0-50degreesCelsius1-5V->0-100degreesCelsius

2different types(seetransducer):

PT-100TemperatureSensor

1-5V

PT-100TemperatureSensorConvertingfromVoltagetoDegreesCelsius

𝑦 = 𝑎𝑥 + 𝑏

𝑦 − 𝑦( =𝑦) − 𝑦(𝑥) − 𝑥(

𝑥 − 𝑥(

1𝑉 5𝑉0℃

100℃

𝑥(,𝑦( = (1,0)

𝑥),𝑦) = (5,100)

SaveDatatoFile(Datalogging)

Right-click-Properties

RecommendedSettings

DataloggingExample

Students: (1)LogTemperatureData,bothCelsiusandFahrenheit(useSubVI)toa“MeasurementFile”.(2)UseaMultimeterinordertocheckthevaluesinthecircuit.(3) ThenPlottheDataintheFileinExcel.(4) YoushouldalsocreateanewVIinLabVIEWwhereyouplotthedatafromtheFileinaGraph

DataloggingExample– BlockDiagram

MeasurementFilter

Hans-PetterHalvorsen,M.Sc.

(Youmayskipthispart)

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.

Asyoucanseethisgivesgoodresults.Thefilterremovesthenoisefromthesignal.

Students:TrythisExample.

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 thenightusinge.g,aTC-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:hans.p.halvorsen@hit.noBlog:http://home.hit.no/~hansha/