10-virtual instrumentation & gpib

24

Click here to load reader

Upload: darshan-thakkar

Post on 01-Dec-2014

86 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 10-Virtual Instrumentation & GPIB

Virtual Instrumentation & GPIB

Page 2: 10-Virtual Instrumentation & GPIB

What is GPIB?

GPIB stands for General Purpose Interface Bus. It is also commonly referred to as IEEE 488 and HPIB, A standard GPIB setup has one controller, at least one instrument (such as an oscilloscope, multimeter, etc.), and as many GPIB cables.

National Instruments PCI-GPIB Board (controller)

Page 3: 10-Virtual Instrumentation & GPIB

GPIB Hardware

PCI-GPIB Board (controller)

GPIB cable

Page 4: 10-Virtual Instrumentation & GPIB

GPIB

The controller will allow the user to interact with the instrument.

Instruments Computer

Page 5: 10-Virtual Instrumentation & GPIB

GPIB Signals & LinesData Lines: 8 data lines carry both data and command messages.

Handshake Lines: 3 lines asynchronously control the transfer of message bytes between devices.

• DAV: Data Valid• NDAC: Not Data Accepted• NRFD: Not Ready for Data

Interface Management Lines: 5 lines manage the flow of information across the interface.

• ATN: Attention• IFC: Interface Clear• REN: Remote Enable• SRQ: Service Request• EOI; End or Identify

Ground lines: 8 - for shielding and signal returns.

Page 6: 10-Virtual Instrumentation & GPIB

Controllers, Talkers, and Listeners of GPIB

• Each device has a unique GPIB primary address between 0 and 30

• The Controller defines the communication links to devices that request service, sends GPIB commands, and passes/receives control of the bus.

• Controllers instruct Talkers to talk and to place data on the GPIB. You can address only one device at a time to talk.

• The Controller addresses the Listener to listen and to read data from the GPIB. You can address several devices to listen.

Page 7: 10-Virtual Instrumentation & GPIB
Page 8: 10-Virtual Instrumentation & GPIB

Data to be transferred across the GPIB at the maximum rate of 1 Mbyte/s :

• A maximum separation of 4 m between any two devices.

• A maximum cable length of 20 m.

• A maximum of 15 devices connected to each bus

Page 9: 10-Virtual Instrumentation & GPIB

GPIB Connections

Linear Configuration Star Configuration

Page 10: 10-Virtual Instrumentation & GPIB

GPIB Instrument Drivers

• All instrument drivers in the library have the same basic VI hierarchy.

Page 11: 10-Virtual Instrumentation & GPIB

Instrument drivers have VIs in the following categories:• Initialize—Initializes the communication channel to the

instrument. This VI also can perform reset operation, and it can perform any necessary actions to place the instrument in its default power-on state or other specified state.

• Configuration—Configures the instrument to perform operations, such as setting up the trigger rate.

• Action/Status—Contains two types of VIs. Action VIs cause the instrument to initiate or terminate test and measurement operations. Status VIs obtain the current status of the instrument or the status of pending operations. An example of an action VI is Acquire Single Shot.

Page 12: 10-Virtual Instrumentation & GPIB

An example of a status VI is Query Transfer Pending:

• Data—Transfers data to or from the instrument, such as reading a measured waveform from the instrument or downloading a waveform to the instrument.

• Utility—Performs a wide variety of functions, such as reset, self-test error query, and revision query.

• Close—Terminates the communication channel to the instrument and deallocates the resources for that instrument.

Page 13: 10-Virtual Instrumentation & GPIB

INITIALIZATION

When you initialize the communication channel to an instrument, you must know the resource name or instrument descriptor. A resource is an instrument or interface, and the instrument descriptor is the exact name and location of a resource in the following format:

Interface Type::Address::INSTR• For example, GPIB::2::INSTR is the instrument

descriptor for a GPIB instrument at address 2.

Page 14: 10-Virtual Instrumentation & GPIB

EXCERCISE

Requiring you to communicate with an instrument thru the GPIB port on your computer. The following procedures will help you learn how to design your software so that you can do the most possible with your GPIB device by communicating to it thru the GPIB port.

Page 15: 10-Virtual Instrumentation & GPIB

• First you need to configure the NI Instrument Simulator for use with GPIB communication

• Flip the switches to the positions shown below. If the GPIB Cable is not already connected to the instrument and the GPIB Board, do so at this time.

Switch configuration for GPIB communication with the NI Instrument Simulator with instrument OFF.

EXCERCISE

Page 16: 10-Virtual Instrumentation & GPIB

Now you will build a VI that is able to communicate with the GPIB Instrument. You will use VISA commands, all of which are very simplistic and general by nature.

In fact, this program could even be used for communicating with a serial,

PXI, or VXI Device simply by changing the VISA Resource Name.

Page 17: 10-Virtual Instrumentation & GPIB

• To place the appropriate VIs right click on the block diagram and go to Functions > Instrument I/O > VISA place VISA Write and VISA Read on the block diagram.

• VISA Open and VISA Close can be found under Functions > Instrument I/O > VISA > VISA Advanced.

• VISA resource name, write buffer (“”), read buffer, return count, and byte count can all be created by right clicking on their respective nodes with the wiring tool and either creating an indicator, a constant, or a control depending upon what is needed.

Page 18: 10-Virtual Instrumentation & GPIB

This VI does the following:

• VISA Open prepares a session of communication between LabVIEW and the instrument that is specified in VISA Resource Name.

• VISA Write then triggers the proper handshaking lines, signals to the desired device that a transmission is about to occur, breaks the ASCII text into 8 bit binary code, and sends 1 bit along each DIO line to the instrument.

• VISA Read then awaits the impending signal transmission that is signaled by the appropriate handshaking lines, reads up to the number of bytes specified in the byte count constant, converts the binary data of received from each of the DIO lines into ASCII text, and returns the total size of the received string array.

• VISA Close closes the VISA session.

• If an error occurs the Simple Error Handler displays what error occurred and where within the VI it occurred.

Page 19: 10-Virtual Instrumentation & GPIB

• On the front panel put *IDN? in the write buffer (“”). This is a standard command that asks an instrument to identify itself. Run the VI. The device should answer with National Instruments GPIB and Serial Device Simulator Rev B.1 (or the name of the device in use).

• Type FORM: DATA ASC; SOUR:FUNC SIN; SENS:DATA? in the write buffer (“”), and run the VI. Once the VI has run, make a screenshot of both the front panel with the waveform and block diagram.

• Type FORM: DATA ASC; SOUR:FUNC SQU; SENS:DATA? In the write buffer (“”), and run the VI. Once the VI has run, make a screenshot of both the front panel with the new waveform.

Page 20: 10-Virtual Instrumentation & GPIB

Example 2

• Build a VI using some of the instrument driver VIs. The VI will be used to look at the voltage history of the random DC signal output by the Instrument Simulator, and then record the maximum and minimum voltages, and also allow you to set the initial voltage range..

Page 21: 10-Virtual Instrumentation & GPIB
Page 22: 10-Virtual Instrumentation & GPIB

– Open a new VI, go to the empty block diagram, right click to get the functions palette, go to Functions > Instrument I/O > Instrument Drivers.

– Go to the NI Device Simulator subpalette and place NI DEVSIM Initialize.vi and NI DEVSIM Close.vi on the Block. Diagram.

– From the Configuration subpalette select NI DEVSIM Multimeter Configuration.vi.

– From the Data subpalette select NI DEVSIM Measure DC Voltage.vi.

Page 23: 10-Virtual Instrumentation & GPIB

- Go to Functions > Array to find Build Array and Array Max & Min.

- To add a Shift Register simply right click on the while loop

and click Add Shift Register.

- Once the Build Array is wired to the Shift Register then you can place an empty array constant by right clicking the Shift Register Create > Constant (make sure you do not assign any values to this empty constant, or that will be an initial value for the Graph and Array).

- All other indicators and controls can be created by right clicking on their respective nodes with the wiring tool and either creating an indicator or a control depending upon what is needed

Page 24: 10-Virtual Instrumentation & GPIB

This VI does the following:

• NI Devsim Initialize.vi initializes the device for communication and prepares the software for the instrument type as indicated in the VISA resource name.

• NI Devsim Multimeter Configuration.vi configures the multimeter range to either the default, minimum or maximum levels (0 to 10 VDC, 0 to 1 VDC, or 0 to 100 VDC).

• NI Devsim Read Measure DC Voltage.vi asks the device what its current VDC is, and then reads the instrument’s response to the question. It then formats the response into a single numeric value.

• Build array.vi assimilates the individual numeric values into an array of values.• • The array is plotted on a Waveform Graph.

• Array Max & Min.vi searches the array for the maximum and minimum values, and then displays these in the appropriate indicators.

• Wait (ms) causes there to be a slight delay in the while loop so as to allow the user to see each individual point displayed.

• The while loop stops when the user presses the stop button on the front panel or when an error occurs.

• Once out of the while loop NI Devsim Close.vi closes the VISA session with the device.

• Any errors are reported by the Simple Error Handler.vi.