版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 脂肪肝营养干预配餐手册
- 黄瓜霜霉病药剂选用指南
- 器材设备维护保养指南
- 月嫂专业技能实操考核评分标准
- 油菜花后肥水管理技术方案
- 消防灭火实战演练实施方案
- 2026年中国功能性食品行业市场前景及投资研究报告:高质量发展
- 客户需求挖掘沟通技巧
- 环保设施在线监测系统管理
- 教育理论试题及解析
- 六年级语文下册期中复习 课件
- 病理性骨折的护理
- AIB(2022版)统一检查标准-前提方案与食品安全程序
- 桥梁墩身施工安全注意事项模版
- 激素调节身体多种机能 高二上学期生物浙科版选择性必修1
- 《工程伦理》课后习题及答案
- 地灾防治工程设计中应注意的问题
- GB/T 24356-2023测绘成果质量检查与验收
- 化工机械与设备专业人才培养方案
- 医学免疫学英文版课件:Complement system补体系统
- GB/T 629-1997化学试剂氢氧化钠
评论
0/150
提交评论