American Journal of Biomedical Engineering

p-ISSN: 2163-1050    e-ISSN: 2163-1077

2016;  6(5): 139-146



Controlling a Servo Motor Using EEG Signals from the Primary Motor Cortex

Somer M. Nacy, Sadeem N. Kbah, Hind A. Jafer, Ibraheem Al-Shaalan

Biomedical Engineering Department, Alkhwarizmi College of Engineering, University of Baghdad, Baghdad, Iraq

Correspondence to: Somer M. Nacy, Biomedical Engineering Department, Alkhwarizmi College of Engineering, University of Baghdad, Baghdad, Iraq.


Copyright © 2016 Scientific & Academic Publishing. All Rights Reserved.

This work is licensed under the Creative Commons Attribution International License (CC BY).


Brain Computer Interface means the group of processes in which the generated signals of EEG in the human brain can be interpreted and transferred to control an external device. In this paper, a novel method is adopted to control the rotation of a servo motor via EEG signals extracted from the human brain cortex. These signals have to pass through a processing procedure consisting mainly noise filtration and signal normalizing. The processed signal is fed to Arduino, which in turn controls the servo motor rotation.

Keywords: Brain Computer Interface, EEG signal, Motor cortex

Cite this paper: Somer M. Nacy, Sadeem N. Kbah, Hind A. Jafer, Ibraheem Al-Shaalan, Controlling a Servo Motor Using EEG Signals from the Primary Motor Cortex, American Journal of Biomedical Engineering, Vol. 6 No. 5, 2016, pp. 139-146. doi: 10.5923/j.ajbe.20160605.02.

1. Introduction

The human brain is the most developed and sophisticated part in the human body, it starts to show an electrical activity between (17-23) week in the embryonic time, when the baby born he has up to 1011 neuron with (5x1014) synapses [1]. The human brain controls all the body functions and movements, however limbs and other parts of the human body can stop functioning totally because of the lose of connections between parts of the brain and these limbs and organs due to any damage in the nervous system, which will leave the body paralysed and not capable of doing daily life functions [2].
The first Brain-Computer Interface (BCI) as an idea was described by Dr. Grey Walter in 1964, however started as a wide research field since the 70’s of the last century [3], after EEG signal was recorded from all lobes of the cortex for the first time by Beryer in 1943 [4]. The first description and first recording of an electrical signal from the motor cortex was done by Dr. Walter and had been done by asking a volunteer under open brain surgery to press a bottom and record the electrical activity of the cortex region [5]. Another kind of computer-human interface had been produced, like using of human skin as touch interface [6], or controlling a wheelchair using the tongue [7], also using an eye-tracking system in human-computer interface [8]. Vernon and Joshi used an over ear muscle to control a television [9].
The BCI has been acheived using many devices, like EEG, MEG and fMRI [10], however EEG considered as the most suitable one since it is non-invasive, low cost compared to other modalities specially fMRI, portability and ease of use [11]. Nowadays there are a lot of research centers all over the world that work to develop the Brain-Computer Interface since this subject has a lot of importance in the field of human brain studying and understanding its emotions [12], in addition to that it has an importance to improve the life of amputee people who have serious problems in living their lives normally and do all the normal functions [13].
In this paper we introduced a novel method of controlling a servo motor using the EEG signals taken directly from the cortex of the brain, which can be later attached to an artificial hand as a biomedical application. It can be considered as a new and more difficult method, yet necessary since some people loses all their limbs due to an accident, which makes it difficult and near impossible to take and EMG recording from the rest of their limbs. Our method is illustrated in brief in Figure (1). The process we passed through in order to obtain our final pulses was to prepare the EEG recording device to ensure obtaining a signal in a readable format, then we chose the channel that is related to the motor cortex part of the brain and eliminate the others to reduce the internal noise of the device. The obained signal then was fed to a PC to do the required processing and pulse extraction to control the motion of a servo motor using Arduino.
Figure 1. Flow-chart of the work

2. The Brain Cortex

The cortex is the most outer part of the grey matter in the brain, it covers the other parts of the brain with a layer of (2-3) mm in thickness, Figure (2). The cortex consists of regions that can be classified according to the complexity of the functions they do to primary cortices and associated cortices. Primary cortices are more involved in receiving the sensing signals from parts of the human body and are located to the posterior parts of the brain, while the associated cortices are responsible for more complex functions like memorizing, thinking and decision making and are located mostly in the anterior superior parts of the brain.
Figure 2. The human brain cortex and its parts [16]
Functionally, the cortex can be divided to the following parts [14]:
Ÿ Motor Cortex.
Ÿ Sensory Cortices.
Ÿ Visual cortex.
Ÿ Auditory Cortex.
Ÿ Language Cortex.
Ÿ Prefrontal Cortex.
In this work we concentrated mainly on the motor cortex since it is responsible for prompting the start of the movement and control the speed and directions of the movement [15], as will be illustrated in the next section.

3. Electroencephalography (EEG)

The EEG is a medical method used to record the electrical activity of human brain cortex due to the presence of action potential [2]. The EEG signal is very important since it is used for research as in studying of cortical parts functions like understanding specific properties, such as attention, alertness, mental acuity. It is used also for diagnostic purposes, diagnosis of epilepsy and other brain traumas. However, it is considered as one of the lowest biological signals when it comes to its amplitude (0.5-100 µ)V, which makes it very difficult to record [17].
The EEG signal represents the aggregation of multiple action potentials of single neurons, accumulated in one electrical wave and arranges in frequency bands as in Table (1) and as presented graphically in Figure (3).
Table 1. The frequency band of an EEG signal [19]
Figure 3. This Frequency bands of EEG signal [22]
The strength of these brain waves is not equal all over the day, in fact the domination of different EEG bands related to the brain activity and its degree of awakens. For example when the brain is in an awake state and fully alerted the (β) wave will be the most dominant in the EEG signal, while if the brain is awake and at rest state (α) wave will be the dominant, (α) waves also plays an important role in the encoding of the limb movements [20], on the other hand if the brain in sleep state or near sleep the EEG signal will tends to lower frequency bands like (θ) wave [19].
So it will be useful to understand why the (α) wave was chosen to make it the controller of the servo motor.

3.1. Choice of Alpha Wave

Alpha wave (α) lies in between the (β) and (θ) waves with an amplitude of (30-50) µV [22], so when the (α) wave is dominant the brain will be in transition zone between the conscious and subconscious states, which is the best time to do mental relaxation. The (α) wave also dominates during the meditation and physical exercises [21], that is why we chose it in our study to be the controlling wave of our servo motor, which will be later attached to an artificial hand.
Controlling a servo motor (and later an artificial hand) by using EEG signal requires a full awakens from the person under EEG test, since that person needs to learn to make some kind of control of his own EEG waves and make a conscious thinking of the actions he wants to do, thats why we chose (α) wave as our reference wave to be analysed and to control the later coming actions on the servo motor.

3.2. Types of EEG Electrodes

There are many types of electrodes, which can be divided mainly to surface electrodes and sub-dermal or needle electrodes [23].
Ÿ Reusable disks.
Ÿ EEG Caps with disks.
Ÿ Adhesive Gel Electrodes.
Ÿ Sub-dermal Needles.
The type adopted in this study is the EEG Caps with disks which are surface electrodes, in the Emotiv EEG recording device [24].

4. EEG Artifacts

As it is well known, the EEG signal is considered as the weakest signal among the human biosignals, and it is very likely to be interfered with other internal biosignals and other external signals specially those with the same range of frequencies.
In order to treat all sources of artifacts added to the EEG signal, it is useful to classify them as BIOLOGICAL and EXTERNAL. The main sources of noise added to EEG signal are [17]:
Ÿ Eye movement artifacts: One of the most common problems in EEG recording process is the eye movements artifacts, which will add a rapid signal with ~100 µV to our signal. The eye movement artefacts appears when ever the volunteer blinks or move his eye or eyelids. Normally the closure the recording electrodes to the eye the stronger the recorded noise will be.
Ÿ Cardiogenic Artifacts: Which are the artefacts results from the electrical activity of the heart, it has a much larger amplitude than the EEG with near by frequencies. The good thing about ECG is that it could be detected by bare eyes since it has a fixed rhythms (QRS).
Ÿ Muscle movements artifacts: EMG wave also can be interfered with EEG signals, specially those in the cranial (head and neck) region since these movements are irregular and normally have low frequency values, which will interfere with the low frequency components of the recorded EEG signal.
We have also external noise, which is the noise added from the electromagnetic signals outside the human body which are:
Ÿ Environmental noise: Since the EEG signal is an electromagnetic signal, so any kind of signal available in the outside environment will affect the EEG test. Specially those have a relatively low value of frequency like the 50 Hz power-lines, other electronic devices like laptop PCs and other medical devices in the hospital room can also make a noise interference to our EEG measurement. We can get rid of such noises by using notch filters.
Ÿ Problems due to electrode-scalp contact: It is of great importance to make sure that all the electrodes have a good contact with the scalp, otherwise a capacitive effect will occur and make an additional noisy effect to the main EEG signal.

5. The Used EEG Device

The device used in this research is the EMOTIV EPOC as depectied in Figure (4). It is a scientific contextual EEG, easy to use and has a reasonable accuracy [24]. The Emotiv EPOC specific properties are as mentioned in Table (2), the electrode locations are shown in Figure (5).
Figure 4. The Emotiv EPOC device [24]
Table 2. The specificatoins of EMOTIV EPOC [25]
Figure 5. Locations of the electrodes of Emotiv EPOC device [24]
Generally the Emotiv EPOC device induce more noise than other wireless EEG measurement devices according to a comparison study, so the signal has to be filtered after choosing the right channel to work on.

6. Procedure

In order to reach to the final signal, we had to pass through many steps shown briefly as listed below:

6.1. Choosing the Right Channel

The device used (Emotiv EPOC) has 14-channels only, since we can not change the main listed jobs of the channels, which impose some conditions in choosing the effective channels that are in real contact with the targeted region and in choosing the best reference electrode. Considering Figure (5) and taking into consideration the location of the motor cortex, we chose to work on the signal taken from channel (F3), since it is the best one to record the EEG signal of the motor cortex as we worked on the signal of the right hand. One of the limitations is that the Emotiv EPOC has its own file extension, which can not be loaded to MATLAB® before converting it to another form (CSV), which will prevent the online connection between the Emotiv and the PC or the Arduino.

6.2. Training the Volunteer

In order to ensure a full domination of (α) band and reduce all the other sources of noise to its minimum values, the volunteer had been trained to sit relaxed and concentrate only on moving his right hand with the minimum effort.
To do that, the volunteer has followed a prepared Power Point slide show, which has a fixed movement period and relaxation period. During the movement period, which was lasting for 1 second, the volunteer moves his right hand ONE TIME upward from his side to (90o). Then the relaxation period starts, in which the volunteer relaxs and keeps his hand lifted in position (90o), where this period was lasting for 3 seconds. The next cycle starts by another movement but in this case the volunteer will bring his hand down to rest position (beside him), as in Figure (6).
Figure 6. The training process of the volunteer
This cycle has been repeated for (10) times for each recording session, hence several EEG signals were recorded and the best one was chosen.

6.3. Processing

After loading the data as a single matrix with14 channels we chose channel F3 and extract it from the matrix, its plot is shown in Figure (8). The obtained signal was noisy and includes a bias voltage, in order to extract the pulses out of the signal the flowchart procedure shown in Figure (7) was followed:
Figure 7. Procedure flow-chart
Figure 8. The raw EEG signal of channel F3 in time domain, the x-axis represents the real time of EEG recording during right-hand movement
Filtering A bandpass filter is used with a pass frequency between (8-13) Hz which is the band frequency of alpha wave (α). The filtered signal is then normalized to remove any bias noise caused by a stray capacitor, hence to get a signal, as shown in Figure (9).
Figure 9. The filtered EEG signal of channel F3 in time domain, the x-axis represents the real time of EEG recording during right-hand movement
Processing As it can be seen from Figure (7), the signal was noisy and contains some kind of bias noise, since it goes around 4200 µV, the bias voltage comes due to EEG artefacts. So first of all we get rid of this bias voltage by normalizing the signal. In order to make the design more realistic, we coded our program to analyse the taken EEG signal with an interval of 1 second. So, the processing includes disassembling of the signal to 1 second compartments, this will be useful later when we add an online analysis facility when it is possible. These packages of 1 second will be treated with a Pulse detector to extract the pulses with a certain threshold from the rest of the signal. The extraction of the pulses done in such a way that kept the time between pulse to pulse identical to that of the recorded signal from the volunteer, see Figure (7). The pulse detector is a code programmed in MATLAB to detect the differential change in the signal, whether is goes up or down and then compare it with an already settled threshold value. This will ensure extraction of the right pulses occurred due to hand movements.
At this point a special library of MATLAB (Arduio Support Package) has been used to establish an online connection between the MATLAB and the Arduino, which in this case will allow us to add further analysis in the future as it is required to control the servo motor (robotic arm) in a process including the decoding of the EEG signals taken from the associated motor cortex to do a more precise simulation to the hand movements and do even more complicated movements, which include the involvement of multiple joints (in the same time) of the robotic hand.
The final signal (pulses), shown in Figure (10) will then be fed to a micro-controller (Arduino) which will control the movement of the attached servo motor. The pulse signal shown in Figure (10) coincides totally with the hand movements recorded in the original F3 EEG signal as shown in Figure (11).
Figure 10. The pulses extracted from the filtered F3 EEG signal, which will be fed to the Arduino micro-controller
Figure 11. A superimpose image of the original F3 EEG signal and the pulses signal

6.4. Arduino

Arduino is an open-source prototyping platform based on easy-to-use hardware and software [26]. Arduino is used to control the attached servo motor to make certain movements based on the orders coming directly from the MATLAB (the attached PC). Until now our work includes controlling the movement of the servo motor with a certain speed to a certain angle, these movements are direct responses to the recorded EEG signal of the movement of the volunteer right hand.
The connection between the PC and Arduino micro-controller was achieved as follows:
1. The ’Tower ProTM Micro Servo 9g motor, SG90’ servo motor was connected to the Arduino micro-controller through pins (5V), (GND) and D9PWM . Here we chose this type of servo motor in order to eliminate the use of external power supply, since it is small enough that can be powered by the Arduino board itself, as shown in Figure (12).
2. Another wire was connected from the Arduino board (D9PWM pin) to the Servo motor input port, this wire will ensure a transmission of the movement and stop pulses between the Arduino and the servo motor.
Figure 12. A schematic of the Arduino-Servo connection map
A flowchart of the code sequence loaded to the Arduino broad is shown in Figure (13).
Figure 13. Flowchart of the Servo-control circuit
The Servo motor was settled to rotate at 90° movement when it receives a pulse from the PC, and rotates another 90° backward to its original position when receiving the second pulse from the PC. These pulses are given at certain times considering exactly with the time of volunteer’s right hand movement (extracted from the recorded F3 EEG signal).
The Arduino micro-controller operates as to control and ensure the Servo motor’s start and stop positions.
In the future we are planing to include a more prolonged analysis to the EEG signal which will include the extraction of the direction and speed of movement from EEG signals taken exactly from the associated cortex (which is responsible for controlling the hand movements in human beings).

7. Conclusions

Considering how weak is the EEG signal, the signal-to-noise ratio of the obtained EEG signal was good, which eased our work later to extract the pulses from the F3 signal.
The volunteer has to be trained to sit back and relax in order to obtain this clear signal, which suggests the use of different mobile EEG recording devices if we want to go more and make this research a practical product, specially if we add the obstacles we encountered when we tried to connect the Emotiv EPOC to MATLAB, which was not possible due to that the Emotiv EPOC device was not designed to operate online in association with a PC, also the type of file used by the Emotiv EPOC to save the recorded signals is not readable by several known programming platforms such as MATLAB (also checked for Python).
However, the final results were good, we managed to move the servo motor with pulse signals extracted from an EEG signal obtained from the motor cortex of a volunteer when he moved his hand.


[1]  M. Teplan, FUNDAMENTALS OF EEG MEASUREMENT, Neural Prostheses: Linking Brain Signals to Prosthetic Devices, Institute of Measurement Science, Slovak Academy of Sciences, 9, 841 04 Bratislava, Slovakia MEASUREMENT SCIENCE REVIEW, Volume 2, Section 2, 2002.
[2]  Carlos Pedreira, Juan Martinez and Rodrigo Quian Quiroga, Neural Prostheses: Linking Brain Signals to Prosthetic Devices. Department of Informatics and Applied Mathematics, Federal University of Rio Grande do Norte (UFRN), Natal, RN, Brazil, SBC Journal on 3D Interactive Systems, volume 4, number 1, 2013.
[3]  Alessandro L. Stamatto Ferreira, Leonardo Cunha de Miranda, Erica E. Cunha de Miranda, Sarah Gomes Sakamoto, A Survey of Interactive Systems based on Brain-Computer Interfaces.
[4]  P. M. Shende and V. S. Jabade, "Literature review of brain computer interface (BCI) using Electroencephalogram signal," Pervasive Computing (ICPC), 2015 International Conference on, Pune, 2015, pp. 1-5. doi: 10.1109/PERVASIVE.2015.7087109, IEEE.
[5]  Bernhard Graimann, Gert Pfurtscheller, Brendan Allison, Brain-Computer Interfaces, ISBN: 978-3-642-02090-2 (Print) 978-3-642-02091-9 (Online), Book, The Frontiers Collection, 2010, Revolutionizing Human-Computer Interaction, “PDCA12-70 data sheet,” Opto Speed SA, Mezzovico, Switzerland.
[6]  C. Harrison, D. Tan, and D. Morris, “Skinput: appropriating the body as an input surface,” in Proceedings of the ACM CHI Conference on Human Factors in Computing Systems (CHI’10), ACM, 2010, pp. 453– 462, doi: 10.1145/1753326.1753394.
[7]  Y. Nam, Q. Zhao, A. Cichocki, and S. Choi, “Tongue-Rudder: a glossokinetic-potential-based tongue-machine interface,” in IEEE Transactions on Biomedical Engineering, vol. 59, n. 1, IEEE, 2012, pp. 290–299, doi: 10.1109/TBME.2011.2174058.
[8]  S.S. Liu, A. Rawicz, S. Rezaei, T. Ma, C. Zhang, K. Lin, and E. Wu, “An eye-gaze tracking and human computer interface system for people with ALS and other locked-in diseases,” in Journal of Medical and Biological Engineering, vol. 32, n. 2, pp. 37–42, 2012.
[9]  S. Vernon and S.S. Joshi, “Brain-muscle-computer interface: mobile- phone prototype development and testing,” in IEEE Transactions on Information Technology in Biomedicine, vol. 15, n. 4, IEEE, 2011, pp. 531–538, doi: 10.1109/TITB.2011.2153208.
[10]  Jerry J. Shih,a, Dean J. Krusienski,b and Jonathan R. Wolpawc, Brain-Computer Interfaces in Medicine, Mayo Clin Proc. 2012 Mar; 87(3): 268–279. doi: 10.1016/j.mayocp.2011.12.008, PMCID: PMC3497935.
[11]  Han-Jeong Hwanga, Soyoun Kimb, Soobeom Choia and Chang-Hwan Ima, EEG-Based Brain-Computer Interfaces: A Thorough Literature Survey, International Journal of Human-Computer Interaction, Volume 29, Issue 12, 2013, pages 814-826.
[13]  Anirudh Vallabhaneni, Tao Wang, Bin He, Brain—Computer Interface, Neural Engineering, Part of the series Bioelectric Engineering, pp 85-121.
[14]  The Cerebral Cortex,
[15]  Motor Cortex,
[17]  David Ibañez, Artifacts Contaminating Your EEG Recordings, 18 December, 2014,
[18]  EEG Bands,
[19]  5 Types Of Brain Waves Frequencies: Gamma, Beta, Alpha, Theta, Delta, Mental Health Daily,
[20]  Karim Jerbi, Etienne Combrisson, Sarang Dalal, Juan Vidal, Carlos Hamame, et al.. Decoding, cognitive states and motor intentions from intracranial EEG: How promising is high-frequency brain activity for brain-machine interfaces?. Epilepsy and Behavior, Elsevier, 2013, 28 (2), pp.283-302.
[21]  Jorge Ochoa, EEG Frequency Bands,
[22]  P. L. Nunez., Neocortical Dynamics and Human EEG Rhythms, Neurology September 1995, vol. 45 no. 9, 1793-1793-a.
[23]  EEG electrodes,
[25]  Ries, Anthony J.; Touryan, Jon; Vettel, Jean; McDowell, Kaleb; Hairston, W. David, A Comparison of Electroencephalography Signals Acquired from Conventional and Mobile System, Journal of Neuroscience and Neuroengineering, Volume 3, Number 1, February 2014, pp. 10-20(11), American Scientific Publishers.