3674|0

6

帖子

10

TA的资源

一粒金砂(初级)

楼主
 

PG-1000系列脉冲发生器SCPI远程控制 [复制链接]

PG-1000系列脉冲发生器SCPI远程控制.pdf (1.12 MB, 下载次数: 3)

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







  • 概要



可以连接仪器至用户的网络中,实现打印、文件共享、互联网访问等其他功能。请联系贵公司的网络管理员,并使用标准Windows在用户的网络中配置仪器。


仪器是通过VXI-11 (LAN)协议进行控制的,用户可以利用SCPI命令远程控制仪器,请参考《Pulse Rider PG-1000 programmer manual》了解详细的SCPI命令语法、语句。


  • 工具/准备



2.1 PG-1000系列SDK


  • 用户在www.activetechnologies.it网站注册账户后,登录网站并“Register”仪器。
                                  
  • 点击“Support”—“ClientArea”,访问“Users Products”界面。
  • 点击AT-PG1072或AT-PG1074链接,访问下载界面。点击SDK-AT-PULSE-GENERATOR安装包并下载。
    SDK内包括:
                 AT InstrumentCommunicator安装程序(用途,参考下节“配置系统”的第9步)
                 C++例程
    C#例程
    LabVIEW例程



2.2 NI VISA


Client-PC(即Remote PC)中下载并安装NI VISA


VISA为硬件与开发环境(比如,Visual Studio .NETLabVIEWLabWindows/CVIMeasurement Studio for MicrosoftVisual 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进行如下配置:


  • 使用LAN线缆连接仪器与Client-PC。
  • 在Client-PC中安装NI VISA与NI MAX。
  • 打开Client-PC中的NI MAX。点击“Add Network Device ”——“VISA TCP/IP Resource…”。
  • 选择“Auto-detect of LAN Instrument”,并点击“Next”。
  • 面板将会显示在LAN网络中搜索到的仪器,选择PG-1000系列仪器,并点击“Next”。
             
  • 输入“Alias”(此步非必须,可省略),并点击“Next”。
  • 点击“Finish”。
  • PG-1000仪器资源将会在“NetworkDevices”列表中显示。
  • 现在,可以使用NI Visa Test Panel或AT Instrument Communicator(软件的获取下载,参考“PG-1000系列 SDK”小节的第3步;软件的使用,参考下节“使用AT Instrument Communicator调试系统”)发送SCPI命令至PG-1000。



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




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


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


通过以下步骤,操控Client-PCAT Instrument Communicator软件实现对PG-1000仪器的控制:


  • Client-PC中安装AT Instrument Communicator软件。
  • 在“Device”列表中选择PG-1000系列仪器。
  • 点击“Connect”按钮。
  • 若连接成功,Command”复选框内的“Write”、“Read”等按钮将会可选(非灰色)
  • 在“Command”文本框内输入*IDN?并点击“Write”按钮。
  • 点击“Query”按钮。
  • 在“Event Logger”列表中,PG-1000系列仪器会显示返回值,例如:
    ACTIVE TECHNOLOGIES,AT-PULSE-RIDER PG1072 00000001,SCPI 99.0, SV 1.0.0 where 00000001 is theserialnumber, SCPI 99.0 is the SCPI command version and SV 1.0.0 is thesoftware version.
  • TXT命令脚本(script)文件包括一系列SCPI命令(每行一条命令),用户可以发送TXT命令脚本文件。点击“File”—“Open”打开加载TXT命令脚本文件对话框。
  • 参考《Pulse Rider PG-1000 programmer manual》了解详细的SCPI命令语法、语句。



5. 例程/范例


PG-1000系列SDK中包含由很多种语言编写的例程,例如LabVIEWMicrosoft Visual C++Microsoft C# .NE语言。


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


NI VISANationalInstruments公司提供的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++例程,需要安装MicrosoftVisual 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:HIGH1.5");


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


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


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


            // Set the pulse parameters


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


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


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


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


            // Set the pulse mode


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


            tbAnswer.Text =vs.SendTo(sInstrumentAddress, "OUTPut2:PULSe:MODeSINgle");


            // Turn On the channels


            tbAnswer.Text = vs.SendTo(sInstrumentAddress,"OUTPut1ON");


            tbAnswer.Text =vs.SendTo(sInstrumentAddress, "OUTPut2ON");


            // Set the trigger mode and arm the instrument


            tbAnswer.Text =vs.SendTo(sInstrumentAddress, "TRIGger:MODECONTinuous");


            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++


可以在…\VS2015Examples\PulseRiderMSVC\TCPIP文件夹内找到C++例程,例程是使用 Microsoft® Visual C++语言编写的。


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


/* This example demonstrates opening a simpleTCPIP connection and   */


/* implements a single pulse generation inContinuous 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 charoutputBuffer[VI_FIND_BUFLEN];


static ViSession defaultRM, instr;


static ViStatus status;


static ViUInt32 count;


static characBuffer[10000000] = "";   


static unsignedint u32Timeout = 20000; //timeout value in milliseconds




static constchar 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;


    ViFindListobjFindList;




    /* 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 ResourceManager!\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;  


}


点赞 关注(1)
 
 

回复
举报
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/8 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表