Chapter 6 Application Programs
Example Program for C and C++
135
6
Example Program for C and C++
The following C programming example shows you how to send and receive
formatted I/O. This example programming shows you how to use the SCPI
commands for the instrument with the VISA functionality and does include
error trapping. For more information on non-formatted I/O and error trapping,
refer to the Agilent Technologies VISA
User’s Guide
.
The following C programming example was written in Microsoft
Ò
Visual C++
version 1.52 using project type “QuickWin application’’, and using the large
memory model and C++ version 4.x or 5.0 using project type “Windows 32
application’’. Be sure to move the “
visa.lib
(Windows
Ò
3.1) or visa32.lib
(Windows
Ò
95/NT)” and “
visa.h
” file to the lib and include development
directory. These are usually found in the
c:\vxipnp\win(win95
or
winnt)\lib\msc
or
c:\vxipnp\win (win95
or
winnt)\include
directory.
Diode.c
/*Diode.C
This example program steps the power supply through 11 voltages and measures the current
response. It prints the voltage step and the current response as a table. Note that the
GPIB address is the default address from the factory for the power supply.*/
#include <visa.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <conio.h>
#include <stdlib.h>
ViSession
defaultRM;
/* Resource manager id
*/
ViSession
power_supply;
/* Identifies power supply
*/
int
bGPIB = 1;
/* Set the number to 0 for use with the RS-232 */
long
ErrorStatus;
/* VISA Error code
*/
char
commandString[256];
char
ReadBuffer[256];
void
delay(clock_t wait);
void
SendSCPI(char* pString);
void
CheckError(char* pMessage);
void
OpenPort();
void main()
{
double
voltage;
/* Value of voltage sent to power supply
*/
char
Buffer[256];
/* String returned from power supply
*/
double
current;
/* Value of current output of power supply
*/
Continued on next page
Summary of Contents for E364XA Series
Page 9: ...8...
Page 15: ...14 Contents Contents...
Page 16: ...1 Quick Start...
Page 26: ...2 General Information...
Page 38: ...3 Front Panel Operation and Features...
Page 70: ...4 Remote Interface Reference...
Page 122: ...5 Error Messages...
Page 133: ...Chapter 5 Error Messages Calibration Errors 132...
Page 134: ...6 Application Programs...
Page 145: ...Chapter 6 Application Programs Example Program for Excel 97 144...
Page 146: ...7 Tutorial...
Page 157: ...Chapter 7 Tutorial Remote Programming 156...
Page 158: ...8 Specifications...
Page 166: ...Appendix Service Information...
Page 175: ...Appendix Service Information General Disassembly 174 General Disassembly...
Page 207: ......
Page 208: ......
Page 209: ......
Page 210: ......
Page 211: ......
Page 212: ......
Page 213: ......
Page 214: ......
Page 215: ......
Page 216: ......
Page 217: ......
Page 218: ......