Design and Implementation of a Prosthesis System Controlled by Electromyographic Signals Means, Characterized with Artificial Neural Networks

Around the world many people loss a body member for many reasons, where advances of technology may be useful to help these people to improve the quality of their lives. Then, designing a technologically advanced prosthesis with natural movements is worthy for scientific, commercial, and social reasons. Thus, research of manufacturing, designing, and signal processing may lead up to a low-cost affordable prosthesis. This manuscript presents a low-cost design proposal for an electromyographic electronic system, which is characterized by a neural network based process. Moreover, a hand-type prosthesis is presented and controlled by using the processed electromyographic signals for a required particular use. For this purpose, the user performs several movements by using the healthy-hand to get some electromyographic signals. After that, the obtained signals are processed in a neural network based controller. Once an usable behavior is obtained, an exact replica of controlled motions are adapted for the other hand by using the designed prosthesis. The characterization process of bioelectrical signals was performed by training twenty characteristics obtained from the original raw signal in contrast with other papers in which seven characteristics have been tested on average. The proposed model reached a 95.2% computer test accuracy and 93% accuracy in a real environment experiment. The platform was tested via online and offline, where the best response was obtained in the online execution time.


Introduction
In 2017, around 57.7 million people in the world suffered the amputation of a limb due to traumatic cases [1]. This means that affected people see the quality of their lives diminished, being of great importance to design prostheses that may be set to each particular situation. Moreover, the design of prostheses which can be controlled and can react in a "natural" way, regarding the required complex motions of mechanisms, is of paramount interest.
For this purpose, the use of bioelectrical electromyographic (EMG) signals is proposed as element of control. EMG signals are generated by every muscular contraction. Then, the user could control the prosthesis in the same way that would react if had the body member.
From above, development of bio mechatronic prosthesis with EMG signals is presented in this manuscript, being a way to get each movement and particular bioelectrical representation that can be characterized to obtain signals that can be used as commands. characteristics extraction of the raw EMG signal, the input vector of used neural network, and the signal process development are described. In Section 4, experiments and data acquisition are shown, analyzing the obtained results by showing a comparison with other similar proposals. Finally, in Section 5 the conclusions to analyze the improvements obtained and future work are stated.

Preliminaries
This section presents the preliminaries for better understanding of the proposed prosthesis. Focusing on artificial neural networks and electronic filters.

Filters
Electronic filters allows passing or suppressing a certain set of frequencies, such as lowpass (signals with high frequencies are suppressed), high-pass (signals with low frequencies are suppressed) and band-pass (allows the passage of a set of frequencies, delimited by a lower and an upper limit). For instance, in Figure 1 a low-pass filter was used to decrease the presented noise of the signal, allowing only the one belonging to the required signal. Depending on the type of components used, there are passive and active filters. The passive ones only contain resistive, capacitive, and inductive elements, while the active ones contain active components, that are typically operated and tuned by using operational amplifiers. Regarding active filters, three of the most used active filters are: Butterworth, Bessel, and Chebyshev. If an ideal low-pass filter existed, all the active filters would eliminate signals above the cutoff frequency, and perfectly pass signals below the cutoff frequency. However, in a real situation, many trade-offs should be considered to get the optimum performance for a given application.
In this work, the Butterworth filter is used to obtain the required signals of the user body, since they are easy to handle at many real time applications [21,22]. Then, these obtained signals are used on the artificial neural network.

Artificial Neural Networks
The simplest model of a biological neuron is the well-known perceptron, introduced by Frank Rosenblatt, which emulates a neuron behavior by reproducing its main characteristics. In this model, the information reception through different inputs P 1 , P 2 , . . . , P n , as they were dendrites to stimulates the neuron nucleus, and the final value depends on an active response (1) or inactive response (0) of the neuron. Thus, the mathematical representation of the neuron activation function can be defined as where W 1 , . . . , W n are the synaptic weights, and b is the bias of the neuron. A schematic representation of perceptron can be seen in Figure 2. In this work, a supervised learning was implemented for the training process of the neuron, i.e., the output values for a set of input data are known by the designer. Then, if the expected output z is different from the obtained output y, an error e = z − y = 0 is obtained and the synaptic weights of the neuron are adjusted as result of this error. Such that, W i = W i + γeX i where γ is the learning factor, and X i are the inputs.
This adjustment is performed while e = 0. When e = 0 in all cases, a trained neuron is obtained. From this neuron, that is the minimum unit, more complex configurations can be built by interconnecting them, giving way to artificial neural network architectures.
An ANN is a computational scheme that emulates the learning process of a biological brain. Also, the ANN are connectionist systems, i.e., interconnection of different independent neurons is performed, until a network of neurons communicated by means of synaptic weights is arrange, a neural network general scheme can be seen in Figure 3, which basically consists of the input layer, the output layer, and the hidden layers. The neurons number in the input layer is conditioned by the number of elements in the input vector with which was trained. The number of neurons in the output layer corresponds to the classes or classification sets number that the problem contains. Finally, the neurons number in the hidden layers will depend on the nature and complexity of the addressed problem. Before an ANN can classify a behavior or structure, it must be trained, which means that a user must told it what to learn. To carry out this training, it is necessary to enter many phenomena or problem known cases to be learned, the network will adjust itself in such way that it will learn that for a set of inputs, there is a certain output. The cases with which a network is trained are stored in a dataset, and the ANN will obtain all the information from such dataset.

Materials and Methods
This section presents the entire design and development process of the proposed system, from the electronic to the artificial learning part and its implementation. The neural network that controls the prosthesis needs to be fed by a database to work and be able to learn to replicate the desired movements. In this case, the signals database is captured from the user who performs different muscle contractions movements. For this reason, it is necessary to design an electromyographic signal sensor that obtain and adapt such signals to be processed and stored, in order to be used for training the neural network. The design of this sensor is presented.

Electromyographic Sensor Design
To design an electronic device capable of sensing small electromagnetic variations, the obtained EMG signals were amplified, filtered, and conditioned to be used by an Arduino board.
To replicate the movements for a hand, different types of sensing methods can be used for this purpose, such as cyber gloves [30], cameras [31], and electromyography [32]. The electromyography was the used method in this paper. Despite the available EMG sensors on the market, such as Myoware and Oymotion, in this proposal the own EMG sensor is made to obtain a raw signal for the Arduino development board. To design this sensor, five stages are considered to condition the signal: pre-amplification, signal filtering (low-pass and high-pass filters), final amplification, and offset. Each stage in the signal cleaning process is described as follows.

Pre-Amplification
This stage is the first contact with the signal and the subsequent processes. Thus, instrumentation amplifiers are used, and their working conditions are design by using ideal amplifiers conditions, as infinity input impedance, zero impedance output, high ratio rejection, and highly gain voltage, all this to prevent added noise to the amplified signal. An amplifier of this type can be purchased commercially, however, an own amplification system is designed to adapt it to the needs of the project, this is done by using LM833 operational amplifiers.
The general amplification circuit, based on the EMG sensor, is divided in two amplification stages, due to, if all the amplification is carried out in a single stage, saturation would be generated in the output, and consequently an EMG signal loss. Figure 4 shows the amplification circuit designed with LM833, which serves as a signal pre-amplifier. Where V3 is the output signal given by, where V2 and V1 are the circuit's input voltages, R 1 , R 2 , R 3 , R 4 are resistances for amplification setting. From Equation (1), it is possible to notice that the gain depends on R 2 , but the variation depends on R 1 , if R 3 = R 4 is considered.

Third Order Low-Pass Butterworth Filter
A raw signal is susceptible to noise and contamination, so it should be conditioned before using it, for that reason a pre-amplification stage is proposed where a Butterworth active filter is used to filtering and discarding frequencies and values that do not give a representative value on the input signal. Later, the following must be considered: higher order filters, use a higher number of operational amplifiers, resistors, and capacitors. Considering this, it is decided to design a third order filter, which needs less components, and has an adequate cutoff frequency response. A cutoff frequency of 500 Hz is established to eliminate noise caused by electronic equipment and electronic components of the sensor itself. Figure 5 shows the designed filter. A simulation of this filter is performed by using R = 12 kΩ, C 2 = 47 µF, C 3 = 4.7 µF, and a LM833N amplifier where is obtained that the real cutoff frequency is at 471 Hz, since the EMG frequency interest range is between 0 to 500 Hz and the greatest amount of information is between 50 Hz and 150 Hz, this cutoff frequency is acceptable. This filter has a 61 dB drop per decade.

Third Order High Pass Filter
A high pass filter should be designed for better signal matching and handling. Then, a cutoff frequency of 20 Hz is established, this cutoff frequency is selected to eliminate the noise caused by the movement of the cable that connects the electrode and the skin. The electrical signals from both noise sources have most of their energy in the frequency range from 0 to 20 Hz. The designed circuit is shown in Figure 6. Simulation of this filter is carried out to obtain that the real cutoff frequency is 22.7 Hz, the filter has a drop of −60.3 dB per decade.

Non-Inverting Amplifier
In the second amplification stage, a non-inverting amplifier is made, which is designed to deliver a minimum gain of 1 and a maximum gain of 30 according to the R 2 potentiometer value of 20 KΩ, the amplifier design is shown in Figure 7.

Offset (Non-Inverting Summing Amplifier)
Once the signals are amplified and filtered, an EMG signal is available, which consists of positive and negative voltages, but is not compatible with the chosen microcontroller device, Arduino. To adapt this signal and avoid microcontroller damage, one last conditioning signal stage is necessary, consisting of a non-inverting summing amplifier. An offset circuit that equalize all the resistances, raises the potentiometer's voltage, this allows placing the signal at 2.5 V as a new reference, obtaining an EMG signal ready to be processed by the Arduino, the designed offset circuit from 0 V to 9 V is shown in Figure 8.

Neural Network Design
Considering that the amplified signals are obtained and adapted, they are stored within a dataset and used for training the neural network, however, for a better neural network learning and classification, is necessary to extract certain signal characteristics so that the ANN training be adequate and functional. Due to this, using different techniques and algorithms, 20 main characteristics are extracted from each user signals obtained. When these characteristics are obtained, a representative vector is created, and stored in a dataset training and therefore feeds the neural network input.

Extraction of Features
The extraction of characteristics is recommended since they are chosen according to the needs of training and operation of the neural network, for this reason the characteristics extracted from the raw EMG signals and the way to obtain them are described. The 20 characteristics extracted from the raw EMG signal to create the input vectors, in order to train the neural network. Table 1 shows the selected characteristics to be extracted, then a brief explanation of the way in which each of them are calculated is shown in this section.

Mean absolute value (MAV):
It is the sum of each segmentx i of N samples of a signal. Where x k is the k-th sample in segment i, and I is the total number of segments.

Zero crossing (ZC):
It is the number of times the waveform crosses zero. To obtain the result, a comparison is made between two consecutive sections of the signal x k y x (k+1) , such that: A work related to this concept is presented in [33], which is focusing on EMG signals. Slope sign change (SSC): Similar to ZC, but now measuring sign changes between signal elements.
Waveform length (WL): It is the sum of the differences between values of consecutive samples of the EMG signal, up to the last sample. It is obtained as follows.
. P-order auto regressive model AR(P): It is used for a random process representation of a model in which the main variable depends on its past values and it is possible to obtain the coefficients of the auto-correlation function a i , P gives the order, and e(k) is the element error.
Fast Fourier Transform (FFT): Fourier transform allows a signal to be broken down into its individual components, in such way, it is possible to obtain information that would otherwise be hidden itself within the signal. It is defined as: x n e − 2φi N kn , k = 0, . . . , N − 1 where x n is the sampled signal for specific discrete time. A fixed period time sampling was taken to obtain the estimate of the power spectral density, and thus have the characteristics of energy and average power.

Short time Fourier transform (STFT):
It separates the original signal into sections, each of these sections is analyzed by means of the Fourier transform, and each section characteristics are extracted independently. This analysis can be obtained as follows: where w(t) is the window function.
Spectrogram consists of acquiring a certain number of samples through a temporary window, with a specific size. The frequency content is determined for these samples, and they are represented in a three-dimensional graph. Performing this same operation on the total length of the signal. This process gives us frequency information and the variation of energy. For this study, the short Fourier transform of 3-time windows of the EMG signal is obtained, using a standard rectangular window, from each, two characteristics are extracted, the energy and the average power, elements that compose the input vector of the ANN to train the system. Discrete Wavelet Transform DWT: Wavelet continuous transform (CWT), express a continuous x(t) signal as an expansion of coefficients proportional to the product between the signal x(t) and the scaled and displaced version of the mother wavelet ψ (a,b) , where a is the scale parameter to compress or expand and b is the translation parameter that moves the Wavelet. Discrete wavelet transform (DWT) is obtained by discretizing the CWT. The values a = 2 −j and b = k2 −j are usually used to discretize for parameters a and b, hence the mother Wavelet takes the form: Thus, the Wavelet ψ(t) with a scale function φ(t), is associated, which allows us to approximate any function x(t) with these functions, by means of the expression: where c (j,k) are the scale or approximation coefficients, and d (j,k) represents the Wavelet or detail coefficients of the original signal x(t), with respect to the scale function φ(t) and the Wavelet function ψ(t).
The behavior of the DWT is like a "filter banks". Such filters correspond to a low-pass and a high-pass filter, when the original signal passing through them, the output coefficients c (j,k) and d (j,k) respectively, are obtained. A decomposition of the signal can be obtained at different levels by passing the scale coefficients obtained from the previous filtering by an identical pair of filters, thus obtaining the coefficients of the next level.
The Wavelet selected for this article is Daubechies D5, which will provide us with five approximation coefficients and five detail coefficients, for each of the 5 approximation coefficients the variance calculation has been performed.

Experimental Platform
The experimental platform is shown in Figure 9, and it consists of an Arduino Nano board, this card has an ATmega328 microcontroller of AVR architecture. The analog to digital converter has a resolution of 10 bits, with a conversion range voltage of 0 V to 5 V. Pins 5, 6, 9, 10, and 11 are used for servomotor control, and analog pin 2 for EMG signal acquisition. To obtain the EMG signals, low-cost self-adhesive silicone gel electrodes are used, which are reusable, 10 of these worth approximately 7.5 USD. A complete cleaning must be carried out in the area to be placed to keep the skin clean each time a user wears it.
In Figure 10 the electronic circuit schematic built for the control of the hand is presented. Additionally, a complete amplification circuit for sending filtered and conditioned signals to the microprocessor is performed by using a perforated phenolic prototype board.

Results
This section shows the implementation and tests carried out with the EMG signals sensor. To carry out the tests, Simulink/MATLAB software version 2020, Mathworks, (MATLAB Central, Mexico) was used together with the Toolbox Simulink Support Package for Arduino Hardware, with this it is possible to carry out oscilloscope simulations and correctly adjust the signals from electrodes. This is done by adjusting the three potentiometers with the resistive values described in the design of the high-pass and low-pass filters.

Implementation and Testing of EMG Sensor with MATLAB
Users must place the electrodes on the arm to obtain the system signals and send them to the computer that are displayed through an oscilloscope made in Simulink/MATLAB. Figure 11 shows the used position to extract the EMG signals, where the V1 and V2 electrodes must be placed in the muscle in which the EMG signals are acquired, and the GND electrode in a nearby area. It is important to emphasize that it must be an area where the muscle is not working. The proper location for the electrodes is between the innervation zone (or motor unit) and the tendinous insertion, or belly of the muscle [34]. Once the EMG signals are obtained, they are displayed on the oscilloscope designed in Simulink, adjustments are made to adapt the values and the signal can be acquired properly. The final values are as follows, for a gain of 31 in the preamp stage, potentiometer is adjusted to 27.64 Ω and for a gain of 21 in the final amplification, potentiometer is adjusted to 13.6 KΩ, giving a total gain of 735. It is also important to notice that the final applied offset is 1.5 V with a potentiometer resistance of 3.3 KΩ . Then, the gains are tuned, tests are carried out that consist of moving the fingers of the hand with small force and the acquired signals can be observed in MATLAB oscilloscope as shown in Figure 12.

Data Acquisition
Once the signal is acquired satisfactorily, the integrated microcontroller development environment (IDE) is used to create a program that process the muscles signals sent by the electrodes. The acquired signal is discretized by the acquisition system and is important to guarantee that the signals characteristics can be reconstructed, for that reason, the Nyquist theorem is used, this theorem indicates that the sampling frequency must be at least twice than the frequency of the signal that will be reconstructed. The frequency limits that the designed EMG sensor circuit admits go from 22.7 Hz to 472 Hz, where The sampling velocity of created program is 1 kHz, this signal is acquired each time it is requested by MATLAB , the number of samples sent is 60,000 in 60 s, these are sent through the serial port. Each sample generates 2 bytes, so a total of 120,000 bytes are sent over 60 s.
A Simulink/MATLAB interface was created, which is responsible for receiving the sampled signal by the Arduino board, this interface stores the information in matrix structures. Each hand movement generates a particular signal, these are stored in a labeled matrix to identify which movement was generated, these are: closed hand, grip, index, middle and ring finger movement. These movements are shown in Figure 13. We generated a database or "dataset" with the signals of each of the described movements, 50 samples of each movement are collected, with 500 sampling points each. Once obtained, sequences of the same movement are generated and saved as a single vector. Figure 14 shows the obtained sequences. A windowing process is applied to each of these signals (Figure 15), which consists of delimiting only the area of interest and cutting the linear part that does not have information of the muscular effort to be analyzed. In this way, all 500 samples are saved, and the storage is optimized by reducing each signal to only the part of interest. Such signals are stored in arrays for later analysis within a neural network.
Finally, dataset is generated with each structured vector from the extracted characteristics of each movement signal, previously defined and the input array for the neural network is created. In total, 250 signals are obtained, which are divided into 250 vectors of 20 characteristics each, therefore, there is a 20 × 250 matrix.

Training of the Neural Network
This section describes the neural network process training with the dataset obtained and described in Section 4.2.
For the hand movements characterization, a supervised neural network for pattern recognition is created, with a trainlim training function. The network has a 20 neurons input layer, automatically adjusted by the algorithm according to the dataset, there is a 15 neurons hidden layer defined in the program, with a sigmoid activation function and a 5 neurons output layer with a gradient descent function. In Figure 16, the network architecture is shown, as well as its training parameters. The original dataset was divided in two subsets: 60% for training data and 40% for validation, discarding a test subset. From these sets, the generated confusion matrix is observed in Figure 17. It can be seen that in the characterization of these 5 movements, an adequate response was obtained, which achieves a success rate of 95.2%. Notice that before select the training function (TF) mentioned previously, it was necessary to compare and choose from different TF. It is difficult to obtain the best neural network architecture to solve a problem, however, tools like MATLAB has efficient training function which can be used to determine the best suited to our problem. In this case, five TF were analyzed in order to determine which one would be used on the prosthesis. The different TF were implemented in a feedforward neural network.
To make the selection process of the best TF, a database with the hand movements signals has been used, the dataset has been divided into 60% training, 20% validation and 20% testing. The executed TF's and the data obtained from each are shown in Table 2.  Table 2 shown that the Levenberg-Marquardt algorithm corresponding to the trainlm TF, presents the best precision results, being the algorithm used in this approach. Figure 18 shows the performance metrics for each of the TFs, and Figure 19 shows the confusion matrices for each of these TFs.

Emulation of a Human Hand
With the obtained signals and the hand movements characterized by the previously described neural network, a human hand prosthesis was created to verify the operation of the ANN that emulates the hand movements. In order to physically check the movements generated by the neural network, a prosthesis is developed that consists of 5 servomotors, 5 fingers with three phalanges each, which mimic the fingers and hand movements. The neural network sends the necessary signals to the servomotors to replicate the indicated movements, this developed prosthesis is shown in Figure 20. Real environment operational test is carried out by performing 90 random movements, taken from the previously described in Section 4.2. Where 84 movements were correctly replicated and 6 were incorrectly performed, obtaining a 93.3% of assertiveness and 6.6% of error. This is according with the efficiency percentages obtained in the training and validation.
The EMG signal characteristics extracting, and neural network training methods are compared with others to analyze and demonstrate that the used method has an adequate response and is at least as effective as the most efficient known methods. This comparison is shown in Table 3.
This proposal shown similar efficiency to the others, despite having more features per input vector, the efficiency has not been significantly increased. This is interesting, since it could be deduce that there is a maximum number of characteristics that significantly influence the way in which neural networks learn the behavior of EMG signals, a problem that will be investigated in a future work. Notice that the acquisition and experimentation system is a low-cost designed, even so compared to other prototypes and authors that used more expensive EMG sensors our present better response. This fact can lead to the conclusion , that hardware may not have such an influence on the EMG signals characterization success and that the efficiency rate depends only on the neural network training and learning.

Online Execution
Online system testing is performed by using the MATLAB Online tool in which the same offline code is used and the same data is loaded in order to verify the behavior of our system in an online environment. Which will be used as a node of the Internet of things in a future work.
To obtain the system's efficiency in the online environment, about 70 random tests are carried out, where a better behavior in temporal response is obtained. Table 4 shows online and offline tests, the time showed on it, is a mean value.
It can be seen in Table 4 that the online execution time is better than offline execution, in this case, the algorithm was executed in a computer with 6 GB DDR RAM memory and an AMD A8-6410 processor running at 2.4 GHz, which can be an important factor to obtain such results. Notice that the online execution process controls the designed prosthesis in the same way as the offline execution, which is an important fact related to our system.

Conclusions
This manuscript presents an entire EMG signal acquisition system design, which considers the integration of sensor, filtering, and information transmission systems, selection of the adequate algorithm, also shows the EMG signals characterization by neural networks and the online and offline prosthetic hand control using such characterizations.
The neural network training is carried out with vectors that contains 20 extracted features from the raw EMG signals, achieving a 95.2% accuracy in practices and validation, and 93% accuracy in a real environment experiment. Although there is a high response reliability percentage and more features were used for training, the response has not been improved significantly compared to other proposals that only use 6 or 7 features in their training vectors. Which leads to question; there exist an optimal evaluating features number to obtain high efficiency without sacrificing time and processing resources?
The system was evaluated with online and offline executions using MATLAB toolbox, in order to have a homogeneous behavior, observing that the offline execution had better execution time, but both of them control adequately the designed prosthesis.
The development of a low-cost hardware system goal is fulfilled, the performance shown is better than some high-cost professional hardware systems. Which is an advantage for prosthesis implementation and encourage their use in poor or developing countries. Figure 9 shows the entire system developed, i.e., the electronic circuit, the prosthesis and the power supply.

Future Work
The proposed solution can be extended to explore the sensor channels number, which it may has a direct influence with the extracted features number.
The extracted features number optimization is proposed, and the creation of a prosthesis with materials that not only replicate the hand movements, but also be used by a patient in the future as a real hand, this include a better prosthetic hand development, made with additive manufacturing.
There are different methods to do a system recognition, as shown in [42], that would be worthy to test and compare the performance of those methods versus the proposed in this manuscript. Funding: This research was partially funded by UNAM PAPIME PE103322, UNAM PAPIME PE105822 and FESC CI2254.
Institutional Review Board Statement: Not applicable.

Informed Consent Statement: Not applicable.
Data Availability Statement: Supporting data is available via request to authors.