33220a 编程C语言,在33220a gen中加载一个arb波形,在MATLAB中采样率低

matlab(visa)在函数发生器中加载任意波形。

但是,我没有获得我设计的波形。

使用的代码如下。

我最初使用1Hz的简单正弦波测试代码。

然而,产生的波具有非常高的频率(大约为kHz)。

我怀疑这是由于采样频率低得多。

函数发生器的50Mbps采样率会产生大量数据,而MAtlab无法处理这些数据。

另外,我最终想要创造一个1000秒扫描时间的啁啾声。

为此,我需要*降低生成器的采样率*。请为我提供相同的命令。

我使用的代码如下 - fgen = visa('AGILENT','USB0 :: 0x0957 :: 0x0407 :: MY44048510 :: 0 :: INSTR');

set(fgen,'OutputBufferSize',100000);

的fopen(FGEN);

%Query Idendity字符串和报告fprintf(fgen,'* IDN?');

idn = fscanf(fgen);

fprintf(idn)fprintf('\ n \ n')%清除并重置仪器fprintf(fgen,'* RST');

fprintf(fgen,'* CLS');

%创建arb波形fprintf('生成波形... \ n \ n')sRate = 100;

ch = [];

对于t = 0:1 / sRate:10 c = sin(t);

y = num2str(c);

s5 = sprintf(',%s',y);

ch = [ch s5];

end%组合所有字符串%s = [上升宽度下降低];

s = [ch];

%将数据串与scpi命令组合使用arbstring = sprintf('DATA VOLAtiLE%s',s);

%Send命令设置所需的配置fprintf('下载波形... \ n \ n')fprintf(fgen,arbstring);

%make instrument等待数据下载,然后转到下一个%命令set fprintf(fgen,'* WAI');

fprintf('下载完成\ n \ n')%设置所需的配置。

fprintf(fgen,'VOLT 2');

%将最大波形幅度设置为2 Vpp fprintf(fgen,'VOLT:OFFSET 0');

%将偏移设置为0 V fprintf(fgen,'OUTPUT:LOAD 50');

%将输出负载设置为50欧姆fprintf(fgen,'FREQ 1');

%设定频率为1KHz fprintf(fgen,'DATA:COPY TEST16385,VOLATILE');

fprintf(fgen,'FUNC:USER VOLATILE');

fprintf(fgen,'FUNC:SHAP USER');

%启用输出fprintf(fgen,'OUTPUT ON');

%打开通道1输出%读取错误fprintf(fgen,'SYST:ERR?');

errorstr = fscanf(fgen);

%错误检查strncmp(errorstr,'+ 0,“无错误”',13)errorcheck ='生成的任意波形没有任何错误\ n';

fprintf(错误检查)else errorcheck = ['错误报告:',errorstr];

fprintf(错误检查)end%用函数发生器fclose(fgen)关闭签证会话;

我使用以下命令来降低采样率-sRate = 100;

fprintf(fgen,'SOURCE1:FUNCtion:ARB:SRATe'num2str(sRate))程序在此行显示错误

以上来自于谷歌翻译

以下为原文

I have been trying to load an arbitrary waveform in function generator using MATLAB (visa). However, I dont obtain the waveform that I have designed. The code used is given below. I initially tested the code with a simple sine wave of 1Hz. However, the wave generated is of very much higher frequency (of the order of kHz). I suspect it is due to much lower sampling frequency. The 50Mbps sampling rate of the function generator creates a huge amount of data, that cannot be handLED by MAtlab. Also, I ultimately want to create a chirp with 1000 sec sweep time. For that, I need to *reduce the sampling rate of the generator* .Please provide me the commands for the same. The codes I used is given below-

fgen = visa('AGILENT','USB0::0x0957::0x0407::MY44048510::0::INSTR');

set (fgen,'OutputBufferSize',100000);

fopen(fgen);

%Query Idendity string and report

fprintf (fgen, '*IDN?');

idn = fscanf (fgen);

fprintf (idn)

fprintf ('\n\n')

%Clear and reset instrument

fprintf (fgen, '*RST');

fprintf (fgen, '*CLS');

% Create arb waveform

fprintf('Generating Waveform...\n\n')

sRate = 100;

ch = [];

for t = 0:1/sRate:10

c = sin(t);

y = num2str(c);

s5 = sprintf(', %s',y);

ch = [ch s5];

end

%combine all of the strings

%     s = [rise width fall low];

s = [ch];

% combine string of data with scpi command

arbstring =sprintf('DATA VOLATILE %s', s);

%Send Command to set the desired configuration

fprintf('Downloading Waveform...\n\n')

fprintf(fgen, arbstring);

%make instrument wait for data to download before moving on to next

%command set

fprintf(fgen, '*WAI');

fprintf('Download Complete\n\n')

%Set desired configuration.

fprintf(fgen,'VOLT 2'); % set max waveform amplitude to 2 Vpp

fprintf(fgen,'VOLT:OFFSET 0'); % set offset to 0 V

fprintf(fgen,'OUTPUT:LOAD 50'); % set output load to 50 ohms

fprintf(fgen,'FREQ 1'); %set frequency to 1KHz

fprintf(fgen,'DATA:COPY TEST16385, VOLATILE');

fprintf(fgen,'FUNC:USER VOLATILE');

fprintf(fgen,'FUNC:SHAP USER');

%Enable Output

fprintf(fgen,'OUTPUT ON'); % turn on channel 1 output

% Read Error

fprintf(fgen, 'SYST:ERR?');

errorstr = fscanf (fgen);

% error checking

IF strncmp (errorstr, '+0,"No error"',13)

errorcheck = 'Arbitrary waveform generated without any error \n';

fprintf (errorcheck)

else

errorcheck = ['Error reported: ', errorstr];

fprintf (errorcheck)

end

%closes the visa session with the function generator

fclose(fgen);

I used the following command to reduce the sampling rate-

sRate = 100;

fprintf(fgen,'SOURCE1:FUNCtion:ARB:SRATe ' num2str(sRate))

The program shows an error at this line

699ba7046c51816a17b33a7caa85f179.png

1

97b4b3417991aabde46fdac613e34292.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值