Progress Report Week 1,2

My first responsibility is to substitute the wired communication with wireless technology. Since our system will be attached to the human body, some safety issues should be considered. One of our options is to use Bluetooth technology due to its robustness and low power consumption plus its high data transmission capacity. Based on the research by one of our researcher (Gaetano) the common Bluetooth devices on the market use more power than to be acceptable for continuous data transmission by using a reasonable battery size, and also they emit electromagnetic waves which could be harmful for the human brain in the long time transmission. To satisfy all the above constraints and also get ethical permission BluesenseAD [1] chip will be using in this experiment which consumes only 30 mv in transmission mode and generates acceptable electromagnetic waves.

BluesenseAD is a simple module that provides serial Bluetooth communication in mobile wireless networks. All the connection set up, data transmission and configuration can be done by means of AT commands. For better security and less interference from other Bluetooth enabled devices, especially mobile phones, not standard AT commands have been designed for this module. So using program like Hyper Terminal to communicate with Bluesense is not possible and also in the software programming aspect none of the standard libraries can support this communication. At this part of my thesis I am going to develop a program in C++ language to set up a serial connection over Bluetooth based on the protocol provided for BluesenseAD. In the first step the Bluetooth connection will be established manually by means of BlueSoleil [2] application which can also make a virtual Bluetooth serial port for us. Our program should be able to set up, tear down, send and recieve data over created virtual Bluetooth serial connection.

On the other hand, for our BCI (brain-computer interface) experiment, BCI2000 [3] is being used as a framework. BCI2000 is a general-purpose system for BCI research. It can also be used for data acquisition, stimulus presentation, and brain monitoring applications. Since the Bluesense must be integrated to BCI2000 and acquires data from EEG sensors and send it to Bluetooth enabled PC, the driver on PC should be written compatible with BCI2000 application. BCI2000 is an open source C++ program, therefore a new source acquisition module could be implemented for it, but all the rules should comply with BCI2000 and then the whole project should be compiled and linked.

Borland C++ Builder in MS Windows operator system is being used as a development environment. This decision has been made due to BCI2000’s constraints which should be compiled only in Borland C++ version 6 and upper. I started reading about Serial communication in C++ and I’ve found some interesting issues. Serial communication in windows consists of three main functions, opening connection, reading and writing. Opening COM port could be done same as opening file in C++ with some special parameters, one of the important parameter is about Overlapped or Nonoverlapped operation. We will get into the details of Overlapped IO a bit later. After opening a COM port, data might be sent or received to/from the connected device. WriteFile and ReadFile are the two methods that can be used. For setting Serial parameters such as Baudrate, Parity and so on, SetCommState method should be used. As we mentioned before reading could be done Overlapped (asynchronous) or synchronous, for asynchronous communication which has been selected for this project due to its efficiency, some kind of event mechanism is needed. Fortunately, there is a way to ask the system to notify program when certain events happen. But in Windows it is not as straight forward as other event-driven systems. First we should listen to one specific event using SetCommMask method, then we should wait till this event happens and that could be done by using WaitCommEvent method. The complication is exactly at this point. It looks like a pooling system because we are waiting till something happen and all threads are dead. The solution is overlapped IO. Think of overlapped IO as asynchronous IO. Whenever a function makes a call and specifies the overlapped IO structure, it means that it is trying to do the current operation but, if it is not able to be completed immediately, let the program know when it is done with this IO. The way the system lets the program know about the completion is by setting a kernel event object that is part of the lpOverlapped structure. So, all should be done is spawn a thread and make the thread wait for that event object using one of the WaitForSingleObject() APIs. I had a really trouble to understand this concept at the beginning for more information please read about Overlapped IO in windows [4].

So far, I have written a test program that can establish the communication and read/write a Character through the Serial port. To test my program I’m using the application that makes virtual serial port in Windows XP. The next step will be about constructing Bluesense packets and try to communicate with that device.