/cvi/instr/K617/K617.c |
---|
0,0 → 1,273 |
#include <ansi_c.h> |
#include <utility.h> |
#include <gpib.h> |
#include "K617.h" |
K617STATUS K617Stat; |
static int gdev,iret; |
void GpibError(char *msg) { |
printf ("%s\n", msg); |
printf ("ibsta = &H%x <", ibsta); |
if (ibsta & ERR ) printf (" ERR"); |
if (ibsta & TIMO) printf (" TIMO"); |
if (ibsta & END ) printf (" END"); |
if (ibsta & SRQI) printf (" SRQI"); |
if (ibsta & RQS ) printf (" RQS"); |
if (ibsta & CMPL) printf (" CMPL"); |
if (ibsta & LOK ) printf (" LOK"); |
if (ibsta & REM ) printf (" REM"); |
if (ibsta & CIC ) printf (" CIC"); |
if (ibsta & ATN ) printf (" ATN"); |
if (ibsta & TACS) printf (" TACS"); |
if (ibsta & LACS) printf (" LACS"); |
if (ibsta & DTAS) printf (" DTAS"); |
if (ibsta & DCAS) printf (" DCAS"); |
printf (" >\n"); |
printf ("iberr = %d", iberr); |
if (iberr == EDVR) printf (" EDVR <DOS Error>\n"); |
if (iberr == ECIC) printf (" ECIC <Not Controller-In-Charge>\n"); |
if (iberr == ENOL) printf (" ENOL <No Listener>\n"); |
if (iberr == EADR) printf (" EADR <Address error>\n"); |
if (iberr == EARG) printf (" EARG <Invalid argument>\n"); |
if (iberr == ESAC) printf (" ESAC <Not System Controller>\n"); |
if (iberr == EABO) printf (" EABO <Operation aborted>\n"); |
if (iberr == ENEB) printf (" ENEB <No GPIB board>\n"); |
if (iberr == EOIP) printf (" EOIP <Async I/O in progress>\n"); |
if (iberr == ECAP) printf (" ECAP <No capability>\n"); |
if (iberr == EFSO) printf (" EFSO <File system error>\n"); |
if (iberr == EBUS) printf (" EBUS <Command error>\n"); |
if (iberr == ESTB) printf (" ESTB <Status byte lost>\n"); |
if (iberr == ESRQ) printf (" ESRQ <SRQ stuck on>\n"); |
if (iberr == ETAB) printf (" ETAB <Table Overflow>\n"); |
printf ("ibcntl = %ld\n", ibcntl); |
printf ("\n"); |
/* Call ibonl to take the device and interface offline */ |
ibonl (gdev,0); |
exit(1); |
} |
void _VI_FUNC K617_open (int interface, int primary_addr, int secondary_addr, |
int timeout) |
{ |
/* |
gdev = OpenDev ("GPIB0", ""); |
if (ibsta & ERR) GpibError("OpenDev Error"); |
iret = ibpad (gdev, 0); |
if (ibsta & ERR) GpibError("OpenDev Error"); |
iret = ibsad (gdev, NO_SAD); |
iret = ibtmo (gdev, T10s); |
iret = ibeot (gdev, 1); |
iret = ibeos (gdev, 0); |
*/ |
gdev = ibdev(interface,primary_addr,secondary_addr,timeout,1,0); |
if (ibsta & ERR) GpibError("OpenDev Error"); |
Delay(GDELAY); |
return; |
} |
void _VI_FUNC K617_clear (void) |
{ |
iret = ibclr (gdev); /* Clear the device */ |
if (ibsta & ERR) GpibError("OpenDev Error"); |
Delay(GDELAY); |
return; |
} |
void _VI_FUNC K617_send (char *cmd, int len) |
{ |
iret = ibwrt (gdev, cmd, len); |
if (ibsta & ERR) GpibError("OpenDev Error"); |
Delay(GDELAY); |
return; |
} |
int _VI_FUNC K617_receive (char *response, int maxbyt) |
{ |
iret = ibrd (gdev, response, maxbyt); |
if (ibsta & ERR) GpibError("OpenDev Error"); |
response[ibcntl]=0; |
return ibcntl; |
} |
void _VI_FUNC K617_status (void) |
{ |
int len; |
char cres[100]; |
K617_send ("U0X", 3); |
len = K617_receive (cres, 90); |
sscanf(cres," 617%1d%2d%1d%1d%1d%1d%1d%1d%1d%1d%1d%2d%1d%2c", |
&K617Stat.function,&K617Stat.range,&K617Stat.zero_check, |
&K617Stat.zero_correct,&K617Stat.suppress,&K617Stat.trigger, |
&K617Stat.vsource_operate,&K617Stat.read_mode, |
&K617Stat.data_prefix,&K617Stat.display, |
&K617Stat.data_store,&K617Stat.srq,&K617Stat.eoi,K617Stat.terminator); |
K617_send ("X", 1); |
return; |
} |
void _VI_FUNC K617_data_format (int mode) |
{ |
int len; |
char cmd[100]; |
len=sprintf(cmd,"G%0dX",mode); |
K617_send (cmd, len); |
return; |
} |
double _VI_FUNC K617_get (char *prefix, int *loc) |
{ |
int len; |
double value; |
char cres[100]; |
K617_send ("X", 1); |
len = K617_receive (cres, 50); |
if (loc) { |
*loc=-1; |
sscanf(cres,"%4c%lg,%d",prefix, &value, loc); |
prefix[4]=0; |
} else { |
sscanf(cres,"%*4c%lg,%*d",&value); |
} |
return value; |
} |
void _VI_FUNC K617_current_mode (int range) |
{ |
int len; |
char cmd[100]; |
len=sprintf(cmd,"F1R%0dX",range); |
// printf("%d, %s\n",len,cmd); |
K617_send (cmd, len); |
Delay(1); |
return; |
} |
void _VI_FUNC K617_zero_correct (int zcorrect) |
{ |
K617_send ("C0X", 3); |
K617_send ("Z0X", 3); |
if (zcorrect) { |
K617_send ("C1X", 3); |
Delay(2); |
K617_send ("Z1X", 3); |
K617_send ("C0X", 3); |
} |
return; |
} |
void _VI_FUNC K617_trigger_mode (int mode) |
{ |
int len; |
char cmd[100]; |
len=sprintf(cmd,"T%0dX",mode); |
K617_send (cmd, len); |
return; |
} |
void _VI_FUNC K617_reading_mode (int mode) |
{ |
int len; |
char cmd[100]; |
len=sprintf(cmd,"B%0dX",mode); |
K617_send (cmd, len); |
return; |
} |
void _VI_FUNC K617_vsource_set (float value) |
{ |
int len; |
char cmd[100]; |
value=0.05*floor((value+0.025)/0.05); |
len=sprintf(cmd,"V%+0.2fX",value); |
// printf("%d, %s\n",len,cmd); |
K617_send (cmd, len); |
return; |
} |
double _VI_FUNC K617_vsource_get (void) |
{ |
double value; |
K617_reading_mode (4); |
value = K617_get (NULL, NULL); |
K617_reading_mode (0); |
return value; |
} |
void _VI_FUNC K617_vsource_operate (int operate) |
{ |
if (operate) |
K617_send ("O1X", 3); |
else |
K617_send ("O0X", 3); |
return; |
} |
void _VI_FUNC K617_close (void) |
{ |
// iret = CloseDev (gdev); |
iret = ibonl(gdev, 0); /* Take the device offline */ |
if (ibsta & ERR) GpibError("OpenDev Error"); |
return; |
} |
#ifdef K617_MAIN |
#include <cvirte.h> |
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
LPSTR lpszCmdLine, int nCmdShow) |
{ |
int i; |
double value; |
char cres[100]; |
if (InitCVIRTE (hInstance, 0, 0) == 0) return -1; /* out of memory */ |
K617_open (0, 3, 0, 13); |
/* |
K617_clear (); |
K617_current_mode (4); |
K617_zero_correct (1); |
K617_data_format (0); |
K617_trigger_mode (0); |
K617_vsource_set (-100.); |
K617_vsource_operate (1); |
*/ |
K617_status (); |
value=K617_get(cres, &i); |
printf("%s, %lg, %d\n",cres,value,i); |
value=K617_vsource_get(); |
printf("%s, %lg, %d\n",cres,value,i); |
value=K617_get(cres, &i); |
printf("%s, %lg, %d\n",cres,value,i); |
Delay(5); |
// K617_vsource_operate (0); |
K617_close (); |
return 0; |
} |
#endif |
/cvi/instr/K617/K617.fp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/cvi/instr/K617/K617.h |
---|
0,0 → 1,43 |
#include <cvidef.h> |
#include <ivi.h> |
#define GDELAY 0.01 |
typedef struct { |
int function,range,zero_check,zero_correct,suppress,trigger; |
int vsource_operate,read_mode,data_prefix,display,data_store; |
int srq,eoi; |
char terminator[2]; |
} K617STATUS; |
extern K617STATUS K617Stat; |
void _VI_FUNC K617_open (int interface, int primary_addr, int secondary_addr, |
int timeout); |
void _VI_FUNC K617_clear (void); |
void _VI_FUNC K617_send (char *cmd, int len); |
int _VI_FUNC K617_receive (char *response, int maxbyt); |
void _VI_FUNC K617_status (void); |
void _VI_FUNC K617_data_format (int mode); |
double _VI_FUNC K617_get (char *prefix, int *loc); |
void _VI_FUNC K617_current_mode (int range); |
void _VI_FUNC K617_zero_correct (int zcorrect); |
void _VI_FUNC K617_trigger_mode (int mode); |
void _VI_FUNC K617_reading_mode (int mode); |
void _VI_FUNC K617_vsource_set (float value); |
double _VI_FUNC K617_vsource_get (void); |
void _VI_FUNC K617_vsource_operate (int operate); |
void _VI_FUNC K617_close (void); |
/cvi/instr/K617/K617.prj |
---|
0,0 → 1,168 |
[Project Header] |
Version = 551 |
Platform Code = 4 |
Pathname = "/c/MeasurementStudio/cvi/instr/K617/K617.prj" |
CVI Dir = "/c/measurementstudio/cvi" |
VXIplug&play Framework Dir = "/C/VXIpnp/winnt" |
Number of Files = 3 |
Sort Type = "No Sort" |
Target Type = "Executable" |
Build Configuration = "Debug" |
Warn User If Debugging Release = 1 |
Flags = 16 |
Drag Bar Left = 136 |
Window Top = 598 |
Window Left = 539 |
Window Bottom = 914 |
Window Right = 1083 |
[File 0001] |
File Type = "CSource" |
Path = "/c/MeasurementStudio/cvi/instr/K617/K617.c" |
Res Id = 1 |
Exclude = False |
Disk Date = 3336716446 |
Project Flags = 0 |
Compile Into Object File = False |
Object Format = "Win32-MSVC" |
ForceCompile_Debug = False |
ForceCompile_Release = True |
Window Top = 147 |
Window Left = 227 |
Window Height = 0 |
Window Width = 0 |
Source Window State = "1,109,109,109,19,33,19,0,0,88,0,3,0,3,0,47,0,0,30,15," |
Header Dependencies = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25," |
Line Tags = "92," |
[File 0002] |
File Type = "Function Panel" |
Path = "/c/MeasurementStudio/cvi/instr/K617/K617.fp" |
Res Id = 2 |
Exclude = False |
Disk Date = 3336715149 |
Project Flags = 0 |
Window Top = 0 |
Window Left = 0 |
Window Height = 0 |
Window Width = 0 |
[File 0003] |
File Type = "Include" |
Path = "/c/MeasurementStudio/cvi/instr/K617/K617.h" |
Res Id = 3 |
Exclude = False |
Disk Date = 3336964657 |
Project Flags = 0 |
Window Top = 476 |
Window Left = 581 |
Window Height = 0 |
Window Width = 0 |
Source Window State = "1,15,15,15,14,22,23,0,0,88,0,0,0,0,0,25,0,0,11,87," |
Line Tags = "20," |
[SCC Options] |
Use global settings = True |
SCC Provider = "" |
SCC Project = "" |
Local Path = "" |
Auxiliary Path = "" |
Perform Same Action For .h File As For .uir File = "Ask" |
Comment = "" |
Username = "" |
Use Default Comment = False |
Use Default Username = False |
Do Not Include PRJ File in Actions = True |
Suppress CVI Error Messages = False |
[Compiler Options] |
Default Calling Convention = "cdecl" |
Max Number Of Errors = 10 |
Require Prototypes = True |
Require Return Values = True |
Enable Pointer Mismatch Warning = False |
Enable Unreachable Code Warning = False |
Track Include File Dependencies = True |
Prompt For Missing Includes = True |
Stop On First Error File = False |
Bring Up Err Win For Warnings = True |
Show Build Dialog = False |
O Option Compatible With 5.0 = False |
[Run Options] |
Stack Size = 250000 |
Debugging Level = "Standard" |
Save Changes Before Running = "Ask" |
Break On Library Errors = True |
Break On First Chance Exceptions = False |
Hide Windows = False |
Break At First Statement = False |
[Compiler Defines] |
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DK617_MAIN" |
[Command Line Args] |
Command Line Args = "" |
[Included Headers] |
Header 0024 = "/c/MeasurementStudio/cvi/instr/K617/K617.h" |
Header 0001 = "/c/MeasurementStudio/cvi/include/ansi_c.h" |
Header 0002 = "/c/MeasurementStudio/cvi/include/cvidef.h" |
Header 0003 = "/c/MeasurementStudio/cvi/include/ivi.h" |
Header 0004 = "/c/MeasurementStudio/cvi/include/visa.h" |
Header 0005 = "/c/MeasurementStudio/cvi/include/ansi/stdarg.h" |
Header 0006 = "/c/MeasurementStudio/cvi/include/cvirte.h" |
Header 0007 = "/c/MeasurementStudio/cvi/include/visatype.h" |
Header 0008 = "/c/MeasurementStudio/cvi/include/ansi/assert.h" |
Header 0009 = "/c/MeasurementStudio/cvi/include/utility.h" |
Header 0010 = "/c/MeasurementStudio/cvi/include/ansi/limits.h" |
Header 0011 = "/c/MeasurementStudio/cvi/include/ansi/locale.h" |
Header 0012 = "/c/MeasurementStudio/cvi/include/ansi/ctype.h" |
Header 0013 = "/c/MeasurementStudio/cvi/include/ansi/errno.h" |
Header 0014 = "/c/MeasurementStudio/cvi/include/ansi/float.h" |
Header 0015 = "/c/MeasurementStudio/cvi/include/ansi/signal.h" |
Header 0016 = "/c/MeasurementStudio/cvi/include/ansi/stdlib.h" |
Header 0017 = "/c/MeasurementStudio/cvi/include/ansi/math.h" |
Header 0018 = "/c/MeasurementStudio/cvi/include/ansi/setjmp.h" |
Header 0019 = "/c/MeasurementStudio/cvi/include/ansi/string.h" |
Header 0020 = "/c/MeasurementStudio/cvi/include/ansi/stddef.h" |
Header 0021 = "/c/MeasurementStudio/cvi/include/ansi/stdio.h" |
Header 0022 = "/c/MeasurementStudio/cvi/include/ansi/time.h" |
Header 0023 = "/c/MeasurementStudio/cvi/include/gpib.h" |
Header 0025 = "/c/MeasurementStudio/cvi/include/vpptype.h" |
Max Header Number = 25 |
[Create Executable] |
Executable File_Debug = "/c/MeasurementStudio/cvi/instr/K617/K617_dbg.exe" |
Target Creation Date_Debug = 3336719389 |
Force Creation of Target_Debug = False |
Executable File_Release = "" |
Target Creation Date_Release = 0 |
Force Creation of Target_Release = False |
Icon File = "" |
Application Title = "" |
DLL Exports = "Include File Symbols" |
DLL Import Library Choice = "Gen Lib For Current Mode" |
Use VXIPNP Subdirectories for Import Libraries = False |
Use Dflt Import Lib Base Name = True |
Where to Copy DLL = "Do not copy" |
Add Type Lib To DLL = False |
Include Type Lib Help Links = False |
Type Lib FP File = "" |
Type Lib Guid = "" |
Uses DataSocket = 0 |
Uses NIReports = 0 |
Uses DCom95 = 0 |
Instrument Driver Support Only = False |
[External Compiler Support] |
UIR Callbacks File Option = 0 |
Using LoadExternalModule = False |
Create Project Symbols File = True |
UIR Callbacks Obj File = "" |
Project Symbols H File = "" |
Project Symbols Obj File = "" |
[DLL Debugging Support] |
External Process Path = "" |