From 13df7ffdb80aa7df231c81d2fd82eb282c13e654 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Sun, 10 Nov 2024 21:40:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=B9=E9=85=8DV0.38=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Untitled.m | 51 ++++++++++++++++++++++++++++----------------------- iio_sys_obj.m | 18 ++++++++++++++---- libiio_if.m | 42 ++++++++++++++++++++++-------------------- untitled6.asv | 17 ----------------- 4 files changed, 64 insertions(+), 64 deletions(-) delete mode 100644 untitled6.asv diff --git a/Untitled.m b/Untitled.m index 8200bfa..f901620 100644 --- a/Untitled.m +++ b/Untitled.m @@ -21,31 +21,37 @@ x = 0:T/N:T; -y= x(1:2:N); %采样x的奇数点 -z=x(2:2:N);%采样x的偶数点 + y= x(1:2:N); %采样x的奇数点 + z=x(2:2:N);%采样x的偶数点 + tx = adi.AD9361.Tx('uri',uri); + tx.CenterFrequency = fc; + tx.DataSource = 'DMA'; + tx.EnableCyclicBuffers = true; + tx.AttenuationChannel0 = -20; + i = 0; + while 1 + i = i + 1; + z = i %10 + pause(0.1); + fi=10000*sin(2*pi*100000*z*y); + fq=10000*sin(2*pi*100000*z*y); + subplot(2,2,1) + plot(fi) + subplot(2,2,2) + plot(fq) + complexArray = fi + fq*1i; + complexArray = complexArray'; + + %% Tx set up -fi=10000*sin(2*pi*30000*y) + 10000*sin(2*pi*900000*y); -fq=10000*sin(2*pi*30000*z) + 10000*sin(2*pi*900000*z); - -subplot(2,2,1) - -plot(fi) -subplot(2,2,2) - -plot(fq) - -complexArray = fi + fq*1i; -complexArray = complexArray'; - -%% Tx set up -tx = adi.AD9361.Tx('uri',uri); -tx.CenterFrequency = fc; -tx.DataSource = 'DMA'; -tx.EnableCyclicBuffers = true; -tx.AttenuationChannel0 = -20; -tx(complexArray); + tx(complexArray); + if i >= 5000 + break; % 当i等于5时退出循环 + end +end + %% Rx set up rx = adi.AD9361.Rx('uri',uri); rx.CenterFrequency = fc; @@ -59,7 +65,6 @@ for k=1:10 end end rx.release(); -tx.release(); %% Plot nSamp = length(out); diff --git a/iio_sys_obj.m b/iio_sys_obj.m index ce875ce..9268791 100644 --- a/iio_sys_obj.m +++ b/iio_sys_obj.m @@ -294,7 +294,17 @@ classdef iio_sys_obj < matlab.System & matlab.system.mixin.Propagates ... obj.str_cfg_in(i,j+1) = 0; str = char(obj.str_cfg_in(i,:)); end + d = obj.iio_dev_cfg.cfg_ch(i).ctrl_dev + j = obj.iio_dev_cfg.cfg_ch(i).port_attr + s = str + if strcmp('in_voltage1_gain_control_mode',j) + continue + end + if strcmp('out_voltage_rf_bandwidth',j) + continue + end writeAttributeString(obj.iio_dev_cfg.cfg_ch(i).ctrl_dev, obj.iio_dev_cfg.cfg_ch(i).port_attr, str); + end end end @@ -343,15 +353,15 @@ classdef iio_sys_obj < matlab.System & matlab.system.mixin.Propagates ... cfg_ch_no = 0; config = getObjConfig(obj); if(~isempty(config)) - cfg_ch_no = length(config.cfg_ch); + cgf_ch_no = length(config.cfg_ch); end - if(data_ch_no + cfg_ch_no ~= 0) - varargout = cell(1, data_ch_no + cfg_ch_no); + if(data_ch_no + cgf_ch_no ~= 0) + varargout = cell(1, data_ch_no + cgf_ch_no); for i = 1 : data_ch_no varargout{i} = sprintf('DATA_IN%d', i); end - for i = data_ch_no + 1 : data_ch_no + cfg_ch_no + for i = data_ch_no + 1 : data_ch_no + cgf_ch_no varargout{i} = config.cfg_ch(i - data_ch_no).port_name; end else diff --git a/libiio_if.m b/libiio_if.m index d4ae244..7de9194 100644 --- a/libiio_if.m +++ b/libiio_if.m @@ -608,10 +608,17 @@ classdef libiio_if < handle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [ret, val] = readAttributeDouble(obj, attr_name) % Find the attribute - [ret, ch, attr] = findAttribute(obj, attr_name); - if(ret < 0) + try + [ret, ch, attr] = findAttribute(obj, attr_name); + if(ret < 0) + val = 0; + return; + end + catch e + warning("ddd"); + ret = 1; val = 0; - return; + return ; end % Create a double pointer to be used for data read @@ -679,23 +686,18 @@ classdef libiio_if < handle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function ret = writeAttributeString(obj, attr_name, str) % Find the attribute - try - [ret, ch, attr] = findAttribute(obj, attr_name); - if(ret < 0) - return; - end - - % Write the attribute - if(ret > 0) - calllib(obj.libname, 'iio_channel_attr_write', ch, attr, str); - clear ch; - clear attr; - else - calllib(obj.libname, 'iio_device_attr_write', obj.iio_dev, attr_name, str); - end - catch e - disp("error ",e) - + [ret, ch, attr] = findAttribute(obj, attr_name); + if(ret < 0) + return; + end + + % Write the attribute + if(ret > 0) + calllib(obj.libname, 'iio_channel_attr_write', ch, attr, str); + clear ch; + clear attr; + else + calllib(obj.libname, 'iio_device_attr_write', obj.iio_dev, attr_name, str); end end end diff --git a/untitled6.asv b/untitled6.asv deleted file mode 100644 index 3603559..0000000 --- a/untitled6.asv +++ /dev/null @@ -1,17 +0,0 @@ - -T=10e-3; %信号时宽 -B=3e6; %信号带宽 -fs=4*B; %采样频率 -N=fix(T*fs); %采样点数 - -x = 0:T/N:T; - -f=sin(2*pi*300*x) + sin(2*pi*200*x); - -plot(f) - -y= x(1:2:N); %采样x的奇数点 -z=x(2:2:N);%采样x的偶数点 - -I = -