EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: dotcom.com on August 29, 2023, 02:42:22 am

Title: EEG Design help?
Post by: dotcom.com on August 29, 2023, 02:42:22 am
Currently working on an EEG design for an ESP32 microcontroller. This was part of my capstone project, and I am just working on this for fun and to learn more as this was my partners subsystem. I modifying my partners design which was originally on Multisim.
So the first image is the full EEG transient.

Next a notch filter AC sweep which is used twice for the 60 Hz noise.

I went back testing each component finding the differential gain and common mode of the instrumentation amplifier
Differential Mode Gain Ad  = 100.4 mV / 1.04 mV = 96.5385 V/V
Common Mode Gain Ac = -489.32µ/0.9927 mV =  0.48932mV/0.9927mV = -0.4929 V/V
Common Mode Rejection Ratio (CMRR) = 20log10(Ad/|Ac|) = 45.8385 dB
This was interesting as in the datasheet for the IC it can reach 110 and I know ideally you want to be at least above 100dB

I am also planning on implementing a voltage regular for the negative 3.3V onto the instrumentation amplifier as the ESP32 can not take negative voltages but I am trying to perfect the amplifier first before so.

I also ran AC Sweeps on my bandpass filter, which I am trying to get the 3-12 and 12-30Hz frequency for alpha and beta waves.

Any advice on anything I'm doing wrong? Still trying to figure everything out and learn.


EDIT:
I have accounted for DC Offset for the CMRR and now here are my modified calculations:

To amplify an input signal of 0.1mV to the range of the ESP32 3.3V, I pick a range of 0.1V to 2.5V to allow for some signal peaks.
Determine the desired output midpoint based on your output range:
Midpoint Output = (0.1V + 2.5V) / 2 = 1.3V
Calculate gain to amplify to the midpoint of 1.3V
Gain = Midpoint Output / Input = 1.3V/(0.0001 - 0.00001)V = 14,444.4 V/V
(Adaptive gain control? - for consistent amplified signal?)
The gain of the INA118 is set by connecting a single external resistor, RG, connected between pins 1 and 8.
G = (1 + 50 kΩ) / Rg
To find Rg with gain 14,444.4 V/V
Rg = (1+50kΩ)/14444.4 = 0.00353kΩ = 3.53Ω
Differential Mode Gain Ad  = Vout diff / Vin diff = 1.21V / 0.000089 V  = 13463.1V/V
Common Mode Gain Ac = 0.001366mV/94.8µV = 1.361 µV/94.8µV = 0.014409 V/V
Common Mode Rejection Ratio (CMRR) = 20log10(Ad/|Ac|) = 119.41dB

I am now working on working on modifying the instrumentation amplifier for a positive power supply, so I have switching the IC to a single supply and adding a voltage regulator.
Title: Re: EEG Design help?
Post by: moffy on August 29, 2023, 02:59:11 am
The instrument CM picture is that of one of the notch filters. To simulate CM on the instrument amp, join pins 1 & 2 together and connect them both to the same signal source, then measure the output versus input. It will be frequency dependent as all CMRRs are.
Title: Re: EEG Design help?
Post by: dotcom.com on August 29, 2023, 03:38:31 am
The instrument CM picture is that of one of the notch filters. To simulate CM on the instrument amp, join pins 1 & 2 together and connect them both to the same signal source, then measure the output versus input. It will be frequency dependent as all CMRRs are.

Its not? Pins 1 and 2 have the same valued voltage source. However should it be a single voltage source that goes into both the inverting and noninverting or two separate sources of same voltage and frequency.
Title: Re: EEG Design help?
Post by: moffy on August 29, 2023, 06:25:01 am
The instrument CM picture is that of one of the notch filters. To simulate CM on the instrument amp, join pins 1 & 2 together and connect them both to the same signal source, then measure the output versus input. It will be frequency dependent as all CMRRs are.

Its not? Pins 1 and 2 have the same valued voltage source. However should it be a single voltage source that goes into both the inverting and noninverting or two separate sources of same voltage and frequency.

Because that is the definition of Common Mode, the same voltage on both inputs as opposed to Differential Mode, the difference between the voltage on both inputs.

P.S. Please look at: https://www.ti.com/lit/ds/symlink/ina118.pdf?ts=1693290331912&ref_url=https%253A%252F%252Fwww.google.com.au%252F (https://www.ti.com/lit/ds/symlink/ina118.pdf?ts=1693290331912&ref_url=https%253A%252F%252Fwww.google.com.au%252F) and section 8.2 'The Functional Block Diagram' there is a voltage generator shown Vcm which is connected to both inputs.
Title: Re: EEG Design help?
Post by: Marco on August 29, 2023, 06:57:56 am
Why are you measuring the DC offset of the output?
Title: Re: EEG Design help?
Post by: dotcom.com on September 13, 2023, 08:46:37 pm
The instrument CM picture is that of one of the notch filters. To simulate CM on the instrument amp, join pins 1 & 2 together and connect them both to the same signal source, then measure the output versus input. It will be frequency dependent as all CMRRs are.

Its not? Pins 1 and 2 have the same valued voltage source. However should it be a single voltage source that goes into both the inverting and noninverting or two separate sources of same voltage and frequency.

Because that is the definition of Common Mode, the same voltage on both inputs as opposed to Differential Mode, the difference between the voltage on both inputs.

P.S. Please look at: https://www.ti.com/lit/ds/symlink/ina118.pdf?ts=1693290331912&ref_url=https%253A%252F%252Fwww.google.com.au%252F (https://www.ti.com/lit/ds/symlink/ina118.pdf?ts=1693290331912&ref_url=https%253A%252F%252Fwww.google.com.au%252F) and section 8.2 'The Functional Block Diagram' there is a voltage generator shown Vcm which is connected to both inputs.

I see, but I did make the switch and found the output to still be the same.
Title: Re: EEG Design help?
Post by: dotcom.com on September 13, 2023, 08:56:15 pm
Why are you measuring the DC offset of the output?

At which part? The final EEG? For that I'm not trying to look for the DC offset, and I think whatever is happening there, it's occurring due to my instrumentation amplifier. I'm trying to measure the actual output of the EEG.
Title: Re: EEG Design help?
Post by: Marco on September 14, 2023, 10:31:47 am
AFAICS you used the DC level of the output for your CMRR calculation, not the AC amplitude.
Title: Re: EEG Design help?
Post by: dotcom.com on September 15, 2023, 04:33:25 am
AFAICS you used the DC level of the output for your CMRR calculation, not the AC amplitude.

Ohh I see, so you mean that when I calculated for the common mode gain I didn't account for the DC offset. I did not see or even think about that. Thanks so much. I've also made a lot of changes to the design and will be updating everything soon. I am currently still improving this amplifier and to account for the ESP32 MCU, which is restricted to a positive 3.3V so I am switching to a single supply IC; the INA 122 and also adding a voltage regulator.
Title: Re: EEG Design help?
Post by: jonpaul on September 15, 2023, 05:43:12 am
WHAT IS EEG?

Title: Re: EEG Design help?
Post by: dotcom.com on September 23, 2023, 12:54:35 am
WHAT IS EEG?

EEG stands for electroencephalogram, which is a medical test used to measure the electrical activity of the brain, via electrodes applied to your scalp.