Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) ASTESJ www.astesj.com ISSN: 2415-6698 Special Issue on Multidisciplinary Innovation in Engineering Science & Technology

Design of an EEG Acquisition System for Embedded

Kanishk Rai1,*, Keshav Kumar Thakur1, Preethi K Mane1, Narayan Panigrahi2

1Department of Electronics and Instrumentation, BMS College of Engineering, 560019, India

2Centre for Artificial Intelligence and Robotics, DRDO, 560093, India A R T I C L E I N F O A B S T R A C T Article history: The human brain is one of the most complex machines on the planet. Being the only method Received: 17 April, 2020 to get real-time data with high temporal resolution from the brain makes EEG a highly Accepted: 17 June, 2020 sought upon signal in the neurological and psychiatric domain. However, recent Online: 12 July, 2020 developments in this field have made EEG more than just a tool for medical professionals. The decreasing size and increasing complexity of EEG acquisition systems have brought it Keywords: out of the lab and into the field where it is used for varied applications like neurofeedback, Electroencephalogram (EEG) person recognition and other recreational activities. Amalgamation of the EEG signal with (IOT) new developing standards of Industry 4.0 to control basic IOT devices using edge Brain Computer Interface (BCI) computing techniques marks the next step in the design and development our low-cost yet Acquisition system robust Brain Computer Interface (BCI); which is just one of the many applications that a Edge Computing versatile and well-built EEG acquisition system can be used for.

1. Introduction were many limitations of the design. We studied the base design and propose a refined design which will overcome the followings What makes the human brain so complex is not just the 100 drawbacks of the initial design: billion neurons that it is constituted of but also the 100 trillion plus synapses or the unique ways in which those neurons connect and a) Overcome the limitations of low sampling rate communicate with each other. Even with more than 7.5 billion b) To perform filtering and feature extraction from acquired people on the planet, no two brains are alike. Therefore, designing EEG signal on the board itself a unified device that can capture the diverse Electroencephalogram (EEG) signals emanating from different brains is a challenging c) To reduce and eliminate the noise during the EEG signal task. EEG signals can be processed to extract the characteristic acquisition process by reducing wires in the system patterns of the brain to study its spatio-temporal characteristics. d) Better processing mechanism to extract and interpret the Though other methods of measuring brain activity like EEG data acquired, in real-time Magnetic Resonance Imaging (MRI) and Functional Magnetic The whole system has now been fabricated on a Printed Circuit Resonance Imaging (fMRI) have more spatial resolution yet, they Board (PCB) and the primary mode of communication between the lack temporal resolution and are often more costly to setup and acquisition system and the host computer is now wireless to operate. EEG on the other hand offers better temporal resolution minimize artefacts introduced due to wire movements and other and is a cost-effective solution which can directly measure brain Electromagnetic Interference (EMI) / Electromagnetic activity. EEG can approximate spatial activity with the use of Compatibility (EMC) interference. The detailed design update is greater number of electrodes placed on the scalp, providing better enumerated in the system design section. resolution and thus, making it a scalable choice. The next section discusses current research trend in the field of A low cost yet robust design of an EEG acquisition system was BCI (Brain Computer Interface) and HMI (Human Machine presented at the IEEE International Symposium on Smart Interface) using EEG, followed by the Problem Definition. Next, Electronic Systems (iSES) (Formerly iNiS), 2019 [1]. Though the we briefly look at the testing results from our initial design and design was primarily focused on reduction of cost of highlight its shortcomings. We then move on to introduce the manufacturing so that the system becomes affordable, yet there updated block diagram and directly compare the initial and the updated components. This serves the double purpose of *Kanishk Rai, +91-8853389016, [email protected] www.astesj.com 119 https://dx.doi.org/10.25046/aj050416 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) introducing the initial design while highlighting the updates in the using a commercially available EEG headset. They have improved model. We next discuss the results obtained during implemented Empirical Mode Decomposition (EMD) to reduce testing of the improved EEG acquisition system and finally, we noise and simulated mouse clicks with the help of blinks. Next we illustrate one of the many applications of our system - which is to come across articles [10-14] that focus on controlling robotic arms automatically control IoT devices such as the television, lights, or wheelchairs for amputees and paraplegics using different wheel chair and fan depending upon the state of the subject e.g. computational techniques for identification and classification of active, semi active, asleep in real time. various signals in the EEG like Event-related Potential (ERP), P300, Mu rhythm, etc. and demonstrate the accuracy and ease with 2. Literature Review which these EEG based BCIs can control simple devices. 2.1. Background Taking this use of EEG one step forward multiple articles [15- Since the first experiments of electroencephalography on 21] discuss integrating EEG with the Internet of Things (IOT) to control different devices in a smart home using protocols like humans in 1929, the electroencephalogram (EEG) of the human Message Queue Telemetry Transport (MQTT) and Extensible brain has been used mainly to evaluate neurological disorders in Messaging and Presence Protocol (XMPP). These interfaces can the clinical environment and to investigate brain functions in the further be used to improve healthcare and the general living laboratory. An idea that brain activity could be used as a standard of differently-abled people and in-turn make everyone’s communication channel between the subject and an IoT device has life easier. However, there is much work still to be done in this gradually emerged [2-6]. The possibility of recognizing a single domain considering the new threats that continuously emerge in message or command, considering the complexity, distortion, and the realm of cyber security. variability of brain signals appeared to be extremely remote. Yet EEG demonstrates direct correlations with user intentions, thereby Researchers have worked upon and built multiple EEG enabling a direct brain-computer communication channel. acquisition systems [22-28] but have not used these systems to demonstrate an application. Others have demonstrated the use of Brain-Computer Interface (BCI) technology, as it is known, is EEG for various applications be it in terms of person recognition a communication channel that enables users to control devices and applications without the use of muscles. The development of [29-32] or in the field of healthcare [33-38] or the ones mentioned cognitive neuroscience field has been instigated by recent above, but they have either used commercially available EEG advances in brain imaging technologies such as acquisition systems or pre-existing datasets. With our research we electroencephalography, magneto encephalography and functional aim to bridge this gap by not only building a robust yet low-cost magnetic resonance imaging. The first BCI prototype was created EEG acquisition system but also using the same system to control by Dr. Vidal in 1973. This system was intended to be used as a IoT devices in real-time, and in doing so we not only design the promising communication channel for persons with severe hardware to acquire EEG data but also develop the software for disabilities, such as paralysis, Amyotrophic Lateral Sclerosis (ALS), stroke or cerebral paralysis. data representation and signal processing which showcase the edge computing capabilities of our device. Since then BCI research has been successfully used not only for helping the disabled, but also as being an additional data input 3. Problem Definition (Limitations of Existing Designs of channel for healthy people. It can be exploited as an extra channel EEG Acquisition Systems) in game control, augmented reality applications, household device control, fatigue and stress monitoring and other applications. BCI The research trends towards problems addressed in the EEG design represents a new frontier in science and technology that and BCI/HMI domain [1] show us that only 3 out of 30 requires multidisciplinary skills from fields such as neuroscience, publications focus on data acquisition and 5 out of 30 discuss EEG engineering, computer science, psychology and clinical signal processing. However, this can paint a slightly misleading rehabilitation. picture. To fully understand the need to design and develop a low- 2.2. Review of EEG for BCI Applications cost yet robust EEG acquisition system capable of edge processing we need to look at the research trends towards adaptation of Controlling real-world objects with nothing more than our technology where only 2 out of 21 publications [1] use custom- mind is no longer science fiction. Jaime, et al [7] have proved the built EEG acquisition systems, while others rely on expensive same by demonstrating the fact that the steering of a tractor by use alternatives available in the market or pre-existing datasets [1]. of surface EOG and EEG signals is just as accurate as manual guidance or GPS guidance with a minimal variation in response The above gaps in research are the major motivation behind time. this research, but the problems encountered while designing a robust yet low-cost EEG acquisition system are two-fold: Furthermore, Yuan, et al [8] have conclusively established the feasibility of using a consumer-level EEG headset to realize an Domain specific problems are: - online steady-state visual-evoked potential (SSVEP)-based BCI during human walking using a 14 channel commercially available • To ensure that the pickup, amplification and transmission of EEG headset to implement a four-target online SSVEP decoding EEG signal is done while introducing minimum noise in the system which has in-turn helped bridge the gap between laboratory signal. BCI demonstrations and real-life application of consumer-level • To ensure that the sampling rate of the acquisition system is EEG headsets. at lest 2.5 times the highest frequency of input EEG signal, but Starting with some simple applications, Gerardo Rosas- at the same time not too high so as to avoid the problem of Cholula, et al [9] have successfully controlled a mouse pointer oversampling. www.astesj.com 120 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) • To ensure that the resolution of the system is enough to A brief description of output from the initial design of our EEG register minute changes in the peak-to-peak amplitude and the acquisition system is as follows: frequency of the EEG signal. Problems specific to the design of our acquisition system are: • To build a Graphical User Interface (GUI) that accurately represents the EEG signal picked up by the acquisition system in real-time. • To perform real-time processing and feature extraction from EEG signal in order to build a device capable of edge processing.

4. System Design After careful examination of EEG signals and other medical Figure 2: Data Acquisition in MATLAB interfaced with grade systems available in the market, we have arrived at the following design-constraints to design our EEG acquisition system. Design constraints: • EEG voltage range: 10 V to 100 V • Useable EEG frequency range: 0.3 Hz to 60 Hz • Max variation of input signal per unit time: 50V • Sampling Rate: 256 to 1k SPS The subsequent sections talk about the step by step design of each component in the acquisition system. Beginning with an Figure 3: Power spectral density of data acquired from single sensor coming from instrumentation amplifier with a gain of 101 introduction to the initial system design, its results and drawbacks. Once the data acquisition is complete, MATLAB then 4.1. Initial Block Diagram, Testing and Observations computes the power spectral density of the acquired EEG signal as observed in Figure 3. Major peaks seen around 5, 10, 25 and 32 Hz For the initial design [1] as shown in Figure 1, gold plated, cup correspond to Alpha, Beta and Theta waves which contribute shaped electrodes (placed on the scalp using the international 10- majorly to awake EEG patterns. 20 system) were connected to the instrumentation amplifiers (INA333) which were then directly connected to the analog input pins of Arduino Mega. We only used 3 input channels; two for data and one for reference. Arduino IDE however, is neither capable of plotting data from multiple channels nor is it capable of performing complex algorithms on the acquired data.

Figure 4: Comparison of data acquired from a medical grade system and our Figure 1: Initial block diagram proposed system Therefore, to overcome the abovementioned drawbacks, we Figure 4 shows the comparison of saccade, fix and blink data. interfaced Arduino with MATLAB, which is used to plot real time Subplot 1 shows the data from our system, while Subplot 2 shows frequency domain and time domain spectrum of the incoming EEG the data from the medical grade system. Similar for Subplot 3 and signal with further possibility of manipulating data and 4. It is evident from the above figure that our proposed system representing it in different formats. captures the correct data as all peaks match between both signals. The drawback here is the low sampling rate because of which the Figure 2 shows the acquired EEG data from a single channel reconstructed signal does not have as much detail as is required for connected to analog port A0 of the Arduino at a baud rate of 9600. complex analysis – this can be seen when comparing Subplot 3 and Subplot 1 shows the real time RAW EEG signal amplified 101 4. The maximum rate at which the data is captured by our initial times whereas subplot 2 shows the real time Frequency plot (FFT). system is about 5 to 20 Hz [1]. www.astesj.com 121 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) 4.2. Drawbacks of the Initial System The chip communicates with the using SPI (Serial Programming Interface) which can be used to configure the Due to the low sampling rates which are in-turn caused by the chip to read data in Continuous mode or Single Shot mode and also hardware limitations of the 10-bit ADC on Arduino Mega2560, we to read the output data from the inbuilt registers. were only able to capture data at a maximum rate of 20 Hz. But the Practical Nyquist Sampling Theorem states that to properly 4.5. Microcontroller capture and reconstruct incoming signal, the sampling frequency Arduino Mega from the initial design has now been replaced of the acquisition system must be at-least 2.5 times the maximum with ESP 8266 NodeMCU as the choice of microcontroller for our frequency component of the incoming signal, therefore to capture system. The NodeMCU has a L106 32-bit RISC microprocessor brain waves with a maximum useable frequency component of 60 running at 80 MHz. It supports 32 KB instruction RAM and 80 KB Hz, the acquisition system must have a sampling rate of 150 Hz or user-data RAM. It comes with integrated IEEE 802.11 b/g/n Wi- higher. To overcome this issue of lower sampling rate, we propose Fi connectivity and matching network WEP or WPA/WPA2 the use of an ADC (ADS1299) introduced after the instrumentation authentication. It has 16 GPIO pins and also supports SPI amplifier and before the microcontroller as shown in the block communication – all of which is ideal for our application. The diagram of our initial design (Figure 1). NodeMCU does not only have more GPIO pins, better clock speed The microcontroller Arduino Mega does not have the inherent of the processor and more flash and SRAM than the Arduino, but capability to transmit data wirelessly meaning more noise is also operates at a lower 3.3 V which translates to less power introduced in the signal due to the movement of the wires. This is consumption for battery powered wireless use of our EEG overcome by replacing Arduino with NodeMCU that has an inbuilt acquisition system. wireless transmitter. 4.6. Initial Observations with ADS1299 Moreover, the use of MATLAB for signal processing and To set up and test the SPI connection between ADS1299 and representation poses its own set of limitations including the need NodeMCU, ADS is soldered on an adaptor (Figure 6) and the for a MATLAB license to use our system, hence the same is connections are made on a bread-board (Figure 7). It must be noted replaced by a GUI built using open-source code in Python. that for this initial testing, ADS is connected to Arduino. Once the 4.3. Improved Block Diagram connections are verified, the final PCB is interfaced with NodeMCU. The initial components of the system like the Electrodes (gold- plated, cup shaped, copper, non-invasive), Electrode Placement (international 10-20 system), Electrode Cap and the Instrumentation Amplifier (INA333) remain the same and are carried over from the initial design (Figure 1).

Figure 6: ADS1299 soldered on an adaptor Figure 5: Updated Block Diagram Figure 5 shows the block diagram of the updated hardware with an Analog to Digital Converter introduced in the system after the instrumentation amplifier to handle the conversion of analog data to digital domain at a much faster rate. The ADS1299 connects to the NodeMCU using SPI, which then transmits the data wirelessly to the host computer that runs a Python GUI for data processing, filtration and signal representation. 4.4. Analog to Digital Converter (ADC) The ADC chosen for our application is the TI analog front-end chip ADS1299, which is specifically designed to capture biopotential signals like EEG, ECG, EOG, EMG, among others. The chip has a 24-bit Sigma-Delta based architecture, with a maximum data rate of 16 kSPS. It boasts of a -110 dB CMRR and a Signal to Noise Ratio of 121 dB. It is a low power, low noise, high precision chip. It can further be multiplexed to use more channels and is available in 4, 6 and 8 channel alternatives. Figure 7: ADS1299 connected to Arduino Mega using SPI on a bread board www.astesj.com 122 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) After running multiple tests Arduino Mega is able to read the microcontroller NodeMCU and for other purposes. Internally, the correct Device ID (Figure 8). The device ID reads 1111 1100 ADC has multiple pins that require 5V and 3.3V to power up the where the last four bits correspond to the 4 channel ADS1299 chip. Analog and Digital circuits in the chip respectively. This means that the SPI communication was successful, but due to the inherent noise of the system which is set-up on a bread-board, For the input electrodes, each channel is first passed through the output is not consistent. the non-inverting pin of the instrumentation amplifier INA333 for first stage amplification. The signal is then passed through an RC Therefore, the next logical step is to design a PCB to acquire high-pass filter to remove DC offsets and fed to the ADC via the signals. This is carried out in the next subsection. referential montage with one reference electrode and an internal bias. The example Schematic using the ADS1299 in an EEG Data Acquisition Application in Referential Montage from its datasheet is shown in Figure 9. The advantage of using the referential montage is that all electrodes are referenced to a single reference electrode instead of being referenced to each-other as is the case with sequential montage.

Figure 8: Correct device ID of ADS1299-4PAG displayed on serial monitor of Arduino IDE connected to Arduino

4.7. Design for PCB Fabrication The PCB is designed using an open-source software called PCB Artist. The schematic for the design is shown in Figure 10. The design comprises of a power supply unit which steps down the incoming 220V AC to 5V and 3.3V DC. Both the 5V and 3.3V Figure 9: Use of ADS1299 in referential montage lines have been taken out as well to provide power to the

5 4 3 2 1

POWER 5V 3.3V REGULATOR SUPPLAY REGULATOR 3.3V 12V U1 5V U2 LM7805 DPAK LM1117 SOT223

1 3 3 D 2 IN OUT IN OUT

BR1 N

1

G /

D 4 J

+

D NC D

N

D A G 5V

3 2 1 1 2 C1 C2 C3 1 C4 C100uF/25V 0805 4.7UF 0.1uF 1 1000uF/25V 2 - 2 3 2 3 JACK1 4 DC JACK BRIDGE 1A C5 C6 0.1uF 0.1uF 5V 5V 5V

5V J1 R1 5V 1 1K TP1 1 TESTPOINT 2 1 C7 C8 C9 C10 C11 C12 CON2 U3 TP2 0.1uF 0.1uF 0.1uF 0.1uF 0.1uF 0.1uF 1 8 R2 TESTPOINT RG RG 2 7 2.2K 1 VIN- V+ 3 6 TP3 VIN+ VOUT 4 5 TESTPOINT 3.3V V- REF INA333 R4 C13 C C TP4 392K 0.1uF TESTPOINT 1 R7 R5 1K 2.2K

C14 C15

4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

9 0.1uF 0.1uF

6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 U4 4 1 8 R8 J8 RG RG 2 7 2.2K VIN- V+ 2 3 6 1 48 VIN+ VOUT 1 4 5 2 47 DRDY V- REF 1 CON2 3 46 GPIO4 2 INA333 4 45 GPIO3 J2 C16 C17 3 5 44 GPIO2 CON4 0.1uF 0.1uF 4 6 43 DOUT 1 R9 7 42 GPIO1 2 1K 8 41 DAISY IN 3 9 40 SCLK J3 4 10 39 CS CON5 5 J5 U6 11 38 START 1 1 8 R10 12 37 CLK 1 RG RG 2 2 7 2.2K 13 36 RESET 2 VIN- V+ 3 3 6 14 35 PWDN J4 3 VIN+ VOUT 4 4 5 15 34 DIN CON5 3.3V B 4 V- REF 5 B 16 33 5 INA333 CON5

R12 R11

7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2

1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 1K C18 C19 C20 C21 1 U5 1K 0.1uF 0.1uF 0.1uF 0.1uF ADS1298IPAG

U7 1 1 8 R13 RG RG 2 7 2.2K LED1 VIN- V+ 3 6 5V 0805 VIN+ VOUT 4 5 V- REF

INA333 2 J6 R14 1 C22 C23 C24 C25 C26 1K 2 0.1uF 0.1uF 0.1uF 0.1uF 0.1uF CON2 U8 5V MH1 MH2 MH3 MH4 1 8 R15 1 1 1 1 RG RG A 2 7 2.2K A VIN- V+ M HOLE1 M HOLE3 M HOLE2 M HOLE4 3 6 VIN+ VOUT 4 5 V- REF C27 C28 C29 C30 KESHAV INA333 J7 0.1uF 0.1uF 0.1uF 0.1uF Title 1 2 ADS1298IPAG CON2 Size Document Number Rev B

Date: Tuesday, April 30, 2019 Sheet 1 of 1 5 4 3 2 1 Figure 10: Schematic for PCB design www.astesj.com 123 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) The final fabricated, two-layer PCB is shown in Figure 11 and Figure 12.

Figure 11: Fabricated PCB (top)

Figure 13: Register configuration of ADS1299

Figure 12: Fabricated PCB (bottom)

5. Output from PCB

Once the PCB is fabricated, it is connected to the microcontroller using SPI interface. The ADS1299 is then configured to transmit continuous data with 24-bit resolution at 250 SPS. The register values corresponding to the above configuration are shown in Figure 13 with the correct device ID. Even though the chip is capable of acquiring data at speeds up to 16 kSPS, we have not used these higher sampling rates to avoid Figure 14: Incoming data from EEG electrodes in ADS1299 the problem of oversampling. www.astesj.com 124 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) Figure 14 shows the filtered data acquired from the EEG microcontroller. Furthermore, the splitting of acquired EEG signal sensors connected to the input channels of ADS1299. The RAW into its component waves based on their frequency ranges and data is in Hexadecimal format. This is converted to Decimal format feature classification & identification in different frequency ranges and then scaled down to convert into Volts. Since we have used a is also implemented on the microcontroller. 4 channel ADS1299 chip, the data format as observed in the output is . The last 4 bits in each row are of no use to us because those channels don’t exist on an ADS1299-4PAG chip. 6. Data Representation using Python GUI

6.1. Design

The code for the GUI is burnt on the NodeMCU using the Arduino IDE after installing relevant drivers. First off, this code checks the device ID coming from the attached ADS1299 chip and if it is correct, modifies the register values to acquire data. In our case the ADS is set to acquire data at 250 SPS in continuous mode. It then creates the GUI window as shown in Figure 15.

Figure 16: Real-time frequency and time domain plot of acquired EEG signal The major peaks observed in the frequency domain plot of Figure 16 are in the range of 7 to 30 Hz which comprise mainly of Alpha (7-12 Hz) and Beta (12-30 Hz) waves that constitute a major portion of awake EEG. 7. Use of EEG for IOT application Now that we have successfully designed and built a plug and play device for EEG acquisition and a GUI for data representation it is time to use it for an IOT application to highlight its edge computing capabilities. We know in hospitals; the staff has to keep an eye on patients that cannot move to ensure that they are comfortable. The lights are off when they sleep and the fan is turned on as and when Figure 15: Python GUI window needed. Keeping this equipment running all the time does not only This GUI window has options to toggle the 50 Hz filter, Low cause discomfort to the patient but also a higher electricity bill and Pass filter and the band pass filter all of which are deployed in the waste of energy. python code using digital filtering. No hardware filters are To tackle this issue, we use our EEG acquisition system to deployed because they clip waveforms; due to the cutoff from op- monitor the Alpha and Beta waves of the patient. We know that in amp power supply and induce more noise and drift in the system. awake EEG the Alpha waves’ peak-to-peak amplitude is low when our eyes are open and high when our eyes are closed. This variation 6.2. Output can be used to turn off lights in a room when the patient closes A simple test to capture EEG data is run on the subject for 60 his/her eyes to sleep. Similar interactions are observed in the Beta seconds. The real-time time domain plot and the frequency plot are waves when an individual moves or even thinks of moving their observed in Figure 16. limbs to perform a certain function or action. These variations in frequency and peak-to-peak amplitude can be monitored and with The GUI has a continuous rolling time domain plot with a 4 the right threshold can be used to turn on or off a fan. second window (customizable) and frequency domain plot that accumulates frequency responses over the course of time that the 7.1. Block Diagram experiment is run. In Figure 17 our acquisition system is now represented as a As observed in Figure 16, our acquisition system performs black-box which wirelessly transmits data to the host computer filtering in real-time on the PCB itself with the use of hardware where the GUI displays EEG waves in both time and frequency high-pass filter implemented using the RC filter and low-pass & domain in real-time. notch filter implemented in software in the code burned on to the www.astesj.com 125 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020)

Figure 17: Block diagram for IOT application using EEG Once the data is received by the GUI, it is transmitted to MATLAB 7.2. Algorithm Work-flow using serial communication. MATLAB checks the peak-to-peak As shown in Figure 18 the incoming EEG data from the Python amplitude of the incoming signal and matches it against a set GUI is serially transmitted to MATLAB where an algorithm threshold in real-time. Once the threshold is met; in case of Alpha continuously scans this data and based upon the initial value of the waves the peak-to-peak amplitude crosses the threshold, the light (on or off) compares it with the upper (light on) or lower (light program sends a command to Arduino Mega which in-turn off) threshold. When the EEG peak-to-peak amplitude crosses the transmits it wirelessly using an IR module to actuate or control the respective threshold, the Arduino sends a command wirelessly to final control element which in this case are the lights. the actuator to change the state of the light. A similar algorithm is applied to control the fan, however in that case, changes in a combination of frequency and amplitude; in the Beta range of frequency (12 – 30 Hz), meeting the threshold result in the change of state of the fan. Based on further analysis of the EEG signal in various frequency ranges, multiple such IOT devices can be controlled. However, for such an application the processing module will have to apply AI, machine learning and deep learning algorithms to improve efficiency and the user will also have to be trained enough to concentrate in certain ways in order to control different objects. 8. Results and Discussion Figure 19 shows the output plotted from channels F1 and F2. The x-axis is time and y-axis is amplitude in milli-volts. The experiment in this case lasted for 20 seconds, where the subject’s eyes were open for the first 10 seconds and then closed for the next 10 seconds. As observed in the figure, the EEG peak-to-peak variation is less when the subject’s eyes were open except for a few spikes which correspond to blinks. The variation in peak-to-peak voltage increases dramatically half way through the experiment when the subject’s eyes were closed. This corresponds to the increase in Alpha Wave activity in Awake EEG when our eyes are closed. At the 12 second mark in the experiment when the subject’s eyes were closed, the lights turned off after detection of increase in Alpha wave activity at the 10 second mark. The 2 second delay is introduced to reduce the chance of false positives. The above experiment, quite simply demonstrates the accuracy Figure 18: Algorithm flow chart of the data coming from our EEG acquisition system and its ability www.astesj.com 126 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) to control an IOT device (the lights) precisely in real-time. It is The cost of our EEG acquisition system is much less compared generally observed that the filtering of noise from the EEG signal to other commercially available EEG acquisition systems because is done post its collection. Same goes for the removal of artifacts of the fact that we have stripped down the design to a bare from the EEG signal. Also, the analysis of the signal such as minimum and have only retained the most essential components selection of features, classification and training of the classifier is that make it work efficiently and effortlessly. It must be noted that carried out after the data is acquired and stored in a secondary the cost mentioned for our system is applicable when single parts device making the entire flow of denoising, analysis and were ordered, the cost will further come down by about 15-20% classification of EEG a delayed process. when ordering parts and fabricating PCBs in bulk. For our particular application we have used the ADS1299 – 4PAG chip that has 4 input EEG channels and one reference channel. For other applications that require more input channels, more ADS1299 chips can be daisy-chained to achieve a 16, 32 or even a 64 channel EEG acquisition system.

Figure 19: Plotted output from serial data communicated to MATLAB However, our recommended design can be used to remove the noise in the EEG acquisition system and detect the features from the signal at the time of the acquisition in the device itself. Therefore, moving the denoising of the signal and classification in the EEG acquisition system to a real time system (Edge computing). Table 1 shows a comparison of our EEG acquisition system with other commercially available systems. Table 1: Cost comparison of EEG acquisition systems

S.no. Product Cost Figure 20: Daisy chain configuration of two ADS1299 chips 1. NeuroSky (1 or 3 channels) INR 6999 (1 channels) Figure 20 shows how two ADS1299 chips can be daisy- INR 18,000 (3 chained to achieve up-to 64 input channels. channels) 2. EMOTIV EPOC (5 or 14 USD 299 (5 channels) Furthermore, Table 2 shows a broad specification comparison channels) {INR 21,220} of our EEG acquisition system with others available in the market. The performance metrics considered are sampling rate, bandwidth, USD 799 (14 channels) {INR number of EEG acquisition channels, mode of transmission 56,707} between the acquisition system and the host computer, placement of reference electrodes and the medium of conduction used 3. OpenBCI (8 – 16 Channels) USD 249.99 (4 between the electrode and the scalp. It is worth mentioning that all channels) {INR 17,742} devices considered, use non-invasive electrodes for data acquisition. A direct comparison of data is also shown in Figure 4. USD 499.99 (8 channels) {INR As evident in table 2, our EEG acquisition system is not only 35,485} the most cost effective, but also happens to be superior when USD 949.99 (16 comparing hardware specifications with those of other channels) {INR commercially available products. The use of Wi-Fi for wireless 67,423} transmission gives our system the maximum range of 4. Neuro Insight (4,6,8 can be INR 15,821 (4 communication. Our system also gives the user the ability to daisy-chained) – our acquisition channels) choose the number of channels (by daisy-chaining ADS1299, system ADS1299-4PAG and ADS1299-6PAG chips), bandwidth (by INR 16,242 (6 manipulating the cut-off frequency of high-pass and low-pass channels) filters) and sampling rate (by changing the register value on INR 16,604 (8 ADS1299 to be as high as 16kSPS). None of these are offered by channels) any other product in the market right now. www.astesj.com 127 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) Table 2: Comparison of EEG acquisition systems

S. EEG Sampling rate Bandwidth # of EEG Channels Transmission Reference Conductive no. System (Hz) (Hz) Mechanism

1. NeuroSky 512 100 1 or 3 Bluetooth Earlobe None

2. EMOTIV 256 43 5 or 14 Bluetooth Left / right Saline based EPOC mastoid

3. OpenBCI 1000 60 8 to 16 RFD Earlobe Gel / Dry Bluetooth

4. Neuro 1000 100 4,6,8 (can be daisy- Wi-Fi Earlobe Gel Insight (configurable) chained up to 64) (our system)

9. Conclusion [3] Alice Caplier, Sylvie Charbonnier and Antoine Picot, “On-Line Detection of Drowsiness using Brain and Visual Information,” IEEE Trans. Syst., Man, Cybern. A, Syst., Humans, vol. 42, no. 3, pp. 773-774, May 2012 From the above design and application, the followings can be https://doi.org/10.1109/TSMCA.2011.2164242 concluded: [4] Somnath Roy, Amarnath De, Narayan Panigrahi, “Saccade and Fix Detection from EOG Signal” in 2019 IEEE International Symposium on Smart • The proposed system captures accurate EEG signal despite the Electronic Systems (iSES) (Formerly iNiS), Rourkela, India, 2019 commercially available off the shelf electronic components https://doi.org/10.1109/iSES47678.2019.00099 used in designing the overall system - making it a low-cost yet [5] Panigrahi N, De A, Roy S, “A Method to Detect Blink from The EEG Signal” in Intelligent Computing and Communication, ICICC 2019, Advances in robust instrument for capturing EEG data. Intelligent Systems and Computing, vol. 1034, Springer, Singapore, 2019 • In order to improve the robustness of the signal captured the https://doi.org/10.1007/978-981-15-1084-7_24 ADC with the instrumentation amplifier is soldered on the [6] Panigrahi N, Lavu K, Gorijala S.K, Corcoran P, Mohanty S.P., “A Method for Localizing the Eye Pupil for Point-of-Gaze Estimation” in IEEE Potentials same board with the microcontroller, resulting in a single 38(1), 37-42, 2019 https://doi.org/10.1109/MPOT.2018.2850540 smaller unit, making the overall device more portable. [7] Jaime Gomez-Gil, Israel San-Jose-Gonzalez, Luis Fernando Nicolas-Alonso • To increase the number of EEG signal channels to be captured and Sergio Alonso-Garcia “Steering a Tractor by Means of an EMG-Based through the proposed system more ADS1299 chips must be Human-Machine Interface”, MDPI Sensors ISSN 1424-8220, Published: 11 July 2011 https://doi.org/10.3390/s110707110 daisy-chained, this will further make the system modular and [8] Yuan-Pin Lin, Yijun Wang and Tzyy-Ping Jung “Assessing the feasibility of robust, where more input channels can be added on demand online SSVEP decoding in human walking using a consumer EEG headset”, based on the needs of the user. Journal of NeuroEngineering and Rehabilitation, Published online 2014 Aug 9 https://doi.org/10.1186/1743-0003-11-119 Further research can be carried out to compare the power [9] Gerardo Rosas-Cholula, Juan Manuel Ramirez-Cortes, Vicente Alarcon- consumption v/s performance of various components like the Aquino, Pilar Gomez-Gil, Jose de Jesus Rangel-Magdaleno and Carlos instrumentation amplifier, ADC and microcontroller to design a Reyes-Garcia, “Gyroscope-Driven Mouse Pointer with an EMOTIV® EEG Headset and Data Analysis Based on Empirical Mode Decomposition” truly power efficient, battery powered EEG acquisition system Sensors, 13, 10561-10583, 2013 https://doi.org/10.3390/s130810561 capable of collecting data over long periods of time. The reason for [10] T. A. Mariya Celin & B. Preethi “Brain Controlled And Switch Controlled moving from an AC powered device to a battery powered one is to Robotic Leg For The Paraplegics” ITSI Transactions on Electrical and get rid of the noise at 50 Hz and its harmonics. Electronics Engineering (ITSI-TEEE), 2320 – 8945, Volume -1, Issue -1, 2013 On the software front, the python code can be improved to [11] Howida.A.Shedeed, Mohamed F.Issa, Salah M.El-Sayed, “Brain EEG display more than one EEG channel at a time. Further Signal Proccessing for Controlling a Robotic Arm”, IEEE, pp.152-157, 2013 computational capabilities and the ability to connect with more https://doi.org/10.1109/ICCES.2013.6707191 than one device at a time can be added to completely eliminate the [12] Kamlesh H. Solanki, Hemangi Pujara, “Brainwave Controlled Robot” use of MATLAB and finally, the software must also have the International Research Journal of Engineering and Technology (IRJET), vol. ability to export recorded data in popular EEG formats like 02, pp. 609-612, July 2015 European Data Format (EDF), CSV, etc. for further analysis and [13] Sun Chuan, Wu Chaozhong, Chu Duanfeng, Tian Fei, “A Design of Brain- computer Interface Control Platform for Intelligent Vehicle”, The 3rd storage. International Conference on Transportation Information and Safety, June 25 – June 28, 2015 https://doi.org/10.1109/ICTIS.2015.7232147 References [14] B. Jenita Amali Rani and A. Umamakeswari “Electroencephalogram-based Brain Controlled Robotic Wheelchair” Indian Journal of Science and [1] Kanishk Rai, Keshav Kumar Thakur, Preethi K Mane, Narayan Panigrahi, Technology, Vol 8(S9), 188–197, May 2015 “Designing Low Cost Yet Robust EEG Acquisition System” in 2019 IEEE https://dx.doi.org/10.17485/ijst/2015/v8iS9/65580 International Symposium on Smart Electronic Systems (iSES) (Formerly [15] E. Mathe and E. Spyrou, “Connecting a consumer brain-computer interface iNiS), Rourkela, India, 2019 https://doi.org/10.1109/iSES47678.2019.00096 to an internet-of-things ecosystem,” in Proceedings of the 9th ACM [2] Kim Dremstrup Nielsen, Alvaro Fuentes Cabrera, O.F. do Nascimento, "EEG International Conference on PErvasive Technologies Related to Assistive based Brain Computer Interface - towards a better control Brain computer interface research at Aalborg university,” IEEE Transactions on Neural Environments, ser. PETRA ’16, pp. 90:1–90:2, 2016 Systems and Rehabilitation Engineering., vol. 14, no. 2, Article ID 1642769, https://doi.org/10.1145/2910674.2935844 pp. 202–204, 2006 https://doi.org/10.1109/TNSRE.2006.875529 [16] C. P. Brennan, P. J. McCullagh, L. Galway, and G. Lightbody, “Promoting autonomy in a smart home environment with a smarter interface” in Annual www.astesj.com 128 K. Rai et al. / Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 4, 119-129 (2020) International Conference of the IEEE Engineering in Medicine and Biology [36] Reza Khosrowabadi “Stress and Perception of Emotional Stimuli: Long-term Society, 2015 https://doi.org/10.1109/EMBC.2015.7319522 Stress Rewiring the Brain” Basic and Clinical Neuroscience, 9(2), 107-120, [17] B. Sujatha, G. Ambica “Eeg Based Brain Computer Interface For Controlling 2017 https://dx.doi.org/10.29252%2FNIRP.BCN.9.2.107 Home Appliances” International Research Journal of Engineering and [37] Jeffrey M. Rogers, Jacob Bechara and Stuart J. Johnstone “Acute EEG Technology (IRJET) Volume: 02 Issue: 09, Dec-2015 Patterns Associated with Transient Ischemic Attack” Clinical EEG and [18] Abdel Ilah N. Alshbatat, Peter J. Vial, Prashan Premaratne, Le C. Tran “EEG- Neuroscience, Article first published online: July 25, 2018; Issue published: based Brain-computer Interface for Automating Home Appliances” May 1, 2019 https://doi.org/10.1177/1550059418790708 JOURNAL OF COMPUTERS, VOL. 9, NO. 9, SEPTEMBER 2014 [38] Mohammad Nami, Samrad Mehrabi, Sabri Derman “Employing Neural http://dx.doi.org/10.4304/jcp.9.9.2159-2166 Network Methods to Label Sleep EEG Micro-Arousals in Obstructive Sleep [19] Anu K E, Jini Joseph, Shalu Narayanan, Sophy George, Minu Mary Joy “Non Apnea Syndrome” Journal of Advanced Medical Sciences and Applied Invasive Electroencephalograph Control for Smart Home Automation” Technologies 3(4):221-226, 2017 http://dx.doi.org/10.32598/jamsat.3.4.221 International Journal of Advanced Research in Electrical, Electronics and Instrumentation Engineering Vol. 5, Special Issue 3, March 2016 [20] Khaleel Alhalaseh, Hassan Migdadi, Rania Al Halaseh Y, Mohammad Al- Gara “Home Automation Application Using Eeg Sensor” Proceedings of 98th The IRES International Conference, Antalya, Turkey, 21st-22nd January, 2018 [21] Mohammad H. Alomari, Aya Samaha, and Khaled AlKamha “Automated Classification of L/R Hand Movement EEG Signals using Advanced Feature Extraction and Machine Learning” (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 4, No. 6, 2013http://dx.doi.org/10.14569/IJACSA.2013.0406 [22] Tomas Uktveris and Vacius Jusas “Development of a Modular Board for EEG Signal Acquisition” MDPI Sensors, Published: 3 July 2018 https://doi.org/10.3390/s18072140 [23] Bo Luan, Mingui Sun, and Wenyan Jia “Portable Amplifier Design for a Novel EEG Monitor in Point-of- Care Applications” Proc IEEE Annu Northeast Bioeng Conference, 2014 https://doi.org/10.1109/NEBC.2012.6207127 [24] Amlan Jyoti Bhagawati and Riku Chutia “Design of Single Channel Portable Eeg Signal Acquisition System For Brain Computer Interface Application” International Journal of Biomedical Engineering and Science (IJBES), Vol. 3, No. 1, January 2016 http://dx.doi.org/10.5121/ijbes.2016.310 [25] C.Jaganathan, A.Amudhavalli,T.Janani, M.Dhanalakshmi, Nirmala Madian “Automated Algorithm For Extracting α, β, δ, θ Of A Human Eeg” International Journal of Science, Engineering and Technology Research (IJSETR) Volume 4, Issue 4, April 2015 [26] Juan Tian*, Wuli Song “LabVIEW for EEG Signal Processing” Saudi Journal of Engineering and Technology Vol-1, Iss-4, Oct-Dec, 2016 DOI: https://doi.org/10.21276/sjeat.2016.1.4.10 [27] M. Rajya Lakshmi, Dr. T. V. Prasad, Dr. V. Chandra Prakash “Survey on EEG Signal Processing Methods” International Journal of Advanced Research in Computer Science and Software Engineering 4(1), pp. 84-91, January – 2014 [28] Miss. N. R. Patil, Prof. S. N. Patil “Review: Wavelet transform based electroencephalogram methods” International Journal of Trend in Scientific Research and Development (IJTSRD) Vol. 2 Issue 3 Mar-Apr Page: 1777, 2018 [29] Tien Pham, Wanli Ma, Dat Tran, Phuoc Nguyen, and Dinh Phung “A Study on the Feasibility of Using EEG Signals for Authentication Purpose” ICONIP 2013, Part II, LNCS 8227, pp. 562–569, 2013 [30] Theerawit Wilaiprasitporn, Apiwat Ditthapron, Karis Matchaparn, Tanaboon Tongbuasirilai, Nannapas Banluesombatkul and Ekapol Chuangsuwanich “Affective EEG-Based Person Identification Using the Deep Learning Approach” Journal of Latex Class Files, Vol.14, August 2018 https://doi.org/10.1109/TCDS.2019.2924648 [31] Byoung-Kyong Min, Heung-Il Suk, Min-Hee Ahn, Min-Ho Lee, and Seong- Whan Lee, “Individual Identification Using Cognitive Electroencephalographic Neurodynamics” IEEE Transactions on Information Forensics And Security, VOL. 12, NO. 9, September 2017 https://doi.org/10.1109/TIFS.2017.2699944 [32] Gerald Matthews, Lauren Reinerman-Jones, Julian Abich IV, Almira Kustubayeva “Metrics for individual differences in EEG response to cognitive workload: Optimizing performance prediction” Personality and Individual Differences 118, 22–28, 2017 https://doi.org/10.1016/j.paid.2017.03.002 [33] Dragoljub Gajic, Zeljko Djurovic, Stefano Di Gennaro, Fredrik Gustafsson “Classification of EEG Signals for Detection of Epileptic Seizures Based on Wavelets and Statistical Pattern Recognition” Biomedical Engineering: Applications, Basis and Communications, (26), Published 21 February 2014 https://doi.org/10.4015/S1016237214500215 [34] Prof. Shamla Mantri,Vipul Patil, Rachana Mitkar “EEG Based Emotional Distress Analysis – A Survey” International Journal of Engineering Research and Development Volume 4, Issue 6, PP. 24-28, October 2012 [35] Fares Al-shargie, Tong Boon Tang, Nasreen Badruddin, Masashi Kiguchi “Mental Stress Quantification Using Eeg Signals” ResearchGate Publication 2016, from book International Conference for Innovation in Biomedical Engineering and Life Sciences: ICIBEL2015, Putrajaya, Malaysia, (pp.15- 19), 6-8 December 2015 https://doi.org/10.1007/978-981-10-0266-3_4 www.astesj.com 129