STM32 DIY board with ADS1299: SparkyEEG
So I've been wanting to do something like this for a while and you guys got me reinvigorated. I just designed a board this weekend that uses and STM32 instead of atmel, also with the ADS1299: http://buildandcrash.blogspot.com/2013/12/eeg-design-time-for-something-totally.html
I'd be curious if anyone has comments on the schematic. My intention is to power it from my phone and use that for the signal processing (or relaying it to a computer if that is not sufficient). Hopefully I can help out on the signal processing side with you guys.
I'd be curious if anyone has comments on the schematic. My intention is to power it from my phone and use that for the signal processing (or relaying it to a computer if that is not sufficient). Hopefully I can help out on the signal processing side with you guys.
Comments
Do you have any names, posts or links on the toolchain you are using for design, layout, board manufacturing, etc. I'm completely impressed on how you are making this look so easy. :-) If you've covered this already on your site or <a href="http://www.openpilot.org/">OpenPilot</a>, etc., just give that link.
You can also do dual sided boards in a home oven. Freedom was like that ( http://buildandcrash.blogspot.com/2012/11/assembly-and-first-flight.html ) but it's a lot more of a PITA to paste the back and you have to be pretty careful not to shake the parts off when reflowing the second side. If this works out well I'll very likely try some sort of mashup between Freedom with an ADS1299 - the Overo brings in WiFI, bluetooth, and a heck of a lot of processing power in a small footprint. It just gets fairly hot so might not feel nice on the head, not to mention throwing off a lot of EMI. For now it seems like smart phones are probably a better target for the processing power if you don't need something standalone.
As to toolchains, it sounds like you are asking about the hardware side more than software. I use Altium, which is nice and powerful but not so great for open source. I keep meaning to switch back to gEDA (or maybe try KICAD), which isn't as slick or polished but makes the hardware more accessible. However, it's hard to beat momentum - I modified Sparky in probably less than 12 hours, most of which was making footprints. The boards I sent to smart-prototyping.com who are ridiculously cheap. For faster prototypes I like using 4pcb.com since it's less than a week to get the boards back, but it ends up more expensive. For the assembly it's probably best documented here: http://buildandcrash.blogspot.com/2013/05/sparky-testing-and-building-no-crashing.html but I'm not particularly good at assembly and I bet you can find better descriptions of getting a good paste application. For commercial assembly at OP we used to use http://www.myropcb.com/ . I also used them for manufacturing PCBs for my <a href="http://buildandcrash.blogspot.com/2011/11/esc-development.html" title="ESCs">ESCs</a>
By the way, regarding your comment about the mystery of our use of the negative inputs instead of the positive ones, I left a comment on your blog explaining what we were thinking.
Regarding your schematic, what resistor values are you planning on using in-series with the electrodes...5K? They're not labeled on the schematic.
Also, with the processor and the ADS1299 on the same PCB, you've got to be really careful about keeping your analog ground separate from the digital ground used by the processor....or you'll get noise-o-rama.
Thanks for sharing!
Chip
Yeah I'm going to use 5k on the input. I meant to go back and label that. I didn't have any 5k parts mapped to vendors in my heavy schematic library so just used a stub 0402. Thanks for catching that - I'd have been annoyed when I ordered the parts.
I was pretty strict in the layout about grounds so I hope I'll be ok. I didn't make any distinction between the *1 and regular analog pins which I'm a little nervous about.
Here are images of the top and bottom copper (added to blog):
And you can see I managed to keep the AVSS plane pretty pristine.
(As an aside, I know that you already remarked about your decision to exclude electrical isolation...but it does make me nervous. I'd reconsider. Stay safe, man!)
Chip
I've been through your blog post, and I want to ask, why is it 'preferred' or 'recommended' to use the P input for the electrodes? Since it's a differential and the signal should be the 'same' anyway, why does it matter?
@biomurph: I probably should have chosen my words differently. My impression from the datasheet and more strongly from the EVM is that using the positive inputs as the signal is the usage TI intended. For 99% of things I don't think it will make a difference and Chip <a href="http://buildandcrash.blogspot.com/2013/12/eeg-design-time-for-something-totally.html?showComment=1387230313112#c8592122302831292749" title="commented">commented</a> on my blog as to why you guys implemented it that way. It makes sense and you gain flexibility with regard to selectable referencing on a per-channel basis.
What you lose is a some of the flexibility TI designed in to use any channel as either a bias or reference electrode (routed _out_ through SRB2 and back in through SRB1). I added a jumper on my board to establish this path if desired and then you just leave off a reference electrode. However, I don't really expect to use it this way (unless the bias electrode fails) since I'd rather not give up a channel.
There is also a connection from BIAS_IN to the positive pin of all the electrodes while in the MAIN configuration
Which means you can get away without the bias electrode (and in principle the bias current should not be enough or fast enough to alter the signal much in the bandwidth of interest). This might be a nice feature just to have one less cable to connect (and fail).
However, ultimately I don't think these things will alter the signal quality in standard configurations - we just have flexibility in slightly different directions.
here's some links
PIC32MX250F128
http://ww1.microchip.com/downloads/en/DeviceDoc/61168C.pdf
ChipKIT
http://chipkit.net/
Would be interested in your thoughts.
Yes, I do see the significance of being able to route the bias or ref to any of the electrode channels. This is a good reason to move the V4 design back in that direction (P-channel electrodes). My thought was that the firmware could measure brain signals while actively changing the ref position. Would this be at all useful for brain research? I guess it's best to have one ref position and stick to it for consistency, but something in me says that the ability to dynamically change the reference position could aid in signal processing somehow... (but how?).
Maybe you could help us decide on a design question. I am thinking of making the V4 as versatile as possible and allowing access to both the N and P channels would be useful. My thought is to tie them together at the pins, so that either could be selected by the internal muxer. I will be experimenting with this idea on one of my V2 prototypes here (using an ohmic connection between the N&P pins, aka solder-blob) do you have any thoughts on that?
Also, in all of our tests using battery operated setups (USB from laptop on battery power) we have not seen a noticeable difference in signal with the bias attached (earlobe or mastoid) or completely unattached. Perhaps we're missing something...
I think it depends a lot on how noisy is your 60 hz AC EMF environment. The Bias connection is universally used in neurofeedback applications, as well as all Electro-cap users at AFz. I _have_ seen some weird effects on rare occasions when the bias lead is not connected well. These were with AC powered laptops and USB connected amps.
A <a href="http://www.eevblog.com/forum/microcontrollers/chipkit-max32-vs-arduino-due-(mips-vs-arm)/">thread on MIPS vs ARM</a> comparisons and experience.
Chip
I used PIC's many years ago and really liked them. However, I haven't kept up much with them so can't speak from experience. It looks like they have a GCC port which is nice. One concern I would have with that is I don't see an FPU option. That can make a huge difference with the data processing capabilities. On the STM32 we can run real time FFT on a 500 Hz data stream. That being said, I think all the significant processing will be offloaded to a phone or a computer so I'm not convinced this is a relevant distinction.
Since you asked, I'd also hesitate a little about providing two options unless you know of a way to make a good abstraction layer. The Atmega and PIC32 are substantially different architectures and trying to support both is going to create a long term maintenance issue. I think you might struggle a bit to run the same code on both. However, if you look at what DIYDrones does they have an abstraction layer that lets them run the same core logic code on Arduino and STM32.
@biomurph
Yeah that was what kicked me over the edge. I couldn't think of a case where I would want to separately reference the different channels. If everything were working properly, say you have vref1 and vref2 and you reference channels 1-4 against vref1 and 5-7 against vref2 and channel 8 records the difference. From that combination of potentials you can work out any relative potential. Perhaps there might be a situation where you want to measure left side to one reference and right to another but don't want to record the left-right potential. That could give you one more channel for free.
Regarding the design flexibility question, this is more of a design philosophy than technical question I think (since we don't have data to indicate one is better yet). I would definitely focus on the tests on your existing boards if you can to determine one best strategy, rather than design the board with lots of options. But ultimately, that's just my personal preference and aesthetic.
My guess would be other issues will be dominant. For example, at 16 channels or more is it important to buffer the reference channel since the input impedance ends up so much lower than the positive channels. How much this ends up making a difference is really a result of the model of the whole system including all the parasitics. If the person is moving (potential wise) relative to the analog supplies then that signal will be scaled differently on the positive and negative inputs. I've personally worked with a 100 channel electrophysiology system where this ended up being a big issue, but in that case there were a lot of things to make us susceptible to it - long cables, multiple grounds, lower input impedances on the negative inputs.
This is something the bias signal _should_ be able to help suppress, especially in a batter powered system. Keeping the analog supplies at the same potential as the person. When you say you leave it off, what was pushing the subject to the same potential as the electronics? If all you had going to the subject were electrodes that went into high impedance inputs, I'm quite surprised there wasn't a noticeable difference because you are essentially measuring an open circuit (unless the reference is that well matched).
p.s. sorry about the essay
I cut my teeth on a PIC as well, back in the day.
Our main reason for selecting the ChipKIT is that it uses the same bootloader method as the Arduino does, and so it's possible to upload over bluetooth just as easily. I realize that ARM has alot of benefits to it, but I haven't seen an open system that I can re-program over serial like arduino. Do you know one?
We need to provide our community with a powerful on-board uC for mobile projects, and ChipKIT, with it's arduino IDE clone and porting of arduino libraries and functions makes it attractive. All of the arduino code that we have currently will drop right into ChipKit IDE and run (ok, we likely have to modify libraries to fit...). I've been around the horn on this a couple of times, but don't mind taking another trip...
It looks like Olimex has resurrected the Maple
https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/
and the IDE seems to be kinda exactly the same....
i'll have to get one to play with.
If you want to be able to do a meaningful amount of processing on board I would be seriously looking at something like an STM32F4 series then (or any fairly fast FPU equipped M3 core). That gives you 168 MHz + FPU. However, that would probably be able to at least pull out the power at a few frequency bands of interest in continuous time from 16 channels.
However, if ChipKIT will run the existing code with minimal modifications I would say that is a sufficient argument to go with it. If you ever need crazy power (for embedded) then I'd be considering adding some kind of computer-on-module (e.g. gumstix) capabilities.
You can see my notes here
http://buildandcrash.blogspot.com/2014/01/eeg-stuffing-and-testing.html
And a video of it talking via my phone here
Logic analyzer is impressive also. As is your phone app and uC code. Bravo.
Chip
https://github.com/peabody124/TauLabs/tree/eeg (it's currently structured as a branch from Tau Labs but I'll work on that eventually).
The next step is to get the impedance monitoring working and make it use that for swapping the electrodes used in the bias detection. Testing that with one of the leads open results in the bias doing funny things.
Got my heartbeat
>> I guess it is time to jury rig up a headband.
No way, man. With this kind of success, it's time to simply declare victory, that you're the master of the universe, and that it's time to go drink a beer. (At least, that's what I'd do in your situation right now!)
Chip
Plotting the difference amongst the leads produced a much cleaner signal:
I assume that your spectrogram is in dB...what's the dynamic range (difference between blue and red)?
Very cool.
Chip
<code>spectrogram(dat(1000:end),512,[],[],250);</code>
I was fairly impressed with how abrupt the changes are. I expected to need a lot of processing to see this but I could very obviously see it on the display on Android. I'll post photos later.
BTW as an aside I got impedance monitoring at least roughly working and tested in matlab using an algorithm that will super easily work on the MCU. I'll try and finish that and upload more details tonight or tomorrow.
Also, your alpha is a little faster than mine. It's unclear whether the alpha frequency actually relates to anything important, but they do say that alpha tends to slow with age. So far, I have the slowest eyes-closed alpha of anyone I know. Hmmm...
...well, with the exception of one guy I know who exhibits no eyes-closed alpha at all!
Chip
I agree with Chip, your alpha is shockingly crisp, even with 60dB range.
I'm also not surprised. Everybody has different alpha outputs. My alpha is distressingly non-existent.
What electrodes are you using?
What is your power supply? It looks single +5V?
I've found the bias drive to work differently between single and dual supplies, Have you measured the bias using the method shown in the datasheet?
Looks like you separated the grounds famously! And with two layers, no less! awesome!
I've been working with 0603 packages as my smallest, and have been hand soldering. For the ADS chip itself, I used paste and a reflow pen.
Thanks for posting!
Joel
Heh. Hopefully my mu waves can be modulated as suddenly. I'll upload a video shortly of it working once I have the patience to wire my head up again. I want to figure out what measurements to get to make it productive. What was interesting was when I closed my eyes I also saw a fairly rapid depolarization. I spent a few minutes trying to see if it was a muscle artifact but I couldn't reproduce it by squinting
My electrodes were washers with wire soldered to them and electrode paste:
Once I got those things were substantially cleaned up. My heart rate also looked quite nice
Yeah, I'm using a single sided supply. I'm pretty sure the bias circuit is working now - it generally sits near 2.5. I need to set up up with a scope and really analyze that and the impedance monitoring properly though. It's been too much fun to just hit the ground running
And yeah, 0402 is fun. I wouldn't want to hand solder much
I ordered some Klydex. I'm going to take a crack at making a electrode cap by molding it to my head shape. Then I'll epoxy nuts with wires soldered to them on the outside and try passing screws through to couch my scalp (flat end, not penetrating). Then I can apply paste to the screws at throw them away if they get too messy (or put additional nuts on the inside if I need more surface area).