GPIB-VC编程

GPIB-VC编程CompilingandLinkingVISAPrograms(C/C++)Thissectionprovidesasummaryofimportantcompiler-specificconsiderationswhendevelopingWin32applications.1.LinkingtoVISALibrariesYourapp

大家好,又见面了,我是你们的朋友全栈君。Compiling and Linking VISA Programs (C/C++)

This section provides a summary of important compiler- specific considerations when developing Win32 applications.

1 . Linking to VISA Libraries

Your application must link to the VISA import library as follows, assuming default installation directories and Microsoft compilers:

    C:\Program Files\VISA\winnt\lib\msc\visa32.lib The following steps will help you do this. This information is specific to your development 

environment.

Microsoft Visual C++ Version 6.0 Development Environment

1 Use the  File menu to create a new project or open an existing project.

2 Select  Project > Settings from the menu and click the C/C++ tab.

3 Select  Code Generation from the  Category  list box and select Multi-Threaded using DLL from the  Use Run-Time Libraries list box. (VISA requires these definitions for Win32.) Click  OK to close the dialog box.

4 Select  Project > Settings from the menu. Click the  Link tab and add visa32.lib to the Object/Library Modules  list box. Optionally, you may add the library directly to your project file. Click  OK to close the dialog box.

5 You may want to add the  include  files and  library  files

search paths. They are set as follows:

• Select  Tools > Options from the menu.

• Click the  Directories tab to set the include file path.

• Select  Include Files from the  Show Directories For list box.

• Click at the bottom of the list box and type:  

C:\Program Files\VISA\winnt\include

(This assumes that you used the default installation

location for VISA.)

• Select  Library Files from the  Show Directories For list box.

• Click at the bottom of the list box and type:  

C:\Program Files\VISA\winnt\lib\msc

(This assumes that you used the default installation

location for VISA.)

6 Add or create your C or C++ source files. For example, to build the sample described below, select  Project > Add to Project > Files… and type or browse to  C:\Program Files\Agilent\IO Libraries Suite\ ProgrammingSamples\C\VISA\idn.c.

7 Click  Build > Rebuild All to build the VISA program.

示例:电源型号:Agilent  GPIB线 开发环境为VS2010

1.首先安装GPIB驱动,驱动安装文件比较大,请自行下载安装,我用的NI驱动

2.编写一个Win32程序,实现打开和关闭电源的功能。

主要代码如下:

 

//包含VISA头文件和库文件
#include "WinNT//include//visa.h"                               
#pragma comment(lib, "WinNT//lib//msc//visa32.lib")

电源初始化函数

BOOL CXXXDlg::InitPower()
{
	
	char chStatusDesc[_MAX_DIR] = {0};
	int retCnt=0;	
	char instrDesc[100]={0};	
	ViFindList find_list;	
	float voltSetting, currSetting;
	voltSetting = atof(ini_powervolt);
	currSetting = atof(ini_powercurrent);
	VISAstatus=viOpenDefaultRM(&defrm);
	if (VISAstatus != VI_SUCCESS)
	{
		return FALSE;
	}
	VISAstatus = viFindRsrc(defrm,"GPIB?*INSTR",&find_list,(ViPUInt32)&retCnt, instrDesc);
	
	VISAstatus=viOpen(defrm,instrDesc, VI_NULL, VI_NULL, &session);


	if (VISAstatus!=VI_SUCCESS)
	{
		return FALSE;
	}
	//Set voltage
	viPrintf(session,"VOLT %f \n",voltSetting);


	//Set current level
	viPrintf(session,"CURR %f \n",currSetting);
	return TRUE;
}

打开电源

void CXXXDlg::OnBnClickedBtnPowerOn()
{
	if (!InitPower())
	{
		AfxMessageBox("Init Power Fail,Please Check the GPIB Connected!");
		return;
	}


	viPrintf(session,"OUTP ON \n");
}

关闭电源

void CXXXDlg::OnBnClickedBtnPoweroff()
{
	if (!InitPower())
	{
		AfxMessageBox("Init Power Fail,Please Check the GPIB Connected!");
		return;
	}


	viPrintf(session,"OUTP OFF \n");
}

上面的示例只是简单的展示了开启和关闭电源的基本功能,实际开始时需要根据具体需求来扩展。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/148878.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Win10 1709 无法访问局域网共享问题及解决[通俗易懂]

    Win10 1709 无法访问局域网共享问题及解决[通俗易懂]摘要Win10升级更新为1709以后,出现了不能匿名访问局域网共享,同时本机的共享也无法被其它机器匿名访问。本文给出了设置方法来解决此问题。1.前言Win10的安全性设置越来越严格,与此同时,也带来了易用性的缺失。新手往往会陷入很多功能不能使用的窘境中,从而导致了对Win10的排斥。局域网共享就是一个很典型的例子。对很多中小企业而言,无密码的局域网共享是非常方便和实用的功能,对于提…

  • 【C语言】的%*d、%.*s等详解:「建议收藏」

    目录:0.前言【精简版】:时间少的看这里:时间长的可以看我下面的啰嗦:1.必备入门小知识:2.正题1:scanf(1)%*d被枪毙了:(2)【%.*d】的队友被枪毙了:2.正题2:printf就不讲了,前面的【前言】似乎讲得很明白了吧。0.前言【精简版】:其实网上也有很多关于这方面的解释,但是总会让新手甚至小老手有些迷茫,比如网上有一种解释就说:忽略……你忽略啥啊你…时间少的看这里:<1>scanf:注意:在scanf里只有%*d和%.*d有意义,其他的%*f,%

  • matlab约束条件怎么写_matlab数组超过预设大小

    matlab约束条件怎么写_matlab数组超过预设大小网上例子:假设我们要用matlab解决如下线性规划问题:max4x1+2×2+x3s.t.2×1+x2<=1×1+2×3<=2×1+x2+x3=1×1>=0x1<=1×2>=0x2<=1×3>=0x3<=2如果用yalmip的话,只需要如下简单几句:>>x=sdpva…

    2022年10月13日
  • Modbus测试工具ModbusPoll与Modbus Slave使用方法「建议收藏」

    Modbus测试工具ModbusPoll与Modbus Slave使用方法「建议收藏」Modbus测试工具ModbusPoll与ModbusSlave使用方法

  • 高达起源the origin_idea找不到tomcat

    高达起源the origin_idea找不到tomcat“Theoriginserverdidnotfindacurrentrepresentationforthetargetresourceorisnotwillingtodisclosethatoneexists.”,在web开发的过程中,看到这一段错误提示,不管是在入门阶段还是已经是web老手都会感到很头痛。我也是在使用JSTL库的过程中,出现了这

    2022年10月14日
  • java基础之java输入输出语句[通俗易懂]

    java基础之java输入输出语句[通俗易懂]1、使用Scanner使用时需要引入包importjava.util.Scanner;首先定义Scanner对象Java基础学习:java输入输出语句比如:Java基础学习:java输入输出语句2、使用BufferedReader用前需要引入importjava.io.Reader;Java基础学习:java输入输出语句比如:Java基础学习:java输入输出语句应该注意的是:Java把从键盘输入的数据一律看作是字符串,因此若要从键盘输入并让系统认可是数值型数据,必须经过转换。

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号