GPIB编程资料

2019-08-20 20:27

GPIB编程的资料不过NI的列子是最简单明了的:

********************************************************************* Refer to the language interface documentation for details on * which header and .obj files to include in your project.

********************************************************************/ #include #include \#include

void GpibError(char *msg); /* Error function declaration */ int Device = 0; /* Device unit descriptor */

int BoardIndex = 0; /* Interface Index (GPIB0=0,GPIB1=1,etc.) */ void main() {

int PrimaryAddress = 2; /* Primary address of the device */ int SecondaryAddress = 0; /* Secondary address of the device */ char Buffer[101]; /* Read buffer */

/******************************************************************* Initialization - Done only once at the beginning of your application.

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

Device = ibdev( /* Create a unit descriptor handle */ BoardIndex, /* Board Index (GPIB0 = 0, GPIB1 = 1, ...) */ PrimaryAddress, / * Device primary address */ SecondaryAddress, /* Device secondary address */

T10s, /* Timeout setting (T10s = 10 seconds) */ 1, /* Assert EOI line at end of write */ 0); /* EOS termination mode */ if (ibsta & ERR) {

/* Check for GPIB Error */ GpibError(\ }

ibclr(Device); /* Clear the device */ if (ibsta & ERR) {

GpibError(\ }

/******************************************************************** Main Application Body - Write the majority of your GPIB code here.

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

ibwrt(Device, \ /* Send the identification query command */ if (ibsta & ERR) {

GpibError(\ }

ibrd(Device, Buffer, 100); /* Read up to 100 bytes from the device */ if (ibsta & ERR) {

GpibError(\ }

Buffer[ibcntl] = '\\0'; /* Null terminate the ASCII string */

printf(\ /* Print the device identification */

/*********************************************************** * Uninitialization - Done only once at the end of your application.

***************************************************************/ ibonl(Device, 0); /* Take the device offline */ if (ibsta & ERR) {

GpibError(\ }

ibonl(BoardIndex, 0); /* Take the interface offline */ if (ibsta & ERR)

{

GpibError(\ } }

/***************************************************************** * Function GPIBERROR * This function will notify you that a NI-488 function failed by * printing an error message. The status variable IBSTA will also be * printed in hexadecimal along with the mnemonic meaning of the bit * position. The status

variable IBERR will be printed in decimal * along with the mnemonic meaning of the decimal value. The status * variable IBCNTL will be printed in decimal. * * The NI-488 function IBONL is called to disable the hardware and * software. * * The EXIT function will terminate this program.

******************************************************************/ void GpibError(char *msg) {

printf (\

printf (\ if (ibsta & ERR ) printf (\ if (ibsta & TIMO) printf (\ if (ibsta & END ) printf (\ if (ibsta & SRQI) printf (\ if (ibsta & RQS ) printf (\ if (ibsta & CMPL) printf (\ if (ibsta & LOK ) printf (\ if (ibsta & REM ) printf (\ if (ibsta & CIC ) printf (\ if (ibsta & ATN ) printf (\

if (ibsta & TACS) printf (\ if (ibsta & LACS) printf (\ if (ibsta & DTAS) printf (\ if (ibsta & DCAS) printf (\ printf (\

printf (\ if (iberr == EDVR)

printf (\ if (iberr == ECIC)

printf (\ if (iberr == ENOL)

printf (\ if (iberr == EADR)

printf (\ if (iberr == EARG)

printf (\ if (iberr == ESAC)

printf (\ if (iberr == EABO)

printf (\ if (iberr == ENEB)

printf (\ if (iberr == EOIP)

printf (\ if (iberr == ECAP)

printf (\ if (iberr == EFSO)

printf (\ if (iberr == EBUS)

printf (\

if (iberr == ESTB)

printf (\ if (iberr == ESRQ)

printf (\ if (iberr == ETAB)

printf (\printf (\ printf (\

/* Call ibonl to take the device and interface offline */ ibonl (Device,0); ibonl (BoardIndex,0); exit(1); }


GPIB编程资料.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:矿井供电系统事故专项应急预案(修改)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: