Borrar filtros
Borrar filtros

can I have independent analog output and digital counter output in the same session ?

1 visualización (últimos 30 días)
Hi everyone
I have a setup with both recording and stimulating electrodes. I would like to record the effects of a certain stimulus which is basically designed by a slightly modified sinewave law and given as an output through an analog output channel in my recording session.
I am able able to record the signal through the recording electrodes. All good so far.
Fs = 20000; % 1 second
s = daq.createSession('ni');
channels = [0 1]; % data are written to channels AI0 and AI1
s.addAnalogInputChannel('Dev3',channels, 'Voltage'); % these are the recording channels
s.addAnalogOutputChannel('Dev3',0, 'Voltage'); % this is the analog output
stimulus = sin(2*pi*[1:120000]*700);
queueOutputData(s,stimulus'); % this puts out the sine stimulus
% here I want to add a trigger to another recording device with a given frequency
ch1 = addCounterOutputChannel(s,'Dev1','ctr0','PulseGeneration');
ch1.Frequency = 40;
ch1.DutyCycle = 0.1; % default value 0.1, amount of time the pulse stays active (from 0 to 1)
ch1.Terminal
% s.DurationInSeconds = 180
s.Rate = Fs; % sample rate
s.startForeground; % run recording
pause(180);
It all works fine except that the digital trigger runs only for a short amount of time which depends on the amount of data points given by the stimulus.
Instead, I would like to extend the duration of the whole session beyond the duration of the output stimulus (let's say for instance 180 seconds, as in the example). uncommenting that line though, gives me an error ("DurationInSeconds cannot be set when there are output channels in the session. You must specify or change the amount of data queued to change the number of scans acquired."). I understand that basically the two output channels need to be linked and use the same "timebase"...is it possible to uncouple them ?
One solution would be to design a stimulus which includes blanks spaces (0 values) for the whole session duration except for the time when the analog output is active).
Is there a cleaner way ?

Respuestas (0)

Categorías

Más información sobre Data Acquisition Toolbox Supported Hardware en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by