Stone_Mei的个人空间 https://www.eechina.com/space-uid-139656.html [收藏] [复制] [RSS]

博客

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

已有 1444 次阅读2018-8-30 16:18 | MAX, SCPI, 脉冲发生器, 虹科

带图完整文章:http://www.hongketest.com/portal.php?mod=view&aid=57

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


 

 TOC \o "1-3" \h \z \u 1.   概要... PAGEREF _Toc523404668 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600360038000000

2.   工具/准备... PAGEREF _Toc523404669 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600360039000000

2.1 PG-1000系列SDK. PAGEREF _Toc523404670 \h 1 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370030000000

2.2 NI VISA.. PAGEREF _Toc523404671 \h 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370031000000

2.3 NI NAXMeasurement & Automation Explorer... PAGEREF _Toc523404672 \h 3 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370032000000

2.4 PG-1000系列软件... PAGEREF _Toc523404673 \h 3 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370033000000

3. 配置系统(使用NI MAX... PAGEREF _Toc523404674 \h 4 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370034000000

4. 调试系统(使用AT Instrument Communicator... PAGEREF _Toc523404675 \h 8 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370035000000

5. 例程/范例... PAGEREF _Toc523404676 \h 9 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370036000000

5.1 LabVIEW... PAGEREF _Toc523404677 \h 10 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370037000000

5.2 Microsoft C#. PAGEREF _Toc523404678 \h 11 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370038000000

5.3 Microsoft C++.. PAGEREF _Toc523404679 \h 13 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003500320033003400300034003600370039000000


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-PG1072AT-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 .NETLabVIEWLabWindows/CVIMeasurement Studio for Microsoft Visual StudioMatLab等)提供编程接口。NI VISANational Instruments公司提供的VISA I/O标准。NI VISA包括软件库、交互式工具(例如, NI I/O TraceVISA交互式控制)、配置程序等。

2.3 NI NAXMeasurement & Automation Explorer

Client-PC(即Remote PC)中下载并安装NI MAX软件。

2.4 PG-1000系列软件

打开PG-1000系列仪器中自带的控制软件,找到“Remote/Local”界面中的VXI-11LAN协议)Server。默认情况下,VXI-11 Server是开启的,意味着PG1000系列仪器可以接收来自Client-PCSCPI命令。

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 VISANI 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 PanelAT Instrument Communicator(软件的获取下载,参考“PG-1000系列 SDK”小节的第3步;软件的使用,参考下节“使用AT Instrument Communicator调试系统”)发送SCPI命令至PG-1000

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

VXI-11LAN协议)Server可以为在同一LAN网络下的PG-1000仪器与Client-PC提供软件接口。

AT Instrument Communicator软件需安装在Client-PC中,且Client-PC中需安装NI VISA

通过以下步骤,操控Client-PCAT 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中包含由很多种语言编写的例程,例如LabVIEWMicrosoft Visual C++Microsoft C# .NE语言。

例程可以在安装了NI VISA并兼容Microsoft Windows®PC上运行。

NI VISANational Instruments公司提供的VISA I/O标准。NI VISA包括软件库、交互式工具(例如, NI I/O TraceVISA交互式控制)、配置程序等。

在软件中使用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:VOLT:LOW -1.5");

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce2:VOLT:HIGH 2");

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce2:VOLT:LOW -2");

            // Set the pulse parameters

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce1:PULSe1:WIDth 50 ns");

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce1:PULSe1:DELay 0");

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOURce2:PULSe1:WIDth 50 ns");

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "SOUrce2:PULSe1:DELay 50 ns");

            // Set the pulse mode

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "OUTPut1:PULSe:MODe SINgle");

            tbAnswer.Text = vs.SendTo(sInstrumentAddress, "OUTPut2:PULSe: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.txtGenerateMultiplePulse.txtGeneratePulseTriggerIN.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 <stdio.h>

#include <stdlib.h>

#include <string>

 

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("SOURce1:PERiod 600 ns");

    VisaWrite("SOURce2:PERiod 600 ns");

    VisaWrite("SOURce1:VOLT:HIGH 1");

    VisaWrite("SOURce1:VOLT:LOW -1");

    VisaWrite("SOURce2:VOLT:HIGH 0.5");

    VisaWrite("SOURce2:VOLT:LOW -0.5");

    // Set the Pulse Parameters

    VisaWrite("SOURce1:PULSe1:WIDth 100 ns");

    VisaWrite("SOURce2:PULSe1: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; 

}




路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

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