[经验栈]C#与是德科技信号发生器(Keysight RF Signal Generators)N9310A通信操作

1、前言

这次使用的仪器是是德科技(keysight)的射频信号发生器,型号为N9310A,来一张正面照。

keysightRFN9310A.png

2、C#代码

2.1 参考C#与泰克示波器(Tektronix oscilloscope)通信操作中C#代码;

2.2 可以用是德科技提供的通信代码;

环境:IO 程序库套件

项目-引用-添加-程序集-Keysight.Visa

using System;
using Ivi.Visa;
using Keysight.Visa;
 
namespace IdnSample
{
   class IdnSample
   {
     static void Main(string[] args)
        {
        GpibSession session = new GpibSession ("MyInstr",
                                             Ivi.Visa.AccessModes.None,
                                             2000);
        
        try
        {
           IMessageBasedFormattedIO io = session.FormattedIO;
           io.PrintfAndFlush("*IDN?");//发送查询设备指令
           string[] response = new string[] { "", "", "", "" };
           io.Scanf("%,s", out response);//读取信息,以逗号或空格划分字符串
           Console.WriteLine("Manufacturer: {0}", response[0]);
           Console.WriteLine("Instrument Model: {0}",
                             response[1].TrimEnd(new char[] {'\n'}));
           if (response.Length > 2)
           {
              Console.WriteLine("Firmware Revision: {0}",
                                response[2].TrimEnd(new char[] {'\n'}));
           }
           if (response.Length > 3)
           {
              Console.WriteLine("Serial Number: {0}",
                                response[3].TrimEnd(new char[] {'\n'}));
           }
       }
       catch
       {
          Console.WriteLine("*IDN? query failed");
       }
       finally
       {
          ession.Dispose();
          session = null;
       }
          Console.WriteLine("Press any key to end...");
          Console.ReadKey();
       }
   }
}

2.3 使用Ivi.Visa.Interop类;

using System;
using Ivi.Visa.Interop;

namespace HardwareAutomation
{
    public class IviVisaInteropInstrumentsAPIs
    {
        FormattedIO488 instrument = new FormattedIO488();
        ResourceManager rm = new ResourceManager();

        public void Set(string usbAddress, int timeOut)
        {    
            instrument.IO = (IMessage)rm.Open(usbAddress, AccessMode.NO_LOCK, 0, "");
            instrument.IO.TerminationCharacterEnabled = true;
            instrument.IO.Timeout = timeOut;
        }
    
        public void Write(string WriteStr)
        {
            instrument.WriteString(WriteStr, true);
        }


        public string Read()
        {
            try
            {
                return instrument.ReadString();
            }
            catch (Exception e)
            {
                //Console.WriteLine(e);
                //throw;
                return "";
            }
        }    
    }
}

3、简单指令

:SYSTem:DATE?		//查询日期,用于确认信号发生器是否连接正常

:FREQuency:CW 5 MHz		//设置频率为5MHz

:FREQuency:CW?		//查询频率

:AMPLitude:CW 5 dBm		//设置幅度为5dbm

:RFOutput:STATe ON		//打开射频输出



:AM:STATe ON		//打开调幅模式

:AM:DEPTh 5		//设置调幅深度

:AM:SOURce EXT		//设置调幅源为外部

:MOD:STATe ON		//使能设置



:FM:STATe ON		//打开调频模式

:FM:DEViation 5 KHz		//设置调频偏差为5KHz

:FM:SOURce EXT		//设置调频源为外部

:MOD:STATe ON		//使能设置



:PULM:STATe ON		//打开脉冲模式

:PULM:SOURce EXT		//设置脉冲源为外部

:MOD:STATe ON		//使能设置

参考资料

N9310A User’s Guide

Keysight VISA.NET Help(C:\Program Files\ (x86)\Keysight\IO Libraries Suite\VisaNet.chm)

  • 5
    点赞
  • 48
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值