Problem connecting NeuroSky Mindwave Mobile to Matlab

11 views (last 30 days)
I am trying to connect the headset to Matlab but this error came up. I'm using Matlab R2015b on Windows 10 64bit OS. Can anyone help?
Error using loadlibrary
There was an error loading the library "C:\Users\user\Documents\MATLAB\Thinkgear.dll"
C:\Users\user\Documents\MATLAB\Thinkgear.dll is not a valid Win32 application.
Error in readRAWnew (line 26)
loadlibrary('Thinkgear.dll');
Caused by:
Error using loaddefinedlibrary
C:\Users\user\Documents\MATLAB\Thinkgear.dll is not a valid Win32 application.
The code that I used:
function readRAW
%run this function to connect and plot raw EEG data
%make sure to change portnum1 to the appropriate COM port
clear all
close all
data = zeros(1,256); %preallocate buffer
portnum1 = 6; %COM Port #
comPortName1 = sprintf('\\\\.\\COM%d', portnum1);
% Baud rate for use with TG_Connect() and TG_SetBaudrate().
TG_BAUD_57600 = 57600;
% 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_RAW = 4;
%load thinkgear dll
loadlibrary('Thinkgear.dll');
fprintf('Thinkgear.dll loaded\n');
%get dll version
dllVersion = calllib('Thinkgear', 'TG_GetDriverVersion');
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;
% Set/open stream (raw bytes) log file for connection
errCode = calllib('Thinkgear', 'TG_SetStreamLog', connectionId1, 'streamLog.txt' );
if( errCode < 0 )
error( sprintf( 'ERROR: TG_SetStreamLog() returned %d.\n', errCode ) );
end;
% Set/open data (ThinkGear values) log file for connection
errCode = calllib('Thinkgear', 'TG_SetDataLog', connectionId1, 'dataLog.txt' );
if( errCode < 0 )
error( sprintf( 'ERROR: TG_SetDataLog() returned %d.\n', errCode ) );
end;
% Attempt to connect the connection ID handle to serial port "COM3"
errCode = calllib('Thinkgear', 'TG_Connect', connectionId1,comPortName1,TG_BAUD_57600,TG_STREAM_PACKETS );
if ( errCode < 0 )
error( sprintf( 'ERROR: TG_Connect() returned %d.\n', errCode ) );
end
fprintf( 'Connected. Reading Packets...\n' );
%record data
j = 0;
i = 0;
while (i < 10240) %loop for 20 seconds
if (calllib('Thinkgear','TG_ReadPackets',connectionId1,1) == 1) %if a packet was read...
if (calllib('Thinkgear','TG_GetValueStatus',connectionId1,TG_DATA_RAW) ~= 0) %if RAW has been updated
j = j + 1;
i = i + 1;
data(j) = calllib('Thinkgear','TG_GetValue',connectionId1,TG_DATA_RAW);
end
end
if (j == 256)
plotRAW(data); %plot the data, update every .5 seconds (256 points)
j = 0;
end
end
%disconnect
calllib('Thinkgear', 'TG_FreeConnection', connectionId1 );

Accepted Answer

Walter Roberson
Walter Roberson on 17 Nov 2015
You are trying to call a 32 bit driver from a 64 bit version of MATLAB. You will need to run the 32 bit version of MATLAB. (Even then, you might have additional problems due to compatibility problems that are present in Windows 10)
Note: R2015b will be the last 32 bit version of MATLAB.
  5 Comments
Walter Roberson
Walter Roberson on 29 Nov 2016
Looi Kelly: if you have a license for a newer version of MATLAB, then you can install the 32 bit version of that, up to and including R2015b. If you have an R2016a or R2016b license, you can still download R2015b.
Also it appears that http://store.neurosky.com/products/pc-developer-tools-4-0 probably supports 64 bit now.

Sign in to comment.

More Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!