Instrument Control Toolbox
Total Page:16
File Type:pdf, Size:1020Kb
Instrument Control Toolbox For Use with MATLAB® Computation Visualization Programming User’s Guide Version 1 How to Contact The MathWorks: 508-647-7000 Phone 508-647-7001 Fax The MathWorks, Inc. Mail 3AppleHillDrive Natick, MA 01760-2098 http://www.mathworks.com Web ftp.mathworks.com Anonymous FTP server comp.soft-sys.matlab Newsgroup [email protected] Technical support [email protected] Product enhancement suggestions [email protected] Bug reports [email protected] Documentation error reports [email protected] Subscribing user registration [email protected] Order status, license renewals, passcodes [email protected] Sales, pricing, and general information Instrument Control Toolbox User’s Guide COPYRIGHT 2000 by The MathWorks, Inc. The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or repro- duced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by or for the federal government of the United States. By accepting delivery of the Program, the government hereby agrees that this software qualifies as "commercial" computer software within the meaning of FAR Part 12.212, DFARS Part 227.7202-1, DFARS Part 227.7202-3, DFARS Part 252.227-7013, and DFARS Part 252.227-7014. The terms and conditions of The MathWorks, Inc. Software License Agreement shall pertain to the government’s use and disclosure of the Program and Documentation, and shall supersede any conflicting contractual terms or conditions. If this license fails to meet the government’s minimum needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to MathWorks. MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks, and Target Language Compiler is a trademark of The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective holders. Printing History: November 2000 First printing New for Version 1 (Release 12) Contents Preface What Is the Instrument Control Toolbox? ................xii ExploringtheToolbox..................................xii Related Products ..................................... xiii SystemRequirements................................. xiii AssociatedProducts................................... xiii Using This Guide ...................................... xv ExpectedBackground.................................. xv LearningtheInstrumentControlToolbox.................. xv HowThisGuideIsOrganized........................... xvi Installation Information .............................. xvii ToolboxInstallation.................................. xvii Hardware and Driver Installation . ................. xvii Typographical Conventions .......................... xviii Getting Started 1 Toolbox Components .................................. 1-2 M-FileFunctions..................................... 1-3 TheInterfaceDriverAdaptor........................... 1-4 Communicating with Your Instrument ................. 1-5 Communicating with a GPIB Instrument . 1-5 Communicating with a GPIB-VXI Instrument . 1-6 Communicating with a Serial Port Instrument . 1-7 i Understanding the Toolbox Capabilities ................ 1-9 TheContentsM-File .................................. 1-9 DocumentationExamples.............................. 1-9 Demos.............................................. 1-9 Examining Your Hardware Resources ................. 1-13 GeneralToolboxInformation .......................... 1-13 InterfaceInformation................................. 1-13 AdaptorInformation ................................. 1-14 InstrumentObjectInformation......................... 1-16 Getting Help ......................................... 1-17 TheinstrhelpFunction ............................... 1-17 ThepropinfoFunction................................ 1-18 The Instrument Control Session 2 Overview ............................................. 2-2 Creating an Instrument Object ......................... 2-3 ConfiguringPropertiesDuringObjectCreation ............ 2-4 CreatinganArrayofInstrumentObjects.................. 2-4 Connecting to the Instrument .......................... 2-6 Configuring and Returning Properties .................. 2-7 ReturningPropertyNamesandPropertyValues ........... 2-7 ConfiguringPropertyValues........................... 2-10 SpecifyingPropertyNames............................ 2-10 DefaultPropertyValues .............................. 2-11 Writing and Reading Data ............................ 2-12 WritingData ....................................... 2-13 ReadingData....................................... 2-18 ii Contents Disconnecting and Cleaning Up ....................... 2-23 DisconnectinganInstrumentObject .................... 2-23 CleaningUptheMATLABEnvironment................. 2-23 Controlling GPIB Instruments 3 GPIB Overview ....................................... 3-2 WhatIsGPIB?....................................... 3-2 ImportantGPIBFeatures.............................. 3-3 GPIBLines.......................................... 3-4 StatusandEventReporting ............................ 3-9 Using Vendor Tools to Identify and Test Your Resources . 3-14 Creating a GPIB Object ............................... 3-18 TheGPIBObjectDisplay.............................. 3-19 Configuring the GPIB Address ........................ 3-20 Writing and Reading Data ............................ 3-21 RulesforCompletingWriteandReadOperations.......... 3-21 Example:WritingandReadingTextData................ 3-22 Example:ReadingBinaryData......................... 3-24 Example:ParsingInputDataUsingstrread.............. 3-26 Example:UnderstandingEOIandEOS.................. 3-27 Using Events and Actions ............................. 3-30 Example:IntroductiontoEventsandActions............. 3-30 EventTypesandActionProperties...................... 3-31 StoringEventInformation ............................ 3-32 CreatingandExecutingActionFunctions................ 3-33 Enabling Action Functions After They Error . ........... 3-34 Example: Using Events and Actions to Read Binary Data . 3-34 Triggers ............................................. 3-36 Example:ExecutingaTrigger.......................... 3-36 iii Serial Polls .......................................... 3-38 Example:ExecutingaSerialPoll ....................... 3-38 Controlling Instruments Using the VISA Standard 4 VISA Overview ........................................ 4-2 Using Vendor Tools to Identify and Test Your Resources . 4-3 The GPIB Interface ................................... 4-5 CreatingaVISA-GPIBObject........................... 4-5 TheVISA-GPIBAddress............................... 4-7 The VXI Interface ..................................... 4-9 CreatingaVISA-VXIObject........................... 4-10 TheVISA-VXIAddress ............................... 4-12 Register-Based Communication . ........... 4-13 The GPIB-VXI Interface .............................. 4-21 CreatingaVISA-GPIB-VXIObject...................... 4-22 TheVISA-GPIB-VXIAddress.......................... 4-24 The Serial Port Interface ............................. 4-26 CreatingaVISA-SerialObject ......................... 4-26 Configuring Communication Settings . ........... 4-28 Controlling Serial Port Instruments 5 Serial Port Overview .................................. 5-2 WhatIsSerialCommunication?......................... 5-2 TheSerialPortInterfaceStandard ...................... 5-2 ConnectingTwoDeviceswithaSerialCable............... 5-3 SerialPortSignalsandPinAssignments.................. 5-5 iv Contents SerialDataFormat ................................... 5-9 Finding Serial Port Information for Your Platform . 5-13 Creating a Serial Port Object ......................... 5-16 TheSerialPortObjectDisplay ......................... 5-17 Configuring Communication Settings .................. 5-18 Writing and Reading Data ............................ 5-19 AsynchronousWriteandReadOperations................ 5-19 RulesforCompletingWriteandReadOperations.......... 5-20 Example:WritingandReadingTextData................ 5-21 Using Events and Actions ............................. 5-24 EventTypesandActionProperties...................... 5-24 StoringEventInformation ............................ 5-25 Example:UsingEventsandActions..................... 5-27 Using Control Pins ................................... 5-29 SignalingthePresenceofConnectedDevices ............. 5-29 ControllingtheFlowofData:Handshaking .............. 5-32 Saving and Loading the Session 6 Overview ............................................. 6-2 Saving and Loading Instrument Objects ................ 6-3 SavingInstrumentObjectstoanM-File .................. 6-3 SavingInstrumentObjectstoaMAT-File................. 6-5 Debugging: Recording Information to Disk .............. 6-6 Example:IntroductiontoRecordingInformation ........... 6-6 CreatingMultipleRecordFiles.......................... 6-7 SpecifyingaFilename................................. 6-7 TheRecordFileFormat................................ 6-8 Example:RecordingInformationtoDisk................. 6-10 v Function Reference 7 Overview ............................................. 7-2 GettingCommandLineFunctionHelp ................... 7-2 Functions Grouped by Category ........................ 7-4 BaseFunctions......................................