完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我是通过VC ++编程安捷伦设备的新手。
有没有人有通过VC ++或C ++程序在波形发生器上生成标准(正弦波)的代码?干杯,MIshra 以上来自于谷歌翻译 以下为原文 Hi there, I am new to programming agilent devices thru VC++. Does anyone have the code to Generate a Standard(sine) wave on the waveform generator thru a VC++ or C++ program ? Cheers, MIshra |
|
相关推荐
2个回答
|
|
找到一个并使用它来使用VC ++ 2008Create在“win32控制台应用程序”下的一个newm项目包括Visa32.lib #include“stdafx.h”#include #include #include #include #include #include #include #pragma warning(disable:
4996)#define CHECK(func) do { ViStatus _s =(func); if(_s { fprintf(stderr,“错误:%s返回%d n”,#func,_s); exit( 0); } } while(0)/ *指定默认地址* / #define DEFAULT_LOGICAL_ADDRESS“USB0 :: 0x0957 :: 0x0407 :: MY44028438 :: 0 :: INSTR”void main(){ViSession viDefaultRM,Instrument; ViRsrc TxtAddress = DEFAULT_LOGICAL_ADDRESS; ViUInt32 actual; char SCPIcmd [10000]; unsigned short i; CHECK(viOpenDefaultRM(&amp; viDefaultRM)); CHECK(viOpen(viDefaultRM,TxtAddress,VI_NULL,VI_NULL,&amp; Instrument)); / *指定long 波形下载的秒超时* / CHECK(viSetAttribute(Instrument,VI_ATTR_TMO_VALUE,40000)); strcpy(SCPIcmd,“* RST n”); / *重置函数发生器* / CHECK(viWrite(Instrument,(ViBuf)SCPIcmd, (ViUInt32)strlen的(SCPIcmd),安培;实际)); strcpy的(SCPIcmd,” * CLS n“); / *清除错误和状态寄存器* / CHECK(viWrite(仪器,(ViBuf)SCPIcmd,(ViUInt32)strlen(SCPIcmd),&amp; actual)); / *计算波形* / fprintf(stderr,“计算波形...... n“); strcpy(SCPIcmd,”DATA VOLATILE“); for(i = 1; i 以上来自于谷歌翻译 以下为原文 Found one and got it to work with VC++ 2008 Create A newm project under "win32 console application" Include Visa32.lib #include "stdafx.h" #include #include #include #include #include #include #include #pragma warning(disable:4996) #define CHECK(func) do { ViStatus _s = (func); if (_s < 0) { fprintf(stderr, "Error: %s returned %dn", #func, _s); exit(0); } } while (0) /* Specify the default address */ #define DEFAULT_LOGICAL_ADDRESS "USB0::0x0957::0x0407::MY44028438::0::INSTR" void main() { ViSession viDefaultRM, Instrument; ViRsrc TxtAddress = DEFAULT_LOGICAL_ADDRESS; ViUInt32 actual; char SCPIcmd[10000]; unsigned short i; CHECK(viOpenDefaultRM(&viDefaultRM)); CHECK(viOpen(viDefaultRM, TxtAddress, VI_NULL, VI_NULL,&Instrument)); /* Specify long seconds timeout for waveform download */ CHECK(viSetAttribute(Instrument, VI_ATTR_TMO_VALUE, 40000)); strcpy(SCPIcmd,"*RSTn"); /* Reset the function generator */ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); strcpy(SCPIcmd,"*CLSn"); /* Clear errors and status registers */ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); /* Compute waveform */ fprintf(stderr, "Computing Waveform...n"); strcpy(SCPIcmd, "DATA VOLATILE"); for(i = 1; i <= 5; i++) /* Set rise time (5 points) */ sprintf(SCPIcmd, "%s,%3.1f", SCPIcmd, (double)(i - 1)/5); for(i = 6; i <= 205; i++) strcat(SCPIcmd, ",1"); /* Set pulse width (200 points) */ for(i = 206; i <= 210; i++) /* Set fall time (5 points) */ sprintf(SCPIcmd, "%s,%3.1f", SCPIcmd, (double)(210 - i)/5); for(i = 211; i <= 4000; i++) strcat(SCPIcmd, ",0"); /* Set remaining points to zero */ strcat(SCPIcmd,"n"); /* Doccwnload data points to volatile memory */ fprintf(stderr,"Downloading Arb...n"); CHECK(viWrite(Instrument,(ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); fprintf(stderr,"Download Completen"); /* Set up arbitrary waveform and output */ strcpy(SCPIcmd,"DATA:COPY PULSE, VOLATILEn"); /* Copy arb to non-volatile memory */ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); strcpy(SCPIcmd, "FUNCtion:USER PULSEn"); /* Select the active arb waveform */ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); strcpy(SCPIcmd, "FUNCtion:SHAPe SQUAREn"); /* Output the selected arb waveform */ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); strcpy(SCPIcmd, "OUTPut:LOAD 50n"); /* Output termination is 50 Ohms*/ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); strcpy(SCPIcmd, "FREQuency 5000;VOLTage 5n"); /* Output frequency is5 kHz @ 5 Vpp */ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); strcpy(SCPIcmd, "OUTPut ONn"); /* Enable output */ CHECK(viWrite(Instrument, (ViBuf)SCPIcmd, (ViUInt32)strlen(SCPIcmd),&actual)); CHECK(viClose(Instrument)); CHECK(viClose(viDefaultRM)); } |
|
|
|
很高兴你能找到一个例子。
这是另一个非常基本的问题:***************************************** ********************************* // *示例程序,用于启用具有以下信号特征波形的简单正弦波输出 :SineFrequency:1000 HzAmplitude:2 Volt Peak to PeakOffset:0 VoltOutput Impedence:50 OhmChannel1输出:Enabled * / #include #include #include void main(){ViSession oRm,oMIO; char strResult [256] = {0}; char noErrString [256] = {“+ 0,”没有错误“ n”}; char buf [256]; //提及Visa连接字符串here.char instAdd [] =“TCPIP0 :: 146.223.123.106 :: inst0 :: INSTR“; //打开资源管理器并为communicationviOpenDefaultRM(&amp; oRm)创建签证会话; viOpen(oRm,instAdd,VI_NULL,VI_NULL,&amp; oMIO); //查询Idendity字符串和report.viPrintf(oMIO ,“* IDN? n”); viScanf(oMIO,“%t”,&amp; buf); printf(“仪器标识字符串:%s n”,buf); //清除并重置instrumentviPrintf(oMIO,“ * CLS n“); viPrintf(oMIO,”* RST n“); //发送命令以设置所需的配置维护(oMIO,”FUNCTION SIN n“); viPrintf(oMIO,“FREQUENCY 1000 n”); viPrintf(oMIO,“VOLT:UNIT VPP n”); viPrintf(oMIO,“VOLT 2 n”); viPrintf(oMIO,“VOLT:OFFSET 0 n”) ); viPrintf(oMIO,“OUTPUT:LOAD 50 n”); //启用output.viPrintf(oMIO,“OUTPUT ON n”); //读取ErrorviQueryf(oMIO,“SYST:ERR? n”,“ %t“,&amp; strResult); if(!(strcmp(strResult,noErrString))){printf(”生成没有任何错误的正弦波 n“);} else {printf(”错误报告:%s“,strResult );} // Exitprintf(“ n按[Enter]退出”); getchar(); viClose(oRm); viClose(oMIO);} 以上来自于谷歌翻译 以下为原文 Glad you were able to find an example. Here is another very basic one: ****************************************************************************/ /* sample program that enables a simple sine wave output with following signal characteristics Wave Shape: Sine Frequency: 1000 Hz Amplitude: 2 Volt Peak to Peak Offset: 0 Volt Output Impedence: 50 Ohm Channel1 Output: Enabled */ #include #include #include void main() { ViSession oRm, oMIO; char strResult[256] = {0}; char noErrString[256] = {"+0,"No error"n"}; char buf[256]; //Mention Visa connection string here. char instAdd[] = "TCPIP0::146.223.123.106::inst0::INSTR"; //Open a resource manager and create a visa session for communication viOpenDefaultRM(&oRm); viOpen(oRm,instAdd,VI_NULL,VI_NULL,&oMIO); //Query Idendity string and report. viPrintf(oMIO,"*IDN?n"); viScanf(oMIO,"%t",&buf); printf("Instrument Identity String: %s n", buf); //Clear and reset instrument viPrintf(oMIO,"*CLSn"); viPrintf(oMIO,"*RSTn"); //Send commands to set the desired configuration viPrintf(oMIO,"FUNCTION SINn"); viPrintf(oMIO,"FREQUENCY 1000n"); viPrintf(oMIO,"VOLT:UNIT VPPn"); viPrintf(oMIO,"VOLT 2n"); viPrintf(oMIO,"VOLT:OFFSET 0n"); viPrintf(oMIO,"OUTPUT:LOAD 50n"); //Enable output. viPrintf(oMIO,"OUTPUT ONn"); //Read Error viQueryf(oMIO,"SYST:ERR?n","%t",&strResult); if(!(strcmp(strResult,noErrString))) { printf("Sine Wave generated without any errorn"); } else { printf("Error reported: %s",strResult); } //Exit printf("nPress [Enter] to exit"); getchar(); viClose(oRm); viClose(oMIO); } |
|
|
|
只有小组成员才能发言,加入小组>>
1240 浏览 0 评论
2352 浏览 1 评论
2163 浏览 1 评论
2030 浏览 5 评论
2914 浏览 3 评论
983浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
713浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
813浏览 0评论
1240浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 15:55 , Processed in 2.226702 second(s), Total 82, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号