summaryrefslogtreecommitdiff
path: root/src/HW/mindflex/document.en.rest.txt
blob: b79320ddb320a5d9a2ed68312e471fb4abc82d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
========================
Playing with a Mind Flex
========================
:CreationDate: 2015-10-23 13:11:34
:Id: HW/mindflex
:tags: - hardware
       - software
 
Some time ago I bought a `Mind Flex`_, with the idea of interfacing it
to some motors, and control a thing **with my mind**!. As for the
"thing", I bought a `Keepon`_.
 
Of course they sat unused for years.
 
Then I got myself a `MicroView`_, because it was pretty.
 
Of course it, too, sat unused for years.
 
I've finally started putting the three together.
 
.. _`Mind Flex`: http://store.neurosky.com/products/mindflex
.. _`Keepon`: http://www.mykeepon.com/
.. _`MicroView`:
   http://learn.microview.io/Intro/general-overview-of-microview.html
 
Software setup
==============
 
First of all, I had to set up the Arduino IDE + compilers. On a Gentoo
system it used to be a bit tricky (although there is `a very clear post on the
Apollo NG site`_ that helped), but now it's just::
 
  emerge arduino crossdev dev-java/rxtx
 
  USE="multilib cxx" crossdev --target avr
 
These additional symlinks are probably still needed, though::
  
  ln -nsf /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts \
          /usr/avr/lib/ldscripts
 
  ln -nsf /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts \
          /usr/x86_64-pc-linux-gnu/avr/binutils-bin/2.20.1/ldscripts
 
  cd /usr/avr/lib
 
  ln -nsf avr5/crtm328p.o .
  ln -nsf avr6/crtm2561.o .
  ln -nsf avr6/crtm2560.o .
 
.. _`a very clear post on the Apollo NG site`:
   https://apollo.open-resource.org/mission:log:2015:01:20:gentoo-crossdev-compile-avr-gcc-for-arduino-and-cura
 
Arduino libraries
-----------------
 
I needed two libraries: the one to `read the Neurosky EEG data`_, and
the one to `control the MicroView hardware`_.
 
I cloned them in my "sketchbook" directory::
 
  mkdir -p ~/sketchbook/libraries
  cd ~/sketchbook/libraries
 
  git clone git@github.com:geekammo/MicroView-Arduino-Library.git \
      MicroView
 
  git clone git@github.com:kitschpatrol/Brain
 
Note that the MicroView library needs to be in a folder called
``MicroView``, not ``MicroView-Arduino-Library``: the Arduino IDE
really dislikes dashes in library names.
 
I also copied code from `BeatBots' GitHub repository`_.
 
.. _`read the Neurosky EEG data`:
   https://github.com/kitschpatrol/Brain
.. _`control the MicroView hardware`:
   https://github.com/geekammo/MicroView-Arduino-Library/
.. _`BeatBots' GitHub repository`:
   https://github.com/beatbots/mykeepon
 
Hardware setup
==============
 
I followed the instruction at `Frontier Nerds`_, soldering a wire to
the "T" pin of the Neurosky board, one wire to ground, and (my
addition) one wire to battery "+". This way I can power the MicroView
from the same batteries as the Mind Flex: when I tried powering them
separately, the Neurosky board seemed to have serious difficulty
getting a signal, probably because of noise on the power line.
 
I then connected (currently via a small breadboard) the MicroView to
the wires: ground to ground, power to VIN, signal to pin Rx.
 
.. _`Frontier Nerds`: http://www.frontiernerds.com/brain-hack
 
For the Keepon, I connected four wires as explained by BeatBots:
ground to ground, power to A0 (to read when the Keepon is turned on),
clock to A5, data to A4.
 
The program
===========
 
You can `browse the repository for the program`_; I'm using EMACS and the
`Arduino Makefile`_, instead of the normal IDE, because I like
command-line interfaces better than point&click, and also because my
C++ is so rusty that the real-time feedback of Flymake is necessary.
 
Currently working:
 
* read from the Neurosky
* get control of the Keepon every time it's turned on
* queue commands to the Keepon
* show all status on the MicroView
 
Future work:
 
* read the status of the Keepon (button presses, sensors, maybe ever
  microphone?)
* write some more interesting logic to map brain readings to movements
 
.. _`browse the repository for the program`:
   https://www.thenautilus.net/cgit/keepon-eeg/tree/
.. _`Arduino Makefile`: https://github.com/sudar/Arduino-Makefile