labview manual lesson9-11

55
1 Lesson 9 Data Acquisition and Waveforms TOPICS Plug-in DAQ devices Data Acquisition in LabVIEW Analog Input Data Logging Analog Output Counters Digital I/O

Upload: gozdegokce

Post on 21-Nov-2015

31 views

Category:

Documents


2 download

DESCRIPTION

A brief discussion of boards and DAQ concepts.The organization of LabVIEW DAQ VIs.How to acquire an analog reading.How to output an analog signal.How to use counters.How to acquire data continuously.GPIB (IEEE 488) background.Instrument drivers in LabVIEW.GPIB control using VISASerial communication background.Serial control using VISA ASCII and binary waveform transfer.

TRANSCRIPT

  • Lesson 9Data Acquisition and WaveformsTOPICSPlug-in DAQ devicesData Acquisition in LabVIEWAnalog InputData LoggingAnalog OutputCountersDigital I/O

    LV Basics I

  • Overview and ConfigurationFundamental task of a DAQ system is to measure or generate real-world physical signals

    DAQ system consists of:TransducersSignal ConditioningPlug-in DAQ deviceDriverSoftware

    LV Basics I

  • Measurement Software FrameworkNI-DAQ contains:Traditional NI-DAQNI-DAQmx

    LV Basics I

  • DAQ Hardware Configuration Measurement & Automation Explorer (MAX)

    LV Basics I

  • Channels and TasksSignalsai 0ai 1ai 2Sine Wave 1Sine Wave 2Sine Wave 3Channel namesTasksTiming and Triggering

    LV Basics I

  • The DAQ Signal Accessory

    LV Basics I

  • NI-DAQmx versus Traditional NI-DAQAccuracyPerformanceProductivityQuality BestGood FairCompatibility

    FeatureNI-DAQmxTraditional NI-DAQTest Panels DAQ Assistant with code generation noOn-line diagnostics Scaling to voltage and physical units 50 kS/s with single point I/O Measurement multithreading Instant calibration Automatic selection of optimal gains Guaranteed lossless data 650 Alliance membersIntegration with LabVIEWDeveloper Exchange discussion forumCompatible with Legacy ISA Boardsno

    LV Basics I

  • Data Acquisition in LabVIEWTraditional NI-DAQSpecific VIs for performing: Analog Input Analog Output Digital I/O Counter operationsNI-DAQmxNext generation driver: VIs for performing a task One set of VIs for all measurement types

    LV Basics I

  • NI-DAQmx Data AcquisitionSingle set of VIs used to perform analog I/O, digital I/O, and counter operationsDAQ Assistant Express VI Quickly and easily program the DAQ device Creates a local task Most applications can use the DAQ Assistant Express VI

    LV Basics I

  • NI-DAQmx Data Acquisition Task TypesMeasurement type can be:Analog InputAnalog OutputCounter InputCounter OutputDigital I/O

    LV Basics I

  • Analog InputAnalog Input task is specific to the measurement

    LV Basics I

  • Analog Input Task Timing and TriggeringConfigures the number of samples and sample rate for the taskConfigures the start and reference triggers for the task

    LV Basics I

  • Data LoggingIt is often necessary to permanently store data that is acquired from the DAQ deviceLabVIEW includes the ability to read and write a LabVIEW Measurement FileLabVIEW Measurement File is an ASCII text file

    LV Basics I

  • Analog OutputAnalog Output task is specific to the generation type

    LV Basics I

  • Analog Output Task Timing and TriggeringConfigures the number of samples and sample rate for the taskConfigures the start and reference triggers for the task

    LV Basics I

  • CountersA counter is a digital timing deviceTypical uses of a counter: Event counting Frequency measurement Period measurement Position measurement Pulse generationGateSourceOutputCount RegisterCount register Stores the current count of the counterSource Input that causes the counter to increment each time it togglesGate Input that is used to enable or disable the function of the counterOutput Signal that generates pulses or a series of pulses

    LV Basics I

  • Digital Input and OutputDigital I/O can read from or write to a line or an entire digital portA digital port is a collection of digital lines

    LV Basics I

  • SummaryMAX is the primary configuration and testing utility that is available for the DAQ device.The DAQ Assistant is used to configure the DAQ device and perform data acquisition.Most application can use the DAQ Assistant. For applications that require advanced timing and synchronization use the VIs that come with NI-DAQmx.The DAQ Assistant can perform Analog Input, Analog Output, Digital I/O, and Counter operations.

    LV Basics I

  • Lesson 10Instrument ControlTOPICSInstrument Control Overview GPIB Communication and ConfigurationInstrument I/O AssistantVirtual Instrument Software Architecture (VISA)Instrument DriversSerial Port CommunicationWaveform Transfers

    LV Basics I

  • Instrument Control OverviewControl any instrument if you know the following:Type of connector on the instrumentType of cables neededElectrical properties involvedCommunication protocols usedSoftware drivers availableInstrumentsComputer

    LV Basics I

  • GPIB CommunicationGPIB InstrumentsGPIB CableGPIB Interface

  • Standards Introduction196519871990199219931975HP designs HP-IB (Hewlett Packard Interface Bus)HP-IB becomes IEEE 488IEEE 488.2 adoptedIEEE 488 becomes IEEE 488.1SCPI (Standard Commands for Programmable Instruments) added to IEEE 488.2IEEE 488.2 revisedHS488 proposed1999HS488 approved

    LV Basics I

  • GPIB Hardware SpecificationsMax cable length between devices = 4 m (2 m average)Max cable length = 20 mMax number of devices = 15 (2/3 powered on)

    LV Basics I

  • GPIB Software Architecture WindowsDriver Software(*.DLL)Instrument Driver VIsNI-VISALabVIEWDiagnostics Tools:GPIB Diagnostic ToolNI-SpyConfiguration Tools:Measurement & Automation ExplorerInterface Board(GPIB, PXI, VXI, computer based, etc.)

  • Configuring GPIB Board and InstrumentsMeasurement & Automation Explorer (MAX)

    LV Basics I

  • What is the Instrument I/O Assistant?Accessed through a LabVIEW Express VISets up device communication and data parsing step by step through a configuration interface

    LV Basics I

  • Communicating with an Instrument

    LV Basics I

  • Virtual Instrument Software ArchitecturePlatform independentVISA is the backbone of the IVI and Plug & Play Instrument DriversInterface independentMust know SCPI command set to program directly with VISA

    GPIBVXISerialPXIVISA

    LV Basics I

  • VISA TerminologyResourceInstrument, Serial Port, or Parallel PortSessionConnection to a ResourceInstrument DescriptorResource locationFormat: Interface Type::Address::INSTRExamples:

    LV Basics I

  • Instrument Descriptor SyntaxResource Name contains interface infoVISA Aliases also workInterfaceResource Name Grammar

    SerialASRL[board][::INSTR]

    GPIBGPIB[board]::primary address[::INSTR]

    VXIVXI[board]::VXI logical address[::INSTR]

    GPIB-VXIGPIB-VXI[board][::GPIB-VXI primary address]::VXI logical address[::INSTR]

    LV Basics I

  • VISA Resource NameExact name and location of the instrumentUse the VISA Resource Name controlYou can specify the full resource name of the VISA Alias

    LV Basics I

  • Instrument Drivers More than 1200 LabVIEW Instrument drivers Programming simplified to high-level API

    LV Basics I

  • Installing and Finding Instrument DriversDrivers available at ni.com/idnetInstall the instrument driver VI Library into LabVIEW 7.0\instr.lib directoryAccess drivers from FunctionsInputInstrument Drivers subpalette

    LV Basics I

  • IDNET - Instrument Driver NetworkLearn about driversGet help with developing driversSubmit your driver to the networkDownload drivers

    LV Basics I

  • Instrument Driver Model

    LV Basics I

  • Instrument Driver VIsInitialize Configure Action/Status Data Utility Close

    LV Basics I

  • Instrument Driver Inputs and OutputsInstrument DescriptorVISA Sessions A connection or link to a specific instrumentCreated after instrument is initializedUsed throughout VI whenever you communicate with that specific instrumentError clusterHP34401A Initialize.vi

    LV Basics I

  • Putting It All TogetherInitialize instrumentDo operation(s)Close instrumentCheck error status

    LV Basics I

  • Serial CommunicationPopular means of communication between computer and peripheral deviceData sent one bit at a time across the cableUsed for low transfer rates or long distancesOnly a cable is needed since most computers have at least one available serial portRS-232 InstrumentRS-232 CablePC SerialPort

    LV Basics I

  • Serial Hardware ConnectionRS-232DCE or DTE configurations9-pin or 25-pinRS-422DCE or DTE8-pinRS-485MultidropPinDTEDCE

    1 DCDInputOutput2 RxD I O3 TxD O I4 DTR O I5 Com - -6 DSR I O7 RTS O I8 CTS I O9 RI I O

    LV Basics I

  • Serial CommunicationTerminologyBaud rate bits per secondData bits inverted logic and LSB firstParity optional error-checking bitStop bits 1, 1.5, or 2 inverted bits at data endFlow control hardware and software handshaking options

    LV Basics I

  • Using the Instrument I/O Assistant with Serial Select COMX as the instrument address Use the I/O Assistant as done with GPIB

    LV Basics I

  • SummaryLabVIEW can communicate with any instrument that connects to your computer if you know the interface typeUse the Measurement & Automation Explorer (MAX) to detect, configure, and test your GPIB interface and instrumentsUse the Instrument I/O Assistant for easy and fast GPIB and serial programming.An instrument driver eliminates the need for your to have detailed knowledge of the specific strings used by an instrumentInstrument Library more than 2000 instruments supportedInstrument driver VIs share a common hierarchy and come with an example to help you get started

    LV Basics I

  • Lesson 11VI CustomizationTOPICSConfiguring Appearance of Front Panel SubVI Front PanelsKeyboard ShortcutsVI PropertiesCustomizing Palettes

    LV Basics I

  • Customizing VI PropertiesAccess VI Properties by right-clicking the icon pane or selecting it from the File menuAffects every instance of that VI in all applications

    LV Basics I

  • Window AppearanceOnly affects VI panel while VI is running

    LV Basics I

  • Window SizeSet minimum and current panel sizeAdjust size of panel relative to the monitorScale objects on panel as window resizes

    LV Basics I

  • Creating Pop-Up Panels Every InstanceUse Top-Level Application Window or Dialog appearance typesCreate custom window appearance

    LV Basics I

  • Creating Pop-Up Panels Single InstanceAccess SubVI Node Setup by right-clicking on subVI icon on calling VIs diagram

    LV Basics I

  • Key NavigationAssigns keyboard strokes to front panel controls

    LV Basics I

  • Preventing Editing of a VIOpens, runs, and closes LabVIEW without user intervention Remove menus, Abort button, etc

    Save with Options

    LV Basics I

  • SummaryUse VI Properties to set VI execution, window, and documentation optionsUse SubVI Node Setup to set execution options for a single instance of a subVIUse the Key Navigation option to assign front panel controls to a keyboard key combinationUse the Save with Options from the file menu to make backups of your VIsYou can often edit VIs by aborting them from the diagram of another VI

    LV Basics I

  • Technical Support ResourcesAward-Winning Website www.ni.com/supportDrivers & UpdatesProduct ManualsKnowledgeBasesExample CodeTutorialsApplication NotesDiscussion Forums

    LV Basics I

  • Info-LabVIEW ListserveUser-sponsored Internet mailing listSend subscription messages to the Info-LabVIEW list [email protected] other administrative messages to the Info-LabVIEW list maintainer [email protected] a message to subscribers at [email protected]

    LV Basics I

  • LabVIEW PublicationsLabVIEW Technical Resource quarterly newsletter by LTR Publishing LabVIEW Graphical Programming and LabVIEW Power Programming by Gary W. Johnson, McGraw-HillLabVIEW for Everyone by Lisa K. Wells and Jeffrey Travis, Prentice-HallLabVIEW Signal Processing by Mahesh Chugani, Abhay Samant, and Michael Cerna, Prentice-HallLabVIEW Applications and Solutions by Rahman Jamal and Herbert Pichlik, Prentice-Hall

    LV Basics I

    This lesson introduces data acquisition.

    This lesson covers: A brief discussion of boards and DAQ concepts.The organization of LabVIEW DAQ VIs.How to acquire an analog reading.How to output an analog signal.How to use counters.How to acquire data continuously.

    The most important thing to remember about both Lesson 9 and 10 is that this course is not meant to be anything more than a BRIEF introduction to let them know this capability exists. If they are pressing for more information, point them to the other Customer Education courses.Before a computer-based measurement system can measure a physical signal, such as temperature, a sensor or transducer must convert the physical signal into an electrical one, such as voltage or current. You might consider the plug-in DAQ device to be the entire measurement system, but it is actually only one system component. You cannot always directly connect signals to a plug-in DAQ device. In these cases, you must use signal conditioning accessories to condition the signals before the plug-in DAQ device converts them to digital information. The software controls the DAQ system by acquiring the raw data, analyzing, and presenting the results.

    NI-DAQ 7.0 contains two NI-DAQ driversTraditional NI-DAQ and NI-DAQmxeach with its own application programming interface (API), hardware configuration, and software configuration.Traditional NI-DAQ is an upgrade to NI-DAQ 6.9.x, the earlier version of NI-DAQ. Traditional NI-DAQ has the same VIs and functions and works the same way as NI-DAQ 6.9.x. You can use Traditional NI-DAQ on the same computer as NI-DAQmx, which you cannot do with NI-DAQ 6.9.x.NI-DAQmx is the latest NI-DAQ driver with new VIs, functions, and development tools for controlling measurement devices. The advantages of NI-DAQmx over previous versions of NI-DAQ include the DAQ Assistant for configuring channels and measurement tasks for a device; increased performance, including faster single-point analog I/O and multithreading; and a simpler API for creating DAQ applications using fewer functions and VIs than earlier versions of NI-DAQ.Traditional NI-DAQ and NI-DAQmx support different sets of devices.This lesson concerns the NI-DAQmx driver.The Windows Configuration Manager keeps track of all the hardware installed in your computer, including National Instruments DAQ devices. If you have a Plug & Play (PnP) device, such as an E-Series MIO device, the Windows Configuration Manager automatically detects and configures the device. If you have a non-PnP device, or legacy device, you must configure the device manually using the Add New Hardware option in the Control Panel.You can verify the Windows Configuration by accessing the Device Manager, available by selecting StartSettingsControl PanelSystemDevice Manager. You can see Data Acquisition Devices, which lists all DAQ devices installed in your computer. Double-click a DAQ device to display a dialog box with tabbed pages. The General tab displays overall information regarding the device. The Resources tab specifies the system resources to the device such as interrupt levels, DMA, and base address for software-configurable devices. The NI-DAQ Information tab specifies the bus type of the DAQ device. The Driver tab specifies the driver version and location for the DAQ device.LabVIEW installs Measurement & Automation Explorer (MAX), which establishes all device and channel configuration parameters. After installing a DAQ device in your computer, you must run this configuration utility. MAX reads the information the Device Manager records in the Windows Registry and assigns a logical device number to each DAQ device. Use the device number to refer to the device in LabVIEW. Access MAX either by double-clicking its icon on the desktop or selecting ToolsMeasurement & Automation Explorer in LabVIEW.In Traditional NI-DAQ you can configure a set of virtual channels, or a collection of property settings that include a physical channel, the type of measurement or generation specified in the channel name, and scaling information. In Traditional NI-DAQ and earlier versions, virtual channels are a simple method to remember which channels are used for different measurements. NI-DAQmx Channels are similar to the virtual channels of Traditional NI-DAQ. NI-DAQmx also includes tasks which are integral to the API. A task is a collection of one or more channels and the timing, triggering, and other properties that apply to the task itself. A task represents a measurement or generation you want to perform.Channels created only inside a task are local. Channels defined outside a task are global and can be used separately. Configuring virtual channels is optional in Traditional NI-DAQ and earlier versions, but is integral to every measurement you take in NI-DAQmx. In Traditional NI-DAQ, you configure virtual channels in MAX. In NI-DAQmx, you can configure virtual channels either in MAX or in a program, and you can configure channels as part of a task or separately.In the example, analog input signals are routed into the DAQ system. The ai signals have been given channel names of Sine Wave 1, Sine Wave 2, and Sine Wave 3. The DAQ System is programmed to perform a task. A task is a collection of one or more channels, timing, and triggering. A task represents a measurement or generation you want to perform.not in course manual:

    Before the class starts Exercise, you should explain the following points about using the DAQ Signal Accessory (DSA):The 5V line from the DAQ device supplies power to the DSA.Analog input channels 1 and 2 are available at the quick connect terminal located in the lower central portion of the top panel. The IC temperature sensor is hard-wired to AI channel 0 and is located in the lower right hand corner of the top panel.Analog output channels 0 and 1 are available at the quick connect terminal located at the lower central portion of the top panel.The function generator is located in the lower central portion of the top panel. It produces a sine wave and a square wave. Use the Frequency Range selector switch to select a frequency range and then use the Frequency Adjust knob next to it to further adjust the frequency.There is a row of four LEDs in the middle of the DAQ Signal Accessory that correspond to Lines 0 to 3 on Port 0 of the MIO board. The four LEDs use inverted logic.Briefly describe the other parts of the DSA.Instructor make sure each student has at least one wire with stripped ends.Point out all the benefits of using NI-DAQmx.

    However, if you are using a legacy board or a legacy application, continue to use Traditional NI-DAQ.The Data Acquisition palette in LabVIEW contains a palette for traditional NI-DAQ and one for NI-DAQmx.Traditional VIs are divided by the type of measurement; DAQmx VIs are divided by the type of task.The DAQmx-Data Acquisition palette contains all of the VIs necessary to perform analog I/O, digital I/O, and counter/timer operations. The VIs are organized so that the most common operations can be performed using the VIs. You can configure a task to perform a very specific function by using the Property Nodes in the palette. Many applications that do not require advanced timing and synchronization can be performed by using the DAQ Assistant Express VI. This course describes the use of the DAQ Assistant Express VI to perform data acquisition.

    The DAQ Assistant Express VI allows you to easily configure the data acquisition device. When you place the DAQ Assistant Express VI on the block diagram, a dialog box appears where you configure a local task to perform a specific measurement function. Creating a local task allows you to specify the exact type of measurement to take.Once you create a task, the information for the local task is stored in the DAQ Assistant Express VI. You can reconfigure the DAQ Assistant Express VI by double-clicking the VI and creating a new task.

    An analog input measurement type for a task can be voltage, temperature, strain, current, resistance, or frequency.Each measurement type has its own characteristics, such as resistor values for current measurements, or strain gauge parameters for strain measurements.Task TimingWhen performing analog input, the task can be timed to Acquire 1 Sample, Acquire n Samples, or Acquire Continuously. Acquire 1 Sample: acquires one value from an input channel and immediately returns the value. This operation does not require any buffering or hardware timing. Acquire n Samples: One way to acquire multiple samples for one or more channels is to acquire single samples in a repetitive manner. However, acquiring a single data sample on one or more channels over and over is inefficient and time consuming. Moreover, you do not have accurate control over the time between each sample or channel. Instead you can use hardware timing, which uses a buffer in computer memory, to acquire data more efficiently.Acquire Continuously: view, process, or log a subset of the samples as they are acquired.Task TriggeringWhen a device controlled by NI-DAQmx does something, it performs an action. Two very common actions are producing a sample and starting a waveform acquisition. Every NI-DAQmx action needs a stimulus or cause. When the stimulus occurs, the action is performed. Causes for actions are called triggers.Start Trigger: This trigger starts the acquisition.Reference Trigger: This trigger establishes the reference point in a set of input samples. Data acquired up to the reference point is pretrigger data. Data acquired after the reference point is posttrigger data. It is often necessary to permanently store data that is acquired from the DAQ device. The following considerations are important when planning to store data to a file.Not all data logging applications use LabVIEW to process and analyze the stored data. Consider which applications will read the data that is stored. The format in which the data is stored defines which applications can read the file. Since LabVIEW contains standard file operation functions that exist in other languages, the programmer is in complete control over the data logging process. LabVIEW includes the ability to create a LabVIEW Measurement File, an ASCII text file that can be read by a spreadsheet, or a text editor. The LabVIEW Measurement File is easy to create in LabVIEW, and easy to read in LabVIEW or other applications. The Write LabVIEW Measurement File Express VI located on the FunctionsOutput palette writes signals to a LabVIEW Measurement File. When you place this Express VI on the block diagram, a configuration dialog box appears where you can specify how to store the file.The Read LabVIEW Measurement File Express VI located on the FunctionsInput palette reads signals in a LabVIEW Measurement File. The data is read one point at a time, so it is necessary to place this Express VI in a loop.Use analog output to perform digital-to-analog (D/A) conversions. An analog output task can be voltage or current.To perform a voltage or current task, a compatible device must be installed that can generate that form of signal.Task TimingWhen performing analog output, the task can be timed to Generate 1 Sample, Generate n Samples, or Generate Continuously. Generate 1 Sample: Use single updates if the signal level is more important than the generation rate. You can use software timing to control when your device generates a signal. This operation does not require any buffering or hardware timing. Generate n Samples: You can use software timing or hardware timing to control when a signal is generated. With software timing, the rate at which the samples are generated is determined by the software and operating system instead of by the measurement device. With hardware timing, a TTL signal, such as a clock on your device, controls the rate of generation. A hardware clock can run much faster than a software loop. A hardware clock is also more accurate than a software loop. Use Generate n Samples if you want to generate a finite time-varying signal, such as an AC sine wave.Generate Continuously: Continuous generation is similar to generate n samples, except that an event must occur to stop the generation. Task TriggeringStart Trigger: This trigger starts the generation.Reference Trigger: The reference trigger is not supported for analog output tasks.A counter is a digital timing device. You typically use counters for event counting, frequency measurement, period measurement, position measurement, and pulse generation. A counter contains four main components: a count register, a source, a gate, and an output.Count RegisterStores the current count of the counter. You can query the count register with software.SourceAn input signal that can change the current count stored in the count register. The counter looks for rising or falling edges on the source signal. Whether a rising or falling edge changes the count is software selectable. The type of edge selected is referred to as the active edge of the signal. When an active edge is received on the source signal the count changes. Whether an active edge increments or decrements the current count is also software selectable. GateAn input signal that determines if an active edge on the source will change the count. Counting can occur when the gate is high, low, or between various combinations of rising and falling edges. Gate settings are made in software.OutputAn output signal that generates pulses or a series of pulses, otherwise known as a pulse train. When you configure a counter for simple event counting, the counter increments when an active edge is received on the source.Measuring and generating digital values is used in a variety of applications including controlling relays and monitoring alarm states. Generally, measuring and generating digital values is used in laboratory testing, production testing, and industrial process monitoring and control.Digital I/O can read from or write to a line or an entire digital port, which is a collection of lines. You can use the digital lines in your DAQ device to acquire a digital value. This acquisition is based on software timing. On some devices, you can configure the lines individually to either measure or generate digital samples. Each line corresponds to a channel in your task.You can use the digital port(s) in your DAQ device to acquire a digital value from a collection of digital lines. This acquisition is based on software timing. You can configure the ports individually to either measure or generate digital samples. Each port corresponds to a channel in your task.

    Do not immediately display this slide.

    Suggested questions for class participation:

    How are DAQ Boards configured?How can you test the configuration of your board? Point out that more in-depth DAQ information is available in the LabVIEW DAQ course.This chapter introduces Serial and GPIB instrument control using LabVIEW.

    This lesson covers: GPIB (IEEE 488) background.Instrument drivers in LabVIEW.GPIB control using VISASerial communication background.Serial control using VISA ASCII and binary waveform transfer.

    You are not limited to the type of instrument that you control if you choose industry-standard control technologies. You can use instruments from many different categories, including serial, GPIB, VXI, PXI, computer-based instruments, Ethernet, SCSI, CAMAC, and parallel port devices. This lesson describes the two most common instrument communication methods, GPIB and serial port communication.Take note of the following with PC control of instrumentation:Type of connector (pinouts) on the instrumentCables needednull-modem, number of pins, male/femaleElectrical properties involvedsignal levels, grounding, cable length restrictionsCommunication protocols usedASCII commands, binary commands, data formatSoftware drivers availableGPIB CommunicationsBriefly describe a typical system containing several GPIB devices connected to a computer. Describe that one device is the System Controller and the others are Talkers/Listeners. Each device on the GPIB has a unique address.GPIB instruments offer test and manufacturing engineers the widest selection of vendors and instruments for general-purpose to specialized vertical market test applications. GPIB instruments have traditionally been used as standalone benchtop instruments where measurements are taken by hand. Many GPIB instruments used today are still used in this fashion. Introduction of Standards to Instrument CommunicationIn 1965, Hewlett-Packard designed the Hewlett-Packard Interface Bus (HP-IB) to connect their line of programmable instruments to their computers. Because of its high transfer rates (nominally 1 MB/s), this interface bus quickly gained popularity. It was later accepted as IEEE Standard 488-1975. Today, the name General Purpose Interface Bus (GPIB) is more widely used than HP-IB. Because the original IEEE 488 document contained no guidelines for a preferred syntax and format conventions, work continued on the specification to enhance system compatibility and configurability among test systems. This work resulted in a supplement standard IEEE 488.2, Codes, Formats, Protocols, and Common Commands, for use with IEEE 488 (renamed to ANSI/IEEE Standard 488.1-1987). IEEE 488.2 does not replace IEEE 488.1. Many devices still conform only to IEEE 488.1. IEEE 488.2 builds on IEEE 488.1 by defining a minimum set of device interface capabilities, a common set of data codes and formats, a device message protocol, a generic set of common device commands, and a new status reporting model.In 1990, the IEEE 488.2 specification included the Standard Commands for Programmable Instrumentation (SCPI) document. SCPI defines specific commands that each instrument class, which usually includes instruments from various vendors, must obey. Thus, SCPI guarantees complete system compatibility and configurability among these instruments. It is no longer necessary to learn a different command set for each instrument in an SCPI-compliant system, and it is easy to replace an instrument from one vendor with an instrument from another.

    Hardware SpecificationsThe GPIB is a digital, 24-conductor parallel bus. It consists of eight data lines (DIO 1-8), five bus management lines (EOI, IFC, SRQ, ATN, REN), three handshake lines (DAV, NRFD, NDAC), and eight ground lines. The GPIB uses an eight-bit parallel, byte-serial, asynchronous data transfer scheme. This means that whole bytes are sequentially handshaked across the bus at a speed that the slowest participant in the transfer determines. Because the unit of data on the GPIB is a byte (eight bits), the messages transferred are frequently encoded as ASCII character strings.Additional electrical specifications allow data to be transferred across the GPIB at the maximum rate of 1 MB/sec because the GPIB is a transmission line system. These specifications are:A maximum separation of 4 m between any two devices and an average separation of 2 m over the entire bus. A maximum cable length of 20 m.A maximum of 15 devices connected to each bus with at least two-thirds of the devices powered on.If you exceed any of these limits, you can use additional hardware to extend the bus cable lengths or expand the number of devices allowed.Note For more information about GPIB, visit the National Instruments GPIB support website at http://www.ni.com/support/gpibsupp.htm.Underneath and between the different hardware components are the software components that are the heart of your instrumentation system. The figure above shows the software architecture for Windows 2000/XP from the perspective of the computer. The instrument is connected to the computer through a built-in connector such as RS-232 or an installed interface board such as GPIB or VXI/MXI. Driver-level software for instrument is in the form of a Dynamic Link Library (DLL). In the example shown in the figure above, LabVIEW is the high-level application software layer. LabVIEW includes built-in functions for GPIB, serial, VXI, and computer-based instruments that load and use the installed driver software.As with all Windows device drivers, any DLLs you install for interface boards will also interact with the Windows Registry so that resources such as base addresses, interrupt levels, and DMA channels can be assigned. Configuration and diagnostic software tools are also available with National Instruments hardware.

    Refer in-depth questions to technical support or suggest that the students purchase the GPIB course.

    Instructor - Show how the Measurement & Automation Explorer allows you to obtain information about your GPIB interfaces as well as the DAQ board.

    Explain that the Measurement and Automation Explorer (MAX) allows you to:Configure the GPIB card and search for instrumentsSet the VISA alias nameRun NI-SpyConfigure IVI instrument drivers (be careful you may confuse some people if you go into a long dialogue about IVI).If a GPIB+ card is installed you can run the GPIB analyzer software from MAXThe Instrument I/O Assistant located on the FunctionsInput and FunctionsAll FunctionsInstrument I/O palettes is a LabVIEW Express VI that allows you to easily test communication with your instrument and develop a sequence of query, parse, and write steps. These steps can be saved as an Express VI for instant use or can be converted to a LabVIEW subVI. Use the Instrument I/O Assistant when an instrument driver is not available.Communicating with an InstrumentOnce you have placed the I/O Assistant on the block diagram, the wizard opens. The wizard starts in the Select Instrument step, where you can choose a GPIB or serial instrument. You also can check the interface properties from this window.After selecting the instrument, you can add sequences to Query and Parse, Write, or Read and Parse. In addition, after you have set up a communication sequence with one instrument, you can set up additional instruments in the same Express VI.In the figure above, a GPIB instrument was set up, then a query (*IDN?) was sent to the instrument. The response was automatically parsed, resulting in a string output. Using VISA FunctionsVISA is the underlying layer of function calls used in the LabVIEW instrument driver VIs to communicate with the driver software. This section describes what VISA is and how you use VISA functions in LabVIEW instrument drivers.

    VISA History and DefinitionsFor many years, industry has moved toward purchasing instrumentation from a variety of vendors. This allows engineers to select the best possible equipment for their applications without being locked into a specific vendor. This trend required the definition of hardware standards to ensure the compatibility between different modules. This was one of the factors leading to the development of the VXI specification. But even with these improved hardware standards, a system was time consuming and expensive to put together. Successful integration of a multivendor system requires all hardware and software products work together, eliminating system-level compatibility issues for end-users.National Instruments initially addressed the software problems with instrument drivers, which helped reduce both integration time and software development costs. In 1993, National Instruments joined with GenRad, Racal Instruments, Tektronix, and Wavetek to form the VXIplug&play Systems Alliance. The goals of the alliance are to ensure multivendor interoperability for VXI systems and to reduce the development time for an operational system.VISA Programming TerminologyBefore being introduced to VISA programming, you should become familiar with some of the VISA terminology. The most important objects in the VISA language are known as resources. The functions you can use with an object are known as operations. In addition to the operations that you can use an object, the object has variables, known as attributes, associated with it that contain information related to the object.Three terms need definitions: Resource: This is any instrument in your system (includes serial and parallel ports).Session: You must open a VISA session to a resource to communicate with it, similar to a communication channel. When you open a session to a resource, you are returned a VISA Session Number, which is a unique handle to that instrument. You must use the Session Number in all subsequent VISA functions. In LabVIEW, this is a refnum.Instrument Descriptor: This is the exact name of a resource. The descriptor specifies the interface type (GPIB, VXI, ASRL), the address of the device (logical address or primary address) and the VISA Session type (INSTR or Event).VISA: Virtual Instrument Software Architecture. A protocol built upon 488.2 driver and functions to meet the industry needs for having a way to easily interface with multiple I/Os and have all manufacturers of instruments and instrument drivers follow a protocol.

    VISA created by the VXIplug&play Alliance which is composed of the top 35 instrument manufacturers such as HP. National Instruments is a leading member of the alliance.

    The resource name contains information on the type of I/O interface and the device address.Explain to the students that we need some means of identifying which device we want to talk to. This is done by specifying a VISA resource name.Two examples of VISA resource names are shown on the slide.The first one tells the VISA functions that the instrument can be found on:The GPIB busAt primary address 2and that it is an instrument type deviceThe second example is a VISA alias and is assigned to the instrument in MAX.The alias allows you to give an instrument a meaningful name

    LabVIEW provides more than 1200 LabVIEW instrument drivers from more than 50 vendors. You can use these instrument drivers to build complete systems quickly. Instrument drivers drastically reduce software development costs because developers do not need to spend time programming their instruments. You can reuse the drivers in a variety of systems and configurations. LabVIEW instrument drivers simplify instrument programming to high-level commands, so you do not need to learn the low-level instrument-specific syntax needed to control your instruments. The programming is broken down into general functions for the DMM These instrument drivers are called LabVIEW instrument drivers because the source code is graphical programming made from standard LabVIEW functions and VIs. LabVIEW instrument drivers are in the form of VI libraries and are organized into categories of instrument functions. You will learn about each category.Installing and Accessing Instrument DriversYou can find the LabVIEW instrument drivers on your LabVIEW installation CD or download them from the National Instruments web page at www.ni.com/idnet. The LabVIEW Instrument Wizard can automatically install instrument drivers.If you install the LabVIEW instrument drivers from the CD yourself or download them from the web page, you first decompress the instrument driver files to get a directory of instrument driver files. Place this directory into the LabVIEW\instr.lib directory on your computer. The next time you launch LabVIEW, you can access the instrument driver VIs from the Input Instrument Drivers subpalette of the Functions palette as shown in the slide above.

    The Instrument Driver Network at ni.com is the industrys largest source of instrument drivers, featuring drivers for over 2,200 instruments from 150 vendors. Here, you can learn about, download, develop, and submit drivers for controlling instruments from LabVIEW, LabWindows/CVI, and Measurement Studio. All instrument drivers in the library have the same VI Tree structure. Therefore, once you learn to use one instrument driver, all others have the same basic hierarchy. In fact, this hierarchy, sequence of VIs, and error checking are used in many other areas of I/O in LabVIEW such as file I/O, data acquisition (DAQ), and TCP/IP communications.The structure of an instrument driver is shown in the figure above. The high-level functions are built from the lower-level functions. For the most control over the instrument, you would use the lower-level functions. However, the high-level functions like the Getting Started VI you used in the previous lesson are easy to use and have soft front panels that resemble the instrument. The component functions of instrument drivers are organized into the following categories: InitializeConfigureAction/StatusDataUtilityClose Instrument Driver VIsInitializeInitializes the communication channel to the instrument. The initialize VI can optionally perform an identification query and reset operation. In addition, it can perform any necessary actions to place the instrument in its default power-on state or other specified state.ConfigureA collection of VIs that configure the instrument for the operations you want to perform. An example is a function to set up the trigger rate.Action/StatusContains both action and status 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 function is Acquire Single Shot. An example of a status function is Query Transfer Pending.DataVIs that transfer data to or from the instrument such as reading a measured waveform from the instrument or downloading a waveform to the instrument.UtilityVIs that perform a wide variety of useful functions such as reset, self-test, error query, and revision query.CloseTerminates the communication channel to the instrument and de-allocates the resources set aside for that instrument.

    Inputs and Outputs Common to Instrument Driver VIs Now that you have learned some common techniques for building and editing LabVIEW VIs, you will start using instrument driver VIs to build applications. Just as all instrument drivers share a common set of functions, they also share common inputs and outputs. Instrument DescriptorThe instrument descriptor is the address or VISA alias of the instrument.VISA SessionsBefore you can communicate with an instrument, you need to open a communication link to the instrument with an Initialize VI. When the connection to the instrument is made, a VISA session number is returned. That VISA session is a connection or link to a resource, your instrument. Each time you communicate with that device again, you need to wire the VISA session input on the instrument driver VIs. After you are finished communicating with the instrument, you call the Close instrument driver VI, and all references or resources for the instrument are closed. Note VISA session and instrument descriptor are terms used with the majority of LabVIEW instrument drivers that were written with VISA 2.0. LabVIEW instrument drivers written with VISA 2.5 and later use the term VISA resource name. The functionality and usage are practically identical. Putting It All Together

    Now that you have learned all the instrument driver-specific inputs and outputs, you are ready to use those VIs to communicate with an instrument. The diagram above initializes the DMM with its VISA Alias, uses an Application Example VI to configure and read data from the meter, and closes the instrument, and then the error status is checked. You will see this same sequence of events in every application that uses an instrument driver. Notice how the Instrument Descriptor, VISA Sessions, and Error I/O terminals are wired. Remember that you can right click on the instrument driver VI terminals and choose Create Constant, Create Control, or Create Indicator as needed.

    Serial Port CommunicationSerial communication is a popular means of transmitting data between a computer and a peripheral device such as a programmable instrument or even another computer. Serial communication uses a transmitter to send data, one bit at a time, over a single communication line to a receiver. You can use this method when data transfer rates are low or you must transfer data over long distances. Serial communication is popular because most computers have one or more serial ports, so no extra hardware is needed other than a cable to connect your instrument to the computer (or two computers together).Serial communication requires that you specify four parameters: the baud rate of the transmission, the number of data bits encoding a character, the sense of the optional parity bit, and the number of stop bits. Each transmitted character is packaged in a character frame that consists of a single start bit followed by the data bits. A typical character frame encoding the letter m is shown in the slide above. Baud rate is a measure of how fast data is moving between instruments that use serial communication. RS-232 uses only two voltage states, called MARK and SPACE. In such a two-state coding scheme, the baud rate is identical to the maximum number of bits of information, including control bits, that are transmitted per second. MARK is a negative voltage and SPACE is positive; the slide above shows how the idealized signal looks on an oscilloscope. The truth table for RS-232 is:Signal > +3 V = 0 Signal < -3 V = 1The output signal level usually swings between +12 V and -12 V. The dead area between +3 V and -3 V is designed to absorb line noise.

    There are several recommended standards (RS) for serial communication. Each varies in hardware and software specifications. The students must be familiar with their instrument and what connector is used before you can begin controlling that device with their computer.

    There are three main Serial I/O types:

    RS-232Connector found on most PCs. This is a single-ended communication method where only one device can be connected per port. Two connector types, 8- or 25-pin. Two configurations, DCE or DTE.

    RS-422Connector found on most Macs. This is a differential communication method. Connector has 8 pins.

    Instructor: See how many students are going to use or are interested in Serial I/O. Then cover the material in this and the next four slides accordingly. Go over the following Serial I/O terminology:

    Baud rateHow many bits per second are transferred on the serial cable.Data bitsHow many bits represent a data value.ParityOptional error checking bit that is added to the data.Stop bitsCertain number of bits added to the end of each data transfer.Flow controlOptional hardware or software handshaking parameters for communicating with a device.Use the I/O Assistant just like with GPIB communication.

    Do not immediately display this slide.

    Suggested questions for class participation:

    What GPIB boards does LabVIEW support?What is the difference between GPIB and serial?What type of GPIB instruments will LabVIEW support? (488.2 and 488 instruments)What is VISA?Why use the Instrument I/O Assistant?What is the purpose of an instrument driver?What is the Instrument Wizard and how do you use it?

    SubVI Node Setup is used to set execution options for a single instance of a subVI.

    Does not affect other calls to that same subVI in the diagram. (VI Setup options affect every instance of that VI.)

    Key Navigation can be accessed from the pop-up menu of any front panel control. The operation of the control can be associated with specific keys or key combinations.

    Not in course but mention if there is time:When running a VI, you can hit the tab key to enable key focus to the front panel controlsTo key focus inside arrays and clusters - use +down arrow (to step into array or cluster) and +up arrow (to step out of array or cluster). Then use tab to key focus each element.Explain to the students that when you change the VI Setup options in a certain combination, they can make it almost impossible to edit their VI again. For example, Run When Opened, all menu bars and toolbars disabled, and Exit LabVIEW function.

    Show the Save with Options window and encourage the students to save a copy of their VIs (and the hierarchy) to a new location before they start modifying the VI Setup options.

    Point out that you can save VIs without diagrams and with passwords.

    CAUTION: Explain to your students the dangers of saving a VI without a diagram or with a password. Once you remove the diagram, that code is lost and cannot be recovered. This also means that that VI will only work in the version of LabVIEW in which it was created, in other words, you will not be able to open that VI in a future edition of LabVIEW. Additionally, there is no method for unlocking VIs for which you forget the password.Do not show this slide immediately.

    Discussion questions:

    What is the difference between VI Setup and SubVI Node Setup?How do you make a subVI open its front panel when it is run?Why should you use the Save with Options before modifying your VI Setup options?How can you edit a VI that opens, runs, and closes or is locked?In what ways can you customize the Controls and Functions palettes?

    Review the summary slide.B. Info-LabVIEW ListserveInfo-LabVIEW is an e-mail group of users from around the world who discuss LabVIEW issues. The people on this list can answer questions about building LabVIEW systems for particular applications, about where to get instrument drivers or help with a device, and about problems that appear. Subscription and posting information is listed in the figure above.You may also want to search the ftp archives at ftp:// ftp.pica.army.mil/pub/labview/. The archives contain a large set of donated VIs for doing a wide variety of tasks. User Support NewsgroupsThe National Instruments User Support Newsgroups are a collection of Usenet newsgroups covering National Instruments products as well as the general fields of science and engineering. You can read, search, and post to the newsgroups to share solutions and find additional support from other users. You can access the User Support Newsgroups from the National Instruments support Web page.

    E. LabVIEW PublicationsLabVIEW Technical Resource (LTR) NewsletterSubscribe to LabVIEW Technical Resource to discover power tips and techniques for developing LabVIEW applications. This quarterly publication offers detailed technical information for novice users as well as advanced users. In addition, each issue includes a disk of LabVIEW VIs and utilities that implement methods covered in that issue. To order LabVIEW Technical Resource, call LTR publishing at (214) 706-0587 or visit ltrpub.com. LabVIEW BooksThe books listed above are just a few of the ones written about LabVIEW programming and applications. The National Instruments Web site contains a list of all the LabVIEW books and links to places to purchase these books. Publisher information is listed above so you can directly contact the publisher for more information on the contents and ordering information for these books.