完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好!使用HP3458A在数字化模式下,我们尝试使用SINT数据格式,以便为我们提供更快的采样率。我们理解SINT数据以二进制格式返回。
我们有问题将二进制数据解码为整数或双数。从User manuel引用:'SINT示例以下程序以SINT格式输出10个读数,检索'比例因子并将每个读数的比例因子乘以。 使用TRANSFER语句将读数传输到控制器(此“100第4章进行测量”命令特定于使用BASlC语言的Hewlett-Packard 200/300控制器)。 TRANSFER语句是在GPIB上传输读数的最快方法,尤其是在与直接内存访问(DMA)'GPIB接口一起使用时。 每当'测量/传输速度很重要时,你应该使用TRANSFER语句。我们正在使用GPIB总线将数据传输到主机pc.Subset我们的代码:调用ibwrt(dev,“PRESET DIG”)调用ibwrt(dev, “OFORMAT SINT”)调用ibwrt(dev,“APER,0”)调用ibwrt(dev,“SWEEP 15.259e-6,”& numofdata)调用ibwrt(dev,“MEM FIFO”)调用ibwrt(dev,“TRIG” LEVEL“)调用ibwrt(dev,”SLOPE NEG“)调用ibwrt(dev,”Level 10,DC“)调用ibwrt(dev,”TARM SGL“)调用ibwrt(dev,”RMEM 0,1“)调用ibrd( dev,RRdata)RRdata包含从HP返回的数据。我们想知道如何解码它。 manuel说它是每个样本2个字节。当我们改为ASCII格式时,事情正常。 但我们需要SINT更快的速度。任何帮助? 以上来自于谷歌翻译 以下为原文 Hello! Using the HP3458A In digitizing mode, we are trying to use the SINT data format, to allow faster sampling rates for us. We understand the SINT data comes back in binary format. We are having issue's decoding the binary data into an integer or double number. Quoting from User manuel: 'SINT Example The following program outputs 10 readings in SINT format, retrieves the 'scale factor and multiplies the scale factor times each reading. The readings 'are transfcrred to the controller using the TRANSFER statement (this '100 Chapter 4 Making Measurements 'command is specific to Hewlett-Packard 200/300 controllers using BASlC 'language). The TRANSFER statement is the fastest way to transfer readings 'across the GPIB, especially when used with the direct memory access (DMA) 'GPIB interface. You should use the TRANSFER statement whenever 'measurement/transfer speed is important. We are using the GPIB bus to transfer the data to the host pc. Subset of our code: Call ibwrt(dev, "PRESET DIG") Call ibwrt(dev, "OFORMAT SINT") Call ibwrt(dev, "APER, 0") Call ibwrt(dev, "SWEEP 15.259e-6, " & numofdata) Call ibwrt(dev, "MEM FIFO") Call ibwrt(dev, "TRIG LEVEL") Call ibwrt(dev, "SLOPE NEG") Call ibwrt(dev, "Level 10, DC") Call ibwrt(dev, "TARM SGL") Call ibwrt(dev, "RMEM 0,1") Call ibrd(dev, RRdata) RRdata contains the data returned form the HP. We'd like to know how to decode this. The manuel says it's a 2 byte's per sample. When we change to an ASCII format, things are working fine. But we need the SINT for faster rates. Any help? |
|
相关推荐
8个回答
|
|
使用3458A时数据格式化很麻烦,您使用的编程环境是什么?
C,C#,VB,VEE,Matlab,Labview等....如果我知道你正在使用哪一个,我可以尝试提供一个例子。 以上来自于谷歌翻译 以下为原文 Data formatting is a pain when using the 3458A, what programming environment are you using? C, C#, VB, VEE, Matlab, Labview, etc.... I can try and provide an example if I know which one you are using. |
|
|
|
|
|
|
|
嗨,只是跟进.C或C#也会很好,如果这有助于得到一个例子。再次,感谢你的帮助。
以上来自于谷歌翻译 以下为原文 Hi, just following up. C or C# will be fine too if that helps get an example. Again, appreciate your help. |
|
|
|
#include #include #include #include #include using namespace std; // //这个宏简化了代码的读取,但提供了错误检查//#defineCHECK(func) do { ViStatus _s =(func);
if(_s { fprintf(stderr,“错误:%s返回%d n”,#func,_s); exit(0); } } while(0)//指定仪器的VISA地址 //说明了GPIB,USB 2.0或LAN //使用主VISA配置器获取VISA地址//由Agilent Connection Expert处理的配置//必须确定系统的每个仪器的VISA地址#define DEFAULT_ADDRESS_3458“GPIB0 :: 22: :INSTR“void main(){ViSession viDefaultRM,Inst_dmm; ViRsrc TxtAddress_dmm = DEFAULT_ADDRESS_3458; float dummyRead; // float * array = NULL; // array = new float [1000000]; // float * scaled = NULL; // scaled = new float [1000000]; float array [512]; float scaled [512]; ////初始化Instruments进行通信并将它们设置为reset condition //将接口配置为20秒超时// CHECK(viOpenDefaultRM( &amp; viDefaultRM)); //打开DMM CHECK的路径(viOpen(viDefaultRM,TxtAddress_dmm,VI_NULL,20000,&amp; Inst_dmm)); CHECK(viSetAttribute(Inst_dmm,VI_ATTR_TMO_VALUE,700000)); //最大速度读数vCarar(Inst_dmm); viPrintf(Inst_dmm, “复位 n”); viPrintf(Inst_dmm,“end on n”); viPrintf(Inst_dmm,“预设dig n”); viPrintf(Inst_dmm,“dcv 10 n”); viPrintf(Inst_dmm,“aper 1.4E-6 n”) ; viPrintf(Inst_dmm,“trig auto n”); viPrintf(Inst_dmm,“mem off n”); //设置读数并触发instrumentviPrintf(Inst_dmm,“nrdgs 512 n”); viPrintf(Inst_dmm, “tarm sgl n”); //从3458AviScanf(Inst_dmm,“%512hy”,&amp; array [0])中移除读数和比例因子; viPrintf(Inst_dmm,“iscale? n”); viScanf(Inst_dmm, “%f n”,&amp; dummyRead); cout //乘以iscale for(int i = 0; i {scaled = dummyRead * array ; cout} / * //输出数据到文件, 可以用excel,matlab等进行分析... ofstream DMMwaveform; DMMwaveform.open(“DMMwaveform.csv”); for(int g = 0; gDMMwaveform DMMwaveform.close(); * / CHECK(viClose(Inst_dmm)); 检查(viClose(viDefaultRM)); // coutcoutchar wait = getchar();} 以上来自于谷歌翻译 以下为原文 #include #include #include #include #include #include using namespace std; // // This macro simplifies the reading of code and yet provides error checking // #define CHECK(func) do { ViStatus _s = (func); if (_s < 0) { fprintf(stderr, "Error: %s returned %dn", #func, _s); exit(0); } } while (0) // Specify the VISA addresses for instruments // GPIB, USB 2.0, or LAN are illustrated // Use Primary VISA Configurator to obtain VISA addresses // Configuration handled by Agilent Connection Expert // You must determine your system's VISA Address for each instrument #define DEFAULT_ADDRESS_3458 "GPIB0::22::INSTR" void main() { ViSession viDefaultRM, Inst_dmm; ViRsrc TxtAddress_dmm = DEFAULT_ADDRESS_3458; float dummyRead; // float* array = NULL; // array = new float [1000000]; // float* scaled = NULL; // scaled = new float [1000000]; float array[512]; float scaled[512]; // // Initialize Instruments for communication and set them to reset condition // Configure the interface for 20 second timeout // CHECK(viOpenDefaultRM(&viDefaultRM)); // Open path to DMM CHECK(viOpen(viDefaultRM, TxtAddress_dmm, VI_NULL, 20000, &Inst_dmm)); CHECK(viSetAttribute(Inst_dmm, VI_ATTR_TMO_VALUE, 700000)); //max speed readings viClear(Inst_dmm); viPrintf(Inst_dmm,"resetn"); viPrintf(Inst_dmm,"end onn"); viPrintf(Inst_dmm,"preset dign"); viPrintf(Inst_dmm,"dcv 10n"); viPrintf(Inst_dmm,"aper 1.4E-6n"); viPrintf(Inst_dmm,"trig auton"); viPrintf(Inst_dmm,"mem offn"); // set number of readings and trigger the instrument viPrintf(Inst_dmm,"nrdgs 512n"); viPrintf(Inst_dmm,"tarm sgln"); //Remove Readings and scale factor from the 3458A viScanf(Inst_dmm, "%512hy",&array[0]); viPrintf(Inst_dmm,"iscale?n"); viScanf(Inst_dmm,"%fn",&dummyRead); cout << "Reading results" << endl; //multiply by iscale for (int i=0;i<512;i++) { scaled=dummyRead*array; cout << scaled << endl; } /* // Output data to file, can be analyzed with excel, matlab, etc... ofstream DMMwaveform; DMMwaveform.open("DMMwaveform.csv"); for (int g = 0; g<500; g++) DMMwaveform << scaled[g] << endl; DMMwaveform.close(); */ CHECK(viClose(Inst_dmm)); CHECK(viClose(viDefaultRM)); // cout<< "DMMwaveform.csv created" < char wait = getchar(); } |
|
|
|
嗨,谢谢你的代码。
但是我们仍然有SINT格式问题.---------------------------------单个DCV测量工作正常。 ASCII格式的数字转换器也在工作。 但是,当我使用示例代码时,“SINT格式”不起作用。我认为“viScanf(Inst_dmm,”%512hy“,&amp; array [0]);” 工作不正常。 返回值与输入电压(8.6Vdc)不匹配。 甚至没有关闭.---------------------------------这个命令令人困惑,“viScanf(Inst_dmm,”%512hy “&安培;数组[0]);”? 正确的格式“hy”?,可能拼写或其他.---------------------------------程序查看: // Hello_GPIB.cpp:定义控制台应用程序的入口点.//#include“stdafx.h”#include“visa.h”#include“iostream”#include“fstream”int main(int argc,char * argv []){float array [512]; float array2 [256]; float scaled [512]; float retScale = 0; char cbuff [256] = {0}; // printf(“Hello HP3458! n”); ViSession defaultRM,Inst_dmm; char buf [256] = {0}; / *在地址22 * / viOpenDefaultRM(&amp; defaultRM)打开与GPIB设备的会话; viOpen(defaultRM,“GPIB :: 22 :: INSTR”,VI_NULL, VI_NULL,&amp; Inst_dmm); viSetAttribute(Inst_dmm,VI_ATTR_TMO_VALUE,700); //超时MilliSecondsviClear(Inst_dmm); / *初始化设备* / viPrintf(Inst_dmm,“RESET n”); viPrintf(Inst_dmm,“END ON n“); / *发送* IDN? 字符串到设备* / viPrintf(Inst_dmm,“ID? n”); / *读取结果* / viScanf(Inst_dmm,“%s”,buf); / *打印结果* / printf(“仪器识别字符串:% s n“,buf); / * Single Read这是工作* // * NORM * / viPrintf(Inst_dmm,”PRESET NORM n“); // TRIGviPrintf(Inst_dmm,”TARM SGL n“); viScanf( Inst_dmm,“%s”,buf); //这是工作/ *打印结果* / printf(“Ascii Foramt(电压):%s n”,buf); //这是工作/ *结束Sigle读取 * // * Clear * / viClear(Inst_dmm); / *初始化设备* / viPrintf(Inst_dmm,“RESET n”); / *高速DCV ASCII * / viPrintf(Inst_dmm,“END ON n”); / * FAST * / viPrintf(Inst_dmm,“PRESET FAST n”); viPrintf(Inst_dmm,“APER 1.4E-6 n”); viPrintf(Inst_dmm,“OFORMAT ASCII n”); viPrintf(Inst_dmm,“MEM FIFO n“); viPrintf(Inst_dmm,”NRDGS 512,AUTO n“); viPrintf(Inst_dmm,”TARM SGL n“); for(int i = 0; i {// GET DATAviScanf(Inst_dmm,”%s) “,cbuff); //这是工作/ *打印结果* / printf(”Ascii:%s n“,cbuff); //这是工作} // GET ScaleviPrintf(Inst_dmm,”ISCALE? n“) ; viScanf(Inst_dmm, “%f n”,&amp; retScale); / *打印结果* / printf(“比例:%f n”,retScale); / * retScale为1.由于ascii格式* /////// ////////////////////////////////////////////////// /////////// *高速DCV * / viPrintf(Inst_dmm,“END ON n”); // ASCII格式发送cr lf。 SINT和DINT格式不发送./* FAST * / viPrintf(Inst_dmm,“PRESET FAST n”); viPrintf(Inst_dmm,“APER 1.4E-6 n”); viPrintf(Inst_dmm,“OFORMAT SINT n” ); viPrintf(Inst_dmm,“MEM FIFO n”); viPrintf(Inst_dmm,“NRDGS 512,AUTO n”); viPrintf(Inst_dmm,“TARM SGL n”); // GET DATAviScanf(Inst_dmm,“%512hy” “,&amp; array [0]); //没有错误,但值错误。 / *打印结果* / for(i = 0; i {printf(“Data:%f n”,array );} // GET ScaleviPrintf(Inst_dmm,“ISCALE? n”); viScanf(Inst_dmm ,“%f n”,&amp; retScale); / *打印结果* / printf(“Scale:%f n”,retScale); / * retScale是0.000431。这是合理的值吗?我想是的。全尺度 约为32000. 32000 X 0.000431 =约1.4V。* // *打印结果* / for(i = 0; i {printf(“Data;%f n”,array ); scaled = retScale * array ; //没有错误,但值错误.printf(“%f n”,scaled );} / *高速DCV结束* // *清除* / viClear(Inst_dmm) ; / *初始化设备* / viPrintf(Inst_dmm,“RESET n”); viPrintf(Inst_dmm,“END ON n”); // EOI模式为END ON,用于高速模式/ * PRESET DIG * / viPrintf( Inst_dmm,“PRESET DIG n”); / * 10V范围* / viPrintf(Inst_dmm,“DCV 10 n”); viPrintf(Inst_dmm,“APER 1.4E-6 n”); viPrintf(Inst_dmm,“TRIG AUTO” n“); viPrintf(Inst_dmm,”MEM OFF n“); // viPrintf(Inst_dmm,”MEM FIFO n“); // 512个样本/ TriggerviPrintf(Inst_dmm,”NRDGS 512 n“); // TRIGviPrintf(Inst_dmm,“TARM SGL n”); // GET DATAviScanf(Inst_dmm ,“%512hy”,&amp; array [0]); //没有错误,但返回值错误。 没有意义。 //获取ScaleviPrintf(Inst_dmm,“ISCALE? n”); viScanf(Inst_dmm,“%f n”,&amp; retScale); / *打印结果* / printf(“比例:%f n”,retScale) ; for(i = 0; i {printf(“Data;%f n”,array ); scaled = retScale * array ; printf(“%f n”,scaled [i ]); //没有错误,但值错误。} / *关闭会话* / viClose(Inst_dmm); viClose(defaultRM);返回0;} 以上来自于谷歌翻译 以下为原文 Hi, thanks for the code. However we are still having SINT format issues. --------------------------------- A single DCV measurement is working. A digitizer with ASCII format is working, too. However 'SINT format' does not work when I use the sample code. I think "viScanf(Inst_dmm, "%512hy",&array[0]);" is not working correctly. The return value does not match input voltage(8.6Vdc) . Even not close. --------------------------------- This command is confusing, "viScanf(Inst_dmm, "%512hy",&array[0]);"? correct format "hy"?, may spell or something else. --------------------------------- Program for view: // Hello_GPIB.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "visa.h" #include "iostream" #include "fstream" int main(int argc, char* argv[]) { float array[512]; float array2[256]; float scaled[512]; float retScale=0; char cbuff [256] = {0}; //printf("Hello HP3458!n"); ViSession defaultRM, Inst_dmm; char buf [256] = {0}; /* Open session to GPIB device at address 22 */ viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "GPIB::22::INSTR",VI_NULL,VI_NULL,&Inst_dmm); viSetAttribute(Inst_dmm, VI_ATTR_TMO_VALUE, 700); // Time out MilliSeconds viClear(Inst_dmm); /* Initialize device */ viPrintf(Inst_dmm, "RESETn"); viPrintf(Inst_dmm, "END ONn"); /* Send an *IDN? string to the device */ viPrintf(Inst_dmm, "ID?n"); /* Read results */ viScanf(Inst_dmm, "%s", buf); /* Print results */ printf("Instrument identification string:%sn", buf); /* Single Read This is working*/ /* NORM */ viPrintf(Inst_dmm, "PRESET NORMn"); //TRIG viPrintf(Inst_dmm, "TARM SGLn"); viScanf(Inst_dmm, "%s", buf); // This is working /* Print results */ printf("Ascii Foramt(Voltage):%sn", buf);// This is working /* End of Sigle Read */ /* Clear */ viClear(Inst_dmm); /* Initialize device */ viPrintf(Inst_dmm, "RESETn"); /* High Speed DCV ASCII */ viPrintf(Inst_dmm, "END ONn"); /* FAST */ viPrintf(Inst_dmm, "PRESET FASTn"); viPrintf(Inst_dmm, "APER 1.4E-6n"); viPrintf(Inst_dmm, "OFORMAT ASCIIn"); viPrintf(Inst_dmm, "MEM FIFOn"); viPrintf(Inst_dmm, "NRDGS 512,AUTOn"); viPrintf(Inst_dmm, "TARM SGLn"); for (int i=0 ;i<512;i++) { //GET DATA viScanf(Inst_dmm, "%s",cbuff); // This is working /* Print results */ printf("Ascii:%sn",cbuff) ; // This is working } //GET Scale viPrintf(Inst_dmm, "ISCALE?n"); viScanf(Inst_dmm, "%fn",&retScale); /* Print results */ printf("Scale:%fn", retScale); /* retScale is 1. Because of ascii format*/ ////////////////////////////////////////////////////////////////// /* High Speed DCV */ viPrintf(Inst_dmm, "END ONn"); //ASCII format sends the cr lf. SINT and DINT format does not send. /* FAST */ viPrintf(Inst_dmm, "PRESET FASTn"); viPrintf(Inst_dmm, "APER 1.4E-6n"); viPrintf(Inst_dmm, "OFORMAT SINTn"); viPrintf(Inst_dmm, "MEM FIFOn"); viPrintf(Inst_dmm, "NRDGS 512,AUTOn"); viPrintf(Inst_dmm, "TARM SGLn"); //GET DATA viScanf(Inst_dmm, "%512hy",&array[0]); // No error but value is wrong. /* Print results */ for ( i=0 ;i<512;i++) { printf("Data:%fn", array); } //GET Scale viPrintf(Inst_dmm, "ISCALE?n"); viScanf(Inst_dmm, "%fn",&retScale); /* Print results */ printf("Scale:%fn", retScale); /* retScale is 0.000431. Is this resonable value? I guess so. FULL scale is about 32000. 32000 X 0.000431 = about 1.4V. */ /* Print results */ for ( i=0 ;i<512;i++) { printf("Data;%fn",array); scaled=retScale*array; // No error but value is wrong. printf("%fn",scaled); } /* End of High Speed DCV */ /* Clear */ viClear(Inst_dmm); /* Initialize device */ viPrintf(Inst_dmm, "RESETn"); viPrintf(Inst_dmm, "END ONn"); // EOI mode to END ON for High-Speed Mode /* PRESET DIG*/ viPrintf(Inst_dmm, "PRESET DIGn"); /* 10V range */ viPrintf(Inst_dmm, "DCV 10n"); viPrintf(Inst_dmm, "APER 1.4E-6n"); viPrintf(Inst_dmm, "TRIG AUTOn"); viPrintf(Inst_dmm, "MEM OFFn"); //viPrintf(Inst_dmm, "MEM FIFOn"); // 512 samples/Trigger viPrintf(Inst_dmm, "NRDGS 512n"); //TRIG viPrintf(Inst_dmm, "TARM SGLn"); //GET DATA viScanf(Inst_dmm, "%512hy", &array[0]); // No error but return value is wrong. Does not make sense. //GET Scale viPrintf(Inst_dmm, "ISCALE?n"); viScanf(Inst_dmm, "%fn",&retScale); /* Print results */ printf("Scale:%fn", retScale); for ( i=0 ;i<512;i++) { printf("Data;%fn",array); scaled=retScale*array; printf("%fn",scaled); // No error but value is wrong. } /* Close session */ viClose(Inst_dmm); viClose(defaultRM); return 0; } |
|
|
|
你的权利,我的错误。
在我发出之前我没有测试过。 我知道它在某个时间点工作,但我昨晚测试了这个并且遇到了你看到的相同的数据错误。 也许这是我写的程序的早期版本。 直到明天我才可能没有任何东西给你,但我知道我可以为你找到一份工作计划。 真的很抱歉。 以上来自于谷歌翻译 以下为原文 Your right, my mistake. I didn't test it before I sent it out. I know had it working at one point in time, but I tested this last night and was getting the same data errors you are seeing. Maybe this was an early version of a program I wrote. I probably won't have anything for you till tomorrow, but I know I can get a working program to you. Really sorry about that. |
|
|
|
我仍然遇到问题,这非常令人沮丧,因为我知道我以前有这个工作。
我的同事更像是一个编程大师,而不是我自己。 当他回到办公室时,我应该能够弄清楚正在发生什么。%hy来自哪里的小背景:3458A使用Big Endian格式,而我们的PC使用Little Endian格式。 由于3458A发送短路(2字节),所以交换字节。 仪器发送0xCDAB,但我们需要0xABCD。 'y'命令将读回一个字节数组,默认情况下交换字节。 'h'修饰符表示它是2个字节。 以上来自于谷歌翻译 以下为原文 I'm still having problems, which is very frustrating since I know I had this working before. My colleague who is more of a programming guru than myself is currently out. When he gets back in the office I should be able to figure out what's going on. A little background on where the %hy comes from: The 3458A uses a Big Endian format, while our PC’s use a Little Endian format. Since the 3458A is sending a short (2 byte), the bytes are swapped. Instrument sends 0xCDAB, but we need 0xABCD. The ‘y’ command will read back a byte array, while swapping the bytes by default. The ‘h’ modifier says that it is 2 bytes. |
|
|
|
好吧我明白了。
愚蠢的错误我应该早点抓住。 我把我的数组作为一个浮点而不是一个短的,尝试这个应该工作:// 3458A_100K_vstudio08.cpp:定义控制台应用程序的入口点//## include“stdafx.h”#include #include #include# include #include #include using namespace std; // //这个宏简化了代码的读取,但提供了错误检查//#defineCHECK(func) do { ViStatus _s =(func); if(_s { fprintf (stderr,“错误:%s返回%d n”,#func,_s); exit(0); } } while(0)//指定仪器的VISA地址// GPIB,USB 2.0, 或LAN说明//使用主VISA配置器获取VISA地址//由Agilent Connection Expert处理的配置//您必须确定系统的每个仪器的VISA地址#define DEFAULT_ADDRESS_3458“GPIB0 :: 1 :: INSTR”void main() {ViSession viDefaultRM,Inst_dmm; ViRsrc TxtAddress_dmm = DEFAULT_ADDRESS_3458; float dummyRead; short rawdata [512]; float scaled [512]; ////初始化用于通信的仪器并将它们设置为重置条件 //配置接口20秒超时// CHECK(viOpenDefaultRM(&amp; viDefaultRM)); //打开DMM CHECK路径(viOpen(viDefaultRM,TxtAddress_dmm,VI_NULL,20000,&amp; Inst_dmm)); CHECK(viSetAttribute(Inst_dmm,VI_ATTR_TMO_VALUE,700000)); //最大速度读数vCarar(Inst_dmm); viPrintf(Inst_dmm, “复位 n”); viPrintf(Inst_dmm,“end always n”); viPrintf(Inst_dmm,“预设dig n”); viPrintf(Inst_dmm,“mformat SINT n”); viPrintf(Inst_dmm,“oformat SINT n”); viPrintf( Inst_dmm,“dcv 10 n”); viPrintf(Inst_dmm,“aper 1.4E-6 n”); viPrintf(Inst_dmm,“trig auto n”); viPrintf(Inst_dmm,“mem off n”); / /设置读数并触发instrumentviPrintf(Inst_dmm,“nrdgs 512 n”); viPrintf(Inst_dmm,“tarm sgl n”); //从3458AviScanf中移除读数和比例因子(Inst_dmm,“%512hy n “,&amp; rawdata [0]); viPrintf(Inst_dmm,”iscale? n“); viScanf(Inst_dmm,”%f n“,&amp; dummyRead); cout //乘以iscale(int i = 0 ; i {scaled = dummyRead * rawdata ; cout} / * //输出数据到文件,可以用excel,matlab等进行分析... ofstream DMMwaveform; DMMwaveform.open(“DMMwaveform.csv” ); for(int g = 0; gDMMwaveform DMMwaveform.close(); * / CHECK(viClose(Inst_dmm)); CHECK(viClose(viDefaultRM)); // coutcoutchar wait = getchar();} 以上来自于谷歌翻译 以下为原文 Alright I figured it out. Dumb mistake I should have caught sooner. I had my array as a float instead of a short, try this one out should work: // 3458A_100K_vstudio08.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #include #include #include using namespace std; // // This macro simplifies the reading of code and yet provides error checking // #define CHECK(func) do { ViStatus _s = (func); if (_s < 0) { fprintf(stderr, "Error: %s returned %dn", #func, _s); exit(0); } } while (0) // Specify the VISA addresses for instruments // GPIB, USB 2.0, or LAN are illustrated // Use Primary VISA Configurator to obtain VISA addresses // Configuration handled by Agilent Connection Expert // You must determine your system's VISA Address for each instrument #define DEFAULT_ADDRESS_3458 "GPIB0::1::INSTR" void main() { ViSession viDefaultRM, Inst_dmm; ViRsrc TxtAddress_dmm = DEFAULT_ADDRESS_3458; float dummyRead; short rawdata[512]; float scaled[512]; // // Initialize Instruments for communication and set them to reset condition // Configure the interface for 20 second timeout // CHECK(viOpenDefaultRM(&viDefaultRM)); // Open path to DMM CHECK(viOpen(viDefaultRM, TxtAddress_dmm, VI_NULL, 20000, &Inst_dmm)); CHECK(viSetAttribute(Inst_dmm, VI_ATTR_TMO_VALUE, 700000)); //max speed readings viClear(Inst_dmm); viPrintf(Inst_dmm,"resetn"); viPrintf(Inst_dmm,"end alwaysn"); viPrintf(Inst_dmm,"preset dign"); viPrintf(Inst_dmm,"mformat SINTn"); viPrintf(Inst_dmm,"oformat SINTn"); viPrintf(Inst_dmm,"dcv 10n"); viPrintf(Inst_dmm,"aper 1.4E-6n"); viPrintf(Inst_dmm,"trig auton"); viPrintf(Inst_dmm,"mem offn"); // set number of readings and trigger the instrument viPrintf(Inst_dmm,"nrdgs 512n"); viPrintf(Inst_dmm,"tarm sgln"); //Remove Readings and scale factor from the 3458A viScanf(Inst_dmm, "%512hyn",&rawdata[0]); viPrintf(Inst_dmm,"iscale?n"); viScanf(Inst_dmm,"%fn",&dummyRead); cout << "Reading results" << endl; //multiply by iscale for (int i=0;i<512;i++) { scaled=dummyRead*rawdata; cout << scaled << endl; } /* // Output data to file, can be analyzed with excel, matlab, etc... ofstream DMMwaveform; DMMwaveform.open("DMMwaveform.csv"); for (int g = 0; g<500; g++) DMMwaveform << scaled[g] << endl; DMMwaveform.close(); */ CHECK(viClose(Inst_dmm)); CHECK(viClose(viDefaultRM)); // cout<< "DMMwaveform.csv created" < char wait = getchar(); } |
|
|
|
只有小组成员才能发言,加入小组>>
1278 浏览 0 评论
2371 浏览 1 评论
2187 浏览 1 评论
2061 浏览 5 评论
2945 浏览 3 评论
1093浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
746浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
913浏览 0评论
1278浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 12:02 , Processed in 3.362723 second(s), Total 91, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号