完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
各位大家好,我在读取功率计HP436A时出现问题。
附件是我的C#代码,它可以写入但无法从仪表读取。请帮帮我! 非常感谢.////////////////////使用系统;使用Ivi.Visa.Interop;使用System.Threading;命名空间readPmHP436A {class Program {private static Ivi。 Visa.Interop.FormattedIO488 ioPm; private static int adrPm = 12; static void InitializePm(){ioPm = new FormattedIO488Class(); ResourceManager gr1 = new ResourceManager(); ioPm.IO =(IMessage)gr1.Open(“GPIB ::”+ adrPm.ToString(),AccessMode.NO_LOCK,2000,“”); ioPm.IO.Timeout = 7000; } // Read Power,PmHP436A静态字符串ReadPm(){string str; ioPm.WriteString(“9D + V”,true); Thread.sleep代码(50); str = ioPm.ReadString(); 返回str; static void Main(string [] args){InitializePm(); Console.WriteLine(“Pm initialized。”); Console.WriteLine(“Pm读取:{0} dBm”,ReadPm()); }}} 以上来自于谷歌翻译 以下为原文 Hello everyone, I got problem with reading power meter HP436A. The attachment is my C# code, it can write to but can not read from meter. Please help me! Thank you very much. //////////////////// using System; using Ivi.Visa.Interop; using System.Threading; namespace readPmHP436A { class Program { private static Ivi.Visa.Interop.FormattedIO488 ioPm; private static int adrPm = 12; static void InitializePm() { ioPm = new FormattedIO488Class(); ResourceManager gr1 = new ResourceManager(); ioPm.IO = (IMessage)gr1.Open("GPIB::" + adrPm.ToString(), AccessMode.NO_LOCK, 2000, " "); ioPm.IO.Timeout = 7000; } // Read Power, PmHP436A static string ReadPm() { string str; ioPm.WriteString("9D+V", true); Thread.Sleep(50); str = ioPm.ReadString(); return str; } static void Main(string[] args) { InitializePm(); Console.WriteLine("Pm initialized."); Console.WriteLine("Pm read: {0} dBm", ReadPm()); } } } |
|
相关推荐
7个回答
|
|
问题可能不在您的代码中,而是在VISA库使用的终止字符中。
某些库希望仪器输出一个字符串,并在最终字符上设置GPIB“EOI”行。 436A不使用EOI线。 它将发送一串ASCII字符后跟一个序列。因此,您可能必须将终止字符(也称为“行尾”)设置为 n 以上来自于谷歌翻译 以下为原文 the problem may not be in your code, but in the termination character used by the VISA library. Some libraries expect the instrument to output a string with the GPIB "EOI" line set on the final character. The 436A does not use the EOI line. It will send a string of ASCII characters followed by a sequence. So, you may have to set the termination character (aka "end-of-line") to n |
|
|
|
非常感谢你的回复,RayH。你的意思是我需要在ReadPm()方法中添加 n?// Read Power,PmHP436A静态字符串ReadPm(){string str;
ioPm.WriteString(“9D + V”,true); ioPm.WriteString(“ n”,true); //只需添加Thread.Sleep(50); str = ioPm.ReadString(); 返回str; 我希望这会奏效,让我试试。再说,谢谢。哇 以上来自于谷歌翻译 以下为原文 Thank you very much for response, RayH. You mean I need to add n in the ReadPm() method? // Read Power, PmHP436A static string ReadPm() { string str; ioPm.WriteString("9D+V", true); ioPm.WriteString("n", true); // just add Thread.Sleep(50); str = ioPm.ReadString(); return str; } I hope this will work, let me try. Again, thanks. Howe |
|
|
|
试试以下。
换行符不需要在单独的行中:// Read Power,PmHP436Astatic字符串ReadPm(){string str; ioPm.WriteString(“9D + V n”),true); Thread.Sleep(50); str = ioPm.ReadString(); return str;} 以上来自于谷歌翻译 以下为原文 Try below. The newline does not need to be on a separate line: // Read Power, PmHP436A static string ReadPm() { string str; ioPm.WriteString("9D+Vn"), true); Thread.Sleep(50); str = ioPm.ReadString(); return str; } |
|
|
|
亲爱的Odanzy,感谢您的留言。
我已经尝试了这个。阅读Power,PmHP436Astatic字符串ReadPm(){string str; ioPm.WriteString(“9D + V n”,true); Thread.Sleep(50); str = ioPm.ReadString(); return str;}但它也不起作用。我正在考虑安捷伦VEE代码;我使用如下,它工作正常:WRITEREXT“9D + V”EOLREADTEXT X因此,如何在C#代码中设置EOL? 以上来自于谷歌翻译 以下为原文 Dear Odanzy, Thank for message. I already try this. // Read Power, PmHP436A static string ReadPm() { string str; ioPm.WriteString("9D+Vn", true); Thread.Sleep(50); str = ioPm.ReadString(); return str; } But it also doesn't work. I am thinking about Agilent VEE code; I used as below, it works fine: WRITEREXT "9D+V" EOL READTEXT X Therefore, how to set EOL in C# code? |
|
|
|
在VEE中,默认EOL设置为终止字符( n)并设置EOI。
您应该有权通过发送来验证是否启用了EOI。 它可能看起来像。 没时间测试这个,但这看起来像我的一些旧代码.ioPm.IO.SendEndEnabled = true; ioPm.IO.TerminationCharacter =(char)10; ioPm.IO.TerminationCharacterEnabled = true; 以上来自于谷歌翻译 以下为原文 In VEE the default EOL is setup as a termination character (n) and setting the EOI. You should have access to verify that EOI is enabled by sending. It would probably look something like. Didn't have time to test this, but this looks like some of my old code. ioPm.IO.SendEndEnabled = true; ioPm.IO.TerminationCharacter = (char)10; ioPm.IO.TerminationCharacterEnabled = true; |
|
|
|
看上去不错。
让我试试真正的试验台,让你很快知道。谢谢你们。 你周末愉快 以上来自于谷歌翻译 以下为原文 It looks good. Let me try in real test bench and let you know soon. Thanks a lot. You have a good weekend. howe |
|
|
|
亲爱的Odanzy,我从你那里得到的最后一个代码工作正常。
ReadPm()读取功率测量。但是,有一行有错误信息。 我跳过了这一行,但仍然从436A获得了电源。以下是readPm()我使用过的:// Read Power,PmHP436Apublic string ReadPm(){string readPm =“readPm”; ioPm.WriteString(“9D + V”,true); ioPm.IO.SendEndEnabled = true; // ioPm.IO.TerminationCharacter =(char)10; ioPm.IO.TerminationCharacterEnabled = true; Thread.sleep代码(10); readPm = ioPm.ReadString(); return readPm; 你能不能帮我清除line:// ioPm.IO.TerminationCharacter =(char)10的错误信息;非常感谢.Howe 以上来自于谷歌翻译 以下为原文 Dear Odanzy, The last code that I got from you is working fine. ReadPm() read power measurement. However, there is a line got an error message. I skipped this line, but still get reading power from 436A. The following is readPm() I have used: // Read Power, PmHP436A public string ReadPm() { string readPm = "readPm"; ioPm.WriteString("9D+V", true); ioPm.IO.SendEndEnabled = true; // ioPm.IO.TerminationCharacter = (char)10; ioPm.IO.TerminationCharacterEnabled = true; Thread.Sleep(10); readPm = ioPm.ReadString(); return readPm; } Can you please help me to clear the error message for line: // ioPm.IO.TerminationCharacter = (char)10; Thank you very much. Howe |
|
|
|
只有小组成员才能发言,加入小组>>
1231 浏览 0 评论
2351 浏览 1 评论
2161 浏览 1 评论
2026 浏览 5 评论
2910 浏览 3 评论
976浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
709浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
809浏览 0评论
1233浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 09:55 , Processed in 1.371035 second(s), Total 89, Slave 73 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号