14
Title: Construction of a 4-channel EEG amplifier Date: August 22, 2014 Institution: Center for Biomedical Signal Processing and Computation Author: Lucas Silva Lopes, grantee from the Brazil Scientific Mobility Program Index Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Project Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Project Development Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Design Parameters Reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Why not Driven-Right Leg Circuit ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Future Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Introduction This is an informal report about the construction of a 4-channel EEG amplifier by Lucas Silva Lopes, Ming Wang and Dr. An Do during the Summer Quarter of 2014. It was intentionally made as intuitive and empirical as possible to correspond to how the amplifier was built. We acknowledge Dr. Po T. Wang, Dr. Zoran Nenadic, Dr. Payam Heydari, Behzad Samavaty, Esther May-Ann Chu, Colin M. McCrimmon for the help on the development of this project. Project Requirements In this project we wanted to build a 4-channel EEG amplifier to use in a Brain Computer Interface. An Arduino Mega will power the amplifier, so it’s intended to operate under a 5V supply. Its inputs are going to be connected to a 32-channel Quik Cap. Main project requirements are: a channel signal must span from 0 to 5V so there is no waste of ADC bits; the signal must contain as little noise as possible. Project Development Description We first started our project by looking for previous implementations of bio-potential amplifiers utilizing the materials we wanted to work with, more specifically, off-the-shelf instrumentation amplifiers like the INA122 [1] and the INA128 [2], which we knew were suitable for biomedical applications. We then found the following schematic from the article [3] that utilizes the INA122 to build a Human-Machine Interface through Electromyography.

Construction of a 4 channel EEG amplifier

Embed Size (px)

DESCRIPTION

Construction of a 4 channel EEG amplifier for BCI applications.

Citation preview

  • Title: Construction of a 4-channel EEG amplifier Date: August 22, 2014 Institution: Center for Biomedical Signal Processing and Computation Author: Lucas Silva Lopes, grantee from the Brazil Scientific Mobility Program Index Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Project Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Project Development Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Design Parameters Reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Why not Driven-Right Leg Circuit ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Future Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Introduction This is an informal report about the construction of a 4-channel EEG amplifier by Lucas Silva Lopes, Ming Wang and Dr. An Do during the Summer Quarter of 2014. It was intentionally made as intuitive and empirical as possible to correspond to how the amplifier was built. We acknowledge Dr. Po T. Wang, Dr. Zoran Nenadic, Dr. Payam Heydari, Behzad Samavaty, Esther May-Ann Chu, Colin M. McCrimmon for the help on the development of this project. Project Requirements In this project we wanted to build a 4-channel EEG amplifier to use in a Brain Computer Interface. An Arduino Mega will power the amplifier, so its intended to operate under a 5V supply. Its inputs are going to be connected to a 32-channel Quik Cap. Main project requirements are: a channel signal must span from 0 to 5V so there is no waste of ADC bits; the signal must contain as little noise as possible. Project Development Description

    We first started our project by looking for previous implementations of

    bio-potential amplifiers utilizing the materials we wanted to work with, more specifically, off-the-shelf instrumentation amplifiers like the INA122 [1] and the INA128 [2], which we knew were suitable for biomedical applications. We then found the following schematic from the article [3] that utilizes the INA122 to build a Human-Machine Interface through Electromyography.

  • Figure 1 Inspirational design from [3]. The schematic uses practical pinout diagrams for the ICs.

    Figure 2 Same schematic as in Figure 1, but using only standard symbols.

    This amplifier was designed for EMG applications. Still, many things can be learned from it. First of all, let's take a look at pins 5, 6 and 7 of the OPA2241 [4] in Figure 1. Resistors R2 and R3 form a voltage divider that outputs half of the battery voltage. Its output then passes through a voltage follower, or unit gain buffer. This is done so the output of the voltage divider does not get changed by the circuitry that intends measure it. The output of the voltage divider is Vout=(R2/(R3+R2))*Vbattery. When you connect some circuit with input resistance R to it, its new value is Vout=((R2||R)/(R3+(R2||R)))*Vbattery, which is not the same as before. But if the circuit being connected has a really high input impedance, then R2||R R2 and Vout doesnt get affected. This is basically why in circuit design one stage has to have a high input impedance compared to the output impedance of the previous stage, and a low output impedance compared to the input impedance of the next stage [5]. Its commonly said that the rule of thumb is to make the input impedance of the next stage 10 times higher than the output impedance of the previous stage.

  • Figure 3 Voltage Follower schematic.

    Even though the voltage follower doesnt seem to do much, since its output is just the same as its input, it actually does a lot. More precisely, it does exactly what its name says. The voltage follower has very high input impedance and very low output impedance. The idea is, no matter what is the output impedance of the precious stage, the input impedance of the voltage follower is higher, and no matter what is the input impedance of the next stage, the output impedance of the voltage follower is lower. It would work perfectly to avoid the problem described above. Of course that in reality its input impedance is not infinity and its output impedance is not zero, so care must be taken. But turns out that in practice, this is usually a pretty acceptable assumption. This is why voltage followers are said to isolate one part of a circuit from another and are usually called buffers.

    So, at pins 5, 6 and 7 of the OPA2241, after the battery voltage is halved, it passes through a voltage follower. Its output is then connected to several pins of the two amplifiers in Figure 1. After that, the output of the voltage follower is connected to the person? Why feed Vbattery/2 to the body through the reference electrode? Isnt it dangerous? It turns out that its not. Its actually necessary. In both our project and in this application, the output signal must be centered on Vbattery/2 so it can be connected to a microcontroller, for example. This is why this voltage is so important throughout the circuit. More precisely, Vbattery/2 is what is called the Virtual ground of the circuit. All amplifiers and filters are referred to this point instead of the real ground (including the instrumentation amplifier through its reference pin), so the signal is actually changed from centered on 0V to centered on Vbattery/2. The problem is that, for this circuit to work properly, the two amplifier inputs must also be centered on Vbattery/2. We made several tests with the INA122 and other instrumentation amplifiers and concluded that their outputs are centered on their reference voltage as long as both amplifier inputs are also centered on their reference voltage. This is why Vbattery/2 has to be supplied to the body for the circuit to work properly. The next important lesson learned from the circuit in Figure 1 was: why is there a capacitor between the two amplifiers? This is because of amplifiers DC offset. For instance, if the first amplifier had a DC offset higher than or close to the signal of interest and we directly connected it to the second stage, its output would saturate or simply not be centered on Vbattery/2. Because of it, a high

  • pass filter is needed between the two stages. This high pass filter is also useful to get rid of low frequency noise. But in the case of Figure 1, only a capacitor was used instead of a combination of resistor and capacitor. This showed itself to be a problem while trying to implement the circuit. The problem is: since we are using a virtual ground, without the resistor, what is the reference of the filter? The virtual ground or the real ground? This ambiguity seemed to be faced by the circuit as well. Most part of the time it would not work. We believe thats because the real ground is the reference, so the signal is moved back to zero volt and the second stage gets saturated. Sometimes though, the circuit would magically work! We didnt figure out the circumstances for it to work, so we decided to end this ambiguity by adding a resistor and connecting it to the virtual ground. In Figure 4 is the schematic of the circuit we built. We used the OPA4131 [6] instead of the OPA2241. We removed the low pass filter after the last stage because we intended to make a better filter afterwards.

    Figure 4 Schematic with the resistor added to form an RC filter between the two stages.

    So, the design above may work for EMG. But the purpose of our project was to build an EEG amplifier. For that, two things are still necessary: better noise filtering and higher gain. Because we are dealing with very small signals, the 60 Hz noise coming from the power lines is of major concern. This noise can mask the signal completely to the point that we cant even see it. First, we addressed the gain problem: We want to amplify the signal sufficiently so we can see it. But how do we know its there if all we see is 60 Hz noise? Eye blink is known to be a very common artifact in EEG signals. In this case, we could actually make use of it. Our first goal was to observe eye blink, which can be seen even with a lot of 60 Hz noise. Then our next goal was to reduce the 60 Hz noise so we could see the EEG signal.

    To address the gain issue, we had at least two options: increase the gain of one or both the stages we already had; or add stages to add more gain. Its not a good idea to increase the gain of the first stage because the first stage has two

  • main purposes [7]: 1) have a good CMRR to deal with the common mode voltage coming from the body (mainly 60 Hz noise); 2) deal with the huge DC offset coming from the electrodes, which requires the first stage to be low gain. We could increase the gain of the second stage, but it intuitively does not seem a good idea (we would be requiring much from a single stage). So we decided to add a third stage. Because of the reasons explained above, a high pass filter is needed between each stage. We brushed up the circuit we already had (replaced the INA122 by the INA128 and changed some resistor values) and moved the potentiometer from the second stage to the third stage. Its a good idea to have adjustable gain because, even though the books might give a good estimate of the amplitude of the signal, these things vary from person to person, from moment to moment. So we kept one stage as an adjustable gain stage.

    Figure 5 Schematic after adding a third stage and brushing the circuit up.

    Figure 6 Signal recorded from the forehead using the schematic in figure 5. It captures an eye blink. The basic configuration we used to record signals from the forehead was: Vin+ of the amplifier is connected to the forehead, Vin- and Vref are connected each to one mastoid bone behind each ear.

  • Figure 7 60 Hz noise

    The next thing to address was the filtering. The two non-inverting stages we already had could easily be upgraded to active low pass filters. All we needed to do was add capacitors in parallel to the feedback resistors. To avoid that the adjustable gain of the third stage changed its cutoff frequency, the potentiometer was placed in the input resistance instead of the feedback resistance. Now we can see a little bit better the EEG signal, but there is still a lot of 60 Hz noise. Because our bandwidth of interest was between 1 to 30 Hz, we could do something we couldnt with ECG or EMG signals: utilize a notch filter. More specifically we built two notch filters, based on [8]. The two notch filters reduce the 60 Hz noise a lot, but the amount of noise in the signal still depends a lot on: the amount of noise present in the room; cables positioning; electrode contact to the skin; among many other sources of noise that may not have been addressed. More about sources of noise can be found at [9].

    Figure 8 Schematic after adding the filters

  • Figure 9 Signal recorded from the forehead using the schematic in figure 8. The gain in this figure is higher than the gain in figure 6. When we got to the step of moving the circuit from the breadboard to the perforated board, we made some changes. We changed resistor values to avoid too many series and parallel combinations. We also changed the potentiometer from the Third to the second stage. The reason behind this last change was because we tried to combine the second and third stage in a single 1000 gain stage and measured a DC offset of approximately 1V in its output. We concluded that this huge DC offset was associated with the high gain.

    After that, we abandoned the idea of combining the second and third stages. We also concluded it was not good design to leave the higher gain for the last stage (that means, leave the potentiometer in the last stage). The amplitude of its input signal is higher than that of the second stage. If huge gain is really associated with huge DC offset, as we thought it was, then the last stage would get saturated more easily. Not to mention the fact that we dont have high pass filter after the last stage.

    Figure 10 Schematic soldered 4 times in the perforated board (Figure 11). Although not shown in the other schematics, the three protection resistors in the left were always present.

  • Figure 11 4-channels EEG amplifier.

  • Figure 12 Signals from three channels of the board in figure 11. Recorded using Arduino Mega with 256 sampling rate. Plotted using MATLAB. The basic recording configuration was: Vin- from all channels are connected to each other and to a mastoid bone behind one ear. Vref is the same for all channels and is connected to the other mastoid bone behind the other ear. Each Vin+ of each channel is connected to a different place in the forehead.

    The final design looks pretty similar to open source designs like the ModularEEG [10].

    Figure 13 Schematic for 1 channel of the ModularEEG [10]. Design Parameters Reasoning The choice of parameters and components was very dictated by the components available at the moment. We started by using the INA122 and OPA4131. This is also what motivated the search and finding of the article [3] that based our project in the beginning. The OPA4131 is not rail-to-rail and is not intended for a single 5V power supply. Still, most part of our project was developed using it, as well as a 9V battery. Later we would change it for the OPA4241, which is both rail-to-rail and suitable for 5V supply, and use a LM7805 [11] to give 5V. Strangely, the signal was noisier than using the OPA4131 with the 5V supply. We suppose there might be a trade off between rail-to-rail and signal quality. The INA122 was substituted earlier in the project, when we were

  • still using the 9V battery, by the INA128 due to best-observed noise performance. We also decided to use a single separated op amp for the voltage follower when soldering the circuit in the perforated board. For this purpose we used the NTE928M [12]. The filter parameters were chosen both in accordance with what we had and the bandwidth of the signal of interest. We were interested in the alpha and beta waves, which range from approximately 1 Hz to around 30 Hz. In our final design (the circuit that was soldered four times in the perforated board to form a 4-channel EEG amplifier), both High Pass filters had the cutoff frequency 1/(2*pi*1u*100k) 1.59 Hz, the first Low Pass had 1/(2*pi*10n*470k) 33.86 Hz, and the second Low Pass had 1/(2*pi*22n*220k) ~= 32.88 Hz. The Notch filters design was based on [8]. Their Notch frequencies are 1/(2*pi*sqrt(0.22u*(10*247k*10u))) 68.27 Hz. The gains of the stages were roughly based on the gains in [3] and the amplitude characteristics of the EEG signal. Based on the following table from [13], the surface EEG approximate amplitude is 100uV. To fit it in a 5V range the total gain needs to be approximately 5/100u= 50000. For the circuit in figure 1, the first stage has a gain of (5 + 200k/100k) = 7 [1], the second stage has a maximum gain of 100. In our final design, the first stage has a gain of (1+50k/2.2k)~=23.72 [2], and the second stage has a minimum gain of 47. Our additional third stage has a gain of 22, yielding a minimum total gain of approximately 24526.48.

    Table 1 - Typical amplitude and frequency ranges of several common biopotentials [13]. One last common sense rule was used when choosing the design parameters: choosing resistor values that are neither too high nor too low. Commercial resistor values go up to the order of Mega Ohms. The Kilo Ohms range seemed to be a good place to pick resistors from. A better theoretical motivation for this rule can be found at [14]. Low resistor values would require higher currents from the amplifiers while high resistor values would introduce noise. Protection 10k resistors where added in series with the electrodes to avoid the current passing through the body from reaching dangerous values. For a 5V device, worst case is 5V/20k = 0.25 mA, which is under the threshold of perception (from 1-5 mA). These resistors shouldnt affect the operation of the device, since the input impedance of the amplifier should be much higher, making the voltage drop across the resistor negligible. Consider a voltage divider

  • with one resistor much higher than the other: Vout = (Rbig/(Rbig+Rsmall))Vin (Rbig/Rbig )Vin = Vin. Why not Driven Right Leg circuit? The Driven Right Leg circuit is a circuit commonly used in biomedical applications to improve the amplifier CMRR (Common Mode Rejection Ratio) and increase human protection. Better descriptions on how it works can be found in [15]. What it basically does is try to get the common mode voltage (the gain resistor from the instrumentation amplifier is split into 2 to try to get this voltage), invert it, and feed it back to the body. Many different designs can be found in different sources. In some of them, a simple inverting amplifier is used. In others, a single capacitor is placed in the feedback instead of a resistor. In others, a resistor is placed between the output and the feedback resistor terminal. And many others can be found out there. One problem was found while trying to implement the circuit in the INA128 datasheet [2]. The EEG amplifier output measured by the oscilloscope would become a fog from one rail to another. We searched for reasons why it could be happening and figured out it was because of amplifier instability. We then inspired ourselves in [16]. Again, we tried to apply a very practical approach. We knew from [17] that we had to use a capacitor in parallel with the feedback resistor. We tried the schematic in figure 14, which is one of the schematics from [16]. It didnt work. We then left just the 100k resistor and the 1uF capacitor in the feedback. Same result. We then tried to change the capacitor value from 1uF to 220nF. It worked! The output was back to normal! Interestingly, though, the previous design (100k and 1uF) would work with the INA128, even though it didnt work with the INA122. The second design worked with both, so we kept it. What is strange is that the instrumentation amplifier is not even the amplifier used to build the DRL circuit (which was the OPA4131). We couldnt find an explanation for this issue.

    Figure 14 Initial Driven Right Leg circuit design, inspired in [16].

  • Figure 15 Final Driven Right Leg Circuit Design Even though we were able to implement a stable driven right leg circuit, it worked just like the precious design without it, not better, not worse. We made several experiments, tried to increase the feedback resistor, but the signal wouldnt get any better (the 60 Hz noise, which is basically the common mode voltage we were trying to eliminate, wouldnt reduce at all). We then decided to remove the driven right leg circuit because it means fewer components when building the board. We concluded that the 60 Hz noise we were seeing was probably differential and not common and that our instrumentation amplifier, which already had a pretty good CMMR, was already reducing the common mode voltage as much as it was possible. In the search for explanations, we found the article [18]. It concludes that the DRL circuit is not always effective in reducing the 60 Hz noise, since it can come as differential mode instead of common mode noise. It further explains that the DRL can also increase interference in some cases, which makes the authors ask if it is really better to have it in a circuit. Future Improvements We tried to be as quick and straightforward as possible when building this amplifier. Our objective was to build a 4 channels EEG amplifier, mostly with the materials we had, that gave us a sufficiently good signal to use with the Arduino Mega and the software pre written by Dr. An Do. We are sure many improvements could be made to this amplifier. To start, the component values were mainly chosen due to their availability. Also, the filters and amplifiers topologies were also chosen due to their convenience. For example, instead of using two first order active Low Pass filters, we could have made one of them, for example the last one, a second order Low Pass Filter (Butterworth, Bessel, or Chebyshev), and have more options with respect to gain response, phase response and group delay. More on Second Order filters can be found at [19]. References [1] Texas Instruments, Single Supply, MicroPower INSTRUMENTATION AMPLIFIER, INA122 datasheet, Oct. 1997.

  • [2] Texas Instruments, Precision, Low Power INSTRUMENTATION AMPLIFIERS, INA128 datasheet, Oct. 1991 [Revised Feb. 2005]. [3] Siva Sankar A., SUrajNath P., Suparna S. Nair and Venu S. Dharan, Human-Machine Interface through Electromyography , Electronics For You, Feb., p.123, 2014. [4] Texas Instruments, Single-Supply, MicroPOWER OPERATIONAL AMPLIFIERS, OPA4241 datasheet, Oct. 1998. [5] Paul Horowitz and Winfield Hill, Student Manual for The Art of Electronics 2nd ed., Cambridge University Press, 1989, pp. 3-23. [6] Texas Instruments, General-Purpose FET-INPUT OPERATIONAL AMPLIFIERS, OPA4131 datasheet, Nov. 1994 [Revised Dec. 2002]. [7] John G. Webster, Ed., Medical Instrumentation: Application and Design, 4th ed., New York, NY: John Wiley & Sons, Inc., 2010, p 274 [8] Michel Maharbiz, Vivek Subramanian, Electroencephalograph (EEG) Final Project Part 1: Design and Simulation University of California, Berkley Robotics Lab, 2013. [Online]. Available: http://robotics.eecs.berkeley.edu/~pister/42x100sp13/Resources/Lab_8_EEG.pdf. [Accessed: Aug. 12, 2014], pp. 8-13 [9] MettingVanRijn, A. C., Peper, A. and Grimbergen, C. A. (1990) High quality recording of bioelectric events. Part 1: Interference reduction, theory and practice." Med. & Biol. Eng. & Comput., 28, 389-397. [10] OpenEEG, The ModularEEG, OpenEEG, 2014. [Online]. Available: http://openeeg.sourceforge.net/doc/modeeg/modeeg.html. [Accessed: Aug. 12, 2014] [11] Texas Instruments, A7800 SERIES POSITIVE-VOLTAGE REGULATORS, LM7805 datasheet, May. 1976 [Revised May. 2003]. [12] NTE Electronics, Low Power Dual Operational Amplifier, NTE928M datasheet. [13] John G. Webster, Ed., Medical Instrumentation: Application and Design, 3rd ed., New York, NY: John Wiley & Sons, Inc., 1998, p. 259. [14] Analog Devices, Basic Linear Design, Analog Devices Inc., 2006, p. 1.6. [15] John G. Webster, Ed., Medical Instrumentation: Application and Design, 4th ed., New York, NY: John Wiley & Sons, Inc., 2010, pp. 267-269 [16] Matthew Hann, Texas Instruments, Use Spice to analyze DRL in an ECG front end, EDN.com, Jan 5, 2012. [Online]. Available:

  • http://edn.com/design/medical/4368833/Use-Spice-to-analyze-DRL-in-an-ECG-front-end. [Accessed: Aug. 12, 2014] [17] Paul Horowitz and Winfield Hill, The Art of Electronics 2nd ed., Cambridge University Press, 1989, pp. 193-194, pp. 232-233, pp. 242-248 [18] J. Gomez-Clapers, E. Serrano-Finetti, R. Casanella, and R. Pallas-Areny, "Can driven-right-leg circuits increase interference in ECG amplifiers?," in 2011 Annual International Conference of the IEEE Engineering in Medicine and Biology Society,EMBC, 2011, pp. 4780-4783. [19] Texas Instruments, Op Amps For Everyone, Texas Instruments, Inc., Sept. 2001, Ch. 16.

    Title: Construction of a 4-channel EEG amplifierIndexIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Project Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Pro...IntroductionProject RequirementsProject Development DescriptionFigure 2 Same schematic as in Figure 1, but using only standard symbols.Figure 3 Voltage Follower schematic.Figure 4 Schematic with the resistor added to form an RC filter between the two stages.Figure 5 Schematic after adding a third stage and brushing the circuit up.Figure 8 Schematic after adding the filtersFigure 9 Signal recorded from the forehead using the schematic in figure 8. The gain in this figure is higher than the gain in figure 6.Figure 10 Schematic soldered 4 times in the perforated board (Figure 11). Although not shown in the other schematics, the three protection resistors in the left were always present.Figure 11 4-channels EEG amplifier.Figure 12 Signals from three channels of the board in figure 11. Recorded using Arduino Mega with 256 sampling rate. Plotted using MATLAB. The basic recording configuration was: Vin- from all channels are connected to each other and to a mastoid bon...Figure 13 Schematic for 1 channel of the ModularEEG [10].Design Parameters ReasoningWhy not Driven Right Leg circuit?Figure 14 Initial Driven Right Leg circuit design, inspired in [16].Figure 15 Final Driven Right Leg Circuit DesignFuture ImprovementsReferences[12] NTE Electronics, Low Power Dual Operational Amplifier, NTE928M datasheet.