# Conceptual Design of BCI for Mobile Robot Control
## 2 Materials and Methods
### Design of BCI Control System
From this sub-state, the system goes to DataRecStart after 1 s. This sub-state is responsible for the process of switching on the EEG signal recording by the TruScan 24 device, which has been set for 5 s. The DataRecStart subroutine activity is indicated by the variable dataRec. In the next step, after the 5 s have passed, the system goes to the DataRecStop sub-state where the system disables the EEG signal registration process. After leaving the DataRecStop sub-station, the quality of recorded data is checked. For this purpose, errorLen and errorImp functions are used. The errorLen function examines the length of the recorded signal. The result of the function is error error2 = 1, when the registered signal does not contain an adequate number of samples. The errorImp function examines the impedance value of measuring electrodes. The result of this function is error error3 = 1, when the impedance value exceeds 5 k\(\Omega\). If error2 or error3 occurs, immediate return to Idle status takes place. State \({}_{2}\)C\({}_{0}\) Running is abandoned when the connection to the electroencephalograph is broken error1 = 1 or when the value of start = 0 (start button disabling). The exit from the state turns off the light stimulator (led = 0). When errors error2 and error3 do not occur, the system goes to DataProcessing state \({}_{3}\)C\({}_{0}\). The activity of this state is represented by the variable dataProc. This \({}_{3}\)C\({}_{0}\) state consists of four substates, listed in the order of calling: \({}_{31}\)C\({}_{0}\)_DataShowing_, \({}_{32}\)C\({}_{0}\)_DataPreprocessing_, \({}_{33}\)C\({}_{0}\)_FeatureExtraction and \({}_{34}\)C\({}_{0}\)_Classification_. In the DataShowing sub-state, the recorded results are displayed using the show function. The dataShow value represents the DataShowing sub-state activity. Then the system goes to DataPreprocessing sub-state \({}_{32}\)C\({}_{0}\), in which the pre-processing of the registered signal is performed, signaled by the variable dataPre = 1. Pre-processing of the registered signal consists in extracting a fragment of data of a specific length (dataPreProc function) and filtration using the predefined filters (filtration function). The obtained results are further analyzed in the FeatureExtraction state \({}_{33}\)C\({}_{0}\). The purpose of this state is to isolate characteristic features from the signal. In order to test the designed BCI state machine, the detection of characteristic parameters was based on the FFT analysis [15]. This method is based on reading the frequency at which the largest amplitude value was obtained. Determination of the Fourier transform in the FeatureExtraction state \({}_{33}\)C\({}_{0}\) is performed by the fftProc function, and the reading of the frequency with the highest amplitude value is performed by the fMaxFind function. The FeatureExtraction state activity represents the fEPoc variable. The last sub-state \({}_{34}\)C\({}_{0}\) of DataProcessing \({}_{3}\)C\({}_{0}\) state is the Classification, in which a classification of characteristics and sending a control command to the mobile robot is made. Since the task of the developed BCI system is the mobile robot control, one of five characteristics (modes) may be selected as a result of classification:  
- MoveForward;  
- MoveRight;  
- MoveBack;  
- MoveLeft;  
- Unclassified. The command controlling the robot movement is called after that in the state machine using the coder. extrinsic function. \begin{table}
\begin{tabular}{c c c} \hline \hline
**State \({}_{1}\)C\({}_{0}\)** & **State \({}_{2}\)C\({}_{0}\)** & **State \({}_{3}\)C\({}_{0}\)** \\ \hline _Idle_ & _Running_ & _DataProcessing_ \\ \hline \hline \end{tabular}
\end{table} 
Table 2: BCI PC control system \(S_{0}^{\ell}\) states \(C_{0}^{\ell}\).