Effacer les filtres
Effacer les filtres

How to change a parameter while the signal is running?

1 vue (au cours des 30 derniers jours)
Ali Albaidhani
Ali Albaidhani le 4 Avr 2022
Hello everyone,
I want to generate a signal that can be changed while running. I want to be able to change the magnitude while the signal is running. I tried generating a signal in background and i wrote different values for the magnitude in the command box but it didn't change anything.
I have the following code:-
%-------------------------------------
clearvars
clc
d = daqlist("ni");
deviceInfo = d{1, "DeviceInfo"};
dq = daq("ni");
fidData = fopen("logData.bin","w");
fidTime = fopen("logTime.bin","w");
DisplayTime=1;
s = daq.createSession('ni');
s.Rate=5000;
addAnalogInputChannel(s,'Dev2','ai11','Voltage');
lh = addlistener(s,'DataAvailable',@plotData);
lh1 = addlistener(s,'DataAvailable',@(src, event)logData(src, event, fidData,fidTime));
s.IsContinuous=true;
s.NotifyWhenDataAvailableExceeds=floor(DisplayTime*s.Rate);
%Output
addAnalogOutputChannel(s,'Dev2','ao0','Voltage');
Fs=s.Rate
t1=100;
t = 0 :1/Fs : t1-1/Fs;
A=0.5;
data0 = A*sin(2*pi*t*159.2)';
b=repmat(data0,5,1);
queueOutputData(s,b);
datagiver = addlistener(s, 'DataRequired',@(src,event)...
src.queueOutputData(b));
figure(1)
clf
startBackground(s);
%%
s.stop
fclose(fidData);
fclose(fidTime);
%-------------------------------------
Please help if you have an idea. I need to do this because im making a controller for the magnitude value.
Regards
Ali

Réponses (0)

Catégories

En savoir plus sur Data Acquisition Toolbox Supported Hardware dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by