Connect Neurosky Mindwave in ATTENTION

5 次查看(过去 30 天)
I using code :
function read_ATTENTION
TG_DATA_ATTENTION = 2;
Matlab code to read attention using Mindwave mobile
%Clear Screen
clc;
%Clear Variables
clear all;
%Close figures
close all;
%Preallocate buffer
data_att = zeros(1,256);
%Comport Selection
portnum1 = 14;
%COM Port #
comPortName1 = sprintf('\\\\.\\COM%d', portnum1);
% Baud rate for use with TG_Connect() and TG_SetBaudrate().
TG_BAUD_115200 = 115200;
% Data format for use with TG_Connect() and TG_SetDataFormat().
TG_STREAM_PACKETS = 0;
% Data type that can be requested from TG_GetValue().
TG_DATA_ATTENTION = 2;
%load thinkgear dll
loadlibrary('Thinkgear.dll');
%To display in Command Window
fprintf('Thinkgear.dll loaded\n');
%get dll version
dllVersion = calllib('Thinkgear', 'TG_GetDriverVersion');
%To display in command window
fprintf('ThinkGear DLL version: %d\n', dllVersion );
% Get a connection ID handle to ThinkGear
connectionId1 = calllib('Thinkgear', 'TG_GetNewConnectionId');
if ( connectionId1 < 0 )
error( sprintf( 'ERROR: TG_GetNewConnectionId() returned %d.\n', connectionId1 ) );
end;
% Attempt to connect the connection ID handle to serial port "COM3"
errCode = calllib('Thinkgear', 'TG_Connect', connectionId1,comPortName1,TG_BAUD_115200,
TG_STREAM_PACKETS);
if ( errCode < 0 )
error( sprintf( 'ERROR: TG_Connect() returned %d.\n', errCode ) );
end
fprintf( 'Connected. Reading Packets...\n' );
i=0;
j=0;
%To display in Command Window
disp('Reading Brainwaves');
figure;
while i < 20
if (calllib('Thinkgear','TG_ReadPackets',connectionId1,1) == 1) %if a packet was read...
if (calllib('Thinkgear','TG_GetValueStatus',connectionId1,TG_DATA_ATTENTION ) ~= 0)
j = j + 1;
i = i + 1;
%Read attention Valus from thinkgear packets
data_att(j) = calllib('Thinkgear','TG_GetValue',connectionId1,TG_DATA_ATTENTION );
%To display in Command Window
disp(data_att(j));
%Plot Graph
plot(data_att);
title('Attention');
%Delay to display graph
pause(1);
end
end
end
%To display in Command Window
disp('Loop Completed')
%Release the comm port
calllib('Thinkgear', 'TG_FreeConnection', connectionId1 );
but the wrong code command window shows up:
Error: File: Connect.m Line: 36 Column: 88
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
means line 36 is:
errCode = calllib('Thinkgear', 'TG_Connect', connectionId1,comPortName1,TG_BAUD_115200,
TG_STREAM_PACKETS);
can you help me to solve this ? thankyou

采纳的回答

Ilham A.E. Zaeni
Ilham A.E. Zaeni 2019-3-14
Try change line 36 with :
errCode = calllib('Thinkgear', 'TG_SetStreamLog', connectionId1, 'streamLog.txt' );

更多回答(1 个)

williams gerardo cardenas gomez
Tsalsabilla. Could you pass me your mail, please? He needed help connecting mindwave to matlab. mail. wilgera7@gmail.com

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by