Data aquisition tool box- ending background session due to certain sensor value

Hello,
I have a question regarding the data aquistion toolbox.
First I will explain my setup. I have the computer connected to my DAQ-cDAQ-9185 module. This DAQ-module has an output which is amplified and then drives an electrodynamic shaker. With that shaker a mechanical part is excited. On the mechanical part there is a force-sensor. The force sensor data is processed with the DAQ-module.
Right now a signal is created with matlab and after calling the function readwrite the session of recording the sensor data and the excitation-signal is sent onto the shaker. This is a so called foreground session.
clear all
daqlist('ni')
s = daq('ni'); %NI-Systeme
addoutput(s,'cDAQ9185-1ED5E01Mod1',0,'Voltage'); % output
ch = addinput(s, 'cDAQ9185-1ED5E01Mod3',0:1,'Bridge') % input
ch(1).BridgeMode = 'Quarter';
ch(1).NominalBridgeResistance = 120;
s.Rate = 5120; % Samplingrate
%Creating the excitation signal
tend = 60; % excitation time
% generate sinusoidal sweep
t = linspace(0,tend,tend*s.Rate);
f0 = 10;
f1 = 40;
f = linspace(f0,f1,tend*s.Rate);
% amplitude:
A0 = 3;
t1 = 3; % rise and fall timne
A1 = A0*linspace(0,1,t1*s.Rate);
A2 = A0*linspace(1,0,t1*s.Rate);
A = [A1 A0*ones(1,length(f)-2*length(A1)) A2]';
% output signal of sinusoidal sweep with rise and fall time
outputSignal = A.*sin(2*pi*f.*t)';
%Run the generated signal and save the data of the sensors
scanData = readwrite(s,outputSignal); % Anregung starten
So right now a signal is generated and the the readwrite function is called, which starts the aquistion of data and excitation of the skaker. After the time of aquisition is over the data is displayed in the matlab workspace.
My question now is: Is it possible that I have a session which would be in the background (this means I get the data at the "same" moment) and after I measure a certain value with the sensor at some certain moment I call an event function which enables it to slowly decrease the output voltage of the DAQ-card?
So due to a measured signal I change my output of the DAQ-device in a background session.
Best regards,
Christoph

Answers (0)

Categories

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!