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

1、前言2、C#代码2.1 参考C#与泰克示波器(Tektronix oscilloscope)通信操作中C#代码;2.2 可以用是德科技提供的通信代码;2.3 使用Ivi.Visa.Interop类;3、简单指令参考资料

# 1、前言

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

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

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)

你可能感兴趣的:(c)