필터 지우기
필터 지우기

Arduino support package send two value at the same time to different port

조회 수: 3 (최근 30일)
Fan Yang
Fan Yang 2021년 9월 27일
답변: Pratik 2024년 5월 15일
I need to trigger EEG and fMRI at the same time by a visual stimulation I wrote in matlab. I can use the arduino support package to trigger trigger to the EEG system sychronzing the visual stimuli and EEG recording, but I also need to trigger the fMRI scanner. I am thinking connect two arduino boards to my computer via different ports and send two triggers to two ports respectively and simultaneously. How can I do that?
I wrote the code below to synch EEG and visuals stim.
P.S. the visual stim were writen using the VisualStimulus toolbox version 1.0 by Michael Beyeler.
a = arduino('com3','uno'); % Create an adrduino object
f = figure; f.WindowState = 'maximized'; % max the figure window
for deg = (0:7)*45
blank = GratingStim([300 500],'k',20,deg,[1,1],0.1);% generate a blank pic
blank.plot % plot the blank picture
grating=GratingStim([300 500],'k',20,deg); % generate stimuli
writeDigitalPin(a,'D4',1) % write to EEG to start recording
grating.plot % plot the stimuli
writeDigitalPin(a,'D4',0) % write to EEG to end recording
end
clear a % delete the arduino object

답변 (1개)

Pratik
Pratik 2024년 5월 15일
Hi Fan,
As per my understanding, two arduino boards are to be connected to a computer via different ports and two different triggers are to be send to the ports separately.
This can be achieved by creating two Arduino objects. "parfevalOnAll" can be used to run an initialization on each worker that creates an arduino object and stores a reference to it .
Please refer to the following MATLAB Answer which shows how to identify a worker:
Also, please refer to the documentation of "parfevalonall" for more information on running function on all workers in background:
I hope this helps!

카테고리

Help CenterFile Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by