我是靠谱客的博主 欣喜八宝粥,最近开发中收集的这篇文章主要介绍keithley-吉时利-C#-测试电流电压,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

前言:使用GPIB线对测试仪器的连接与控制。(NI,VISA, 488.5)

下载驱动: NI官网

一.测试电流

测试电流需要输入电压。
代码如下:

/// <summary>
/// 测试电流
/// </summary>
public string inputUvOutPutIs(string testType, string Us_val)
{
try
{
// 判断是否为正,是否为负
string judge = "";
if (testType == "+")
{
judge = "";
}
else if (testType == "-")
{
judge = "-";
}
else
{
judge = "";
}
#region >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>参数设置
// 初始化参数
string textToWrite1, textToWrite2, textToWrite3, textToWrite4, textToWrite5, textToWrite6, textToWrite7,
textToWrite8, textToWrite9, textToWrite10, textToWrite11, textToWrite12;
// *****************吉时利
textToWrite1 = Session.Instance.ReplaceCommonEscapeSequences("*RST");
textToWrite2 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:FUNC VOLT"); // 输入源为电压
textToWrite3 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:VOLT:MODE FIX");
// MODE
//textToWrite4 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:CURR:RANG " + CurrentMaterialClass.is_min.ToString()
//
+ " " + CurrentMaterialClass.is_max.ToString()); // 选择输入量程
textToWrite5 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:VOLT:LEV " + judge + Us_val); // Us输入大小
textToWrite6 = Session.Instance.ReplaceCommonEscapeSequences(":SENS:FUNC 'CURR'"); // 测试项为 电压
textToWrite7 = Session.Instance.ReplaceCommonEscapeSequences(":SENS:CURR:PROT " + CurrentMaterialClass.short_circuit.ToString() + "e-6"); // 保护电流,一般为最大值的1.5倍
//textToWrite8 = Session.Instance.ReplaceCommonEscapeSequences(":SENS:VOLT:RANG 10e-3"); // 测试电压的量程
//textToWrite9 = Session.Instance.ReplaceCommonEscapeSequences(":SENSe:CURR:NPLCycles " + Convert.ToInt32((Convert.ToInt32(CurrentMaterialClass.is_test_time) / 20)).ToString()); // nplc 0.1 1 2 12 通电速度
textToWrite9 = Session.Instance.ReplaceCommonEscapeSequences(":SENSe:CURR:NPLCycles 1"); // nplc 0.1 1 2 12 通电速度
textToWrite10 = Session.Instance.ReplaceCommonEscapeSequences(":OUTP ON"); // 输入源开启
textToWrite11 = Session.Instance.ReplaceCommonEscapeSequences(":READ?"); // 返回数据
textToWrite12 = Session.Instance.ReplaceCommonEscapeSequences(":OUTP OFF"); // 输入源开启
#endregion
if (StatusClass.seesionConnectIsSuccess)
{
// 写入数据
Session.Instance.mbSession.RawIO.Write(textToWrite1);
Session.Instance.mbSession.RawIO.Write(textToWrite2);
Session.Instance.mbSession.RawIO.Write(textToWrite3);
//Session.Instance.mbSession.RawIO.Write(textToWrite4);
Session.Instance.mbSession.RawIO.Write(textToWrite5);
Session.Instance.mbSession.RawIO.Write(textToWrite6);
Session.Instance.mbSession.RawIO.Write(textToWrite7);
//Session.Instance.mbSession.RawIO.Write(textToWrite8);
Session.Instance.mbSession.RawIO.Write(textToWrite9);
Session.Instance.mbSession.RawIO.Write(textToWrite10);
// 延时测试
Thread.Sleep(Convert.ToInt32(CurrentMaterialClass.is_test_time));
Session.Instance.mbSession.RawIO.Write(textToWrite11);
// 获取输出数据
string rowStr = Session.Instance.InsertCommonEscapeSequences(Session.Instance.mbSession.RawIO.ReadString());
string[] resStrList = rowStr.Split(',');
// uA
string res_val = Math.Round(Session.Instance.ChangeDataToD(resStrList[1])*1000000, 3).ToString();
//b = rowStr.Replace("\n", "");
//b = b.Substring(1, b.Length - 1); // 测量真实值字符串
// 关闭输入源
Session.Instance.mbSession.RawIO.Write(textToWrite12);
return res_val;
}
return "0";
}
catch (Exception ex)
{
MyDataSaveClass.Instance.SaveLogData("inputUvOutPutIs-ERROR:" + ex.Message);
return "0";
}
}
二.测试电压

测试电压需要输入电流。

注意,吉时利仪器最大输入电压为1000V,不然会仪器报错。

代码如下:

/// <summary>
/// 测试电压
/// </summary>
public string inputIsOutPutUv(string testType)
{
try
{
// 判断是否为正,是否为负
string judge = "";
if (testType == "+")
{
judge = "";
}
else if (testType == "-")
{
judge = "-";
}
else
{
judge = "";
}
#region >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>参数设置
// 初始化参数
string textToWrite1, textToWrite2, textToWrite3, textToWrite4, textToWrite5, textToWrite6, textToWrite7,
textToWrite8, textToWrite9, textToWrite10, textToWrite11, textToWrite12;
// *****************吉时利
textToWrite1 = Session.Instance.ReplaceCommonEscapeSequences("*RST");
textToWrite2 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:FUNC CURR"); // 输入源为电流
textToWrite3 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:CURR:MODE FIX");
// MODE
//textToWrite4 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:CURR:RANG " + CurrentMaterialClass.is_min.ToString()
//
+ " " + CurrentMaterialClass.is_max.ToString()); // 选择输入量程
textToWrite5 = Session.Instance.ReplaceCommonEscapeSequences(":SOUR:CURR:LEV " + judge + (CurrentMaterialClass.is_input/1000).ToString()); // Iv输入大小
textToWrite6 = Session.Instance.ReplaceCommonEscapeSequences(":SENS:FUNC 'VOLT'"); // 测试项为 电压
textToWrite7 = Session.Instance.ReplaceCommonEscapeSequences(":SENS:VOLT:PROT " + CurrentMaterialClass.poor_contact.ToString()); // 保护电压 为接触不良电压,一般为最大值的1.5倍
//textToWrite8 = Session.Instance.ReplaceCommonEscapeSequences(":SENS:VOLT:RANG 10e-3"); // 测试电压的量程
textToWrite9 = Session.Instance.ReplaceCommonEscapeSequences(":SENSe:VOLT:NPLCycles 1"); // nplc 0.1 1 2 12 通电速度
textToWrite10 = Session.Instance.ReplaceCommonEscapeSequences(":OUTP ON"); // 输入源开启
textToWrite11 = Session.Instance.ReplaceCommonEscapeSequences(":READ?"); // 返回数据
textToWrite12 = Session.Instance.ReplaceCommonEscapeSequences(":OUTP OFF"); // 输入源开启
#endregion
if (StatusClass.seesionConnectIsSuccess)
{
// 写入数据
Session.Instance.mbSession.RawIO.Write(textToWrite1);
Session.Instance.mbSession.RawIO.Write(textToWrite2);
Session.Instance.mbSession.RawIO.Write(textToWrite3);
//Session.Instance.mbSession.RawIO.Write(textToWrite4);
Session.Instance.mbSession.RawIO.Write(textToWrite5);
Session.Instance.mbSession.RawIO.Write(textToWrite6);
Session.Instance.mbSession.RawIO.Write(textToWrite7);
//Session.Instance.mbSession.RawIO.Write(textToWrite8);
Session.Instance.mbSession.RawIO.Write(textToWrite9);
Session.Instance.mbSession.RawIO.Write(textToWrite10);
// 延时测试
Thread.Sleep(Convert.ToInt32( CurrentMaterialClass.uv_test_time));
Session.Instance.mbSession.RawIO.Write(textToWrite11);
// 获取输出数据
string rowStr = Session.Instance.InsertCommonEscapeSequences(Session.Instance.mbSession.RawIO.ReadString());
string[] resStrList = rowStr.Split(',');
string res_val =
Math.Round(Session.Instance.ChangeDataToD(resStrList[0]), 3).ToString();
// 关闭输入源
Session.Instance.mbSession.RawIO.Write(textToWrite12);
return res_val;
}
return "0";
}
catch (Exception ex)
{
MyDataSaveClass.Instance.SaveLogData("inputIsOutPutUv-ERROR:" + ex.Message);
return "0";
}
}

最后

以上就是欣喜八宝粥为你收集整理的keithley-吉时利-C#-测试电流电压的全部内容,希望文章能够帮你解决keithley-吉时利-C#-测试电流电压所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部