Controlling measurement instruments via GPIB 通过GPIB控制仪器.docx
《Controlling measurement instruments via GPIB 通过GPIB控制仪器.docx》由会员分享,可在线阅读,更多相关《Controlling measurement instruments via GPIB 通过GPIB控制仪器.docx(22页珍藏版)》请在冰豆网上搜索。
![Controlling measurement instruments via GPIB 通过GPIB控制仪器.docx](https://file1.bdocx.com/fileroot1/2023-7/21/130dfd08-a843-427a-bf4c-0e8a1cb9d048/130dfd08-a843-427a-bf4c-0e8a1cb9d0481.gif)
ControllingmeasurementinstrumentsviaGPIB通过GPIB控制仪器
ControllingmeasurementinstrumentsviaGPIB
IntroductiontoGPIB
GPIB(GeneralPurposeInterfaceBus)isaninterfacestandardforconnectingcomputersandperipherals,whichsupportsthefollowinginternationalstandards:
IEEE488.1,IEC-625,IEEE488.2,andJIS-C1901.TheGPIBinterfaceallowsyoutocontrolvariousinstrumentsfromanexternalcomputer.ThecomputersendscommandsandinstructionstotheinstrumentsandreceivesdatasentfromtheinstrumentsviaGPIB.
Beforesettinguptheinstrumentforremotecommunicationsusingtheelectronic(physical)GPIBinterface,youshouldfamiliarizeyourselfwiththefollowingGPIBrequirements:
▪Auniquedeviceaddressmustbeassignedtoeachdeviceonthebus.
▪Notwodevicescansharethesamedeviceaddress.
▪Nomorethan15devicescanbeconnectedtoanyoneline.
▪Onedeviceshouldbeconnectedforevery6feet(2meters)ofcableused.
▪Nomorethan65feet(20meters)ofcableshouldbeusedtoconnectdevicestoabus.
▪Atleasttwo-thirdsofthedevicesonthenetworkshouldbepoweredonwhileusingthenetwork.
▪Connectthedevicesonthenetworkinastarorlinearconfiguration.Donotuselooporparallelconfigurations.
ThefollowingfigureillustratesatypicalGPIBinterfacesystem.
Figure1:
atypicalGPIBinterfacesystem
Ifnecessary,theGPIBconnectorscanbestackedasshowninthefollowingfigure:
Figure2:
stackofGPIBconnectors
IntroductiontoSCPI
SCPI(StandardCommandsforProgrammableInstruments)isaprogramminglanguageforcontrollinginstrumentfunctionsovertheGPIB(GeneralPurposeInterfaceBus,IEEE488)instrumentbus.SCPIisintendedtofunctionwithstandardGPIBhardwareandconformstotheIEEEStandardDigitalInterfaceforProgrammableInstrumentation.SCPIislayeredontopofthehardwareportionofIEEE488.2.
ThesameSCPIcommandsandparameterscontrolthesamefunctionsindifferentclassesofinstruments.Foreachinstrumentfunction,SCPIdefinesaspecificcommandset.TheadvantageofSCPIisthatprogramminganinstrumentisonlyfunctiondependentandnolongerinstrumentdependent.Severaldifferenttypesofinstruments,forexampleanoscilloscope,acounterandamultimeter,cancarryoutthesamefunction,suchasfrequencymeasurement.IftheseinstrumentsareSCPIcompatible,youcanusethesamecommandstomeasurethefrequencyonallthreeinstruments,althoughtheremaybedifferencesinaccuracy,resolution,speed,etc.
FunctionalityofaSCPIinstrument
ThefunctionsinsideaninstrumentthatcontroltheoperationprovideSCPIcompatibility.
Figure3showsasimplifiedlogicalmodelofthemessageflowinsideaSCPIinstrument.
WhenthecontrollersendsamessagetoaSCPIinstrument,roughlythefollowinghappens:
–TheGPIBcontrolleraddressestheinstrumentaslistener.
–TheGPIBinterfacefunctionplacesthemessageintheInputBuffer.
–TheParserfetchesthemessagefromtheInputBuffer,parses(decodes)themessage,andchecksforthecorrectsyntax.Theinstrumentreportsincorrectsyntaxbysendingcommanderrorsviathestatussystemtothecontroller.Moreover,theparserwilldetectifthecontrollerrequiresaresponse.Thisisthecasewhentheinputmessageisaquery(commandwitha“?
”appended).
TheParserwilltransfertheexecutablemessagestotheExecutionControlblockintokenform(internalcodes).TheExecutionControlblockwillgathertheinformationrequiredforadeviceactionandwillinitiatetherequestedtaskattheappropriatetime.TheinstrumentreportsexecutionerrorsviathestatussystemovertheGPIBandplacesthemintheErrorQueue.
–Whenthecontrolleraddressestheinstrumentastalker,theinstrumenttakesdatafromtheOutputQueueandsendsitovertheGPIBtothecontroller.
SCPIcommandsaresentasASCIIoutputstringswithintheprogramminglanguagestatements,theSCPIsyntaxisindependentofbothprogramminglanguageandinterface.
Figure3:
OverviewofthefirmwareinaSCPIinstrument
TypesofSCPICommands
SCPIhastwotypesofcommands,commonandsubsystem.
CommonCommands
Commoncommandsgenerallyarenotrelatedtospecificoperationbuttocontrollingoverallinstrumentfunctions,suchasreset,status,andsynchronization.Allcommoncommandsconsistofathree-lettermnemonicprecededbyanasterisk:
*RST*IDN?
*SRE8
Figure4:
CommonCommandsSyntaxDiagram
*Fordetails,referto“Agilent_DSA90604A_Infiniiumoscilloscope_programmingguide.pdf”,page26-33
SubsystemCommands
Subsystemcommandsperformspecificinstrumentfunctions.
SCPIisanASCII-basedinstrumentcommandlanguagedesignedfortestandmeasurementinstruments.SCPIcommandsarebasedonahierarchicalstructure,alsoknownasatreesystem.Inthissystem,associatedcommandsaregroupedtogetherunderacommonnodeorroot,thusformingsubsystems.Subsystemcommandsperformspecificpowersupplyfunctions.AportionoftheSOURcesubsystemisshownbelowtoillustratethetreesystem.
SOURceistherootkeywordofthecommand,CURRentisasecond-levelkeyword,LEVelandPROTectionarethird-levelkeywords,andIMMediate,TRIGgeredandSTATearefourth-levelkeywords.Colons(:
)separatehigher-levelfromlower-levelkeywords.
Figure5isatreediagramofthesubsystemcommandsforDCpowersupply6674A.Commandsfollowedbyaquestionmark(?
)takeonlythequeryform.Exceptasnotedinthesyntaxdescriptions,allothercommandstakeboththecommandandqueryform.Thecommandsarelistedinalphabeticalorderandthecommandswithineachsubsystemaregroupedalphabeticallyunderthesubsystem.
Figure5:
SubsystemCommandsTreeDiagram
StructureofaSCPIMessage
SCPImessagesconsistofoneormoremessageunitsendinginamessageterminator.Theterminatorisnotpartofthesyntax,butimplicitinthewayyourprogramminglanguageindicatestheendofaline(suchasanewlineorend-of-linecharacter).
TheMessageUnit
ThesimplestSCPIcommandisasinglemessageunitconsistingofacommandheader(orkeyword)followedbyamessageterminator.
ABOR
VOLT?
Themessageunitmayincludeaparameteraftertheheader.Theparameterusuallyisnumeric,butitcanbeastring:
VOLT20
VOLTMAX
CombiningMessageUnits
Thefollowingcommandmessage(seeFigure6)isbrieflydescribedhere,withmoredetailsinsubsequentparagraphs.
VOLT:
LEV4.5;PROT4.8;:
CURR?
Figure6:
CommandMessageStructure
ThebasicpartsofthemessageinFigure6are:
MessageComponentExample
HeadersVOLTLEVPROTCURR
HeaderSeparatorThecoloninVOLT:
LEV
Data4.54.8
DataSeparatorThespaceinVOLT4.5andPROT4.8
MessageUnitsVOLT:
LEV4.5PROT4.8CURR?
MessageUnitSeparatorThesemicolonsinVOLT:
LEV4.5;andPROT4.8;
RootSpecifierThecoloninPROT4.8;:
CURR?
QueryIndicatorThequestionmarkinCURR?
MessageTerminatorThe(newline)indicator.Terminatorsarenot
partoftheSCPIsyntax.
GPIBsettingandSCPIcommandsforinstruments
GPIBAddressSettingforinstruments
FortheGPIBinterface,messagesareplacedonthebususinganoutputcommandandpassingthedeviceaddress,programmessage,andaterminator.PassingthedeviceaddressensuresthattheprogrammessageissenttothecorrectGPIBinterfaceandGPIBdevice.
ProcessforsettingGPIBaddressforinstrumentsis:
Oscilloscope
−TectronixDSA73304D
oThedefaultsettingsfortheGPIBconfigurationare:
GPIBAddress1.
oTochangeeitheroftheGPIBsettings,dothefollowing:
SelectGPIBConfigurationfromtheUtilitiesmenuonfrontpanel.
−AgilentDSA90604A
oDeviceAddress=(InterfaceSelectCode*100)+OscilloscopeAddress
oEachinterfacecardhasauniqueinterfaceselectcode.Thiscodeisusedbythecomputertodirectcommandsandcommunicationstotheproperinterface.Thedefaultistypically"7"fortheGPIBinterfacecards
oEachoscilloscopeontheGPIBmusthaveauniqueoscilloscopeaddressbetweendecimal0and30.Thisoscilloscopeaddressisusedbythecomputertodirectcommandsandcommunicationstotheproperoscilloscopeonaninterface.Thedefaultistypically"7"forthisoscilloscope.YoucanchangetheoscilloscopeaddressintheUtilities,RemoteInterfacedialogbox.
oDoNotUseAddress21foranOscilloscopeAddress,Address21isusuallyreservedfortheComputerinterfaceTalk/Listenaddress,andshouldnotbeusedasanoscilloscopeaddress.
Signalsourceanalyzer
−AgilentE5052B
oPressSystem>MiscSetup>GPIBSetup>Talker/ListenerAddress.
oEntertheaddressusingtheENTRYblockkeysonthefrontpanel.
DCpowersupply
−AgilentN5745A
oThepowersupplyisshippedwithitsGPIBaddresssetto5.UsethefrontpanelmenuifyouneedtochangetheGPIBaddress.
aPressandholdtheOCP/488buttonforaboutthreeseconds.TheDCVOLTSdisplaywillshowthepresentGPIBaddress.
bTochangetheGPIBaddress,turnthevoltageknobuntilthedesiredGPIBaddressappearsinthedisplay.ValidGPIBaddressesareintherangeof0to30.
−HPAgilent6674A(HPIB)
oThepowersupplyaddresscannotbesetremotely;itmustbesetfromthefrontpanel.Oncetheaddressisset,youcanassignitinsideprograms.
oUsetheADDRESSkeyandnumericalkeypadforenteringaddresses.Thepowersupplyisshippedwitha5stand-aloneaddressasthedefault.Thegeneralprocedureforsettinganaddressis:
Frequencycalibrator/analyzer
−PendulumCNT-91R
oTheaddressofthecounterissetto10whenitisdelivered
oSetGPIBAddressviathefrontpanelUSEROPTmenu
onumberbetween0and30
Warmbox
−VotschWEISSTECHNIKC7-600
oNOTAVEAIIBLE!
!
oUseGPIB-RS232converter(forexampleFT7130GPIB-RS232)
SCPICommandsforinstruments
Osc