Hello guys,
I have been trying to set-up Moku-Go in Matlab in multi-mode with an arbitrary waveform generator and a data-logger. I am trying to log the data from one of the outputs and from one input. The problem is that I do not want to log the data to a file because I want to do multiple measurements and do an average. Because of this, I decided to use the stream data functionality. I want it to stream data as soon as it receives a signal on one of the inputs. Based on the examples, I tried the following code in Matlab:
%% Connect to your Moku
% Configure multi-instrument with platofrm_id 2
mim = MokuMultiInstrument('[fe80::7269:79ff:feb9:43a2]',2, force_connect= 'True');
%%
try
%% Configure the instruments
wg = mim.set_instrument(1, @MokuArbitraryWaveformGenerator);
i = mim.set_instrument(2, @MokuDatalogger);
% configure routing
connections = [struct('source', 'Slot1OutA', 'destination', 'Output1')
struct('source', 'Slot1OutA', 'destination', 'Slot2InA');
struct('source', 'Input2', 'destination', 'Slot2InB');
];
mim.set_connections(connections);
% configure frontend
mim.set_frontend(2, "1MOhm", "DC", "0dB");
%% Configure waveform generator
% generate waveform
t = linspace(0,1,100);
wave = sin(2*pi*t);
wg.generate_waveform(1, "125Ms",wave,10,2);
%% Set up plots
% Get initial data to set up plots
i.set_acquisition_mode('mode','Precision');
stream_duration = 5;
i.enable_input(1,true)
i.enable_input(2,true)
i.start_streaming('duration',stream_duration,'sample_rate' , 1e6)
data = i.get_stream_data();
disp(data.time);
disp(data.ch1);
figure
lh = plot(data.time, data.ch1);
xlabel(gca,'Time (sec)')
ylabel(gca,'Amplitude (V)')
%% Receive and plot new data frames
received_data = data.ch1;
time = data.time;
for j = 1:3
data = i.get_stream_data();
received_data = [received_data; data.ch1];
time = [time; data.time];
set(lh(1),'XData',data.time,'YData',data.ch1);
axis tight
pause(0.3)
end
catch ME
% End the current connection session with your Moku
i.relinquish_ownership();
rethrow(ME)
end
i.relinquish_ownership();
The problem is that at the i.get_stream_data()
it gets stuck and never continues. It does not even throw an error. I am new to this domain so I could really use some help with this.
Thank you for the help in advance!