Chapter 7 Application Programs

Example Programs for C and C++

C / C++ Example: stat_reg.c

/* stat_reg.c /*****************************************************************************

* Required: VISA library.

*

* This program demonstrates the use of the 34970A Status Registers

*

* for an alarm and Operation Complete (OPC) and for enabling and receiving

*

* an SRQ interrupt. This program also shows how to configure a scan for

*

* 10 readings on one channel.

*

******************************************************************************/

#include <visa.h> #include <stdio.h> #include <string.h>

ViSession defaultRM;

/* Resource manager id */

ViSession DataAcqu;

/* Variable to identify an instrument */

char reply_string [256]= {0};

/* string returned from instrument */

double volt [10];

 

int index, count;

 

int srqFlag = {0};

 

/* Function prototypes for SRQ handler */

ViStatus _VI_FUNCH SRQ_handler(ViSession DataAcqu, ViEventType eventType, ViEvent context,ViAddr userHdlr);

void main ()

{

/* Open communication with DataAcqu using GPIB address "9" */ viOpenDefaultRM (&defaultRM);

viOpen (defaultRM,"GPIB0::9::INSTR",VI_NULL,VI_NULL, &DataAcqu);

/* Reset instrument to power-on and clear the Status Byte */ viPrintf (DataAcqu, "*RST;*CLS\n");

/* Configure the Status Registers to generate an interrupt whenever an alarm is detected on Alarm 1 or when the operation is complete */

viPrintf (DataAcqu, "STATUS:ALARM:ENABLE 1\n"); /* Enable Alarm 1 */

viPrintf (DataAcqu, "*ESE 1\n"); /* Enable the Operation Complete bit */ /* Enable Status Byte Register bit 1 (2) and 5 (32) for SRQ */

viPrintf (DataAcqu, "*SRE 34\n");

/* Enable the interrupt handler for SRQ from the instrument */ viInstallHandler(DataAcqu, VI_EVENT_SERVICE_REQ, SRQ_handler, (ViAddr)10); viEnableEvent(DataAcqu,VI_EVENT_SERVICE_REQ, VI_HNDLR, VI_NULL);

/* Configure the instrument to take 10 dc voltage readings on channel 103. Set the alarm and set SRQ if the voltage is greater than 5 volts.*/

viPrintf (DataAcqu, "CONF:VOLT:DC 10,(@103)\n"); viPrintf (DataAcqu, "TRIG:SOURCE TIMER\n"); viPrintf (DataAcqu, "TRIG:TIMER 1\n"); viPrintf (DataAcqu, "TRIG:COUNT 10\n");

viPrintf (DataAcqu, "CALC:LIMIT:UPPER 5,(@103)\n"); viPrintf (DataAcqu, "CALC:LIMIT:UPPER:STATE ON,(@103)\n"); viPrintf (DataAcqu, "OUTPUT:ALARM1:SOURCE (@103)\n"); viPrintf (DataAcqu, "INIT;*OPC\n");

/* Wait for the instrument to complete its operations so waste time and stay in the program in case there is an SRQ */

Continued on next page

330

Page 332
Image 332
Agilent Technologies 34970A manual ++ Example statreg.c

34970A specifications

Agilent Technologies 34970A is a versatile data acquisition and measurement system that has gained popularity in various industries, including research and development, manufacturing, and education. The primary purpose of the 34970A is to offer an efficient solution for data collection, monitoring, and analysis, which can significantly enhance productivity and accuracy in testing applications.

One of the main features of the 34970A is its modular design, allowing users to customize the system according to their specific measurement needs. The mainframe can accommodate up to three plug-in measurement modules, which can include various types of measurements such as analog, digital, temperature, and frequency. This modularity provides flexibility for users to tailor the system to their requirements, making it highly adaptable to different applications.

Another notable characteristic of the Agilent 34970A is its impressive channel configuration. The system can support up to 120 measurement channels when fully configured, enabling extensive data acquisition without the need for multiple devices. This capability is essential for applications requiring simultaneous monitoring of multiple parameters or locations.

The 34970A utilizes advanced signal processing technologies to ensure high-accuracy measurements. The internal 6.5-digit resolution multimeter provides precise readings, while the device also supports various input types, such as thermocouples and RTDs for temperature measurements. The ability to perform mathematical functions, such as summation and averaging, on the acquired data further enhances its usability.

For data storage and management, the Agilent 34970A features built-in memory for storing up to 20,000 readings. Users can also easily transfer data to a PC through the RS-232 interface or GPIB (IEEE 488) for further analysis and reporting. Additionally, it offers the capability to program automatic data logging and scheduling of measurements, which streamlines the testing process and reduces manual intervention.

In terms of user interface, the 34970A is equipped with a large graphical display that provides clear visualization of measurement data and easy navigation through settings and options. The menu-driven interface makes it accessible for users of all skill levels, simplifying the setup and operation of the device.

Overall, the Agilent Technologies 34970A stands out for its modularity, high channel capacity, advanced measurement technologies, and user-friendly interface. As a reliable and efficient data acquisition system, it is well-suited for a wide range of applications, making it an essential tool for engineers and technicians looking to enhance measurement precision and efficiency.