tag:blogger.com,1999:blog-17836468248854294162024-03-13T04:54:08.346-07:00Exploring EEG with STM32F4 and ADS1299Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-1783646824885429416.post-61078070893280424482016-11-10T09:07:00.003-08:002016-11-10T09:07:41.566-08:00My Open Source Flickering Stimulator For SSVEP BCI (MATLAB - Psychtoolbox)I have just published my source code to generate four SSVEP stimuli on my github. Check them out if you are looking for a stable stimulation source.<br />
<br />
https://github.com/taro10h/flicker_stimulator<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com1tag:blogger.com,1999:blog-1783646824885429416.post-61693391414490252702016-07-06T00:49:00.002-07:002016-07-06T01:04:44.957-07:00SSVEP based BCI game with my hardware WEEG [Video]I would like to share the status of my work. This blog post contains a brief description of the system and a demo video of a Brain Computer Interface game. The subject control a game character by looking at different flickering target. The result was great. The game character moves at a decent pace. I will describe more about this system in comming posts.<br />
<br />
<b>Hardware:</b><br />
- WEEG (version 3.2) : Wireless EEG recording device with ADS1299<br />
- Bluetooth module: HC05 to handle wireless data transmission<br />
<br />
<b>Software:</b><br />
- Signal acquitition: Matlab GUI. Major functions in the background: Serial port data acquitition, Ring buffer to balance the datastream, real-time FFT, real-time configrable FIR/IIR filter, data integrity checker, event marker, game controller, and other signal processing functions.<br />
- Stimulation: Flickering stimulation at 4 frequency (6.6Hz, 7.5Hz, 8.75 Hz and 12Hz) by Psychtoolbox 3 ( I built this stimulation software from stratch). Highly recommend this tool box for precise timing experiment (with Matlab).<br />
- Game: Mario maze game ( written on Python). This game communicated with the WEEG signal acquitition via TCP. Insprired by<a href="http://link.springer.com/chapter/10.1007%2F978-3-642-30214-5_4#page-1"> this game</a><br />
<br />
<b>EEG montage:</b><br />
- Bias drive at Left Mastoid<br />
- Differential measurement at 1 channel: 0z-02<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-8_wMS98q9n8/V3y2fNxtPBI/AAAAAAAAFIg/Y3dq1SnTxw0GMw0AMZSUcpJzglG3w3EEACLcB/s1600/ssvep%2Bmodel%2Bwith%2Bweeg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://4.bp.blogspot.com/-8_wMS98q9n8/V3y2fNxtPBI/AAAAAAAAFIg/Y3dq1SnTxw0GMw0AMZSUcpJzglG3w3EEACLcB/s640/ssvep%2Bmodel%2Bwith%2Bweeg.jpg" width="484" /></a></div>
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/HriCj1_7jdI/0.jpg" frameborder="0" height="346" src="https://www.youtube.com/embed/HriCj1_7jdI?feature=player_embedded" width="430"></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
1<span class="Apple-tab-span" style="white-space: pre;"> </span>Zhu, D., Bieger, J., Garcia Molina, G., and Aarts, R.M.: ‘A Survey of Stimulation Methods Used in SSVEP-Based BCIs’, Computational Intelligence and Neuroscience, 2010, 2010, pp. 12</div>
<div style="text-align: center;">
<br /></div>
<br />Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com14tag:blogger.com,1999:blog-1783646824885429416.post-33246821880272629022016-05-31T20:11:00.000-07:002016-05-31T23:44:23.730-07:00Capturing alpha waves with WEEGEE<div class="MsoNormal">
This blog post is an excerpt from my conference paper for the 6th International Conference on the Development of Biomedical Engineering - Ho Chi Minh City, Vietnam. I will post a link to my article once it is available. The detection of alpha waves in my data is an important milestone for my project.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
This experiment concentrates on the analysis of the alpha rhythms (in the range of 8-12 Hz). Alpha brain waves boost up in EEG signal when subject’s eyes are closed, and when subject’s eyes open, alpha waves’ amplitude reduce. This is an ordinary feature of EEG data processing. From the standpoint of a hardware designer, it’s an important assessment for EEG recording hardware to verify that the system can measure ultra low brainwave signal.</div>
<div class="MsoNormal">
The subject is a student (23-year-old) who participated voluntarily in this experiment. The experiment comprises two phases. First, the subject sits and relaxes on a chair with his eyes open for 15s. There are none stimuli in front of the subject’s eyes. Second, the subject closes his eyes in 5s and opens his eye in 5s for every trial. This protocol is illustrated in Fig 1.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-XZJQvve8PsA/V05RHOg9mvI/AAAAAAAAFEU/llJYxEMRFiY3E-K9qpgB_1bsJb5FpYBfQCLcB/s1600/alpha%2Bprotocol%2Bjpeg.jpg" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="81" src="https://1.bp.blogspot.com/-XZJQvve8PsA/V05RHOg9mvI/AAAAAAAAFEU/llJYxEMRFiY3E-K9qpgB_1bsJb5FpYBfQCLcB/s400/alpha%2Bprotocol%2Bjpeg.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Fig. 1 Protocol for detecting alpha waves</div>
<br />
<br />
Every run consists at least 5 trials. We conduct 5 runs in the session. EEG data is recorded in two differential channels. Gelled electrodes are placed on the subject’s scalp according to the International Electrode (10-20) Placement System. One Ground (bias) electrode is placed on the left mastoid. The differential pair of channel 1 is placed on the O2 and the right mastoid. The differential pair of channel 2 is placed on the Oz and O1. The sampling rate is 250 Hz. EEG data was high-pass filtered at 0.3Hz to avoid DC drift and a low-pass filter at 43Hz because the signal of interest would be around 8-12Hz. Data is analyzed and visualized using a Matlab Graphical User Interface (GUI). The Power Spectrum Density (PSD) graph of one run is presented in Fig. 2. The result coherences with the hypothesis in which PSD of alpha waves is high (in red color) when subject’s eye is close; PSD of alpha waves is low when subject’s eye is open and relax.<span style="text-align: center;"> </span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-ugIO6hFutRw/V05RM1XEmSI/AAAAAAAAFEY/bGLjaPO0iesSVy4n7M4DnwiCxeTtEQDoACKgB/s1600/run2_channel2_picture_paper_annotate.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://3.bp.blogspot.com/-ugIO6hFutRw/V05RM1XEmSI/AAAAAAAAFEY/bGLjaPO0iesSVy4n7M4DnwiCxeTtEQDoACKgB/s320/run2_channel2_picture_paper_annotate.jpg" width="320" /></a></div>
<div style="text-align: center;">
<span style="font-family: "times new roman" , serif; font-size: 10.0pt;">Fig. 2 Spectrogram graph to detect alpha waves</span></div>
<div style="text-align: center;">
<span style="font-family: "times new roman" , serif; font-size: 10.0pt;"><br /></span></div>
<div style="text-align: left;">
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/gAbAcYxdP-w/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/gAbAcYxdP-w?feature=player_embedded" width="480"></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
Simulation video</div>
<span style="font-family: "times new roman" , serif; font-size: 10.0pt;"><br /></span></div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com1tag:blogger.com,1999:blog-1783646824885429416.post-26674139500781428192016-04-29T00:06:00.000-07:002016-04-29T00:18:27.982-07:00Armbrain prototype #3: Introducing WEEGEE, the Wireless EEG recording device<div>
I consider my Armbrain prototype #2 was a partial success. I get some improvements compare to the 1st prototype in term of circuit footprint. On the other hands, the analog system doesn't perform as I expected. In prototype #1, I use an ADS1299 Front end - Demo Kit from TI as an analog system with a STM32F407 Discovery board from ST as a digital system. I get everything working together to record ECG and alpha waves of the brain. I decided to layout a new circuit board which comprises essential components from those two evaluation boards. It's the prototype #2. </div>
<div>
<br /></div>
<div>
Its digital system works like a charm. If I send Test Signal from the ADS1299 channels, I can plot the exact plot on the Matlab interface. Also, I demonstrated temperature recording with this hardware in the previous post. I felt great about myself. I moved to the next task, checking analog system performance which is the key feature of this board. It just didn't work. I always got offset value for DC signal and weird noise for AC signal. I tried every possible way to debug the system such as measuring large signal, measuring EKG signal from EKG simulator or using logic analyzer to monitor data transfer. I could locate the issue comes from the ADS chip, yet I couldn't pinpoint the exact problem. I was upset because of this failure. I put off the project for awhile after countless testing and debugging efforts. A year later, I found that I made mistakes in placing polarized capacitor components on negative voltage rail. The positive pole of these capacitors should be soldered to the ground, whereas negative poles should be soldered to Vss. </div>
<div>
<br /></div>
<div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-rYjOAETLmuQ/VyMCWgyVQfI/AAAAAAAAFBk/EP-wgJScHWA6heOt6hI9eo5OMx3fhpt2QCK4B/s1600/capacitor.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" height="164" src="https://1.bp.blogspot.com/-rYjOAETLmuQ/VyMCWgyVQfI/AAAAAAAAFBk/EP-wgJScHWA6heOt6hI9eo5OMx3fhpt2QCK4B/s320/capacitor.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Capacitor placement on negative rail</td></tr>
</tbody></table>
<br /></div>
<div>
I design a better version 3 which is named WEEGEE. The name stands for Wireless EEG recording device. I built and tested the system. It performed very well. It can catch alpha waves, do some SSVEP experiments and measure electrode impedance. I will post more in upcoming blog posts. This new version has a charge circuit for a lithium battery. Any battery from 2.5V to 12V can power up the device thanks to the buck/boost converter TPS63060.</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-7dscNG_C5bM/VyMDv2JYQ1I/AAAAAAAAFB8/t_wwm5fwsCEX62rKcs4cobuyVP09u1eCACK4B/s1600/weegee2.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" height="166" src="https://1.bp.blogspot.com/-7dscNG_C5bM/VyMDv2JYQ1I/AAAAAAAAFB8/t_wwm5fwsCEX62rKcs4cobuyVP09u1eCACK4B/s200/weegee2.jpg" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">WEEGEE - Wireless EEG recording device (v3)</td></tr>
</tbody></table>
The basic spec of this board is listed as below<br />
<br />
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 2.85pt; text-align: center; width: 320px;">
<tbody>
<tr>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: none; border-top: solid windowtext 1.0pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" width="158"><div class="MsoNormal" style="text-align: center;">
Item</div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: none; border-top: solid windowtext 1.0pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" width="162"><div class="tablehead" style="text-align: center;">
Font Size</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 1;">
<td style="border: none; height: 11.4pt; mso-border-top-alt: solid windowtext .5pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
Number of channels</div>
</td>
<td style="border: none; height: 11.4pt; mso-border-top-alt: solid windowtext .5pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
8 (expandable to 32)</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 2;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
Analog Input Option</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
Differential and single ended input for all channels</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 3;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
Resolution</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
24 bit</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 4;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
Min input voltage step</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
22.3nV</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 5;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
Input voltage full-scale</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
188mV</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 6;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
CMRR</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
-110db</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 7;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
Analog power supply</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
Dual ±2.5V</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 8;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
System power supply</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
Single Lithium polymer battery cell 3.7V</div>
</td>
</tr>
<tr style="height: 11.4pt; mso-yfti-irow: 9; mso-yfti-lastrow: yes;">
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 118.65pt;" valign="top" width="158"><div class="MsoNormal" style="text-align: center;">
Steady state current</div>
</td>
<td style="height: 11.4pt; padding: .55pt 2.85pt .55pt 2.85pt; width: 121.5pt;" valign="top" width="162"><div class="MsoNormal" style="text-align: center;">
30mA</div>
<div class="MsoNormal" style="text-align: center;">
<br /></div>
</td>
</tr>
</tbody></table>
</div>
<div>
<div style="text-align: left;">
Also, I summarize the system architecture in the figure below<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-Wubg5-iBHC0/VyMKrQTrOyI/AAAAAAAAFCg/CnSMOUwtef4kQA0zQm8C6nN5hBD1VanSwCLcB/s1600/data%2Bflow%2Bv2.1signed.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://2.bp.blogspot.com/-Wubg5-iBHC0/VyMKrQTrOyI/AAAAAAAAFCg/CnSMOUwtef4kQA0zQm8C6nN5hBD1VanSwCLcB/s640/data%2Bflow%2Bv2.1signed.jpg" width="426" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
</div>
</div>
<div>
<ol>
</ol>
</div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com3tag:blogger.com,1999:blog-1783646824885429416.post-47884733390765403992014-11-01T02:30:00.000-07:002014-11-02T06:56:54.437-08:00Armbrain prototype #2: Bring it on!<div class="separator" style="clear: both; text-align: left;">
Five months have passed from my last post about the Armbrain board. It's been a long and hard time for me. My awesome teammate who took care of signal processing and Matlab user interface left my team to pursuit her higher education abroad. Her contribution was huge. I took time to cover her role and study her code in the project. It's quite a challenge. </div>
<div class="separator" style="clear: both; text-align: left;">
I tried to turn these challenges to opportunities. I learned to use Matlab to acquire and process data. Along the way, I added some nice features to the signal acquisition function such as ring buffers and 8-channel plot. Some data structures concept in this book <a href="http://www.amazon.com/Data-Structures-Algorithms-Michael-Goodrich/dp/0470383275">(Data Structures and Algorithms in C++)</a> was implemented to reduce processing time in Matlab. The result was great! For the first time, I can plot 8+ channel from the ADS1299 chip with sampling rate at 250sample/second in realtime without dropping any package.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Now I got a solid signal acquisition, and visualization. Next step, I will test and debug the circuit signal, performance. Some initial measurement presented offsets and high noise. Let's see what will I got in the next update! </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Check out my video for this update:</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/kFZ6IX5xXlE?feature=player_embedded' frameborder='0'></iframe></div>
<br />Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com4tag:blogger.com,1999:blog-1783646824885429416.post-19685486796582981702014-08-16T22:03:00.000-07:002014-08-16T22:03:03.936-07:00MATLAB Arduino Tutorial 3, 4 and 5<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.youtube.com/watch?v=jfptwZSG5WA" style="font-family: arial, sans-serif; font-size: 21.81818199157715px; letter-spacing: -0.6480000019073486px; text-align: start;">MATLAB Arduino Tutorial 3 - Vector and Magnitude Visualizations of 3-axis Accelerometer Data</a></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/5PShCCYu8jw?feature=player_embedded' frameborder='0'></iframe></div>
<div style="text-align: center;">
Demo tutorial 3</div>
<div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: #222222; font-family: arial, sans-serif; font-size: 24px; font-weight: normal; margin: 0px 0px 5px; overflow: hidden; padding: 0px;">
<br /></div>
<div>
<br /></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://i1.ytimg.com/vi/_1WmWxz9iZA/0.jpg" height="266" width="320"><param name="movie" value="https://www.youtube.com/v/_1WmWxz9iZA?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" /><param name="bgcolor" value="#FFFFFF" /><param name="allowFullScreen" value="true" /><embed width="320" height="266" src="https://www.youtube.com/v/_1WmWxz9iZA?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" type="application/x-shockwave-flash" allowfullscreen="true"></embed></object></div>
<div style="text-align: center;">
Demo tutorial 4</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/SBAUCBRufds?feature=player_embedded' frameborder='0'></iframe></div>
<div style="text-align: center;">
Demo tutorial 5</div>
<div style="text-align: left;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com0tag:blogger.com,1999:blog-1783646824885429416.post-20188554308021926112014-07-08T07:50:00.001-07:002014-07-08T07:50:38.235-07:00MATLAB Arduino Tutorial 2.1 - Serial Connection between Arduino to MATLAB <div>
As I said in the previous tutorial, source code from Arduino Matlab team is not simple. They created wonderful tutorials as a guide for us to learn rather than step by step tutorials for maker. I spent time to study source code from <a href="https://www.youtube.com/watch?v=dfT9Pf_y7NA" style="-webkit-transition: color 0.3s; background-color: #fafafa; color: #009eb8; display: inline; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14.399999618530273px; line-height: 15.680000305175781px; outline: none; text-align: justify; text-decoration: none; transition: color 0.3s;" target="_blank">MATLAB Arduino Tutorial 2 - Connecting and calibrating a 3-axis accelerometer</a><span style="background-color: #fafafa; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14.399999618530273px; line-height: 15.680000305175781px; text-align: justify;"> . </span> It's not straight forward to understand their algorithm because the author explained it briefly. I broke it down to function by function, step by step to rewrite a new code base on theirs. I learned some useful techniques by doing this.</div>
<div>
<br /></div>
<div>
Here is my code for you to refer: <a href="https://github.com/taro10h/MATLAB-Arduino-tutorial">Github repository</a><span id="goog_884408438"></span><span id="goog_884408439"></span><a href="https://www.blogger.com/"></a><br />
I went through my code in the video below. Enjoy.</div>
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/sz2QDILkcFQ?feature=player_embedded' frameborder='0'></iframe></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com0tag:blogger.com,1999:blog-1783646824885429416.post-47669409845054455772014-06-06T21:44:00.000-07:002014-06-08T07:58:10.851-07:00Collecting EOG signal with ArmBrain [updated]As I said in my previous post, the next step after collecting ECG signal is EOG signal (eye movement signal to put it simple). It's in the <a href="http://biomed.engr.sc.edu/bme_lab/lab%20reports/38)%20EOG%20I.pdf">milivolt range</a>. It's good to know the EOG signal form before moving in to EEG signal because EEG signal will include EOG signal artifacts. On the other hands, my friend used EOG signals to control a wheel chair. She collected EOG signals by the<a href="http://www.biosemi.com/products.htm"> Biosemi Active Two</a> <a href="http://www.biosemi.com/faq/prices.htm">EUR 75,000 beast</a>. My professor encouraged me to replace the Biosemi in that application with a low cost EEG/EOG recording device.<br />
<br />
<b>Setup</b><br />
I haven't found a standard for EOG electrode placement as EEG. It's a large signal (1mV p-p from my measurement); it should be easy to collect anyway. I decided to follow the set up from <a href="http://eeghacker.blogspot.com/2013/11/measuring-eog-with-my-eeg-setup.html">EEG hacker</a> to compare results with Chip's trial. Hardware and electrodes were the same as the last post. Below is the adapter from DIN 1.5mm touch-proof connector to regular breadboard jumper wire.<br />
<br />
<div class="separator" style="clear: both; text-align: left;">
<b><br /></b><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-AwA3kfM4KWY/U5KTSOBosDI/AAAAAAAACCw/fUsruU6vxPQ/s1600/IMG_20140604_185728.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-AwA3kfM4KWY/U5KTSOBosDI/AAAAAAAACCw/fUsruU6vxPQ/s1600/IMG_20140604_185728.jpg" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Gold cup EEG electrode adapter</td></tr>
</tbody></table>
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="http://4.bp.blogspot.com/-GAkpdNY-DYE/U5KQphxKUQI/AAAAAAAACCk/F7JO9dhJFNA/s1600/setup+for+EOG+06-06-14.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-GAkpdNY-DYE/U5KQphxKUQI/AAAAAAAACCk/F7JO9dhJFNA/s1600/setup+for+EOG+06-06-14.jpg" height="320" width="240" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.727272033691406px;">Gold cup EEG electrode secured by bandage. The reference electrode is on the right.<br />
<div>
<br /></div>
</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: left;">
<b><br /></b></div>
<div class="separator" style="clear: both; text-align: left;">
<b>Result</b></div>
<div class="separator" style="clear: both; text-align: left;">
I started with the eye blink artifact. I looked forward and blinked every 5s. The signal is very clear, strong and significant. We can use this signal for some simple computer interfaces such as playing a shooting game, sending a confirmation command of for a BCI application.</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-SCZx95JJyEM/U5KUaI8LSII/AAAAAAAACC8/IeH1wIjK3gY/s1600/EOG+Thong+blink+every+5s_annotation.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-SCZx95JJyEM/U5KUaI8LSII/AAAAAAAACC8/IeH1wIjK3gY/s1600/EOG+Thong+blink+every+5s_annotation.jpg" height="318" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Eye blink test</td></tr>
</tbody></table>
Later I ran fft for the signal than I knew the trouble maker. It was the 50 Hz noise spike from the electricity system.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-nnIWnxBdyIE/U5R4pdaoBJI/AAAAAAAACDc/d7Q0heWBB5E/s1600/EOG+eye+blink+every+5+fft.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-nnIWnxBdyIE/U5R4pdaoBJI/AAAAAAAACDc/d7Q0heWBB5E/s1600/EOG+eye+blink+every+5+fft.bmp" height="240" width="320" /></a></div>
<br />
I applied a notch filter on top of the original high pass filter. The result is amazing! It's very sharp signal.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-5BHvGeDbvlQ/U5R45eKk-lI/AAAAAAAACDk/QfPEgEXFEbU/s1600/EOG+Thong+blink+every+5s+after+notch+filter.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-5BHvGeDbvlQ/U5R45eKk-lI/AAAAAAAACDk/QfPEgEXFEbU/s1600/EOG+Thong+blink+every+5s+after+notch+filter.bmp" height="240" width="320" /></a></div>
<br />
<br />
For the next trial, I looked forward for 10s and looked down for 5s. I designed two different intervals so I could easily differentiate two states. I may add another marking channel to ArmBrain board which takes a button input as a marker for a new state.<br />
<div>
<br /></div>
<div>
The result is sufficient for classifying the two states. The mean of forward state signal is higher than 0 baseline and the down state is well below the 0 baseline. I notice that the noise level for this trial is higher than the previous one. It's about 0.5mV p-p compares to 0.3mVp-p of the former data set. Also, I wonder if those spikes in the looking forward portion belongs to eye blink artifact. I may record videos for my trials to match with the result later.</div>
<div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-Ri8RlQbDOWo/U5KYVExIWBI/AAAAAAAACDI/UcErKeGeapQ/s1600/EOG+down+5+-+fwd+10s-+shift+baseline_annotation.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-Ri8RlQbDOWo/U5KYVExIWBI/AAAAAAAACDI/UcErKeGeapQ/s1600/EOG+down+5+-+fwd+10s-+shift+baseline_annotation.jpg" height="318" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Look Down Test</td></tr>
</tbody></table>
<br />
I retried again with a looking forward and up combination. I still got an acceptable graph. A distinct gap presents between the baseline of two states though the signal is not stable as last trial. The baseline drifted and, noise level increased.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-nNZBTRWVqHU/U5KYVFlUQdI/AAAAAAAACDE/k1iyOCRgfd0/s1600/EOG+up+5+-+fwd+10s-+shift+baseline+_annotation.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-nNZBTRWVqHU/U5KYVFlUQdI/AAAAAAAACDE/k1iyOCRgfd0/s1600/EOG+up+5+-+fwd+10s-+shift+baseline+_annotation.jpg" height="318" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Look up test</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I call this a successful measuring session. I got satisfactory results. I have never known about EOG before. I want to thanks Chip from EEGhacker for his detail documentation. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Next step: - try different setups to track eyeball movement like the sample below from BIOPAC.</div>
<div class="separator" style="clear: both; text-align: left;">
- measuring EOG by EEG electrode location</div>
<div class="separator" style="clear: both; text-align: left;">
- build a blink detection system for some fun applications</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.biopac.com/ApplicationImages/eog1.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://www.biopac.com/ApplicationImages/eog1.gif" height="300" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">BIOPACK XY tracking</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com4tag:blogger.com,1999:blog-1783646824885429416.post-28082634415088247212014-06-05T08:47:00.000-07:002014-06-05T08:59:09.598-07:00ECG signal from a simulatorToday I get the <a href="http://www.ms-gmbh.de/en/phantom_start.htm">Phantom 320 </a> ECG signal simulator from my lab. I will use it to test my hardware which called ArmBrain from now (Arm stands for the ARM micro controller; Later, if ArmBrain is used for BCI application, Arm also stands for users' hand).<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-4xvyjKHotac/U5CJnIbbfHI/AAAAAAAACAs/O-alZBcSeDU/s1600/IMG_20140604_185754.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-4xvyjKHotac/U5CJnIbbfHI/AAAAAAAACAs/O-alZBcSeDU/s1600/IMG_20140604_185754.jpg" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>ArmBrain</b> Kit (TI daughter card is on the left; STM32F4 Discovery is on the right; The red board is the FTDI board)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-OCEZlxEw_H8/U5CImeYsDHI/AAAAAAAACAk/6n4r9hLJdCQ/s1600/IMG_20140604_185834.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-OCEZlxEw_H8/U5CImeYsDHI/AAAAAAAACAk/6n4r9hLJdCQ/s1600/IMG_20140604_185834.jpg" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ECG signal simulator</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: left;">
My setup: Left Arm(LA) and Right Arm(RA) signals from the simulator are connected to differential inputs of ADS1299 Channel 1. The Right Leg reference signal is connected to Bias electrode of the ADS board. Below are the graphs of data which I collected.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-42jEuCbThFc/U5CM5kD-ojI/AAAAAAAACBk/EQsOALqZFZs/s1600/ECG+signal+from+simulator+with+Bias.bmp" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-42jEuCbThFc/U5CM5kD-ojI/AAAAAAAACBk/EQsOALqZFZs/s1600/ECG+signal+from+simulator+with+Bias.bmp" height="188" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ECG signal from simulator collected by ArmBrain (3 wires set up)</td></tr>
</tbody></table>
I unplug the RL reference signal to test the output voltage graph without reference. It's noticeably noisier.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-TzGKF2kYC98/U5CPrUglqlI/AAAAAAAACCE/FsUST0lD640/s1600/sim+without+bias_volt.bmp" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-TzGKF2kYC98/U5CPrUglqlI/AAAAAAAACCE/FsUST0lD640/s1600/sim+without+bias_volt.bmp" height="286" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ECG signal from simulator collected by ArmBrain (2 wires set up - no reference)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: left;">
The ECG signal simulator is a good tool to study and test bio-signal circuit. I'm lucky to have it with me. If you don't have it, you can <a href="http://www.instructables.com/id/ECG-Simulator/">build one</a> with Arduino kit. </div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com3tag:blogger.com,1999:blog-1783646824885429416.post-33710223063321810332014-05-28T09:49:00.002-07:002015-05-18T07:20:55.728-07:00Collecting ECG signal with TI ADS1299 daughter card and STM32F4 DiscoveryI will blog about my journey from the beginning with the ADS1299 than I'll write about my ECG recording session. This project is my thesis so I can't post everything before I complete it. I started with the ADS1299 <a href="http://www.ti.com/tool/ads1299eegfe-pdk">Evaluation module</a> from January 2014. The module is helpful to get the feel of ADS1299 chip. A software comes with the module can collect couple seconds of data with different configurations. The designer of the Evaluation board created many jumpers and test points for multiple usage scenarios but it's very confusing to set them up. You will love it later when you understand the design.<br />
<div>
<br />
<b>Build my own module:</b></div>
<div>
I decided to follow a <a href="http://www.mccauslandcenter.sc.edu/CRNL/tools/ads1298">tutorial</a> from Chris Rorden's Neuropsychology Lab which shows a way to collect data from TI daughter card by any micro controller with SPI capability. The tutorial is on Arduino; I ported it to STM32F4 Discovery module.</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-nFfas4EMLJc/U4YJDIVVkjI/AAAAAAAAB_w/HBXiWdub5L0/s1600/IMG_20140222_182251.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="http://3.bp.blogspot.com/-nFfas4EMLJc/U4YJDIVVkjI/AAAAAAAAB_w/HBXiWdub5L0/s1600/IMG_20140222_182251.jpg" width="240" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ADS1299 EVM + STM32F4 Discovery + Bluetooth module</td></tr>
</tbody></table>
<br />
<b>Collecting ECG signal:</b><br />
My ECG set up for this time. another variation is at <a href="http://eeghacker.blogspot.com/2013/11/collecting-ecg-with-my-eeg-setup.html">EEG hacker</a> with disposable electrode.<br />
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-_kjdnX2ti84/U4YP3au_-ZI/AAAAAAAACAQ/YLMIQ1yUbsU/s1600/setup.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-_kjdnX2ti84/U4YP3au_-ZI/AAAAAAAACAQ/YLMIQ1yUbsU/s1600/setup.png" width="289" /></a></div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-KOZw143pcTA/U4YP052FnHI/AAAAAAAACAA/emhHRYKOdn0/s1600/ecg+without+Rl.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="187" src="http://1.bp.blogspot.com/-KOZw143pcTA/U4YP052FnHI/AAAAAAAACAA/emhHRYKOdn0/s1600/ecg+without+Rl.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">My ECG data without right leg electrode</td></tr>
</tbody></table>
I expected to get a noisy signal without a right leg electrode. I don't think it's this bad. Probably I will redo the test later.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-RM9qVondfsI/U4YP0-s0yEI/AAAAAAAACAE/QcSilkr3tK0/s1600/ecg.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="187" src="http://2.bp.blogspot.com/-RM9qVondfsI/U4YP0-s0yEI/AAAAAAAACAE/QcSilkr3tK0/s1600/ecg.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">My ECG data with Right Leg Drive</td></tr>
</tbody></table>
<div>
It's very interesting that Chip from <a href="http://eeghacker.blogspot.com/2013/11/collecting-ecg-with-my-eeg-setup.html">EEG Hacker</a> can capture a good ECG signal with only two electrodes on two hands without a right leg or reference electrode. I can't get any useful data with only two electrodes. The noise overwrites my ECG signal.</div>
<div>
I'm very happy with my ECG signal. It shows that my module is working at 1mV peak-to-peak signal. My next step is to test the EOG signal. EEG signal is still far away from now.<br />
<br />
Update 1: My wiring configuration<br />
Because Sebastian asked me to share the wiring configuration for the STMF4, I would like to share my note on the design. There are three main groups of pins in this design:<br />
SPI group: MOSI, MISO, CS, DRDY, START, SCK<br />
UART group: TX, RX<br />
Generic pins: Power, PWDN, Reset<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-M9i3SlWFGP4/VVnymhbmycI/AAAAAAAADQU/N35s4ldXWrA/s1600/Discovery%2Bwiring.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="223" src="http://4.bp.blogspot.com/-M9i3SlWFGP4/VVnymhbmycI/AAAAAAAADQU/N35s4ldXWrA/s400/Discovery%2Bwiring.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">STM32F4 Pin configuration with ADS 1299 EVM</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
Below are the pin details. Upper half presents signal pins. Lower half presents power pin.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-e1gqeBB26DA/VVnyrknMmiI/AAAAAAAADQc/D8JueYVO56g/s1600/EVM%2Bwiring.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="http://4.bp.blogspot.com/-e1gqeBB26DA/VVnyrknMmiI/AAAAAAAADQc/D8JueYVO56g/s640/EVM%2Bwiring.jpg" width="360" /></a></div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com11tag:blogger.com,1999:blog-1783646824885429416.post-86124339669009088022014-05-22T00:04:00.000-07:002014-05-22T02:43:29.848-07:00Making EEG Electrode AdapterMy EEG recording prototype needs an electrode adapter to collect data from standard EEG electrodes. I followed tutorials from <a href="http://eeghacker.blogspot.com/2013/11/making-eeg-electrode-adapter.html">EEGhacker blog</a> and <a href="http://eeghacker.blogspot.com/2014/01/eeg-electrode-adapter-version-2.html">Version2</a>. Here is the result:<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-d8Ox9rjVaxY/U32QuA8Ta7I/AAAAAAAAB_I/aUmW2YHwiSU/s1600/IMG_20140522_095506.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-d8Ox9rjVaxY/U32QuA8Ta7I/AAAAAAAAB_I/aUmW2YHwiSU/s1600/IMG_20140522_095506.jpg" height="240" width="320" /></a></div>
<div style="text-align: center;">
<span style="text-align: center;">From the Front</span></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-mNQN_H3QWiQ/U32QufkkMAI/AAAAAAAAB_M/wqMfD5OHsk0/s1600/IMG_20140522_095515.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-mNQN_H3QWiQ/U32QufkkMAI/AAAAAAAAB_M/wqMfD5OHsk0/s1600/IMG_20140522_095515.jpg" height="240" width="320" /></a></div>
<div style="text-align: center;">
From the Top</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Notes:</div>
<div style="text-align: left;">
The tutorial is very clear and easy to follow. I purchased 10 different colors terminals from Plastic One . They match with my rainbow jumper wire and the EEG electrode:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-SUfmJQKSP7o/U32U6PmQoYI/AAAAAAAAB_g/QI4KxSBh1hM/s1600/IMG_20140522_130917.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-SUfmJQKSP7o/U32U6PmQoYI/AAAAAAAAB_g/QI4KxSBh1hM/s1600/IMG_20140522_130917.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: left;">
Links for parts in Platics1.com doesn't work because they have just updated their website to a new template. I need to go to the<a href="http://www.plastics1.com/Gallery-CCS.php?CMD=VIEW"> site</a> and search for a specific P/N. I got my parts for free as an educational support/evaluation parts. Thanks Plastics1!</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com1tag:blogger.com,1999:blog-1783646824885429416.post-554930863960200332014-05-16T10:27:00.002-07:002014-05-16T10:27:53.549-07:00AHRS/Head tracking test with GY-85 I have been dreaming about using a Multiple Degrees of Freedom Sensor in my projects for a long time. It would be great for head tracking in BCI application for example. The 9 DOF sensor from ebay GY-85 has stayed on my desk for 6 months but I haven't got a chance to test it. After I got it running, I wrote this tutorial. Hope you will use it for your great projects.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/Ym-kfmHrkqQ?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br />
The<a href="https://github.com/ptrbrtz/razor-9dof-ahrs/wiki/Tutorial" target="_blank"> detail original tutorial</a> is based on the Sparkfun 9DOF Razor IMU. Mine is a GY-85 and an Arduino Fio. You can port it to any other arduino with ease.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Gd6QaFu_G98/U3ZDeK2822I/AAAAAAAAB-Y/TfdQ3wG2TBo/s1600/captutr.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-Gd6QaFu_G98/U3ZDeK2822I/AAAAAAAAB-Y/TfdQ3wG2TBo/s1600/captutr.jpg" height="180" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Physically different boards</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-bms16XzriEw/U3ZGJqanjAI/AAAAAAAAB-k/BHvS6TWQN2U/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-bms16XzriEw/U3ZGJqanjAI/AAAAAAAAB-k/BHvS6TWQN2U/s1600/Capture.PNG" height="246" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Similar electrical units</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
As you can see from the picture above, two configurations are very similar. To get the GY-85 to work , you need to connect it to 5V(prefered) or 3.3V from the Fio is still OK. Then hook up the SCL, SDA as below:</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;">GY-85</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;">Vcc_in -> 5 volt</span><br style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;" /><span style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;">GND -> Ground/GND</span><br style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;" /><span style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;">SCL -> A5 </span><br style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;" /><span style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;">SDA -> A4</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: 15px;">Now you can start to follow the <a href="https://github.com/ptrbrtz/razor-9dof-ahrs/wiki/Tutorial" target="_blank">original tutorial </a>. When you reach the section: Uploading the firmware> Hardware option, please choose this option:</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; font-size: 15px;"><span style="font-family: arial, helvetica, sans-serif;">#define HW__VERSION_CODE 10724 // SparkFun "9DOF Sensor Stick" version "SEN-10724" (HMC5883L magnetometer)</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; font-size: 15px;"><span style="font-family: arial, helvetica, sans-serif;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; font-size: 15px;"><span style="font-family: arial, helvetica, sans-serif;">Why? Because the stick is almost the same as the GY-85 ( without the Atmega on it) and the GY-85 comes with the HMC5883L. Push the code to arduino. Data should appear as mentioned in the tutorial. The rest of the tutorial is straight forward.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Do share with me your success stories. Good luck!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
ps: another great head tracking project with similar configuration is<a href="http://www.rcgroups.com/forums/showthread.php?t=1677559" target="_blank"> here </a></div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com0tag:blogger.com,1999:blog-1783646824885429416.post-72899534906064947692014-05-14T04:26:00.000-07:002014-07-08T07:50:57.062-07:00MATLAB Arduino Tutorial 2.0 - Serial Connection between Arduino to MATLAB ( Streaming value)<div class="tr_bq">
<br /></div>
In the previous post, I demonstrated how to exchange string value between Matlab and Arduino. It's very simple but effective to test the serial port communication. In this post, I will show you how to continuously stream value from analog read of arduino to Matlab plot.<br />
<div>
<br /></div>
<div>
Initially, I intend to post the source code for the <a href="https://www.youtube.com/watch?v=dfT9Pf_y7NA" target="_blank">MATLAB Arduino Tutorial 2 - Connecting and calibrating a 3-axis accelerometer</a> but the code for this tutorial is so complex. The author blends many different MATLAB functions to the barebone of the code. I can't figure them out for now. I try to find another tutorial which tells a simple way to stream int value from arduino to MATLAB. It's in Spanish. Don't worry, it's easy to understand. The code is very clear.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/BMBFKJbjslY?feature=player_embedded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;">Matlab+Arduino: Serial port communication [geekytheory.com]</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="text-align: start;">In this video, the author graph the voltage of a potential meter measured by an analog pin of arduino, and graph it by Matlab continuously</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="text-align: start;"><b>Arduino code: read data from analog pin A3 every 100ms, send data to serialport. You can choose any pin.</b></span></div>
<blockquote class="tr_bq" style="clear: both; text-align: start;">
<span style="text-align: start;"> </span>// the setup routine runs once when you press reset:<br />
void setup() {<br />
// initialize serial communication at 9600 bits per second:<br />
Serial.begin(9600);<br />
}<br />
// the loop routine runs over and over again forever:<br />
void loop() {<br />
// read the input on analog pin 0:<br />
int sensorValue = analogRead(A3);<br />
// print out the value you read:<br />
Serial.println(sensorValue);<br />
delay(100); // delay in between reads for stability<br />
}</blockquote>
<div class="separator" style="clear: both; text-align: justify;">
<span style="text-align: start;"><b>Matlab code: I commented in English</b></span></div>
<blockquote style="clear: both; text-align: start;">
<blockquote style="clear: both;">
function Matlab_Arduino(numero_muestras)</blockquote>
<blockquote style="clear: both;">
close all;</blockquote>
<blockquote style="clear: both;">
clc;</blockquote>
<blockquote style="clear: both;">
%% matrix to store output value</blockquote>
<blockquote style="clear: both;">
y = zeros(1,1000);</blockquote>
<blockquote style="clear: both;">
<br /></blockquote>
<blockquote style="clear: both;">
<br /></blockquote>
<blockquote style="clear: both;">
%%delete(instrfind({Port'},{'COM3'}));</blockquote>
<blockquote style="clear: both;">
%initiate COM Port</blockquote>
<blockquote style="clear: both;">
puerto_serial = serial ('COM3');</blockquote>
<blockquote style="clear: both;">
puerto_serial.BaudRate = 9600;</blockquote>
<blockquote style="clear: both;">
warning('off','MATLAB:serial:fscanf:unsuccessfulRead');</blockquote>
<blockquote style="clear: both;">
<br /></blockquote>
<blockquote style="clear: both;">
fopen(puerto_serial);</blockquote>
<blockquote style="clear: both;">
<br /></blockquote>
<blockquote style="clear: both;">
%counter of samples</blockquote>
<blockquote style="clear: both;">
contador_muestras=1;</blockquote>
<blockquote style="clear: both;">
<br /></blockquote>
<blockquote style="clear: both;">
%initiate figure property</blockquote>
<blockquote style="clear: both;">
figure('Name','Serial comm')</blockquote>
<blockquote style="clear: both;">
title('SERIAL COMMUNICATION MATLAB ARDUINO');</blockquote>
<blockquote style="clear: both;">
xlabel('number mustra');</blockquote>
<blockquote style="clear: both;">
ylabel('Voltage');</blockquote>
<blockquote style="clear: both;">
grid on;</blockquote>
<blockquote style="clear: both;">
hold on;</blockquote>
<blockquote style="clear: both;">
<br /></blockquote>
<blockquote style="clear: both;">
%plot received value until counter samples reach number of prefer samples</blockquote>
<blockquote style="clear: both;">
while contador_muestras <= numero_muestras</blockquote>
<blockquote style="clear: both;">
ylim([0 1024]);</blockquote>
<blockquote style="clear: both;">
xlim([contador_muestras-20 contador_muestras+5]);</blockquote>
<blockquote style="clear: both;">
valor_poten = fscanf(puerto_serial, '%d')';</blockquote>
<blockquote style="clear: both;">
y(contador_muestras) = (valor_poten(1));</blockquote>
<blockquote style="clear: both;">
plot(contador_muestras, y (contador_muestras),'X-r');</blockquote>
<blockquote style="clear: both;">
drawnow</blockquote>
<blockquote style="clear: both;">
contador_muestras = contador_muestras+1;</blockquote>
<blockquote style="clear: both;">
end</blockquote>
<blockquote style="clear: both;">
%close port</blockquote>
<blockquote style="clear: both;">
fclose(puerto_serial);</blockquote>
<blockquote style="clear: both;">
delete(puerto_serial);</blockquote>
<blockquote style="clear: both;">
clear all;</blockquote>
<blockquote style="clear: both;">
</blockquote>
<blockquote style="clear: both;">
end</blockquote>
</blockquote>
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-TsSdbjqQ79E/U3NSrW4dHKI/AAAAAAAAB-E/ibxF4XvFGUw/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-TsSdbjqQ79E/U3NSrW4dHKI/AAAAAAAAB-E/ibxF4XvFGUw/s1600/Capture.PNG" height="275" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: justify;">
<span style="text-align: start;">Good luck!</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com0tag:blogger.com,1999:blog-1783646824885429416.post-18556833969060000852014-05-14T00:35:00.000-07:002014-05-14T00:38:23.236-07:00MATLAB Arduino Tutorial 1 - Serial Connection between Arduino to MATLAB to USBThe <a href="https://www.youtube.com/channel/UCHJ_7c-Ax6IOpWIbjU6uuiA">Matlab Arduino</a> team created awesome tutorial on how to connect matlab with arduino through serial port. They provide these tutorials as a guidance for those who want to do similar things. Source code is not provided. I think it would be helpful to publish the code for those who want to try. I will also comment about some pitfall that I went through when I follow these videos.<br />
<div>
<br /></div>
<div>
<b>My arduino code:</b></div>
<div>
The original video doesn't show the arduino code in the loop portion. I put a digitalWrite for pin 13 as a confirmation for the successful connection, ie pin 13 will lit up after a serial connection is set up successfully between arduino and Matlab:</div>
<div>
<br /></div>
<div>
<blockquote class="tr_bq">
void setup() {<br />
// initialize serial communication at 9600 bits per second:<br />
Serial.begin(9600);<br />
pinMode(13, OUTPUT); <br />
Serial.println('a');<br />
char a = 'b';<br />
while (a != 'a')<br />
{<br />
a = Serial.read();<br />
<br />
}<br />
<br />
}<br />
// the loop routine runs over and over again forever:<br />
void loop() {<br />
digitalWrite(13,HIGH);<br />
}</blockquote>
<div>
<div>
<b><br /></b></div>
<div>
<b>Matlab code</b></div>
I use the same code as the video. IMPORTANT: you must save this code as a setupSerial.m file in the same folder before executing the function:<br />
<div>
<blockquote>
function[s,flag] = setupSerial(comPort)<br />
flag = 1;<br />
s = serial(comPort);<br />
set(s,'DataBits',8);<br />
set(s,'StopBits',1);<br />
set(s,'BaudRate', 9600);<br />
set(s,'Parity', 'none');<br />
fopen(s);<br />
a = 'b';<br />
while (a~='a')<br />
a = fread(s,1,'uchar');<br />
end<br />
if (a=='a')<br />
disp('serial read');<br />
end<br />
fprintf(s,'%c','a');<br />
mbox = msgbox('Serial Comm setup.'); uiwait(mbox);<br />
fscanf(s,'%u');<br />
end</blockquote>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-c3hHy_WxpY8/U3MccYXtRqI/AAAAAAAAB90/zw-3Uvi13Es/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-c3hHy_WxpY8/U3MccYXtRqI/AAAAAAAAB90/zw-3Uvi13Es/s1600/Capture.PNG" height="288" width="400" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com0tag:blogger.com,1999:blog-1783646824885429416.post-16389664480198083072014-02-14T03:31:00.000-08:002014-02-14T03:39:45.315-08:00Getting started with STM32F4 Discovery and Keil C 5 TutorialHere is a very good detail <a href="http://blog.tkjelectronics.dk/2012/04/review-stm32f4-discovery/" target="_blank">review about STM32F407 Discovery</a>. It goes through all the capabilities of the STM32 family, components of the board, compiler consideration. I choose Keil as my compiler; I see many others use Coocox and GCC.<br />
<br />
You should download and read the <u>UM1472 - User manual - Discovery kit for STM32F407/417 lines.</u> Read from the beginning, go through the Quick Start, Hardware Layout. It shows you how to test the board with pre-programmed code. Carefully read the ST-Link/V2 section, you will need it later. And don't forget to pay attention on some warning led, indication for overcurrent. Now you can plug the board to a USB port and follow through the Quick Start.<br />
<br />
<div>
Next step, we will install STM32F407 Discovery Driver<u> </u>on a Win 7 machine. </div>
<div>
1. Download and install <a href="http://www.st.com/web/en/catalog/tools/PF258168" target="_blank">STM32 - ST Link Utility (STSW-LINK004)</a>.</div>
<div>
2. Plug the board in the computer. If your computer recognizes the board, drivers were installed successfully. If not, go to step 3.<br />
3. A wrong driver was installed. You need to remove it to give the way for the correct driver. Go to Computer>Manage devices> Remove the Pre-installed ST Link driver ( Google how to do it).<br />
4. Unplug the boad > Then plug it in a gain > Done!</div>
<div style="font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div>
<div>
It's time to install the toolchain for Keil</div>
<div>
<br /></div>
<div>
1. Download and install Keil. The 4.7 version will have the STM32F4 Discovery Board example</div>
<div style="font-family: Tahoma; text-align: -webkit-auto;">
<a href="http://www.keil.com/arm/mdk.asp">http://www.keil.com/arm/mdk.asp</a></div>
<div style="font-family: Tahoma; text-align: -webkit-auto;">
<br /></div>
<div>
2. If you install Keil 4.7 => Skip to Step 3. Keil 4.7 comes with pre-install STM devices and examples. If you install Keil 5, then install <a href="http://www.keil.com/dd2/Pack/">STMicroelectronics STM32F4 Series Device Support, Drivers and Examples</a> <span style="font-family: Tahoma; text-align: -webkit-auto;"> </span>( look for stm32f4 library with example pack)</div>
<div style="font-family: Tahoma; text-align: -webkit-auto;">
<br /></div>
3. Open windows explore, open the project at <br />
<br />
<a href="http://4.bp.blogspot.com/-1MMw4E55CH0/Uv38s4L6mPI/AAAAAAAAB50/FowarA-h1SI/s1600/Image.png"><img border="0" height="80" src="https://4.bp.blogspot.com/-1MMw4E55CH0/Uv38s4L6mPI/AAAAAAAAB50/FowarA-h1SI/s1600/Image.png" width="400" /></a><br />
<img src="file:///C:/Users/tvo9/AppData/Local/Temp/enhtmlclip/Image.png" /><br />
<br />
4. Uncheck blinky folder property read only tick. Default property is read only to protect the file. Uncheck it for keil C to create axf file.<br />
<br />
<a href="http://1.bp.blogspot.com/-QdwaB492wXc/Uv389sDtzpI/AAAAAAAAB58/SBJgVTi4zDc/s1600/Image1.png"><img border="0" height="320" src="https://1.bp.blogspot.com/-QdwaB492wXc/Uv389sDtzpI/AAAAAAAAB58/SBJgVTi4zDc/s1600/Image1.png" width="253" /></a><br />
<img src="file:///C:/Users/tvo9/AppData/Local/Temp/enhtmlclip/Image(1).png" /><br />
<br />
<br />
5. Open Keil, then open the example project (Blinky.uvproj) => Build all => Download<br />
You should see 4 Leds are blinking at the same time.<br />
<br />
Open:<br />
You should check out <a href="http://www.youtube.com/watch?v=RXOOxby5nns" target="_blank">this video</a> tutorial on how to set up Discovery for Keil C. It used Keil 4.7; if you don't have 4.7, things may be very different as I experienced. To set up a Keil C project from stratch, you must read <a href="http://www.keil.com/appnotes/docs/apnt_230.asp" target="_blank">this application note</a>. It's also a Keil C 101.</div>
<!-- Blogger automated replacement: "https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F4.bp.blogspot.com%2F-1MMw4E55CH0%2FUv38s4L6mPI%2FAAAAAAAAB50%2FFowarA-h1SI%2Fs1600%2FImage.png&container=blogger&gadget=a&rewriteMime=image%2F*" with "https://4.bp.blogspot.com/-1MMw4E55CH0/Uv38s4L6mPI/AAAAAAAAB50/FowarA-h1SI/s1600/Image.png" --><!-- Blogger automated replacement: "https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F1.bp.blogspot.com%2F-QdwaB492wXc%2FUv389sDtzpI%2FAAAAAAAAB58%2FSBJgVTi4zDc%2Fs1600%2FImage1.png&container=blogger&gadget=a&rewriteMime=image%2F*" with "https://1.bp.blogspot.com/-QdwaB492wXc/Uv389sDtzpI/AAAAAAAAB58/SBJgVTi4zDc/s1600/Image1.png" -->Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com0tag:blogger.com,1999:blog-1783646824885429416.post-75931205395541207072014-02-12T04:45:00.004-08:002014-02-12T04:51:19.117-08:00From Arduino to ARM Cortex M4 (STM32F407 Discovery)My EEG acquisition project needs more communication channels, processing muscle, speed than the Arduino can offer*. I decided to take this chance to explore the ARM Cortex M4 which is top of the line for MCU. I will never worry about the limitation of the microcontroller again. But, I started to worry about my knowledge to work with it.
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-SRc2Pi8JQwA/Uvtt7hffxKI/AAAAAAAAB5k/Dm9miPp_Pgo/s1600/stm32f4_discovery_small.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-SRc2Pi8JQwA/Uvtt7hffxKI/AAAAAAAAB5k/Dm9miPp_Pgo/s200/stm32f4_discovery_small.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
In Arduino world, people speak the same language. We use the same IDE, quite similar libraries and boards. The assumption for most documentations, tutorials is that they are for beginners. It's easy to get started and do amazing things in hours! On the other hands, I learn do small projects with STM32 in couples of days or maybe...a week. People use many different IDE (Keil, IAR, Eclipse, Coocox...). Some guru write their own libraries; some use the STM standard peripheral library. Every generation of STM32 (F1,F3,F4). uses different standard libraries. You may find that the F1 library comes with more beginner examples (ex: simple SPI) while the F4 library comes with more complex examples (ex: DMA SPI). I recommend you take a look at F1 library although you work with F4 only because it comes with sample code.<br />
<br />
So far, I enjoy learning STM32F4 in a hard way. It's tough to navigate in its 1700+ reference manual. Once you got the hang of it, you will learn a lot about low level configuration and execution. It's the great thing compare to arduino.
*Some other similar systems still use Arduino. For example: OpenBCI uses Arduino for there 8 channels system. They switch to a 16-bit system for the 16 channels version. Anonymoushttp://www.blogger.com/profile/05594611727147059236noreply@blogger.com0