Page 1 of 2

Problem Connecting to Neurosky Mindwave

Posted: 26 Dec 2011, 09:44
by dinasherif
Hello,
I have posted the following message under the software development and then I rethought that it is more adequate to this thread ....


I have just bought a Neurosky Mindwave and I am trying to connect it to BCI2000 in order to get the raw data and design my own Hybrid BCI paradigm. I have compiled the Neurosky source code and generated the .exe, I have also created the parameter file with the parameters set as indicated on the BCI2000 Neurosky wiki and also created a batch file to call the operator module followed by the Neurosky source module and finally I called the P300 ready made example as a first trial.
the operator GUI launched and I configured the source via the source button then I pressed set config button , I got this message in the system log: "SignalSource confirmed new parameters" but the start button is deactivated !!
The software is halted at this state and nothing is happening ... What might be the problem?

I have also the following questions:

1) Is the written Neurosky source module tested on the Neurosky Mindwave or only on the Mindset (as stated by the Neurosky website the main difference between the mindset and the mindwave is The MindSet uses bluetooth to transmit data, and includes a bluetooth dongle for computers without a built in bluetooth receiver. The MindWave uses RF to transmit data, and includes a RF USB dongle compatible with both Mac and Windows. Both use identical chips)

2) Does the source module interact directly with the dongle or does it connect to the think gear connector program via say sockets?

I would really appreciate any help concerning this matter ,,,

Waiting,

-- Dina.

Re: Problem Connecting to Neurosky Mindwave

Posted: 10 Jan 2012, 16:20
by griffin.milsap
Dina,

Apologies for the delay,

Does the module ever report the ThinkGear DLL Version in the operator log? It would look like this:
"ThinkGear DLL version: ..."

To answer your other two questions, the module communicates with the Mindset through the use of a "COM" port -- serial data stream. For the Mindset, there is a Bluetooth COM port created, and for your Mindwave, I would assume that there is a USB COM Port driver installed. Did you locate which COM port your data is coming in on? Did you set the COM Port parameter appropriately? You can find which COM port your device is on in the device manager.

I've never tested the module with the Mindwave, but only with the Mindset. As you say, they use the same chip -- so I wouldn't expect any incompatibility issues. The driver does not communicate with any of the other neurosky software, but instead talks directly to the driver (which then manages finding connected devices). It is entirely possible that the module needs to be compiled with a newer library and shipped with a newer .dll to support the mindwave -- I'm not sure.

I've identified a *possible* bug in the module, but I don't think it is a problem if the "ThinkGear DLL Version" line is still printing in the log. If you can answer that question for me, I may be able to help.

-Griff

Re: Problem Connecting to Neurosky Mindwave

Posted: 14 Jan 2012, 07:13
by giuseppe
Hi, I'm an Italian student of Computer Science of Verona, I just bought a Neurosky Mindwave headset, and I would like to work with BCI2000 for my graduate thesis, I downloaded the BCI2000Contrib version and installed. I wear the headset and switch it on, than started BCI2000 Launcher with Admin privilage, Set Neurosky on Signal Source, P3SignalProcessing, and P3Speller and click Launch.

Then I Click Config, and click Load Parameters, and loaded parms/p3_tutorial/InitialP3Session.prm.
Finally on source set SourceCh = 1; SampleBlockSize = 1; SamplingRate = 512; SourceChOffset = 0; SourceChGain = 0.2197; COMport = COM5 (It is correct); TransmitChList = 1.

Click on Set Config and this is the log

Code: Select all

2012-01-14T15:05:52 - BCI2000 Started
2012-01-14T15:05:53 - Waiting for configuration ...
2012-01-14T15:05:53 - Waiting for configuration ...
2012-01-14T15:05:53 - Waiting for configuration ...
2012-01-14T15:06:59 - Operator set configuration
2012-01-14T15:06:59 - NeuroSkyADC::Preflight: ThinkGear DLL version: 21.
2012-01-14T15:06:59 - SignalProcessing confirmed new parameters ...
2012-01-14T15:06:59 - SignalSource confirmed new parameters ...
2012-01-14T15:06:59 - Application confirmed new parameters ...
2012-01-14T15:07:02 - Operator started operation
But when I click Start, the program is Waiting... and do nothing...
And Neurosky.exe process usage is 50%CPU

Which could be the problem? Thanks

Re: Problem Connecting to Neurosky Mindwave

Posted: 14 Jan 2012, 12:57
by griffin.milsap
I would be willing to bet that the API isn't successfully retrieving data from the device and is getting stuck in an infinite loop around line 194-200 in NeuroSkyADC.cpp. What's strange is that it seems to be able to connect to the device if it's getting that far.

I know that the module works with the Mindset because that's what we have to test with, but it seems to not work with the Mindwave, and I don't have one over here to test with. Would either of you two be willing to debug this and contribute a fix?

-Griff

Re: Problem Connecting to Neurosky Mindwave

Posted: 14 Jan 2012, 16:06
by giuseppe
Hi, thanks for the quickly response, I think that the problem is probably in the call to TG_GetValueStatus at line 197, in the thinkgear.h file the comment of TG_GetValueStatus function report that:

Code: Select all

 * @param dataType     The type of data value desired.  Select from one of
 *                     the TG_DATA_* constants defined above.  Although many
 *                     types of TG_DATA_* constants are available, each model
 *                     of ThinkGear hardware and headset will only output a
 *                     certain subset of these data types. Refer to the
 *                     Communication Protocol document for your particular
 *                     ThinkGear hardware or headset to determine which data
 *                     types are actually output by that hardware or headset.
 *                     Data types that are not output by the headset will
 *                     always return their default value of 0.0 when this
 *                     function is called.
So I think that maybe TG_DATA_RAW is not output by the headset and so return value 0.0 and does not update, but from Neurosky website
Any applications you develop for the MindWave will work with the MindSet, and vice versa. Both the MindSet and the MindWave use identical communication protocols. Therefore, all applications, and the Development Tools, work with the both devices.
So I really can't understand which is the problem, what you suggest?

Thanks a lot for your support.

Re: Problem Connecting to Neurosky Mindwave

Posted: 14 Jan 2012, 16:34
by griffin.milsap
If this is the case, you should see the signal window updating rather rapidly, as the function just returns immediately with a 0. The application should be sucking quite a lot of CPU and the data is a flat line. Also, if this is the case, it'll make for a nightmare supporting neurosky devices with any sort of a standard module.

More likely than not, the SDK used in this module is simply too old. The Mindwave was released two years after this module was written, and the SDK has been updated several times to support it. I'd wager that we just need to update the .lib and .h, and potentially the .dll files that we ship with the neurosky module.

It is also possible -- although I don't think Neurosky would do this -- that they lock down the raw EEG signal on the mindwave simply because it hits a lower pricepoint than the mindset. Emotiv does this and it has caused support headaches in the past. Could you do a little research on this for me? In the mean time, I'll look into getting an updated SDK working with the module.

-Griff

Re: Problem Connecting to Neurosky Mindwave

Posted: 14 Jan 2012, 17:06
by giuseppe
griffin.milsap wrote: More likely than not, the SDK used in this module is simply too old. The Mindwave was released two years after this module was written, and the SDK has been updated several times to support it. I'd wager that we just need to update the .lib and .h, and potentially the .dll files that we ship with the neurosky module.
How can I recompile the the source with the new version of .obj .lib and .dll files of mindwave?

Thanks,
Giuseppe

Re: Problem Connecting to Neurosky Mindwave

Posted: 14 Jan 2012, 17:47
by griffin.milsap
First, you'll need to acquire the new SDK from their site. You should be able to get it here.

Next, when you install the "Developer tools", it should put the required ThinkGear .lib, .h, and .dll somewhere in your program files directory. If you were to copy-paste these over the existing .lib, .h, and .dll in /src/contrib/SignalSource/NeuroSky/lib/ and src/contrib/SignalSource/NeuroSky/lib/coff and recompile, you may just get lucky enough to have it work. There may be some source code changes required to make it function, however -- and you would be on your own for those.

This is on my list of things to do, but I'm not entirely sure when I'll get time to do it. If you want to take the initiative and update the SDK, be sure to send me the required modifications (assuming that more than a copy-paste is needed), and I'll push them to the repo and ensure you have proper attribution.

Thanks and good luck,

-Griff

Re: Problem Connecting to Neurosky Mindwave

Posted: 15 Jan 2012, 03:53
by giuseppe
I've updated the files (they were different on size), except the .lib on .../omf/ (is correct?), now how can I compile the solution, can I compile only the Neurosky module? Or do i need to download the BCI2000 complete solution?
Sorry if I'm wasting your time, but I really need your help!:)

Edit: I've tried to compile but I got the following error :cry:

Code: Select all

CMake Error at cmake/frameworks/SigProcModuleLib/CMakeLists.txt:103 <ADD_LIBRARY>: Cannot find source file:

C:/.../BCI2000src/buid/.../src/shared/modules/signalprocessing/statistics/StatisticsFilter.cpp

  Tried extensions .c .C .c++ .cc [...]

-- Build files have been written to: ...
I solved this problem by deleting those lines from /build/cmake/frameworks/SigProcModuleLib

Code: Select all

SET( STATSOURCES
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/StatisticsFilter.cpp 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ViewSource.cpp 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ChannelSetSource.cpp 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/DataSource.cpp 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ExpressionSource.cpp 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/FunctionSource.cpp 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ObserverSource.cpp
)

SET( STATHEADERS
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/StatisticsFilter.h 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ViewSource.h 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ChannelSetSource.h 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/DataSource.h 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ExpressionSource.h 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/FunctionSource.h 
  ${BCI2000_SRC_DIR}/shared/modules/signalprocessing/statistics/ObserverSource.h
)

SOURCE_GROUP( Source\\BCI2000_Framework\\shared\\modules\\signalprocessing\\statistics FILES ${STATSOURCES} )
SOURCE_GROUP( Headers\\BCI2000_Framework\\shared\\modules\\signalprocessing\\statistics FILES ${STATHEADERS} )

# Add the required signal processing files into the framework for this project
SET( SRC_BCI2000_FRAMEWORK
  ${SRC_BCI2000_FRAMEWORK}
  ${SIGPROCSOURCES}
  ${STATSOURCES}
)
SET( HDR_BCI2000_FRAMEWORK
  ${HDR_BCI2000_FRAMEWORK}
  ${SIGPROCHEADERS}
  ${STATHEADERS}
)
YEAH!!! It works!!!! Very, very happy!!! :) Thanks a lot for your support!

Re: Problem Connecting to Neurosky Mindwave

Posted: 15 Jan 2012, 11:27
by griffin.milsap
Fantastic. So, you were able to get it compiled without any major source code changes?

Thats great news! I'll see what I can do to update the module in the repo in the next few days.

Thanks for the update!

-Griff

Re: Problem Connecting to Neurosky Mindwave

Posted: 15 Jan 2012, 12:01
by giuseppe
Sad news, I've changed the neurosky.exe and .dll and just as I wrote it started working, then I shut down the pc I switch on and still work, I've done two session then i got an error during the session about time session, don't remember, and from that it stop working, don't care, thanks equally for all...

best regards
giuseppe

Re: Problem Connecting to Neurosky Mindwave

Posted: 16 Jan 2012, 11:32
by griffin.milsap
Sounds like it was eating too much CPU and getting behind in timing. Looking back at the thread, your sampleblock size is set to 1. This means you're clocking the system at 512 Hz -- which I didn't even think was reasonably possible.

You should really set this sample block size to something more reasonable like 32 samples when clocking at 512 samples per second. This means that samples are sent through the system in groups of 32 at a time, meaning that you're only pumping the system at 512/32=16 Hz.

-Griff

Re: Problem Connecting to Neurosky Mindwave

Posted: 16 Jan 2012, 15:38
by giuseppe
Doesn't work... I think that the problem is on connection, because when it works the led on the USB key goes on blue, instead when it doesn't the led flash blue and immediatly red.
But I really can't understand where is the problem, and why somoetimes work and sometimes not...

Re: Problem Connecting to Neurosky Mindwave

Posted: 17 Jan 2012, 09:24
by giuseppe
I noticed that ThinkGear Connector doesn't work on my pc, could this be the problem?? Another think that I noticed is that when I click on Set Config Neurosky.exe CPU usage is 0% then when I click quit, usage goes up to 50%; and also I noticed that I got no error if I run the app when my headset is off!!! So I think that simply sometimes Neurosky.exe doesn't execute... But the problem is always why?

I would like to know, in which file are called the functions preflight, initialize, process, and halt; because I looked at the Neurosky.cpp file but I didn't find any references to this functions.
Thanks.
-giuseppe

Re: Problem Connecting to Neurosky Mindwave

Posted: 24 Jan 2012, 14:21
by griffin.milsap
Giuseppe,

Apologies for being so long to reply. I'm back in the office now and I just spent the morning fixing the NeuroSky module.

I replicated the behavior with the newest version of the MindSet, identified the issue, and fixed it. The update has been pushed to the repo. Although I still don't have a MindWave to test on, but this may actually make it work. Let me know. I still don't have a MindWave to test with, but if you'd be willing to help me out, I'll see what I can do.

As for the other behavior you saw, the previous module would hang when it couldn't connect to the device. This behavior was documented on the wiki page for the module: It seems that this new API does not have this issue anymore, and the new module will no longer hang when it cannot find a device. I'll update the wiki once we push the new binaries out.

Let me know if things work out for you!

-Griff