Live Data Acquisition App with 2 Channels?

How can I modify the Live Data Acquisition App Example to display and save data from 2 channels instead of only 1? The GUI in the example is perfect for my system, and I would just like to be able to add on one more channel.

1 Comment

Hi Adrienne,
Do you have any update about you qustion.
Im trying to do the same.
best regard

Sign in to comment.

Answers (1)

Hi,
I understand that you need two input channels for the Live Data Acquisition app. To achieve that you can do the following
  1. You can edit the mlapp file using the following command.
edit LiveDataAcquisition.mlapp
2. Open the design view and add respective dropdown for Channel-2 from component library. (drag and drop)
3 .In codeview, the DAQSession is created in the function updateChannelMeasurementComponents. You can add another input channel to the same session. You can refer this link
After you make appropriate changes in the code. The app must take in data from two input channels.
Hope this helps!

7 Comments

Hi,
There is no function "updateChannelMeasurementComponents" in the Live DataAcquisiton App. Maybe you mean the "ChannelDropDownValueChanged" function
Also, do you know where I change the app to take in data from 2 input channels and get them to display on the graph.
Have a great day,
Nathan
1.I added DropDown component, named Channel2DropDown.
2.Made Callbacks named Channel2DropDownValueChanged, and added just one line, updateChannelMeasurementComponents(app)
3.In DeviceDropDownValueChanged function, added lines for setting Channel2DropDown.Items and Value
4.in updateChannelMeasurementComponents function, added one line
addinput(d, deviceID, app.Channel2DropDown.Value, measurementType);
but only one Channel is shown on live plot. Am I missing something?
Should I modify also scansAvailable_Callback, etc?
And I'm confusing between
dq = daq('ni')
and
s = daq.createSession('ni');
because LiveDataAcquisition.mlapp is made with dq = daq('ni')
but you suggest to use
how should I modify it in updateChannelMeasurementComponents function?
Hi Norio,
i have a question referring to your first comment here, where you explained the steps you made for adding an additional channel. I used you steps 1. to 4. but for 8 channels. So far it seems to work but I'm not sure what did you do/mean when you wrote: 'added lines for setting Channel2DropDown.Items and Value'. The first part was clear to me but which Value did you change in the code? I'm a bit confused. Would you be please so kind and provide further information on that.
Best regards
Veit
Did anyone actually get this working?
If so could you send me what code you modified.
Thanks
Veit try this % Create a new data acquisition object
d = daq(vendor);
addinput(d, deviceID, app.ChannelDropDown.Value, measurementType);
addinput(d, deviceID, "ai1", measurementType);
...
% Get subsystem information to update channel dropdown list and channel property options
% For devices that have an analog input or an audio input subsystem, this is the first subsystem
subsystem = app.DevicesInfo(deviceIndex).Subsystems(1);
app.ChannelDropDown.Items = cellstr(string(subsystem.ChannelNames));
app.Channel2DropDown.Items = cellstr(string(subsystem.ChannelNames));
Norio try this
% Store continuous acquisition data in FIFO data buffers
buffersize = round(app.DAQ.Rate * app.TimewindowEditField.Value) + 1;
app.TimestampsFIFOBuffer = storeDataInFIFO(app, app.TimestampsFIFOBuffer, buffersize, timestamps);
app.DataFIFOBuffer = storeDataInFIFO(app, app.DataFIFOBuffer, buffersize, data(:,1));%%%isso fez coletar o canal ai0
app.Data2FIFOBuffer = storeDataInFIFO(app, app.Data2FIFOBuffer, buffersize, data(:,2));%%%isso fez coletar o canal ai1
% Update plot data grafico direita ai0
set(app.LivePlotLine, 'XData', app.TimestampsFIFOBuffer, 'YData', app.DataFIFOBuffer);
if numel(app.TimestampsFIFOBuffer) > 1
xlim(app.LiveAxes, [app.TimestampsFIFOBuffer(1), app.TimestampsFIFOBuffer(end)])
end
% Update plot data grafico esquerda ai1
set(app.LivePlotLine2, 'XData', app.TimestampsFIFOBuffer, 'YData', app.Data2FIFOBuffer);
if numel(app.TimestampsFIFOBuffer) > 1
xlim(app.Live2Axes, [app.TimestampsFIFOBuffer(1), app.TimestampsFIFOBuffer(end)])
end
end
Terry, yes i did.
but at the moment Im not able to save bouth channel. I need same help to do this

Sign in to comment.

Products

Release

R2019a

Asked:

on 21 Aug 2019

Commented:

on 21 Aug 2022

Community Treasure Hunt

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

Start Hunting!