原创 GPIB Overview

2008-6-8 09:59 6790 6 6 分类: 测试测量

  What Is GPIB?
  GPIB is a standardized interface that allows you to connect and control multiple devices from various vendors. GPIB is also referred to by its original name HP-IB, or by its IEEEdesignation IEEE-488. The GPIB functionality has evolved over time, and is described in several specifications:
  The IEEE 488.1-1975 specification defines the electrical and mechanical characteristics of the interface and its basic functional characteristics.
  The IEEE-488.2-1987 specification builds on the IEEE 488.1 specification to define an acceptable minimum configuration and a basic set of instrument commands and common data formats.
  The Standard Commands for Programmable Instrumentation (SCPI) specification builds on the commands given by the IEEE 488.2 specification to define a standard instrument command set that can be used by GPIB or other interfaces.
  For many GPIB applications, you can communicate with your instrument without detailed knowledge of how GPIB works. Communication is established through a GPIB object, which you create in the MATLAB workspace.
  If your application is straightforward, or if you are already familiar with the topics mentioned above, you might want to begin with Creating a GPIB Object. If you want a high-level description of all the steps you are likely to take when communicating with your instrument, refer to Instrument Control Session.
  Some of the GPIB functionality is required for all GPIB devices, while other GPIB functionality is optional. Additionally, many devices support only a subset of the SCPI command set, or use a different vendor-specific command set. Refer to your device documentation for a complete list of its GPIB capabilities and its command set.
  Important GPIB Features
  The important GPIB features are described below. For detailed information about GPIB functionality, see the appropriate references in the Bibliography.
  Bus and Connector
  The GPIB bus is a cable with two 24-pin connectors that allow you to connect multiple devices to each other. The bus and connector have these features and limitations:
  You can connect up to 15 devices to a bus.
  You can connect devices in a star configuration, a linear configuration, or a combination of configurations.
  To achieve maximum data transfer rates, the cable length should not exceed 20 meters total or an average of 2 meters per device. You can eliminate these restrictions by using a bus extender.
  GPIB Devices
  Each GPIB device must be some combination of a Talker, a Listener, or a Controller. A Controller is typically a board that you install in your computer. Talkers and Listeners are typically instruments such as oscilloscopes, function generators, multimeters, and so on. Most modern instruments are both Talkers and Listeners.
  Talkers —A Talker transmits data over the interface when addressed to talk by the Controller.
There can be only one Talker at a given time. (同一时刻只能存在一个讲者。)
  Listeners —A Listener receives data over the interface when addressed to listen by the Controller. There can be up to 14 Listeners at a given time. Typically, the Controller is a Talker while one or more instruments on the GPIB are Listeners.
  Controllers —The Controller specifies which devices are Talkers or Listeners. A GPIB system can contain multiple Controllers. One of them is designated the System Controller. However, only one Controller can be active at a given time. The current active controller is the Controller-In-Charge (CIC). The CIC can pass control to an idle Controller, but only the System Controller can make itself the CIC.
  When the Controller is not sending messages, then a Talker can send messages. Typically, the CIC is a Listener while another device is enabled as a Talker.
  Each Controller is identified by a unique board index number. Each Talker/Listener is identified by a unique primary address ranging from 0 to 30, and by an optional secondary address, which can be 0 or can range from 96 to 126. (每个控者被赋予一个唯一的板序列号,而每个讲者/听者则被赋予一个唯一的主地址(从0到30),并可选择一个从地址(0,或者从96到126)。)
  GPIB Data
  There are two types of data that can be transferred over GPIB: instrument dataand interface messages:
  Instrument data —Instrument data consists of vendor-specific commands that configure your instrument, return measurement results, and so on. For a complete list of commands supported by your instrument, refer to its documentation. (由Controller发出)
  Interface messages —Interface messages are defined by the GPIB standard and consist of commands that clear the GPIB bus, address devices, return self-test results, and so on.
  Data transfer consists of one byte (8 bits) sent in parallel. The data transfer rate across the interface is limited to 1 megabyte per second. However, this data rate is usually not achieved in practice, and is limited by the slowest device on the bus.
  GPIB Lines
  GPIB consists of 24 lines, which are shared by all instruments connected to the bus. 16 lines are used for signals, while eight lines are for ground. The signal lines are divided into these groups:
  Eight data lines
  Five interface management lines
  Three handshake lines
  The signal lines use a low-true (negative) logic convention with TTL levels. This means that a line is low (true or asserted) when it is a TTL low level, and a line is high (false or unasserted) when it is a TTL high level. The pin assignment scheme for a GPIB connector is shown below.
  GPIB Pin and Signal Assignments
  Pin Label Signal Name Pin Label Signal Name
  1 DIO1 Data transfer               13 DIO5 Data transfer
  2 DIO2 Data transfer               14 DIO6 Data transfer
  3 DIO3 Data transfer               15 DIO7 Data transfer
  4 DIO4 Data transfer               16 DIO8 Data transfer
  5 EOI End Or Identify               17 REN Remote Enable
  6 DAV Data Valid                     18 GND DAV ground
  7 NRFD Not Ready For Data   19 GND NRFD ground
  8 NDAC Not Data Accepted     20 GND NDAC ground
  9 IFC Interface Clear               21 GND IFC ground
  10 SRQ Service Request        22 GND SRQ ground
  11 ATN Attention                     23 GND ATN ground
  12 Shield Chassis ground        24 GND Signal ground
  Data Lines
  The eight data lines, DIO1 through DIO8, are used for transferring data one byte at a time. DIO1 is the least significant bit, while DIO8 is the most significant bit. The transferred data can be an instrument command or a GPIB interface command.
  Data formats are vendor-specific and can be text-based (ASCII) or binary. GPIB interface commands are defined by the IEEE 488 standard.
  Interface Management Lines
  The interface management lines control the flow of data across the GPIB interface.
  GPIB Interface Management Lines (接口管理线)
  Line Description
  ATN Used by the Controller to inform all devices on the GPIB that bytes are being sent. If the ATN line is high, the bytes are interpreted as an instrument command. If the ATN line is low, the bytes are interpreted as an interface message. (ATN为高,数据线上的字节作为仪器命令对待;ATN为低,数据线上的字节作为接口消息对待。)

  IFC Used by the Controller to initialize the bus. If the IFC line is low, the Talker and Listeners are unaddressed, and the System Controller becomes the Controller-In-Charge. (初始化总线:清空讲者与听者,系统控制器作为CIC。)
  REN Used by the Controller to place instruments in remote or local program mode. If REN is low, all Listeners are placed in remote mode, and you cannot change their settings from the front panel. If REN is high, all Listeners are placed in local mode.
  SRQ Used by Talkers to asynchronously request service from the Controller. If SRQ is low, then one or more Talkers require service(for example, an error such as invalid command was received). You issue a serial poll to determine which Talker requested service. The poll automatically sets the SRQ line high. (讲者通过SRQ向控者异步提交服务请求。)
  EOI If the ATN line is high, the EOI line is used by Talkers to identify the end of a byte stream such as an instrument command. If the ATN line is low, the EOI line is used by the Controller to perform a parallel poll (not supported by the toolbox). (ATN为高,讲者通过EOI表明仪器命令的字节流结束;ATN为低,控者通过EOI实现并行查询。)
  You can examine the state of the interface management lines with the BusManagementStatusproperty.
  Handshake Lines (握手线)
  The three handshake lines, DAV, NRFD, and NDAC, are used to transfer bytes over the data lines from the Talker to one or more addressed Listeners. (握手线:实现从讲者向听者发送数据)
  Before data is transferred, all three lines must be in the proper state. The active Talker controls the DAV line and the Listener(s) control the NRFD and NDAC lines. The handshake process allows for error-free data transmission.
  GPIB Handshake Lines
  Line Description
  DAV Used by the Talker to indicate that a byte can be read by the Listeners.
  NRFD Indicates whether the Listener is ready to receive the byte.
  NDAC Indicates whether the Listener has accepted the byte.
  The handshaking process follows these steps:
  Initially, the Talker holds the DAV line high indicating no data is available, while the Listeners hold the NRFD line high and the NDAC line low indicating they are ready for data and no data is accepted, respectively.
  When the Talker puts data on the bus, it sets the DAV line low, which indicates that the data is valid.
  The Listeners set the NRFD line low, which indicates that they are not ready to accept new data.
  The Listeners set the NDAC line high, which indicates that the data is accepted.
  When all Listeners indicate that they have accepted the data, the Talker sets the DAV line high indicating that the data is no longer valid. The next byte of data can now be transmitted.
  The Listeners hold the NRFD line high indicating they are ready to receive data again, and the NDAC line is held low indicating no data is accepted.
  Note If the ATN line is high during the handshaking process, the information is considered data such as an instrument command. If the ATN line is low, the information is considered a GPIB interface message.
  The handshaking steps are shown below.
  
  
  You can examine the state of the handshake lines with the HandshakeStatusproperty.
  Status and Event Reporting
  GPIB provides a system for reporting status and event information. With this system, you can find out if your instrument has data to return, whether a command error occurred, and so on. For many instruments, the reporting system consists of four 8-bit registers and two queues(output and event). The four registers are grouped into these two functional categories:
  Status RegistersThe Status Byte Register(SBR) and Standard Event Status Register (SESR) contain information about the state of the instrument.
  Enable RegistersThe Event Status Enable Register (ESER) and the Service Request Enable Register (SRER) determine which types of events are reported to the status registers and the event queue. ESER enables SESR, while SRER enables SBR.
  The status registers, enable registers, and output queue are shown below.
  点击看大图
  
  Status Byte Register
  Each bit in the Status Byte Register (SBR) is associated with a specific type of event. When an event occurs, the instrument sets the appropriate bit to 1. You can enable or disable the SBR bits with the Service Request Enable Register (SRER). You can determine which events occurred by reading the enabled SBR bits.
  Status Byte Register Bits
  Bit Label Description
  0-3 – Instrument-specific summary messages.
  4 MAV The Message Available bit indicates if data is available in the Output Queue. MAV is 1 if the Output Queue contains data. MAV is 0 if the Output Queue is empty.
  5 ESB The Event Status bit indicates if one or more enabled events have occurred. ESB is 1 if an enabled event occurs. ESB is0 if no enabled events occur. You enable events with the Standard Event Status Enable Register.
  6 MSS The Master Summary Status summarizes the ESB and MAV bits. MSS is 1 if either MAV or ESB is 1. MSS is 0 if both MAV and ESB are 0. This bit is obtained from the *STB?command.
  RQS The Request Service bit indicates that the instrument requests service from the GPIB controller. This bit is obtained from a serial poll.
  7 – Instrument-specific summary message.
  For example, if you want to know when a specific type of instrument error occurs, you would enable bit 5 of the SRER. Additionally, you would enable the appropriate bit of the Standard Event Status Enable Register (see Standard Event Status Register) so that the error event of interest is reported by the ESB bit of the SBR.
  Standard Event Status Register
  Each bit in the Standard Event Status Register (SESR) is associated with a specific state of the instrument. When the state changes, the instrument sets the appropriate bits to 1. You can enable or disable the SESR bits with the Standard Event Status Enable Register (ESER). You can determine the state of the instrument by reading the enabled SESR bits. The SESR bits are described below.
  Standard Event Status Register Bits
  Bit Label Description
  0 OPC The Operation Complete bit indicates that all commands have completed.
  1 RQC The Request Control bit is not used by most instruments.
  2 QYE The Query Error bit indicates that the instrument attempted to read an empty output buffer, or that data in the output buffer was lost.
  3 DDE The Device Dependent Error bit indicates that a device error occurred (such as a self-test error).
  4 EXE The Execution Error bit indicates that an error occurred when the device was executing a command or query.
  5 CME The Command Error bit indicates that a command syntax error occurred.
  6 URQ The User Request bit is not used by most instruments.
  7 PON The Power On bit indicates that the device is powered on.
  For example, if you want to know when an execution error occurs, you would enable bit 4 of the ESER. Additionally, you would enable bit 5 of the SRER (see Status Byte Register) so that the error event of interest is reported by the ESB bit of the SBR.
  Reading and Writing Register Information
  This section describes the common GPIB commands used to read and write status and event register information.
  GPIB Commands for Reading and Writing Register Information
  Register Operation Command Description
  SESR Read *ESR? Return a decimal value that corresponds to the weighted sum of all the bits set in the SESR register.
  Write N/A You cannot write to the SESR register.
  ESER Read *ESE? Return a decimal value that corresponds to the weighted sum of all the bits enabled by the *ESEcommand.
  Write *ESE Write a decimal value that corresponds to the weighted sum of all the bits you want to enable in the SESR register.
  SBR Read *STB? Return a decimal value that corresponds to the weighted sum of all the bits set in the SBR register. This command returns the same result as a serial poll except that the MSS bit is not cleared.
  Write N/A You cannot write to the SBR register.
  SRER Read *SRE? Return a decimal value that corresponds to the weighted sum of all the bits enabled by the *SREcommand.
  Write *SRE Write a decimal value that corresponds to the weighted sum of all the bits you want to enable in the SBR register.
  For example, to enable bit 4 of the SESR, you write the command *ESE 16. To enable bit 4 and bit 5 of the SESR, you write the command *ESE 48. To enable bit 5 of the SBR, you write the command *SRE 32.
  To see how to use many of these commands in the context of an instrument control session, refer to Example: Executing a Serial Poll.

本文转自
http://www.mathworks.com/access/helpdesk/help/toolbox/instrument/f13-40799.html

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
6
关闭 站长推荐上一条 /3 下一条