EEG-based Brain Computer Interface Prosthetic Hand using Raspberry Pi 4

Accidents, wars, or different diseases can affect upper limbs in such a manner so their amputation is required, with dramatic effects on people’s ability to perform tasks such as grabbing, holding objects, or moving them. In this context, it is necessary to develop solutions to support upper limb amputees to perform daily routine activities. BCI (brain-computer interface) offer the ability to use the neural activity of the brain to communicate or control robots, artificial limbs, or machines without physical movement. This article proposing an electroencephalography (EEG) mind-controlled prosthetic arm. It eliminates the drawbacks like the high price, heaviness, and dependency on the intact nerves related to the myoelectric and other types of prostheses currently in use. The developed prototype is a low-cost 3D-printed prosthetic arm controllable via brain commands using EEG-based BCI technology. It includes a stepper motor controlled by Raspberry Pi 4 to perform actions like open/close movement and holding objects. The project has successfully implemented and achieve the aim to create a prototype of a mind-controlled prosthetic arm system in addition to the necessary experimental tests and calculations regarding torque, force, and the weight that the hand can carry. The paper proves the feasibility of the approach and opens the route for improving the design of the prototype to attach it to the upper-limb amputation stump. Keywords—Prosthetic; brain computer interface (BCI); electroencephalography (EEG); raspberry pi 4; EMOTIV


I. INTRODUCTION
A lot of current prosthetic arms like myoelectric are still expensive, heavyweight, and difficult to use. This paper is an attempt to overcome such drawbacks using EEG-based BCI technology. BCI is an interesting field of research and applications [1] that can help in creating a new way of communication for persons with severe disabilities [2]. The field of BCI has witnessed a great interest especially concerning robotic devices control, with particular focus on health applications, where the utilization of BCI to control prosthesis devices is increasing the quality of life for the patients suffering from diseases causing permanent/temporary paralysis or suffering from the loss of the limb [3]. In such medical cases, the use of BCI gives great independence to patients with severe motor disabilities, providing them with the ability to control external devices such as prosthetic arms [4].
A BCI system, consisting of hardware devices and artificial intelligence software [5], uses several signal sources or techniques to record brain activity. Among these, the electroencephalography (EEG) method offers an appropriate signal along with stability and non-clinical risks [4]. EEG is a non-invasive technique for monitoring the activity of the brain. It uses electrodes placed on the scalp to measures the voltage variation of the brain neurons caused by the ionic current. An EEG device, generally in the form of a headset, records the brain waves of a person when he/she is thinking of a particular action or implementing a muscle movement. These waves are converted into commands to control an external device in real-time. The EEG method is costly effective, accurate, and gives the patient complete control [3]. It also offers the user the possibility of taking off the EEG device when feeling inconvenience [6]. EEG-based BCI plays an essential role in the area of prosthesis control [7], managing the interaction between the patient and the device without requiring an invasive surgical procedure to reconnect nerves and allow amputees to control their prosthesis [6].
Many upper-limb amputees depend on prosthetic hand/arm to restore some of the functionality needed to perform their daily activities. These prostheses still provide less than 50% of the ability of an intact limb despite the increasing enhancements and sophistication. Therefore, frequently rejected due to fatigue and frustration of using them [8]. www.ijacsa.thesai.org In this context, the primary goal of this research is to operate and control a 3D-printed prosthesis hand using EEG signals detected from the brain. This would help in developing the next generation of prostheses [9] as new materials are appearing and being used [10]. 3D printing is commonly used in many medical applications like prosthesis, implants, surgical, etc. [9,11,12], orthotics field also benefitting the advantages of this technology customization to patient need and anatomy.
The use of brainwave signals for controlling prosthetic upper limbs is reported in the literature for different applications. Elstob et al. [12] presented a solution for controlling a five-degree freedom 3D printed prosthesis hand based on the use of EMOTIV EPOC+ EEG headset for detecting brain activity and Arduino Uno as a microcontroller. They also proposed two different software frameworks to control the prosthesis hand.
Beyrouthy et al. [13] have introduced a smart 3D printed prosthesis arm controlled via brain EEG signals obtained by using an EMOTIV EPOC headset. Smart sensors and actuators have been equipped to the arm to give the arm amputee smart feedback regarding the surrounding environment. Raspberry Pi III and Arduino Mega were used to control the prosthesis arm.
Bright et al [14] have developed a low-cost EEG braincontrolled prosthesis arm using a Neurosky Mindwave headset. The prosthetic arm has two main fingers' movements: flexion and extension. Arduino Uno has been used as a microcontroller to control several servo motors to carry out commands.
Chinbat et al. [15] have used Arduino Uno as a microcontroller and EMOTIV EPOC as an EEG headset to control the prosthesis arm via brain commands. The prosthesis arm is a low-cost 3D printed arm that contains smart sensors and actuators to give the arm amputee feedback to the surrounding environment. The prosthetic arm has six movements which are the movement of each finger individually and close all the fingers.
Mariacarla Staffa et al. [3] have proposed a novel approach to control open and close actions of a prosthesis hand. They used an Arduino Uno as a microcontroller, and EMOTIV EPOC+ headset to record brainwaves. They also proposed a "Weightless Neural Network-based classifier" for supervised classification. The experimental results showed that it is proper to use "WiSARD-Classifier" as a referring model for EEG signal classification.
More recently, Parth Limbani et al. [16] have developed a prosthesis arm controlled by brainwaves. They used a NeuroSky mind wave mobile sensor to obtain the EEG signals. An open-vibe software platform has been used for signal processing and classification. Python script has been used to send data from open-vibe to the Arduino microcontroller to control the prosthesis arm. They used a 3D printed arm made of PLA material with an overall weight of about 300 gm without motors.
Literature survey showed that the integration between BCI and prosthesis is a new and promising direction of study. It was also observed that improvements are needed to increase the control efficiency while reducing the complexity of the system. In this context, this research proposes a solution that eliminates the external wireless modules and uses Raspberry Pi 4 only without an Arduino board. Several degrees of force for the finger movements were considered, and force and torque were calculated to determine the maximum gripping force and the maximum weight that the prosthetic hand can take.

II. MATERIALS AND METHODS
In this research, EEG was selected for prosthesis arm control as it provides a dynamic continuous neural activity with high temporal resolution [17]. The schematic representation of the "BCI-controlled prosthesis arm" is presented in Fig. 1.

A. EEG-based BCI Headset
The BCI tool used in the system is the "EMOTIV™ Insight headset" (Emotiv, USA). The "5-channel EMOTIV™ Insight headset" with semi-dry polymer sensors has an internal sampling rate of 128 samples per second per channel was used for experiments. This tool was specially built to allow the use of BCI and research, filtering the signals and wirelessly sending the data to the computer, which offers portability [17]. This mobile EEG headset offers whole-brain sensing and advanced electronics to produce clean, strong signals. The headset can be connected to computers, tablets, and phones. It uses "Bluetooth Low Energy" or "2.4 GHz wireless" (with dongle) to connect. Also, its "LiPo battery 450 mAh" is designed to last for eight hours of functioning. The electrodes of the headset must be placed on the scalp (see Fig. 2) to read the brain activity from the head. The raw gathered information is passed to the Processing Unit over a Bluetooth connection.

B. Stepper Motor
The motor used in this system is the KH42JM2 stepper motor (see Fig. 2). It is a Uni-polar stepper motor with high torque, low vibration, and low noise [18]. It is connected to the L298n stepper motor driver since 12V is required to operate the motor.

C. Processing Unit
The Processing Unit is a computer. The main function of the Processing Unit is to processes the EEG signals. Signal processing techniques are needed to eliminate the noise and artefacts from the raw EEG signals. This is done by applying digital filters. Feature extraction is where the system is responsible for the transformation of the pre-processed brain signals into feature values matching the underlying neurological mechanism. These characteristics are used by BCI to command output devices of the prosthesis arm [17]. "Raspberry Pi 4 Model B" is a fast, and powerful microcomputer that provides high-level performance that makes it an excellent choice for different control projects.

E. L298N Motor Driver
"L298N" is a high-power engine driver module. It is used to drive stepper motors as well as DC motors. It is composed of an "L298" motor driver IC and a "78M05" 5V regulator (see Fig. 2). This motor driver module can command up to 4 DC motors, or 2 DC motors with directional and speed control [19]. It is connected to the 12V stepper motor used in this system.

F. Prosthetic Hand
The prosthetic hand used in this system is a low-cost 3D printed prosthesis hand made of Polylactic Acid (PLA) -a biodegradable, strong, and durable lightweight material. The prosthesis has been developed in a project [20].
The prosthesis hand can perform actions like hand-shaking and picking up objects due to its hand close and hand opening movements (see Fig. 3). This is a prototype of the prosthesis hand that is intended to be developed in the future.  III. SYSTEM IMPLEMENTATION This system consists of four important parts. The first one is the brainwave headset provided by EMOTIV™, the second one is the signal processing part which is carried out on the computer using EMOTIV™ cortex API, and Python for programming, the third part is the Raspberry Pi 4, and the last part is the prosthetic hand.
First, the computer is connected to the Raspberry Pi 4 through a wireless connection for commands transmission and to control the GPIO pins of the Raspberry Pi 4. Fig. 4 shows the circuit diagram of the connection between the stepper motor and Raspberry Pi 4. The stepper motor operated as a bipolar since one coil of the motor connected to the OUT1 and OUT2 of the motor driver, and the other coil connected the OUT3 and OUT4 of the motor driver.  Sampled "EMOTIV™ EEG" signals are sent using a wireless connection to the computer that handles the processing part. Signal processing techniques are applied for noise and artefacts reduction on the raw "EMOTIV™ EEG" signals utilizing digital filters (Data acquisition and digital filtering module in Fig. 1). Feature extraction (module with the same name in Fig. 1) is where the system is responsible for transforming the pre-processed brain signals into feature values that match the underlying neurological mechanism. The features extracted from the headset are dispatched to the Raspberry Pi 4. Two commands were trained to control the open and close movements of the prosthesis hand. The problems encountered to control GPIO pins of the Raspberry Pi 4, especially with RPi.GPIO module were solved by using Secure Shell Protocol (SSH) to create and provide a connection channel between the computer and the Raspberry Pi 4. Python scripts are used on both computer and Raspberry Pi 4. Two Python scripts (one for hand open and the other for hand close) have been written for the Raspberry Pi 4 to control www.ijacsa.thesai.org the GPIO pins thus controlling the stepper motor. The Python code running on RPI (in Raspberry Pi 4) shown in Fig. 5 illustrates how to define the Raspberry Pi 4 GPIO pins where the stepper motor is connected, control the speed and the sequence of the motor where half step sequence has been used. When a user thinks to close or open the prosthetic hand (see Fig. 6), the control signal transmits via a wireless connection through SSH from the computer to the Raspberry Pi 4 to run the required Python script.

IV. FORCES AND TRANSFER OF TORQUE
To calculate the necessary force and torque applied by the motor to move the fingers, and the maximum weight that the hand can carry, a force calculation, and laboratory test was conducted by making the prototype hold different weights. At a mass of 0.2 kg, each finger required approximately 1.962N to close, and about 9.81N in total (all fingers). However, to grip and hold objects, the force would need to be increased, about 20N (by experiment). As mentioned in the motor datasheet, the torque of the motor is 0.26Nm which is not large enough to apply appropriate gripping force; therefore, it was necessary to add a gear with a 2:1 ratio.
The KH42JM2 stepper motor used in this system is the most appropriate one due to its high torque, low vibration, and low noise. The relationship between speed and torque is inversely proportional. To gain higher torque, 1 2 gear ratio has been used to calculate the speed of gear since using 2 1 will give higher speed and thus lower torque. The torque transferred by the gear is: The same procedure is applied using different mass values as shown in the Table I. As shown in Fig. 7, when mass increases, the gripping force increases (linear).
According to the stepper motor specifications, the maximum torque meets 150N. If mass increases, this may damage the stepper motor or crash the prototype. The human hand can take a load of 2-3 kg easily. The force which can be applied by human hand will be: = .
= 3 * 9.81 → 27.24 Gripping forces: = (27.24 + 1) * 5 → 141.5 In conclusion, the current prototype can hold 330 g (see Fig. 8) because the plastic wires used to move the fingers have lost their elasticity by time and usage. To make it handle some weight like a human hand, micro stainless-steel wires should be used. This will give the prototype the necessary elasticity and gripping force as calculated above, similar to the one of a human hand. Comparing to related works, most articles focusing on building a functional EEG-based BCI prosthetic arm without calculating or giving detail regarding torque, force, and the weight that the hand can carry. This paper has successfully achieved the aim of implement a mind-control prosthetic arm giving details and calculations regarding force and the maximum weight that the current prototype can carry to mimic the natural human hand. Additional experimental tests are intended to be achieved regarding measuring the gripping force of the hand using a hand-held dynamometer which is necessary to determine the required gripping force to grasp objects. This is the subject of further work. V. CONCLUSION AND FUTURE WORK EEG-based BCI systems are still quite a new trend, especially in medical fields. In this paper, a structure and implementation of a mind-controlled prosthesis hand system have been presented. The prosthesis hand is made of strong and lightweight materials. The prototype contains one stepper motor controlled by Raspberry Pi 4 to perform open hand and close hand actions. Furthermore, significant experimental tests have been done on the prototype to determine and calculate the torque, force, and maximum weight that the hand can hold. As a result, this implementation has successfully achieved all the aims to create the prototype system of the project.
As future work, the prosthetic arm should be built with more movements involving movement of each finger individually and wrist movement using servo motors. The 3D printed hand design could be improved, so that the Raspberry Pi 4 board, servo motors, and the battery can be placed inside the arm. The entire system structure will be improved to eliminate the computer and to use Raspberry Pi 4 instead as processing and controlling unit. Moreover, the hand-held dynamometer should be used to test and calculate the griping force for the current prototype. All these tests and results will be used to design the next version of the 3D printed prosthetic hand with more improvements. Based on the prototype and considering the user's requirements, the goal is to develop a mind-controlled prosthesis upper limb using non-invasive EEG-based BCI, which is accurate, inexpensive, user-friendly, and smart. This prosthesis design will be optimized for reducing its weight and for allowing an easy, rapid, and stable fixation on the amputee stump.