Data Translation DAQ Adaptor for MATLAB 適用于 MATLAB 的數(shù)據(jù)轉(zhuǎn)換 DAQ 適配器_第1頁
Data Translation DAQ Adaptor for MATLAB 適用于 MATLAB 的數(shù)據(jù)轉(zhuǎn)換 DAQ 適配器_第2頁
Data Translation DAQ Adaptor for MATLAB 適用于 MATLAB 的數(shù)據(jù)轉(zhuǎn)換 DAQ 適配器_第3頁
Data Translation DAQ Adaptor for MATLAB 適用于 MATLAB 的數(shù)據(jù)轉(zhuǎn)換 DAQ 適配器_第4頁
Data Translation DAQ Adaptor for MATLAB 適用于 MATLAB 的數(shù)據(jù)轉(zhuǎn)換 DAQ 適配器_第5頁
已閱讀5頁,還剩57頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

UM-22024-N

DataTranslation

DAQAdaptorforMATLAB?

TrademarkandCopyrightInformation

MeasurementComputingCorporation,InstaCal,UniversalLibrary,andtheMeasurementComputinglogoareeithertrademarksorregisteredtrademarksofMeasurementComputingCorporation.RefertotheCopyrights&Trademarkssectionon

/lega

lformoreinformationaboutMeasurementComputingtrademarks.

Otherproductandcompanynamesmentionedhereinaretrademarksortradenamesoftheirrespectivecompanies.

?2016MeasurementComputingCorporation.Allrightsreserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmitted,inanyformbyanymeans,electronic,mechanical,byphotocopying,recording,orotherwisewithoutthepriorwrittenpermissionofMeasurementComputingCorporation.

Notice

MeasurementComputingCorporationdoesnotauthorizeanyMeasurementComputingCorporationproductforuseinlifesupportsystemsand/ordeviceswithoutpriorwrittenconsentfromMeasurementComputingCorporation.Lifesupportdevices/systemsaredevicesorsystemsthat,a)areintendedforsurgicalimplantationintothebody,orb)supportorsustainlifeandwhosefailuretoperformcanbereasonablyexpectedtoresultininjury.MeasurementComputingCorporationproductsarenotdesignedwiththecomponentsrequired,andarenotsubjecttothetestingrequiredtoensurealevelofreliabilitysuitableforthetreatmentanddiagnosisofpeople.

PAGE

11

PAGE

4

TableofContents

AboutthisManual 5

IntendedAudience 5

HowthisManualisOrganized 5

ConventionsUsedinthisManual 5

WhereToGetHelp 5

Chapter1:Overview 7

Overview 8

Session-BasedorLegacyInterface 9

RelatedInformation 10

Chapter2:Session-BasedDAQAdaptorforMATLAB 11

Overview 12

Requirements 13

Installation 14

HardwareDiscoveryandSessionSetup 15

AnalogInputOperations 16

AnalogInputChannelFunctions,Events,andProperties 16

SettingupanAnalogInputOperation 17

AddingOtherChannelsintheAnalogInputStream 19

PerformingaSingle-ValueInputOperation 20

PerformingaForegroundAcquisition 20

PerformingaBackgroundAcquisition 21

TriggeringAnalogInputOperations 22

AnalogOutputOperations 24

AnalogOutputChannelFunctions,Events,andProperties 24

SettingupanAnalogOutputOperation 24

AddingaDigitalOutputPortintheAnalogOutputStream 26

PerformingaSingle-ValueOutputOperation 27

PerformingaForegroundOutputOperation 27

PerformingaBackgroundOutputOperation 28

TriggeringAnalogOutputOperations 29

AnalogInputandOutputOperationsattheSameTime 31

PerformingI/OOperationsattheSameTimeintheForeground 31

PerformingI/OOperationsattheSameTimeintheBackground 32

DigitalI/OOperations 34

PerformingDigitalInputOperations 34

PerformingaDigitalOutputOperation 34

Chapter3:LegacyDAQAdaptorforMATLAB 35

Requirements 36

Installation 37

SettingupanI/OOperation 38

AnalogInputandOutputSubsystemProperties 39

SettingtheInputType 40

SettingtheSynchronizationMode 40

SettingtheFilterType 40

ChannelProperties 41

ConfiguringaChannelforaVoltageInput 43

ConfiguringaChannelforaCurrentMeasurement 44

ConfiguringaChannelforanIEPE(Accelerometer)Input 44

ConfiguringaChannelforaThermocoupleInput 45

ConfiguringaChannelforanRTDInput 45

RTDSupportforMEASURpointInstruments 45

RTDSupportfortheDT9829andOtherDT-OpenLayersDevices 46

ConfiguringaChannelforaThermistorInput 48

ConfiguringaChannelforaResistanceMeasurement 49

ConfiguringaChannelforaStrainGageInput 49

ConfiguringaChannelforaBridge-BasedSensor 50

ConfiguringtheGainofaChannel 50

UtilityMethodsinMATLAB 51

olDaReadBridgeSensorVirtualTeds 51

olDaReadStrainGageVirtualTeds 53

VoltstoMicroStrain 55

VoltstoBridgeBasedSensor 56

MATLABPropertyNotes 57

MultipleSubsystemsofaSingleType 57

AnalogOutputOperationNotes 58

UsingHardwareTriggers 58

Index

59

AboutthisManual

ThismanualdescribeshowtousetheDataTranslationDAQAdaptorforMATLABtoprogramDataTranslationDT-OpenLayersdevicesusingMATLAB?fromtheMathworks.

IntendedAudience

Thisdocumentisintendedforengineers,scientists,technicians,orothersresponsibleforusingand/orprogrammingDT-OpenLayers-compliantdevicesusingMATLAB.Itisassumedthatyouhavesomefamiliaritywithdataacquisitionprinciplesandthatyouunderstandyourapplication.

HowthisManualisOrganized

Themanualisorganizedasfollows:

Chapter1

,

“Overview,”

describestheDataTranslationDAQAdaptorforMATLAB,describesthesession-basedandlegacyinterfacesoftheDAQAdaptorforMATLAB,andprovidesreferencestorelatedinformation.

Chapter2

,

“Session-BasedDAQAdaptorforMATLAB,”

describesthesession-basedDataTranslationDAQAdaptorforMATLAB.

Chapter3

,

“LegacyDAQAdaptorforMATLAB,”

describesthelegacyDataTranslationDAQAdaptorforMATLAB.

ConventionsUsedinthisManual

Thefollowingconventionsareusedinthismanual:

Notesprovideusefulinformationorinformationthatrequiresspecialemphasis,cautionsprovideinformationtohelpyouavoidlosingdataordamagingyourequipment,andwarningsprovideinformationtohelpyouavoidcatastrophicdamagetoyourselforyourequipment.

Codesnippetsareshownincourier.

WhereToGetHelp

ShouldyourunintoproblemsinstallingorusingtheDataTranslationDAQAdaptorforMATLAB,theDataTranslationTechnicalSupportDepartmentisavailabletoprovidetechnicalassistance.RefertotheDataTranslationwebsite()orcall

508-946-5100.IfyouareoutsidetheUnitedStatesorCanada,callyourlocaldistributor,whosenumberislistedonourwebsite().

AboutthisManual

PAGE

6

PAGE

7

1

Overview

Overview

8

Session-BasedorLegacyInterface

9

RelatedInformation

10

Chapter1

PAGE

10

PAGE

9

Overview

TheDataTranslationDAQAdaptorforMATLABprovidesaninterfacebetweenMATLABandtheDataAcquisitionToolboxandDataTranslation’sDT-OpenLayersarchitecture.

Figure

1

showsthedataflowmodelusingtheDataTranslationDAQAdaptorforMATLAB.

DataTranslationDriversandModules

DataTranslationDT-OpenLayersAPI

DataTranslationDAQAdaptorforMATLAB

DataAcquisitionToolbox

MATLAB

DataFlow

Control

Figure1:DataFlowModelUsingtheDataTranslationDAQAdaptorforMATLAB

DT-OpenLayersprovidesaninterfacetoallofDataTranslation’sanaloganddigitalI/Odataacquisitionhardwaremodules.ByusingtheDataTranslationDAQAdaptorforMATLABwithMATLABandtheDataAcquisitionToolbox,youcanacquiredatafromDataTranslationmodulesdirectlywithinMATLABandthenuseallofMATLAB’sfeaturestoanalyzeanddisplaythedata.

Session-BasedorLegacyInterface

Overview

DataTranslationprovidesbotha64-bitsession-basedinterfaceanda32-bitlegacyinterfaceoftheDAQAdaptorforMATLAB.

Ifwanttousea64-bitversionofMATLAB(releaseR2016aorgreaterofMATLAB),youneedthesession-basedDAQAdaptorforMATLAB.

ForallpreviousversionsofMATLAB(32-bit),youneedthelegacyDAQAdaptorforMATLAB.

Bothinterfacesaredescribedinthismanual.

Chapter1

PAGE

10

PAGE

11

RelatedInformation

RefertoyourMATLABdocumentation,includingdocumentationfortheDataAcquisitiontoolbox,andtheuser’smanualsforyourDataTranslationmodules.FormoreinformationonDT-OpenLayers,refertofollowingdocumentsfromDataTranslation:

OnlinehelpfortheDataAcquisitionToolboxforMATLAB:

/help/daq

DataAcqSDKUser’sManual(UM-18326).ForprogrammerswhoaredevelopingtheirownapplicationprogramsusingtheMicrosoftCcompiler,thismanualdescribeshowtousetheDT-OpenLayersTMDataAcqSDKTMtoaccessthecapabilitiesofDataTranslationdataacquisitiondevices.

DT-OpenLayersfor.NETUser’sManual(UM-22161).ForprogrammerswhoaredevelopingtheirownapplicationprogramsusingVisualC#orVisualBasic.NET,thismanualdescribeshowtousetheDT-OpenLayersfor.NETClassLibrarytoaccessthecapabilitiesofDataTranslationdataacquisitiondevices.

2

Session-BasedDAQAdaptorfor

MATLAB

Overview

12

Requirements

13

Installation

14

HardwareDiscoveryandSessionSetup

15

AnalogInputOperations

16

AnalogOutputOperations

24

AnalogInputandOutputOperationsattheSameTime

31

DigitalI/OOperations

34

Chapter2

Session-BasedDAQAdaptorforMATLAB

PAGE

12

PAGE

13

Overview

DataTranslation’ssession-basedDAQAdaptorforMATLABsupportsanaloganddigitalI/OoperationsonDataTranslationDT-OpenLayers-compliantmodules.

Note:ForDataTranslationmodulesonly,ifyourdevicesupportsdigitalinput,tachometer,orcounteroperationsintheanaloginputstream,youcanreadthevalueofthedigitalinputport,tachometer,orcounterchannelthroughthespecifiedanaloginputsubsystemusingthesession-basedDAQAdaptorforMATLAB.

Similarly,ifyourDataTranslationdevicesupportsdigitaloutputoperationsintheanalogoutputstream,youcanupdatethevalueofthedigitaloutputportthroughthespecifiedanalogoutputsubsystemusingthesession-basedDAQAdaptorforMATLAB.

MEASURpointinstrumentsarenotsupportedusingthesession-basedDAQAdaptorforMATLAB.

Requirements

Youmustinstallthefollowingbeforeinstallingthesession-basedDAQAdaptorforMATLAB:

YourDataTranslationhardwaremodule(s)andtheirdrivers(fromtheDataAcquisitionOMNICDthatshipswithyourhardware)

A64-bitversionofMATLAB-VersionR2016aorhigher

DataAcquisitionToolboxVersion3.9orhigher

InstallDataTranslationcomponentsfromarecentOMNICD,ordownloadthesoftwarefromourwebsite().ContactTheMathWorksforupdatestoyourMATLABcomponents.

Installation

Youcaninstallthesession-basedDAQAdaptorforMATLABoneofthefollowingways:

FromtheDataTranslationwebsite:

NavigatetothefollowingwebpagefortheDataTranslationDAQAdaptorforMATLAB:

/Products/Data-Acquisition-Software/MATLAB-Data-

Acquisition

ClicktheDownloadtab.

ClickFreeDownload.

ClickSession-BasedDAQAdaptorforMATLAB,andthenclickDownload.

ThefileDataTranslationDataAcquisitionToolbox.mltbxisdownloadedtoyourcomputer.

Onceitisdownloaded,right-clickonthefileDataTranslationDataAcquisitionToolbox.mltbx,andclickInstall.

TheInstallDataTranslationDataAcquisitionToolboxdialogappears.

ClickInstall.

TheDataTranslationDAQAdaptorforMATLABisinstalled.

FromwithinMATLAB:

ClickAdd-Ons.

TheAdd-OnsExplorerappears.

SearchforDataTranslation.

ClickSession-BasedDAQAdaptorforMATLAB.

ClickAdd,andselectAddtoMATLAB.

TheDataTranslationDAQAdaptorforMATLABisinstalled.

FromtheMATLABCentralwebsite:

NavigatetotheMATLABCentralmainpage:

/matlabcentral/?s_tid=srchtitle

SearchforDataTranslation.

ClickSession-BasedDAQAdaptorforMATLAB.

ClickDownloadZip.

ThefileDataTranslationDataAcquisitionToolbox.mltbxandthePDFfilethatcontainsthedocumentationaredownloadedtoyourcomputer.

Oncedownloadedandunzipped,right-clickonthefileDataTranslationDataAcquisitionToolbox.mltbx,andclickInstall.

TheInstallDataTranslationDataAcquisitionToolboxdialogappears.

ClickInstall.

TheDataTranslationDAQAdaptorforMATLABisinstalled.

HardwareDiscoveryandSessionSetup

Refertothefollowingwebpageforinformationonthefunctionsandpropertiesthatareavailableforhardwarediscoveryandsessionsetup:

/help/daq/hardware-discovery-and-session-setup.html

NotethattocreateadataacquisitionsessionforDataTranslationdevices,usethe

daq.createSessionfunctionandspecify'dt'asthevendorname.

AnalogInputOperations

ThissectiondescribesinformationaboutperforminganaloginputoperationsusingtheMATLABsession-basedinterface.

AnalogInputChannelFunctions,Events,andProperties

Refertothefollowingwebpageforinformationonthefunctions,events,andpropertiesforsettingupanaloginputchannels:

/help/daq/analog-data-acquisition.html

ForDataTranslationdevices,notethefollowingdifferences:

TerminalConfig–ForDataTranslationdevices,theterminalconfiguration(SingleEndedorDifferential)appliestoallthechannelsoftheanaloginputsubsystem.Therefore,youcannotspecifyonechannelasSingleEndedandanotherchannelasDifferentialforthesamesubsystem.

Range–GainsarenotspecifiedinMATLAB.Therefore,whenspecifyingtheinputrangeforananaloginputchannelonaDataTranslationdevice,youmustspecifytheeffectiveinputrangethatyoudesire.Forexample,assumethatyourdevicesupportsaninputrangeof±10Vandagainof1,whichyieldsaneffectiveinputrangeof±10V,andagainof2,whichprovidesaneffectiveinputrangeof±5V.FortheRangeproperty,specifyeither–10Vto+10Vor–5Vto+5Vforthechannel.

Somedevicesalsoallowyoutoreadthevalueofotherinputchannels,suchasthedigitalinputport,tachometer,orcounters,throughtheanaloginputstream.Forthesedevices,arangeappropriatetothatchanneltype,suchas0to65535forthedigitalinputport,isprovided.Inthesecases,theinputrangeappliesonlytothespecifiedchanneltype.

MeasurementType–Currently,'Voltage'(input)and'IEPE'(input)measurementtypesareavailableforDataTranslationdevicesthatsupportthesecapabilities.

SettingupanAnalogInputOperation

ThissectionshowsanexampleofsettingupananaloginputoperationforaDataTranslationdeviceusingthesession-basedDAQAdaptorforMATLAB:

Discoverconnecteddevicesusingthedaq.getDevicesfunction.Inthefollowingexample,thesystemhasseveraldevicesinstalled,includingtheDataTranslationDT9837Bdevice.TheDT9837BdevicehastheID'DT9837-B(01)',whichissetintheOpenLayersControlPanel(seethedocumentationforyourhardwareformoreinformationontheOpenLayersControlPanel):

devs=daq.getDevicesans=

Dataacquisitiondevices:

indexVendorDeviceID Description

1

ni

Dev1

National

Instruments

USB-9201

2

ni

Dev2

National

Instruments

USB-9234

3

ni

Dev4

National

Instruments

USB-4431

4

ni

Dev5

National

Instruments

USB-9265

5directsound

Audio0

DirectSoundPrimarySoundCaptureDriver

6directsound

Audio1

DirectSoundMicrophone(RealtekHighDefinitionAudio)

7directsound

Audio2

DirectSoundPrimarySoundDriver

8directsound

Audio3

DirectSoundSpeaker/HPRealtekHighDefinitionAudio)

9

dt

DT9837-B(01)DataTranslationDT9837-B(01)

Togetinformationaboutthedevice,clickthedeviceIDorspecifytheindexofthedevicetoquery.Forexample,togetinformationabouttheDataTranslationdevicewithindex9,usethefollowingcommand:

devs(9)

Thefollowinginformationisreturned:

dt.DataTranslationDT9837-B(01)(DeviceID:'DT9837-B(01)')Analoginputsubsystemsupports:

-10to+10Volts,-1.0to+1.0Voltsranges

Ratesfrom195.3to105469.0scans/sec

7channels('0'-'6')'Voltage'measurementtype

CreateasessionforDataTranslationdevicesusingthedaq.createSessionfunction,specifying'dt'asthevendorname.Anexamplefollows;thedefaultnumberofscansandtheacquisitiondurationareshown:

s=daq.createSession('dt')s

s=

DataacquisitionsessionusingDataTranslationhardware:Willrunfor1second(1000scans)at1000.116scans/second.Nochannelshavebeenadded.

Bydefault,theacquisitionisconfiguredtorunforadurationof1secondtoacquire1000scans;forthisdevice,thedefaultrateis1000.116scanspersecond.

Configurethesession,asneeded,usingthefollowingproperties:NumberofScans,DurationinSeconds,Rate,orIsContinuous.Thefollowingexamplesetsthedurationoftheacquisitionto10seconds:

s.DurationInSeconds=10;s

s=

DataacquisitionsessionusingDataTranslationhardware:

Willrunfor10seconds(10000scans)at1000.116scans/second.Nochannelshavebeenadded.

AddanaloginputchannelstothesessionusingtheaddAnalogInputChannelfunction.Thefollowingexampleaddsanaloginputchannels0and1oftheDT9837-B(01)devicetothesession;notethatthesechannelsareconfiguredfortheIEPEmeasurementtype:

ch0=s.addAnalogInputChannel('DT9837-B(01)','0','IEPE');ch1=s.addAnalogInputChannel('DT9837-B(01)','1','IEPE');s

s=

DataacquisitionsessionusingDataTranslationhardware:Willrunfor10seconds(10000scans)at1000.116scans/second.

Numberofchannels:2

indexTypeDevice ChannelMeasurementTypeRange Name

1

ai

DT9837-B(01)

0

IEPE(Diff) -10to+10

Volts

2

ai

DT9837-B(01)

1

IEPE(Diff) -10to+10

Volts

Note:Ifdesired,youcanaddanaloginputandanalogoutputchannelsfromoneormultipledevicesinthesamesession.

Configuretheanaloginputchannels,asneeded,usingthefollowingproperties:Range,TerminalConfig,ID,Coupling,ExcitationCurrent,and/orExcitationSource.

ThefollowingexampleconfiguresIEPEinputsforanaloginputchannel0(chindex1)andanaloginputchannel1(chindex2)ofthe'DT9837-B(01)'device.Channel0isconfiguredforACcouplingandaninternalexcitationcurrentvalueof4mA.Channel1isconfiguredforDCcouplingandnoexcitationsourceisused:

ch0.Range=[-1010];ch0.TerminalConfig='SingleEnded';ch0.Coupling='AC';ch0.ExcitationCurrentSource='Internal';ch0.ExcitationCurrent=0.004;

ch1.Range=[-1010];ch1.TerminalConfig='SingleEnded';ch1.Coupling='DC';ch1.ExcitationCurrentSource='None';

AddingOtherChannelsintheAnalogInputStream

IfyourDataTranslationdevicesupportsreadingthetachometer,digitalinputport,orcounterthroughtheanaloginputstream,youcanaddtheseaschannelsusingtheaddAnalogInputChannelfunction.Notethatyoumustspecify'Voltage'asthemeasurementtypeusingtheaddAnalogInputChannelfunction;however,inthesecases,thevalueistreatedasarawnumberratherthanavoltage.

Refertotheuser’smanualforyourdevicetodeterminewhetherotherchannelscanbeaddedtotheanaloginputstreamaswellastheircorrespondingchannelnumbers.

Thefollowingexampleaddsthetachometer(channel4)oftheDT9837BdevicewithdeviceID

'DT9837-B(01)'totheanaloginputstream:

ch=s.addAnalogInputChannel('DT9837-B(01)','4','Voltage');

Getinformationaboutthechannel:

chans=

Dataacquisitionanaloginputvoltage'4'ondevice'DT9837-B(01)'TerminalConfig:Differential

Range:0to4294967295Name:"

Device:[1x1daq.dt.DeviceInfo]MeasurementType:'Tachometer'

Notethattherangeforthechanneldependsonthechanneltype.Forexample,therangefora16-bitdigitalinputportis0to65535.Thevaluethatisreturnedrepresentsthevalueofthechannel,sointhisexample,ifthefirsteightbitsaresetto1andtheotherbitsaresetto0,thenavalueof255wouldbereturnedforthischannel.

Notethatifyouaddtheanaloginputchannelsaswellasotherchannelstotheinputstream,thespecifiedvoltagerangeisusedfortheanaloginputchannelsonly.

PerformingaSingle-ValueInputOperation

YoucanacquireasingleanaloginputvalueusingtheinputSingleScanfunction.ThefollowingexampleshowshowtoacquireasingleanaloginputvalueforaData

Translationdeviceusingthesession-basedDAQAdaptorforMATLAB.ADataTranslation

DT9837BdevicewithdeviceID'DT9837-B(01)'isusedinthisexample:

Createasession:

s=daq.createSession('dt');

Addanaloginputchannels0and1tothesession:s.addAnalogInputChannel('DT9837-B(01)','0','Voltage');s.addAnalogInputChannel('DT9837-B(01)','1','Voltage');

Acquireananaloginputvalueforeachinputchannelthatwasadded:

data=inputSingleScan(s);

Onevalueisacquiredforeachanaloginputchannelandtheoperationstops.

Readtheacquireddata.Inthisexample,thevalue–0.1495Visacquiredfromanaloginputchannel0and0.8643Visacquiredfromanaloginputchannel1.

data=

-0.1495 0.8643

PerformingaForegroundAcquisition

Whenyouperformananaloginputoperationintheforeground,theoperationblocksMATLABuntiltheoperationiscomplete.Therefore,nootherMATLABcommandscanbeuseduntiltheoperationcompletes.

Thefollowingexampleshowshowtostartananaloginputoperationintheforeground.ADataTranslationDT9837BdevicewithdeviceID'DT9837-B(01)'isusedinthisexample:

Createasessionandaddanaloginputchannel0tothesession:

s=daq.createSession('dt');

Addanaloginputchannel0tothesession:

s.addAnalogInputChannel('DT9837-B(01)',0,'IEPE');

Setthesamplerateto10kHz:

s.Rate=10000;

Setthechannel'sExcitationCurrentto4mA:

s.Channels(1).ExcitationCurrent=.004;

Starttheanaloginputsessionintheforegroundandsavethedataandtheacquisitiontimeinthevariables[data,time]:

[data,time]=startForeground(s);

Plotthedata:

plot(time,data);

Whenyouarefinishedwiththeoperation,deletethesession:

delete(s);

PerformingaBackgroundAcquisition

Whenyouperformananaloginputoperationinthebackground,otherMATLABcommandscanbeexecutedwhiletheanaloginputoperationisinprogress.MATLABisnotblocked.Abackgroundacquisitiondependsoneventsandlistenerstoallowyourcodetoaccessdataasthehardwareacquiresitandtoreacttoanyerrorsastheyoccur.

Refertothefollowingwebpageformoreinformationoneventsandlistenersinbackgroundoperations:

/help/matlab/matlab_oop/events-and-listeners--c

oncepts.html

Tostartananaloginputoperationinthebackground,usethestartBackgroundcommand.UsetheDataAvailableeventtodeterminewhentheacquireddataisavailable.

Note:BydefaulttheDataAvailableeventfireswhen1/10secondworthofdataisavailableforanalysis.IfyouwanttochangethefrequencyofwhentheDataAvailableeventisfired,setIsNotifyWhenDataAvailableExceedsAutotofalse,andmodifythevalueofNotifyWhenDataAvailableExceedsasdesired.RefertoyourMATLABdocumentationformoreinformation.

Listenersexecuteacallbackfunctionwhennotifiedthattheeventhasoccurred.Use

Session.addlistenertocreatealistenerobjectthatexecutesyourcallbackfunction.

Bydefault,theIsContinuouspropertyissettoFalseandtheoperationstopsautomatically.Ifyouhaveacontinuousoperation,setIsContinuoustoTrueandusestopwhenyouwanttostopthebackgroundoperation.

Ifdesired,youcanusewaittoblockMATLABexecutionuntilthebackgroundoperationiscomplete.

ThisexampleshowshowtoacquiredatafromaDataTranslationDT9837BdevicewithdeviceID'DT9837-B(01)'inthebackgroundusingeventsandlisteners:

CreateanDataTranslationsessionobject:

s=daq.createSession('dt');

Addanaloginput0tothesession:

addAnalogInputChannel(s,'DT9837-B(01)','0','Voltage');

AddthelistenerfortheDataAvailableeventandassignittothevariablelh:

lh=addlistener(s,'DataAvailable',@plotData);

CreateasimplecallbackfunctiontoplottheacquireddataandsaveitasplotData.minyourworkingdirectory:

functionplotData(src,event)plot(event.TimeStamps,event.Data)

end

Here,srcisthesessionobjectforthelistenerandeventisadaq.DataAvailableInfoobjectthatcontainsthedataandassociatedtiminginformation.

StartacontinuousbackgroundoperationandseetheplotupdatewhileMATLABisrunning:

s.IsContinuous=true;startBackground(s);

Whenyouarefinishedacquiringdata,stoptheoperation:

s.stop();

Deletethelistener:

delete(lh);

Whenyouarefinishedwiththeoperation,deletethesession:

delete(s);

TriggeringAnalogInputOperations

Note:RefertothefollowingwebpageforinformationonthefunctionsandpropertiesforsettinguptriggersusingMATLAB:

/help/daq/simultaneous-and-synchronized-operations.html

YoucantriggeranaloginputoperationsbasedonanexternaleventifyourDataTranslationdevicesupportsanexternalTTLtriggerfortheanaloginputsubsystem.Refertotheuser’smanualforyourdevicetodetermineitssupportedcapabilities.

TospecifyanexternalTTLtriggeronaDataTranslationdevice,usetheMATLAB

addTriggerConnectionfunction,andspecifythefollowingparameters:

Forthetriggersource,specify'external'.

Forthetriggerdestination,specify'deviceID/EXT_TTL_AI_TRIG',wheredeviceIDistheIDofyourdeviceasdefinedintheOpenLayersControlPanel.SeethedocumentationforyourhardwareformoreinformationonpinassignmentsandtheOpenLayersControlPanel.

Forthetriggertype,specify'StartTrigger'.

Onceyouhavesetupthetriggerconnection,usetheTriggerConditionpropertytosetthetriggerconditionto'RisingEdge'or'FallingEdge'.

ThefollowingexampleshowshowtotriggerananaloginputoperationonaDT9837BdevicewithdeviceID'DT9837-B(01)'usingasignalconnectedtotheexternalTTLtriggerinputonthedevice:

Createasessionandaddtwoanaloginputchannels:

s=daq.createSession('dt');

ch=addAnalogInputChannel(s,'DT9837-B(01)',0:1,'Voltage');

Configuretheterminalconfigurationandrangeofthechannelsinthesession:

ch(1).TerminalConfig='SingleEnded';ch(1).Range=[-10.010.0];

ch(2).TerminalConfig='SingleEnded';ch(2).Range=[-10.010.0];

Createanexternaltriggerconnectionandspecifythatarising-edgetriggerwilltriggeracquisition:

addTriggerConnection(s,'external','DT9837-B(01)/EXT_TTL_AI_TRIG','StartTrigger');

s.Connections(1).TriggerCondition='RisingEdge';

Settherateandthedurationoftheacquisition:

s.Rate=50000;

s.DurationInSeconds=0.01;

Setuptheforegroundoperation:[data,timestamps]=startForeground(s);plot(timestamps,data);

Whentherising-edgetriggerisdetectedontheexternalTTLtriggerinputpinontheDT9837-B(01)device,analoginputdataisacquiredandplottedintheforeground.

AnalogOutputOperations

ThissectiondescribesinformationaboutperforminganalogoutputoperationsusingtheMATLABsession-basedinterface.

AnalogOutputChannelFunctions,Events,andProperties

Refertothefollowingwebpageforinformationonthefunctions,events,andpropertiesforsettingupanaloginputchannels:

/help/daq/analog-signal-generation.html

ForDataTranslationdevices,notethefollowingdifferences:

TerminalConfig–ForDataTranslationdevices,thetermi

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論