EEG signal amplification and interface with Arduino (Part 4/13)

Now that we have discussed all the basics of brainwaves along with the introduction of the brainwave sensor, it is time to move on to the subsequent topics. In this article, we will see how the brainwave chip works, what the expected algorithm inside the sensor should be and what we should do to manufacture such a sensor on our own with any microcontroller or processor.

Discussing the use of the sensor, its main purpose is to detect the brain waves or electrical signals near our brain area, filter them by removing noise and fluctuations and then convert the respective signals into their digital values. FFT power value data from 8 different types of Brainwave are sent serially into our sensor.

Now, we will take a look at the working of the sensor, which will explain the various blocks within the sensor that allow us to convert our brain signals into digital values.

Working

When signals are measured directly from our brain, the amplitude is in the microvoltage range. These signals also contain ambient noise and are also affected by the stray fields present in the area. We, as a body, also emit many other waves, which mix with the sensor and are part of the results. To get a clear signal from the incoming waves, we need to use many filters, amplifiers and a circuit to improve the results.

Following are the steps we need to follow to mimic the sensor and produce similar results.

Steps

1. Amplifier

2. High pass filter

3. Amplifier

4. Low Pass Filter

5. Analog to Digital Converter

6. FFT

7. Coding

8. Serial output

Let's take a look at these steps one by one.

AMPLIFIER

The instrumentation amplifier is used after the raw signals and brings many benefits compared to the simple differential amplifier. In the differential amplifier, the input impedance does not approach infinity. Furthermore, the input resistance at the inverting input is relatively low. Due to the unmatched input impedance, there is a big difference when compared to the non-inverting input.

Although we can increase the input impedance by making changes in the feedback resistance, but to get a gain of 10, we would need a resistance of 10M ohm, if the feedback resistance is 1M ohm. Also, my personal experience is that large resistors are very noisy and it is difficult to match them. Furthermore, large resistance sometimes causes parasitic capacitance.

In case of instrumentation amplifier, we can achieve infinite input impedance and high gain, both at the same time. The result is a circuit with high gain along with CMRR and input impedance. Instrumentation amplifiers are specialized in amplifying weak and noisy signals and are very suitable in our case where the signal is very noisy and of low amplitude.

Therefore, the first step is to apply an instrumentation amplifier with a gain of approximately 100. Thus, we can obtain a signal in the order of millivoltages that can later be read by our circuit and controller.

HIGH PASS FILTER

Now, after we get the amplified output, we need to start filtering the signal and keeping it within the desired frequency. First we will filter out all low frequencies using the high pass filter. We can use a simple passive RC high pass filter, but this will decrease the signal strength to a large extent, which is not desirable in our system. Therefore, we will use active high pass filter after the amplified signal.

We will filter out all frequencies below 0.1 Hz. Our Brainwave signal range is 0.1 Hz to 50 Hz. The lowest brainwave signals are delta waves with frequency range 0.1 to 3 Hz. The frequency cutoff in a high-pass filter is measured by the following formula:

Cutoff frequency = 1/(2*pie*R*C) in Hz

Therefore, we will set the RC values ​​so that the cutoff frequency is 0.1 Hz. In this way, we attenuate frequencies below 0.1 Hz. Now we are left with frequencies that vary from 0.1 Hz to infinity.

An additional benefit of active high pass filter over passive is that we can achieve amplification and gain control.

AMPLIFIER

Again we will use amplifier to amplify our signals. Here we can also use a differential amplifier, as our signal is not that small and the required gain is not on the order of 100. A gain of 5 – 10 is sufficient at this stage. Gain can be achieved by appropriate resistance values ​​and their proportions.

Our main task is to act as a repeater and give the signal more strength to continue processing.

LOW PASS FILTER

Now, after we get the amplified output, we need to start filtering the signal again and limiting the signal within the desired frequency of 0.1 Hz to 50 Hz. We have already limited it to 0.1 Hz. We can use a passive RC low pass filter simple but again this will decrease the signal strength to a large extent which is not desirable in our system. Therefore, we will use active low-pass filter after the amplified signal.

We will filter out all frequencies after 50 Hz this time. Our brainwave signal range is 0.1 Hz to 50 Hz. The highest brainwave signals are gamma waves with a frequency range of 38 Hz to 45 Hz. The cutoff frequency in a low-pass filter is measured by the following formula. This is the same as the high pass filter.

Cutoff frequency = 1/(2*pie*R*C) in Hz

Therefore, we will set the RC values ​​such that the cutoff frequency is 50Hz. This way we attenuate frequencies after 50Hz. Now we are left with frequencies ranging from 0.1 Hz to 50 Hz. We remove noise and stray signals, except in this frequency range. Although there are few signals in this frequency range that are not actual brain waves.

REFERENCE

We also put two probes in our ears. These probes will act as a reference voltage for our signal. The lost signals (noise and body) are also present in the signals captured by the ears. Now, the real signal is the difference between the EEG signal we captured and the reference signals. Reference signals must be subtracted from the EEG signal to obtain more suitable signals with less noise.

In the next step, we need to divide the signals into their specific frequency range so that we can get the signals of different types of brain waves. For example, for alpha waves we need to have signals in the range of 8 to 12 Hz, for beta waves we need to have signals in the range of 10 to 38 Hz and so on.

After successfully defining a range of 0.1 to 50 Hz, we will apply the same filtering technique on this signal and produce signals with the set frequency range with different types of brain waves. We will use high pass filter, amplifier and low pass filter to produce such signals. After completing the filtering of each step, we will have signals with a frequency range of 0.1 to 3 Hz, 3 to 8 Hz, 8 to 12 Hz, 12 to 38 Hz and 38 to 45 Hz.

ADC and SAMPLING

After we have obtained the different signals with different frequency ranges, now it is time to extract digital values ​​from them. We can use any controller for this with integrated ADC.

The built-in ADC automatically converts the signal's analog voltages to digital. Thus, in our controller we will have a sequence of digital values ​​of our analog signals of different waves. We need to save these values ​​in buffer for certain period.

Here the sampling rate will be defined by the delay we maintain between successive analog to digital conversions. We will try to keep it very low for more accuracy.

FFT

Once we have the digital values ​​of our signal, we will find out the FFT from these digital values. FFT stands for fast Fourier transform. An algorithm (FFT) calculates the Discrete Fourier Transform (DFT) of a sequence, or its inverse. Fourier analysis converts a signal from its original domain (usually time or space) to a frequency domain representation and vice versa. An FFT quickly calculates these transformations by factoring the DFT matrix into a product of sparse (mostly zero) factors.

Note: The FFT library is also available for Arduino

Consequently, we can have the FFT values ​​of all the different signals that we filter and manipulate.

SERIAL OUTPUT

After obtaining the FFT values ​​we will make a sequence and transfer them serially one by one. Most controllers support serial communication (RS232 protocol). We will make an array of FFT values ​​of different types of brain waves and transmit this array serially.

So, in this way, we successfully transform the analog brainwave signal into FFT values ​​of different types of brainwaves and imitate the TGAM1 chip and our sensor.

After building the bridge between theoretical and practical views, we can easily identify how and where these values ​​come from. However, if we really try, there will be many more complications and points. Furthermore, the result may be more complex with unexpected variations.

In the next article, we will see how these FFT values ​​can be used to measure the change in different types of waves, controlling LED brightness through meditation and alert level.

Back to the blog

Leave a comment

Comments need to be approved before publication.