2025年泰克-吉时利-2200-远程操作

泰克-吉时利-2200-远程操作泰克 吉时利 2200 远程操作 前言 以下是调试泰克吉时利 2200 直流电源远程操作的调试经验 有需要的可以参考 一 VISA 驱动安装 Visa 驱动在 NI 官网下载 如下地址 https www ni com zh cn support downloads drivers download ni visa

大家好,我是讯享网,很高兴认识大家。

泰克-吉时利-2200-远程操作

前言

以下是调试泰克吉时利2200直流电源远程操作的调试经验,有需要的可以参考。

一、VISA驱动安装

二、电流计设置

Shift–>Menu–>Communication–>USBTMC


讯享网

三、Visa协议头文件,静态库

visa.h,visatype.h
64位Windows:
C:\Program Files (x86)\IVI Foundation\VISA\WinNT\include
C:\Program Files\IVI Foundation\VISA\Win64\include

visa32/64.lib
C:\Program Files\IVI Foundation\VISA\Win64\Lib_x64\msc

四、实现代码

//代码截取吉时利2200 spec #define _CRT_SECURE_NO_WARNINGS #include <C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Include\\visa.h> #include <C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Include\\visatype.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #include <time.h> #include <conio.h> #include <stdlib.h> ViSession defaultRM; //Resource manager id ViSession PWS2200; //Identifies the power supply long ErrorStatus; char commandString[256]; char ReadBuffer[256]; void OpenPort(); void SendSCPI(char* pString); void CheckError(char* pMessage); void delay(clock_t wait); void ClosePort(); int main() { 
    double voltage; char Buffer[256]; double current; OpenPort(); //Query the power supply id, read response and print it sprintf(Buffer, "*IDN?"); SendSCPI(Buffer); printf("Instrument identification string:%s \n", Buffer); SendSCPI("*RST"); //reset the power supply SendSCPI("CURRENT 0.1A"); //set the current to 0.1A SendSCPI("VOLTAGE 3V"); //set the voltage to 3V SendSCPI("OUTPUT 1"); // turn output on voltage = 5.0; current = 0.2; printf("Setting voltage(V) & current(A): %f,%f \n",voltage, current); ErrorStatus = viPrintf(PWS2200, "VOLT %f\n", voltage); //set the output voltage CheckError("Unable to set voltage"); ErrorStatus = viPrintf(PWS2200, "CURRENT %f\n", current); //set the output current CheckError("Unable to set current"); ErrorStatus = viPrintf(PWS2200, "MEASURE:VOLTAGE?\n"); //measure the output voltage CheckError("Unable to write the device"); ErrorStatus = viScanf(PWS2200, "%f", &voltage); //retrieve reading CheckError("Unable to read voltage"); ErrorStatus = viPrintf(PWS2200, "MEASURE:CURRENT?\n"); //measure the output current CheckError("Unable to write the device"); ErrorStatus = viScanf(PWS2200, "%f", &current); //retrieve reading CheckError("Unable to read current"); printf("Measured voltage(V) & current(A): %f,%f \n",voltage, current); SendSCPI("OUTPUT 0"); //turn output off ClosePort(); while (1); //return 0; } void OpenPort() { 
    //Open communication session with the power supply, and put the power supply in remote ErrorStatus = viOpenDefaultRM(&defaultRM); ErrorStatus = viOpen(defaultRM,"USB0::0x05E6::0x2200::::INSTR", 0, 0, &PWS2200); CheckError("Unable to open the port"); SendSCPI("SYSTEM:REMOTE"); } void SendSCPI(char* pString) { 
    char* pdest; strcpy(commandString, pString); strcat(commandString, "\n"); ErrorStatus = viPrintf(PWS2200, commandString); CheckError("Can't Write to Power Supply"); pdest = strchr(commandString, '?'); //Search for query command if (pdest != NULL) { 
    ErrorStatus = viBufRead(PWS2200, (ViBuf)ReadBuffer,sizeof(ReadBuffer), VI_NULL); CheckError("Can't read from driver"); strcpy(pString, ReadBuffer); } } void ClosePort() { 
    viClose(PWS2200); viClose(defaultRM); } void CheckError(char* pMessage) { 
    if (ErrorStatus != VI_SUCCESS) { 
    printf("\n %s", pMessage); ClosePort(); exit(0); } } void delay(clock_t wait) { 
    clock_t goal; goal = wait + clock(); while (goal > clock()); } 

讯享网
讯享网 
小讯
上一篇 2025-03-29 07:07
下一篇 2025-03-28 22:15

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/53336.html