版權(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 大學(xué)教師手冊
- 第22課 偉大的悲劇-2022-2023學(xué)年七年級語文下冊同步講義(部編版)
- 三年級英語下冊 Unit 5 Do you like pears(The second period)第二課時教案 人教PEP
- 九年級歷史上冊 第12課 美國的誕生教案3 新人教版
- 廣東省東莞市寮步宏偉初級中學(xué)八年級地理上冊 第三章 第二節(jié) 土地資源教案 新人教版
- 八年級歷史下冊 第六學(xué)習(xí)主題 科技、教育與文化 第19課《百花爭艷的文藝園地》教案2 川教版
- 池河鎮(zhèn)七年級歷史下冊 第一單元 隋唐時期:繁榮與開放的時代 第1課 隋朝的統(tǒng)一與滅亡教案2 新人教版
- 2024秋一年級道德與法治上冊 第6課 課間十分鐘教案 粵教版
- 九年級歷史上冊 第22課《馬克思主義的誕生》教案 川教版
- 武昌租房合同模板
- 水輪發(fā)電機(jī)組基本概述PPT培訓(xùn)課件
- 安全防范系統(tǒng)的縱深防護(hù)體系
- 最新放射工作人員證申請表
- 住房公積金單位登記開戶申請表
- 文言文《伯牙鼓琴》說課稿及評課稿
- 公安筆錄模板之詢問嫌疑人(書面?zhèn)鲉局伟舶讣?
- leslie人口增長模型模型
- 土壓平衡盾構(gòu)隧道密閉鋼套筒始發(fā)施工工法
- 五年級上冊《用字母表示數(shù)》
- 建筑工地環(huán)境保護(hù)方案
- 高密度聚乙烯(hdpe)工字雙壁纏繞管室外排水管道工程技術(shù)規(guī)程_secret
評論
0/150
提交評論