Open access

Integrating Neural Signal and Embedded System for Controlling Small Motor

Written By

Wahidah Mansor, Mohd Shaifulrizal Abd Rani and Nurfatehah Wahy

Submitted: 18 November 2010 Published: 29 August 2011

DOI: 10.5772/22210

From the Edited Volume

Advances in Mechatronics

Edited by Horacio Martinez-Alfaro

Chapter metrics overview

4,600 Chapter Downloads

View Full Metrics

1. Introduction

Nowadays, controlling electronic devices without the use of hands is essential to provide a communication interface for disable persons to have control over their environment and to enable multi-tasking operation for normal person. Various methods of controlling electronic devices without the use of hands have been investigated by researchers, for examples sip-and-puff, electro-oculogram (EOG signals), light emitter and others [Ding et al., 2005, Kumar et al., 2002; Breau et al., 2004]. In our previous study, EOG signal was found to be suitable for activating a television using a specific protocol [Harun et al., 2009], however, it could not be used when a person is not facing the system. Thus, a method that is more flexible has to be investigated.

The use of neural signals to directly control a machine via a brain computer interface (BCI) has been studied since 1960s. Using an appropriate electrode placement and digital signal processing technique, useful information can be extracted from neural signals [Holzner et al, 2009; Jian et al., 2010; Gupta et al., 1996.] One of the events that can be detected from this signal is eye blink. It can be used as a mechanism to activate and control a machine which can help disable people to do their everyday routines.

Most BCI systems employs a computer to process neural signals and perform control. Since portable system offers benefits such as flexibility, mobility and convenience to use, it is more preferred than a fixed system. An embedded system can be designed to provide portability feature. To include this feature, a microcontroller is required to control its operation and provide a communication link between human and machine.

This chapter discusses how neural signal and embedded system can be combined together to activate a fan connected to a motor. It covers the introduction to neural signal, neural signal processing, embedded system and EEG based fan system hardware and software.


2. Neural signal

Neural signal or commonly known as electroencephalogram (EEG) is the representation of electrical activity of the brain. The overall excitation of the brain determines the amplitude and patterns of the signal. The excitation depends on the activity of the reticular activating system in the brain stem. The pattern changes markedly between states of sleep and wakefulness. The EEG signal is divided into five frequency bands; beta, alpha, theta, delta and gamma. Beta frequency is in the range of 12 Hz – 22 Hz and occurs when the person is awaken and in the state of alertness. Alpha is in the range of 8 – 13 Hz and is present when a person is awaken and relaxed with eyes close. Theta exists in the frequency range of 4 – 8 Hz when a person is sleepy, already sleep and in the sleep transition. The slowest wave is delta which is in the frequency range of 0.5 to 4 Hz and is associated with deep asleep. And finally gamma (22 – 30 Hz) consists of low amplitude & high frequency waves resulting from attention or sensory stimulation. Figure 1 shows the normal EEG signal of a relaxed patient. The signal consists of beta waves which lie in the frequency range of 13 to 22 Hz. Figure 2 shows EEG signal with eye closure and eye opening. The negative amplitude shows the eyelids closure and positive value shows the opening of eyelids.

Figure 1.

Normal EEG signal when a person is relax.

Figure 2.

Normal EEG signal with eye closure and eye opening.

The recorded EEG signals always contain artifacts which impede the analysis of the signals. The artifacts include muscle signals, heart signals, eye movements, power line interference, eye blinks and others. Artifacts in EEG signals typically are characterized by high amplitudes. Eye blinking artifacts always present in EEG signals since it is difficult to make the subject open his/her eye for a long time. In some cases, eye blinking artifacts may be useful and are required as a parameter for activating a system.

In EEG signals, eye blinks occur as peaks with relatively strong voltages. Eye blinks can be classified as short blinks if the duration of blink is less than 200ms or long blinks if it is greater or equal to 200ms [Bulling et al, 2006]. The amplitude of the peaks varies between different subjects. They are often located by setting a threshold in EEG and classified for all activity exceeding the threshold value.

Eye blinks can be classified into three types: reflexive, spontaneous and voluntary. The eye blink reflexive is the simplest response and does not require the involvement of cortical structures. Spontaneous eye blinks are those with no external stimuli specified and they are associated with the psycho-physiological state of the person. The amplitude of spontaneous eye blink is in the range of -4 to 3 V with duration of less than 400 ms and frequency of below 5 Hz. The EEG signal obtained when the eyes moved to the right and left is shown in Figure 3. This signal contains a lot of artifacts caused by spontaneous eye blinking and eyelid movements as the eyeball moved. The signal obtained from these eye movements are not suitable for activating a system as the occurrence of eye movements is difficult to detect. Figure 4 shows EEG with eye movements upward and downwards. This signal consists of noise which covers the required information to be extracted.

Figure 3.

EEG signal obtained when the eyes are moved to the right and left. [Abd Rani et al., 2009]

Figure 4.

EEG signal with eye movement upwards and downwards.

Voluntary eye blinking which is intentional blinking due to predetermined condition, involves multiple areas of the cerebral cortex as well as basal ganglion, brain stem and cerebella structures. Figure 5 shows the EEG signal with voluntary eye blinks. This EEG signal has larger amplitude and longer duration (400 -500 ms) compared to that obtained from spontaneous eye blink. This signal has been filtered which remove the signals above 5 Hz leaving only very clear eye blinking signals. Other artifacts such as 50 Hz power line interference and noise have also been removed using analogue filtering provided by the EEG instrument.

Figure 5.

EEG signal for voluntary eye blinking condition.

The suitable event for activating a system is three continuous eye blinks (with a duration of 1.5 to 2.5 seconds between eye closure and opening as they are not present when the subject is in relax condition [Abd Rani et al., 2009 ]. The duration between the first cycle of eye opening and closure and the second cycle should be 3 to 4.5 seconds.


3. Neural signal processing

Basically, there are two ways of acquiring the EEG signals from the subjects; invasive and non-invasive techniques. In the invasive technique, electrodes are implanted in the subject’s brain and located on the brain surface whereas the non-invasive technique uses electrodes that are placed on the scalp. In most cases, non-invasive technique is more preferable than the invasive technique since it is harmless and easy to use. The standard electrode placement for the non-invasive technique is called International 10-20 system where 10% and 20% of a measured distance starting from craniometric reference points such as nasion, inion, left and right pre-auricular points are used to locate the EEG electrodes. The placement of electrodes for 10-20 system is shown in Figure 6. In this arrangement, a reference and ground electrodes are placed either on the ear lobe or mastoid.

As mentioned previously, the recorded EEG signals contain artefacts which have to be removed in order to obtain good morphological signals. Once a clean EEG signal is obtained, the second stage is to amplify the signal. EEG signal amplitude obtained from the scalp is very small, range up to 100mV which is difficult to see without amplification. The signal also has low frequency. It is necessary to analyse the signal to examine the characteristics of the signal and to ensure the noise has been removed. The signal can be analysed using Fast Fourier Transform (FFT), time-frequency analysis or time scale analysis. The FFT only gives frequency information of the signal, thus, time-frequency analysis or spectrogram is normally used to view the frequency at each time point.

Figure 6.

The International 10-20 System of Electrodes Placement. (Redrawn from [Norani et al., 2010]

The next stage is extracting the underlying information in the signal. Depending on the purpose of the study, this stage can be feature extraction or event detection as shown in Figure 7. If the EEG signal is to be used for activating equipment, a simple and an easy way is to detect an event from the signal, for example eye blinks and use the output which in the form of pulses to activate the equipment. Classification process is necessary if specific features are needed to perform the activation. This stage is also called translation process where the pattern classified is translated into suitable signal to activate equipment.

Figure 7.

EEG signal processing.


4. Embedded system

A computer system that is embedded in an electronic device to perform specific functions is called embedded system. It forms part of the system and controls one device or many devices. The main controller in this system is either a microcontroller or digital signal processing. A microcontroller is a small computer on a single integrated circuit which is designed to control devices. It consists of CPU, memory, oscillator, watchdog and input output units on the same chip. The microcontroller is available in wide range from 4 to 64 bits.

A PIC microcontroller is commonly used in embedded system due to its simplicity and ease of use. It offers several advantages such as design time saving, space saving and no compatibility problems. However, it has limited memory size and input/output capabilities. Figure 8 shows the block diagram of internal architecture of PIC16F877 microcontroller. The PIC microcontroller is built around Harvard architecture where two memories; one for program and the other one for data are separated. Separate buses are used for program and data memories. This eliminates jumping of program code into data or vice versa. PIC microcontroller uses RAM memory or known as file registers to store data during execution and a working register called W register to perform arithmetic and logic functions. User program is stored in the flash program memory and a status register is used to indicate the status of microcontroller through flag bits such as carry, zero, digit carry flags and others. PIC16F877 microcontroller has three 8 bits parallel input/ouput ports, 8 channels of analog inputs and serial outputs.

Figure 8.

Internal architecture of PIC16F877 A microcontroller.


5. EEG based fan system incorporating microcontroller

A block diagram of EEG based fan system incorporating microcontroller is shown in Figure 9. It consists of EEG acquisition system, a microcontroller and a motor circuit. Three electrodes are connected to the EEG acquisition system and located on the subject’s scalp at frontal, occipital and ear lobe. The EEG acquisition system is responsible for recording the EEG signals and passing the signals to the microcontroller system. The recorded EEG signal consists of voluntary and spontaneous eye blinks. Thus, to activate the motor, four seconds eye blinks in EEG signal is used. The functions of the microcontroller are to process the EEG signal, detect four-second eye blinks and use the detection results to control the movements of motor that is connected to a fan. Here, PIC16F877 is used as it can read analogue signal directly without the need of external analog to digital converter circuit. Three eye blinks within duration of four seconds are used since it is the best technique to activate a system [Abd Rani et al, 2009].

There are a few ways of connecting a motor to the microcontroller. If a dc motor is used, a circuit shown in Figure 10 can be implemented. This is a simple circuit which requires 5V supply to operate. A relay can be used to activate the motor if it is connected to 240V ac supply. Figure 11 shows the connection of the microcontroller to the devices on the motor circuit that comprises a transistor, a diode, a relay and a motor.

Figure 9.

Block diagram of EEG based fan system.

Figure 10.

A simple connection of a dc motor to PIC16F877A.

Figure 11.

Connection of a motor to PIC16F877A for EEG based fan system.

5.1. Controlling software for the EEG based fan system

The PIC microcontroller cannot work without software. A controlling program is required to read EEG signals from a subject, detect three time eye blinks and activate the motor. A program written in C language or PIC assembly language can be used to perform the detection and control operation. The process of detecting three time eye blink and activating the ac motor is shown in Figure 12. Initially, the program examines whether the EEG signal amplitude exceeds the maximum threshold voltage, is below minimum threshold voltage or lies between the threshold voltages. When three eye blinks within duration of four seconds is detected, the program sends logic 1 to the output of the microcontroller to drive the relay to activate the motor.

5.2. Examining system functionality

The functionality of the system can be examined in two stages. In the first stage, the performance of the system in detecting four second eye blink is evaluated. Here, the recorded EEG signals that are stored in excel file are used. A digital acquisition card is used as a communication medium between the computer and microcontroller system. The function of DAQ card is to transfer the recorded EEG signals from the computer to the PIC microcontroller. A program written in Visual Basic is used to send the EEG signal from the computer to the microcontroller. To view the EEG signal received at the output of DAQ, an oscilloscope is placed at one of the DAQ analogue channels. The transmitted EEG signal displayed on the computer screen is compared with the signal observed on the oscilloscope. The eye blinks are detected using software written in C language which is programmed on the microcontroller. In order to view the signal send to the motor, the output of the microcontroller is connected to the oscilloscope.

Figure 12.

Process of activating a motor using eye blink detected from EEG.

In the second stage, the functionality of the motor circuit is tested using a simple routine shown in Figure 13. A switch is connected to the input of the microcontroller to initiate the testing. When the switch is turned on, the routine activates the relay that is connected to the motor. Once it is confirmed that the eye blink detection module and motor activation routines are working successfully, these routines can be combined together.

Figure 13.

A simple routine to test the functionality of the motor.


6. Results and discussions

The EEG signal containing eye blinks observed at the output of DAQ is shown in Fig. 14. This signal contains three eye blinks and the length of the signal is 4 seconds. The eyelid closure and opening can be observed clearly through the signal negative and positive amplitudes.

Figure 14.

EEG signal observed at the output of DAQ. [Wahy et al, 2010]

Figure 15 shows the EEG signal with voluntary eye blinks and the pulse obtained when four second eye blinks is detected. This pulse is observed at the Port B of the PIC16F877A microcontroller. The motor starts moving once the transistor connected to port B is switched on.

Figure 15.

Pulses generated at the output of PIC microcontroller when three eye blinks are detected. [Wahy et al, 2010]

Figure 16 shows the EEG signal when the subject is in relax condition. This EEG signal contains spontaneous eye blinks which are not detected by the PIC microcontroller. The amplitude of spontaneous eye blinks is below the threshold value which causes the PIC ignores them and no pulse is generated at the output.

Figure 16.

EEG with spontaneous eye blinks observed at the output of PIC microcontroller. [Wahy et al, 2010]


7. Conclusion

A system that can activate a fan using EEG signal detected by a microcontroller has been described in this paper. The results showed that eye blinks can be detected successfully using PIC16F877A. With a program running on PIC16F877 microcontroller, a simple motor can be activated using neural signal. This application is suitable for people who cannot move their hands or the whole body to control a fan. Using this system, users can control a fan easily without any conventional remote controller. This system is useful for elderly people and disable persons as well as able-bodied people.

For future work, wireless electrodes should be employed in this system. The purpose is to make the users to feel comfortable with no wires hanging on their head. With wireless connection, the microcontroller module can be located at a distance from the user which provides more freedom for normal person to move around. However, this system requires intelligent software to eliminate interference and prevent false detection.



The authors would like to thank Universiti Teknologi MARA, Shah Alam, Malaysia for providing facilities to carry out this research project.


  1. 1. AbdRani. M. S. .MansorW.2009 Detection Of Eye Blinks From EEG Signals For Home Lighting System Activation, Proc of International Symposium on Mechatronics and Its Applications, 14978-1-42443-480-0Sharjah, UAE, March 24-26, 2009
  2. 2. BullingA.WardJ. A.GellersenH.TrosterG.2011 Eye Movement Analysis for Activity Recognition Using Electroculography, IEEE Transaction on Pattern Analysis and Machine Intelligence, 334April 2011), 20060162-8828
  3. 3. BreauF.MarsdenB.Mc CluskeyJ.EllwoodR. J.LewisJ.2004 Light Activated Position Sensing Array for Persons with Disabilities, Proceedings of IEEE on Bioengineering, 0-78038-285-4204205April 17-18, 2004
  4. 4. DingQ.TongK.LiG.2006 Development of an EOG (Electro-Oculography) Based Human-Computer Interface, Proceedings of IEEE EMBS, Shanghai, China, 1-42440-032-568296831Aug 30- Sept 3, 2006
  5. 5. HarunH.MansorW.2009 EOG Signal Detection for Home Appliances Activation”, IEEE Colloquium on Signal Processing and Its Applications, Kuala Lumpur, Malaysia, 978-1-42444-151-8195197March 6-8, 2009
  6. 6. KumarD.PooleE.2002 Classification of EOG for Human Computer Interface, Proceedings of IEEE EMBS/BMES, USA, 0-78037-612-96467
  7. 7. NoraniN. A. M.MansorW.KhuanL. Y.2010 A review of Signal Processing in brain computer interface system, Proceedings of IEEE on Biomedical Engineering and Sciences, 978-1-42447-599-5443449Nov 30- Dec 2, 2010.
  8. 8. WahyN.MansorW.2010 EEG Based Home-lighting System, Proceedings of IEEE on Computer Applications and Industrial Electronics, 978-1-42449-054-7379381Dec 5-8, 2010.

Written By

Wahidah Mansor, Mohd Shaifulrizal Abd Rani and Nurfatehah Wahy

Submitted: 18 November 2010 Published: 29 August 2011