필터 지우기
필터 지우기

Error using calllib Library was not found

조회 수: 8 (최근 30일)
Ajna Ram
Ajna Ram 2019년 2월 13일
댓글: Abdul Rauf 2019년 10월 24일
I am trying to get attention values from NeuroSky Mindwave Mobile 2 using MATLAB but I keep getting Error using Calllib Library not found.
I'm mew with MATLAB, so bear with me :l
MATLAB version is R2015b 32 bits
%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 = 10;
%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
path = 'C:\Users\Downloads\matlabdll\thinkgear.h';
path1 = 'C:\UsersDownloads\ThinkGear_Connector\ThinkGear_Connector\ThinkGear.dll';
loadlibrary(path1,path);
%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( '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( '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 );
  댓글 수: 1
Abdul Rauf
Abdul Rauf 2019년 10월 24일
Hello Ajna,
I am facing same problem. Were you able to resolve this issue?
Please reply if you could help because i direly need someone's help.
Thank You

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by