
Programming Examples
USB Communication (Example #4)
#include “stdio.h”
#include “visa.h”
#include <time.h>
#de
fi
ne MAX_CNT 200
void Sleep( clock_t Wait );
int main(void) {
ViStatus Status; // For checking errors
ViUInt32 RetCount; // Return count from string I/O
ViChar Buffer[MAX_CNT]; // Buffer for string I/O
ViFindList fList;
ViChar Desc[VI_FIND_BUFLEN];
ViUInt32 numInstrs;
ViSession defaultRM, Instr;
int i = 0;
// Begin by initializing the system
Status = viOpenDefaultRM(&defaultRM);
if (Status < VI_SUCCESS) {
printf (“Failed to initialise NI-VISA system.\n”);
return -1;
}
// Look for instrument
Status = viFindRsrc(defaultRM,
“USB?*INSTR{VI_ATTR_MANF_ID==0x0699}”,
&fList, &numInstrs, Desc);
if (Status < VI_SUCCESS) {
printf (“No matching instruments found.\n”);
return -1;
}
// Open communication with GPIB Device
Status = viOpen(defaultRM, Desc, VI_NULL, VI_NULL, &Instr);
if (Status < VI_SUCCESS) {
printf (“Cannot communicate with instrument.\n”);
return -1;
}
// Set the timeout for message-based communication
Status = viSetAttribute(Instr, VI_ATTR_TMO_VALUE, 1000);
// Ask the device for identi
fi
cation
Status = viWrite(Instr, “*IDN?\n”, 6, &RetCount);
Status = viRead(Instr, Buffer, MAX_CNT, &RetCount);
Buffer[RetCount]=0;
printf(“%s\n”,Buffer);
Status = viWrite(Instr, “INIT:CONT OFF;:func ‘per’\n”, 25,
&RetCount);
while( i++<10){
Status = viWrite(Instr, “init;fetc?\n”, 11, &RetCount);
if (Status != VI_SUCCESS) {
FCA3000, FCA3100, MCA3000 Series Programmer Manual
4-9
Содержание FCA3000 Series
Страница 2: ......
Страница 8: ...Preface iv FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 9: ...Getting Started ...
Страница 10: ......
Страница 14: ...Using the USB Interface 1 4 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 15: ...Syntax and Commands ...
Страница 16: ......
Страница 26: ...Command Syntax 2 10 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 135: ...Status and Events ...
Страница 136: ......
Страница 156: ...Status and Events 3 20 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 157: ...Programming Examples ...
Страница 158: ......
Страница 179: ...Appendices ...
Страница 180: ......
Страница 181: ...Appendix A Character Set FCA3000 FCA3100 MCA3000 Series Programmer Manual A 1 ...
Страница 182: ...Appendix A Character Set A 2 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 188: ...Appendix D Reserved Words D 2 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...