Maker Pro
Maker Pro

EEG circuit - need help please!

AnalogKid

Jun 10, 2015
2,913
Joined
Jun 10, 2015
Messages
2,913
Also, do you think using simple voltage followers between stages would be beneficial?

No. These type of filters rely on an input signal with a very low output impedance, which in turn is determined by the type of circuit, the type of opamp, and how much gain-bandwidth it has left over the feedback loop gain. Your frequencies of interest are so low that just about anything will have a very low output impedance. No need for buffers.

ak
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
@AnalogKid , would something like this for the notch filters be better? Twin "T" networks, with high Q. The second one even has a potentiometer for adjustment.
 

AnalogKid

Jun 10, 2015
2,913
Joined
Jun 10, 2015
Messages
2,913
It is a good notch filter circuit, but the example components are an extremely high impedance. You can scale everything by at least 100 to get normal parts and a circuit impedance less prone to picking up radiated noise. Keep in mind that the higher the circuit Q, the more distorted the output waveform will be.

ak
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
What's the best way to take figuring out the component values for the whole circuit? I've never done something like this before, so I'm a little lost on where to start. I have the formulas for the filters, but the amplifier I'm still unsure about.
 

AnalogKid

Jun 10, 2015
2,913
Joined
Jun 10, 2015
Messages
2,913
Only you can specify the overall circuit gain. Once you have that, divide it by any fixed-gain stages like the two filters. Whats left is the gain required of the diff amp, and there is an equation for that in the datasheet.

ak
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
Alright. Here's what I've got:
2enmb0k.png


The ADN stage has a gain of 89.2 by the formula G = 1 + 49400/560. This stayed the same from the Instructables circuit.

The second order filters were adapted from this page, and the component values were kept equal as per AnalogKid's suggestion.

The high pass filter stage (7Hz) follows the fc = 1/(2pi * R * C), which in this case results in a cutoff frequency of 7.2343Hz. The gain of this stage is 2.

The low pass filter stage (30Hz) follows the same fc formula, resulting in a cutoff frequency of 28.42053, which I think is close enough for the circuit's purposes. The gain of this stage is also 2.

The notch filter is adapted from this page, and it has an adjustable Q. I scaled the filter down 5000 to get my values. This stage also follows the same fc formula, which results in a frequency of 60.285Hz. C4 is supposed to be 2x the values of C5 and C6, but the closest value was 4.7uF. This will raise the Q a bit and possibly amplify the signal a bit as per the page, but Q will still be adjustable via the potentiometer.

The amplifier at the end also stayed the same from the Instructables circuit, because I like the ability to adjust the gain from 83 to 455 by the formula G = 1 + R14 / (R15+R16).

The circuit overall will bring the differential signal of a few uV (since the alpha and beta wave range is 10uV-60uV) into the high millivolt range. If I'm getting larger differences, I'll be able to tune down the gain in the last stage, and vice versa if I'm getting really small differences in the waves.


Overall, I'm still a little unsure about the notch filter, and I'd really appreciate feedback on things that should be fixed. Thanks all!
 

AnalogKid

Jun 10, 2015
2,913
Joined
Jun 10, 2015
Messages
2,913
Coming along nicely, much better than where you started.

You may have scaled the three filter network impedances down too far. Since this circuit will be inside a 100% shielded enclosure, you don't need an extra low impedance to control noise pickup. According to the high-end audiocrazies, electrolytic capacigtors are the worst at low signal fidelity. Film capacitors are larger and more expensive, but the best for this kind of circuit. I suggest looking into film capacitors. Determine what will physically fit and what you can afford, and scale the networks based on the caps.

Also, everything after the highpass stage is DC coupled. The output amp might have more offset than signal at it's input.

ak
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
You may have scaled the three filter network impedances down too far. Since this circuit will be inside a 100% shielded enclosure, you don't need an extra low impedance to control noise pickup.

I actually won't be using this circuit inside a shielded enclosure. Should I still scale the filters up a bit?

Also, everything after the highpass stage is DC coupled. The output amp might have more offset than signal at it's input.

Should I be scaling this one down then?
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
I'm really sorry to bother, but could I have a little more help here? I'm unsure of if I need to scale things / what needs to be fixed and I'd really like to purchase parts soon to get this started! I really appreciate everything so far! @AnalogKid @Gryd3
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Sorry for the delay.
I would very strongly suggest a shielded enclosure, and the use of the film capacitors recommended by AnalogKid. You can opt out of either, but you may find yourself picking up more 60Hz noise. This all depends on the quality of the finished product you want. There is nothing stopping you from modifying the device again during the prototyping phase.
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
Sorry for the delay.
I would very strongly suggest a shielded enclosure, and the use of the film capacitors recommended by AnalogKid. You can opt out of either, but you may find yourself picking up more 60Hz noise. This all depends on the quality of the finished product you want. There is nothing stopping you from modifying the device again during the prototyping phase.

Alright, thank you! I'll look into shielded enclosures if the signal isn't what I want after building the circuit.
In terms of the actual circuit though, do you think there are any adjustments that need to be made? Component-wise, filter-wise, anything!
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Alright, thank you! I'll look into shielded enclosures if the signal isn't what I want after building the circuit.
In terms of the actual circuit though, do you think there are any adjustments that need to be made? Component-wise, filter-wise, anything!
Personally, I would have been wiring up the circuit already with the notch-filter we discussed earlier, but AnalogKid pointed out a couple improvements. There are people on here more knowledgeable than I (of course).
All I can tell you is that I am personally happy with the final iteration of the circuit.
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
All I can tell you is that I am personally happy with the final iteration of the circuit.

Alright, thank you! You've been a huge help.

@AnalogKid , if there isn't anything else on scaling/altering the circuit, I'm going to purchase parts tonight! Please let me know if there are any final tweaks needed, and thanks for all your help, too!
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
In searching for film capacitors I realized I needed to scale things, so here's the final result:
New_New_Circuit.png

2.2uF was the highest value I saw on the website I'm ordering from, so I scaled things to match that value. New cutoff values:
High Pass cutoff: 7.234315595.
Low Pass cutoff: 32.8832527.
Notch cutoff: 58.94627522.

The notch is a little off for C4 and R12, where C4 is supposed to be 2x C5 and C6, and R12 is supposed to be 0.5x R10 and R11, but the values work with what the sites have available and there shouldn't be too much of a problem, I think. Purchasing parts now, and they'll hopefully be in early next week for me to build the circuit and test it out.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
In searching for film capacitors I realized I needed to scale things, so here's the final result:
New_New_Circuit.png

2.2uF was the highest value I saw on the website I'm ordering from, so I scaled things to match that value. New cutoff values:
High Pass cutoff: 7.234315595.
Low Pass cutoff: 32.8832527.
Notch cutoff: 58.94627522.

The notch is a little off for C4 and R12, where C4 is supposed to be 2x C5 and C6, and R12 is supposed to be 0.5x R10 and R11, but the values work with what the sites have available and there shouldn't be too much of a problem, I think. Purchasing parts now, and they'll hopefully be in early next week for me to build the circuit and test it out.
You can use small 'trim-pot' adjustable resistors instead of fixed value resistors. They won't be exactly their advertised value anyway, so it may be a good idea to either have spare resistors you can swap out, or a couple well placed ones you can fine-tune. (usually little blue boxes with a tiny screw head on them. You use a flat-head screw-driver to adjust)
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
You can use small 'trim-pot' adjustable resistors instead of fixed value resistors. They won't be exactly their advertised value anyway, so it may be a good idea to either have spare resistors you can swap out, or a couple well placed ones you can fine-tune. (usually little blue boxes with a tiny screw head on them. You use a flat-head screw-driver to adjust)

Are you talking about for the notch? That makes sense. I'll do that!
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Are you talking about for the notch? That makes sense. I'll do that!
pros and cons. They tend to be a little larger, and due to their construction, they may actually pick up a little more noise than using a resistor with very short leads. (The amount should be negligible though)
 

eboaylag

Jan 7, 2016
46
Joined
Jan 7, 2016
Messages
46
Alright, so I'm waiting on parts to arrive. I played around in Fritzing to make a layout for the circuit. If someone's willing to check it over and see if there are any issues, I'd really appreciate it. Fresh eyes would probably be the best, especially for the notch filter, which I had a little difficulty planning out on the breadboard.

On the layout, the yellow wires are the stage transitions. The leftmost is the low pass filter stage to high pass filter stage, next one to the right is high pass to notch, and the rightmost one is notch to amplifier.
White wires indicate connection within a stage, while yellow wires connect between stages as explained above. All dark blue wires deal with ground. All red wires connect to +9V, all black wires connect to -9V, and the purple wire is the final output for the circuit into the Arduino. The cyan.light blue wires are the electrodes. There is a key on the layout photos to help explain the colors and functions.
Also, the end product of this is going to be run through an Arduino into my laptop, instead of via audio cable into the sound card as originally planned.

Also, the potentiometer in the top center of the breadboard is R12 within the notch filter, which Gryd3 recommended since I was having trouble finding a perfect value.

Attached is the schematic, the layout without outlines to divide the stages, and a layout with outlines. Let me know if you see any issues!

New_New_Circuit.png

EEGNew_Notch_Pot_Labelled.png

EEGNew_Notch_Pot_Outlined.png
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Keep in mind the Arduino is directly coupled to the output of your device.
The Arduino will not like a negative input on that signal input so you should either cut the wave-form in half... or put a decoupling capacitor in-between, reduce the output to maybe about 2V p-p and add a DC offset so that the Arduino ADC reads roughly 50% when there is no output.
 
Top