Typical C-SCPI
Example Program
The Verify program (file name verif.cs) is printed below to show a typical
C-SCPI program for the HP E1313/E1413.
/* verif.cs
*/
/*
1.) Prints the HP E1413A Module’s identification, manufacturer, and
*/
/*
revision number.
*/
/*
2.) Prints the Signal Conditioning Plug-ons (SCPs) identification*/
/*
(if any) at each of the SCP positions.
*/
/*
3.) Takes voltage measurements on channels 100 to 163 and returns the*/
/*
readings from the Current Value Table (CVT) and FIFO. */
#include <stdio.h>
#include <cscpi.h>
/* Defines module’s logical address */
#define LADD “24”
/* Declares module as a register device */
INST_DECL(e1413, “E1413A”, REGISTER);
/* Prototypes of functions declared later */
void rst_clr( void );
void id_scps( void );
void start_ad( void );
void get_readng( void );
void prt_readng( float32 * );
int32 check_error( char * );
/
************************************************************************
/
main() /* Main function */
{
char
read_id[80];
/* Clear screen and announce program */
printf(“\033H\033J\n\n
Installation Verification Program\n\n”);
printf(“\n\n
Please Wait...”);
/* Start the register-based operating system for the module */
INST_STARTUP();
/* Enable communications to the module; check if successful */
INST_OPEN(e1413, “vxi,” LADD);
if ( !e1413 )
{
printf(“INST_OPEN failed (ladd = %s).Failure code is: %d\n”,
LADD,cscpi_open_error);
exit(1);
}
/* Read and print the module’s identification */
INST_QUERY(e1413, “*idn?”, “”, read_id);
printf(“\n\nInstrument ID: %s\n\n”, read_id);
rst_clr(); /* Function resets the module */
id_scps();
/* Function checks for installed SCPs */
start_ad();
/* Function sets up the module to make measurements */
get_readng(); /* Function gets and prints readings */
exit(0);
}
/
*************************************************************************
/
void rst_clr() /* Reset the A/D module to its power-on state */
{
int16
opc_wait;
/* Reset the module and wait until it resets */
INST_QUERY(e1413, “*RST;*OPC?”, “”, &opc_wait);
/* Check for module generated errors; exit if errors read */
30 Getting Started
Chapter 1
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com