PG-1000系列脉冲发生器SCPI远程控制

发布时间:2018-8-30 15:52    发布者:Stone_Mei
关键词: MAX , SCPI , 脉冲发生器 , 虹科 , AT

PG-1000系列脉冲发生器SCPI远程控制.pdf (1.12 MB)

本文以Active Technologies公司(简称AT)的PG 1000系列脉冲发生器为例,讲述了在进行SCPI控制仪器前,如何使用NI MAX进行系统配置。





1.        概要        1
2.        工具/准备        1
2.1 PG-1000系列SDK        1
2.2 NI VISA        2
2.3 NI NAX(Measurement & Automation Explorer)        3
2.4 PG-1000系列软件        3
3. 配置系统(使用NI MAX)        4
4. 调试系统(使用AT Instrument Communicator)        8
5. 例程/范例        9
5.1 LabVIEW        10
5.2 Microsoft C#        11
5.3 Microsoft C++        13

1.        概要
可以连接仪器至用户的网络中,实现打印、文件共享、互联网访问等其他功能。请联系贵公司的网络管理员,并使用标准Windows在用户的网络中配置仪器。
仪器是通过VXI-11 (LAN)协议进行控制的,用户可以利用SCPI命令远程控制仪器,请参考《Pulse Rider PG-1000 programmer manual》了解详细的SCPI命令语法、语句。
2.        工具/准备
2.1 PG-1000系列SDK
1.        用户在www.activetechnologies.it网站注册账户后,登录网站并“Register”仪器。

2.        点击“Support”—“Client Area”,访问“Users Products”界面。

3.        点击AT-PG1072或AT-PG1074链接,访问下载界面。点击SDK-AT-PULSE-GENERATOR安装包并下载。

SDK内包括:
                AT Instrument Communicator安装程序(用途,参考下节“配置系统”的第9步)
                C++例程
C#例程
LabVIEW例程
2.2 NI VISA
在Client-PC(即Remote PC)中下载并安装NI VISA。
VISA为硬件与开发环境(比如,Visual Studio .NET、LabVIEW、LabWindows/CVI、Measurement Studio for Microsoft Visual Studio、MatLab等)提供编程接口。NI VISA是National Instruments公司提供的VISA I/O标准。NI VISA包括软件库、交互式工具(例如, NI I/O Trace与VISA交互式控制)、配置程序等。
2.3 NI NAX(Measurement & Automation Explorer)
在Client-PC(即Remote PC)中下载并安装NI MAX软件。
2.4 PG-1000系列软件

打开PG-1000系列仪器中自带的控制软件,找到“Remote/Local”界面中的VXI-11(LAN协议)Server。默认情况下,VXI-11 Server是开启的,意味着PG1000系列仪器可以接收来自Client-PC的SCPI命令。
当PG-1000系列仪器接收SCPI命令时,PG-1000系列软件界面会根据SCPI命令做出相应的变化(例如,参数设置等)。
注意:不能在本地PC(即PG-1000系列仪器本身中的PC系统)中通过SCPI命令控制PG-1000系列仪器。
若VXI-11 Server被关闭,SCPI命令通信将会失败。
3. 配置系统(使用NI MAX)
使用NI MAX进行如下配置:
1.        使用LAN线缆连接仪器与Client-PC。
2.        在Client-PC中安装NI VISA与NI MAX。
3.        打开Client-PC中的NI MAX。点击“Add Network Device ”——“VISA TCP/IP Resource…”。





4.        选择“Auto-detect of LAN Instrument”,并点击“Next”。

5.        面板将会显示在LAN网络中搜索到的仪器,选择PG-1000系列仪器,并点击“Next”。

6.        输入“Alias”(此步非必须,可省略),并点击“Next”。

7.        点击“Finish”。

8.        PG-1000仪器资源将会在“Network Devices”列表中显示。

9.        现在,可以使用NI Visa Test Panel或AT Instrument Communicator(软件的获取下载,参考“PG-1000系列 SDK”小节的第3步;软件的使用,参考下节“使用AT Instrument Communicator调试系统”)发送SCPI命令至PG-1000。

4. 调试系统(使用AT Instrument Communicator)

VXI-11(LAN协议)Server可以为在同一LAN网络下的PG-1000仪器与Client-PC提供软件接口。
AT Instrument Communicator软件需安装在Client-PC中,且Client-PC中需安装NI VISA。
通过以下步骤,操控Client-PC中AT Instrument Communicator软件实现对PG-1000仪器的控制:
1.        在Client-PC中安装AT Instrument Communicator软件。
2.        在“Device”列表中选择PG-1000系列仪器。
3.        点击“Connect”按钮。
4.        若连接成功,“Command”复选框内的“Write”、“Read”等按钮将会可选(非灰色)
5.        在“Command”文本框内输入*IDN?并点击“Write”按钮。
6.        点击“Query”按钮。
7.        在“Event Logger”列表中,PG-1000系列仪器会显示返回值,例如:
ACTIVE TECHNOLOGIES, AT-PULSE-RIDER PG1072 00000001,SCPI 99.0, SV 1.0.0 where 00000001 is the serialnumber, SCPI 99.0 is the SCPI command version and SV 1.0.0 is the software version.
8.        TXT命令脚本(script)文件包括一系列SCPI命令(每行一条命令),用户可以发送TXT命令脚本文件。点击“File”—“Open”打开加载TXT命令脚本文件对话框。
9.        参考《Pulse Rider PG-1000 programmer manual》了解详细的SCPI命令语法、语句。
5. 例程/范例
PG-1000系列SDK中包含由很多种语言编写的例程,例如LabVIEW、Microsoft Visual C++与Microsoft C# .NE语言。
例程可以在安装了NI VISA并兼容Microsoft Windows®的PC上运行。
NI VISA是National Instruments公司提供的VISA I/O标准。NI VISA包括软件库、交互式工具(例如, NI I/O Trace与VISA交互式控制)、配置程序等。
在软件中使用NI VISA编写的仪器驱动,可以处理软件应用程序与硬件仪器之间的通信。
可下载并安装NI VISA。
例程假设系统已经识别PG-1000系列仪器的资源名称(resource name),即IP地址或主机名称,可参考前文“配置系统”小节了解资源名称(resource name)。
5.1 LabVIEW
LabVIEW例程要求最低使用LabView 2013 64 bit版本,可在…\LabView 2013 Examples\AT-PULSE-RIDER-PG1000 Series文件夹内找到LabVIEW工程。

LabVIEW工程中包含一些VI用于控制仪器的基础特性,还包含有三个例程。
双击GenerateSinglePulse.vi,本例程可以连续模式生成单脉冲。在运行VI之前,需要选择“VISA resource name”。
用户可以更改脉宽、延时、高电平、低电平和其他输出参数。
运行VI开始生成输出脉冲,点击“Stop”按钮控件停止PG-1000系列脉冲发生器。

5.2 Microsoft C#
可以在…\VS2015 Examples\PulseRiderCSharp文件夹内找到C++例程,需要安装Microsoft Visual Studio 2015打开例程。

用户需要编译并运行例程;在Form中需要输入“Instrument Address”并点击“Connect”按钮建立连接。
若成功连接,仪器会在“Server Answer”文本框内显示*IDN?命令的返回值。

点击“Generate Pulse”按钮发送SCPI命令至PG-1000系列仪器,仪器将会以连续模式生成输出单脉冲。
private void btnGeneratePulse_Click(object sender, EventArgs e)
        {
            // Reset to default
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "*RST");
            // Set the channel parameters
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce1:VOLT:HIGH 1.5");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce1:VOLTOW -1.5");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce2:VOLT:HIGH 2");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce2:VOLTOW -2");
            // Set the pulse parameters
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce1ULSe1:WIDth 50 ns");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce1ULSe1ELay 0");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce2ULSe1:WIDth 50 ns");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOUrce2ULSe1ELay 50 ns");
            // Set the pulse mode
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "OUTPut1ULSe:MODe SINgle");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "OUTPut2ULSe:MODe SINgle");
            // Turn On the channels
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "OUTPut1 ON");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "OUTPut2 ON");
            // Set the trigger mode and arm the instrument
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "TRIGger:MODE CONTinuous");
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "PULSEGENControl:START");
            // Send the trigger
            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "*TRG");
        }
点击“ Load Script…”按钮可加载SCPI命令TXT脚本文件;在工程目录文件夹内有三个脚本文件:GenerateSinglePulse.txt、GenerateMultiplePulse.txt、GeneratePulseTriggerIN.txt。
5.3 Microsoft C++
可以在…\VS2015 Examples\PulseRiderMSVC\TCPIP文件夹内找到C++例程,例程是使用 Microsoft® Visual C++语言编写的。
/*********************************************************************/
/* This example demonstrates opening a simple TCPIP connection and   */
/* implements a single pulse generation in Continuous Mode.                         */
/*                                                                   */
/* The general flow of the code is                                   */
/*      Open Resource Manager                                        */
/*      Open a session to the TCP/IP site at NI                      */
/*      Perform write/read, and check properties                     */
/*      Close all VISA Sessions                                      */
/*********************************************************************/

#include "visa.h"

#include
#include
#include

static char outputBuffer[VI_FIND_BUFLEN];
static ViSession defaultRM, instr;
static ViStatus status;
static ViUInt32 count;
static char acBuffer[10000000] = "";   
static unsigned int u32Timeout = 20000; //timeout value in milliseconds

static const char acInstrument[] = "TCPIP::192.168.0.6::INSTR"; // instrument address

ViStatus VisaWrite(std::string sInput)
{
        printf("viWrite - %s \n", sInput.c_str());

        status = viWrite (instr, (ViBuf)sInput.c_str(), sInput.length(), &count);

        if (status < VI_SUCCESS)
        {
                viStatusDesc(instr, status, outputBuffer);
                printf("viWrite failed with error code %x - %s\n", status, outputBuffer);
                viClose(defaultRM);
                exit (EXIT_FAILURE);
        }       

        // In case of query command, retrieve the output string
        memset(outputBuffer, 0, sizeof(outputBuffer));

        status = viRead (instr, (ViBuf)outputBuffer, sizeof(outputBuffer), &count);

        if (status < VI_SUCCESS)
        {
                viStatusDesc(instr, status, outputBuffer);
                printf("viRead failed with error code %x - %s\n",status, outputBuffer);
                viClose(defaultRM);
                exit (EXIT_FAILURE);
        }

        outputBuffer[strlen(outputBuffer)-1] = 0;

        if(strlen(outputBuffer) > 0)
        {
                printf("The server response is:\n %s\n\n",outputBuffer);
        }

        return status;
}

int main()
{
        int iIndex = 0;
        FILE* pFile = NULL;
        ViFindList objFindList;

        /* First we will need to open the default resource manager. */
        status = viOpenDefaultRM (&defaultRM);
        if (status < VI_SUCCESS)
        {
                printf("Could not open a session to the VISA Resource Manager!\n");
                exit (EXIT_FAILURE);
        }  

        status = viFindRsrc (defaultRM, "?*INSTR", &objFindList, &count, outputBuffer);
        if (status < VI_SUCCESS)
        {
                viStatusDesc(instr, status, outputBuffer);
                printf("viFindRsrc failed with error code %x - %s\n", status, outputBuffer);
                exit (EXIT_FAILURE);
        }  

        printf("viFindRsrc - %s\n", outputBuffer);

        /* Now we will open a session via TCP/IP */
        status = viOpen (defaultRM, (ViRsrc) acInstrument, VI_NULL, u32Timeout, &instr);
        if (status < VI_SUCCESS)
        {
                printf ("An error occurred opening the session to %s\n", acInstrument);
                viClose(defaultRM);
                exit (EXIT_FAILURE);
        }

        // Set the timeout attribute
        viSetAttribute (instr, VI_ATTR_TMO_VALUE, u32Timeout);

        //Identify and reset the instrument
        VisaWrite("*IDN?");
        VisaWrite("*RST");
        //Set the Channel Parameters
        VisaWrite("SOURce1ERiod 600 ns");
        VisaWrite("SOURce2ERiod 600 ns");
        VisaWrite("SOURce1:VOLT:HIGH 1");
        VisaWrite("SOURce1:VOLTOW -1");
        VisaWrite("SOURce2:VOLT:HIGH 0.5");
        VisaWrite("SOURce2:VOLTOW -0.5");
        // Set the Pulse Parameters
        VisaWrite("SOURce1ULSe1:WIDth 100 ns");
        VisaWrite("SOURce2ULSe1:WIDth 20 ns");
        // Turn On the Outputs
        VisaWrite("OUTPut1 ON");
        VisaWrite("OUTPut2 ON");
        // Set the Pulse Mode
        VisaWrite("SOURce1:PULSe:MODE SINGLE");
        // Set the Trigger Mode
        VisaWrite("TRIGger:MODE CONTinuous");
        // Arm the instrument
        VisaWrite("PULSEGENControl:START");
        // Start the generation
        VisaWrite("*TRG");

        status = viClose (instr);
        status = viClose (defaultRM);
        printf ("\nHit enter to continue.");
        fflush(stdin);
        getchar();

        return 0;  
}



















本文地址:https://www.eechina.com/thread-546584-1-1.html     【打印本页】

本站部分文章为转载或网友发布,目的在于传递和分享信息,并不代表本网赞同其观点和对其真实性负责;文章版权归原作者及原出处所有,如涉及作品内容、版权和其它问题,我们将根据著作权人的要求,第一时间更正或删除。
您需要登录后才可以发表评论 登录 | 立即注册

厂商推荐

相关视频

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
快速回复 返回顶部 返回列表