• No results found

Signal processing through electroencephalography: Independent project in electrical engineering

N/A
N/A
Protected

Academic year: 2021

Share "Signal processing through electroencephalography: Independent project in electrical engineering"

Copied!
32
0
0

Loading.... (view fulltext now)

Full text

(1)

Signal processing through electroencephalography

Independent project in electrical engineering

Tobias Andersson, Albin Sellergren, Jonathan Toft 25 May 2016

(2)

Abstract

This report is about a project where electroencephalography (EEG) was used to control a two player game. The signals from the EEG-electrodes were amplified, filtered and processed. Then the signals from the players were compared and an algorithm decided what would happen in the game depending on which signal was largest. The controls and the gaming mecha-nism worked as intended, however it was not possible to gather a signal from the brain with the method used in this project. So ultimately the goal was not reached.

(3)

Contents

1 Introduction 1

1.1 System overview . . . 2

1.2 Reference works . . . 2

2 Method and Materials 3 2.1 Main components . . . 3

2.1.1 EEG Electrodes . . . 3

2.1.2 Filters and amplifiers . . . 4

2.1.3 Fast Fourier Transform . . . 5

2.1.4 Integrated circuits and shielding . . . 5

2.1.5 Motor . . . 6

2.1.6 Locating the ball . . . 7

2.1.7 Micro controllers . . . 7

2.2 Arduino programming . . . 7

2.2.1 Overview . . . 7

2.2.2 Subsystem - Main . . . 7

2.2.3 Subsystem - Motor . . . 8

2.3 The game device . . . 8

2.3.1 Game dynamics . . . 9 2.3.2 Mechanical construction . . . 10 2.3.3 Design perspective . . . 11 3 Results 13 3.1 Obtained signal . . . 13 3.2 Signal processing . . . 14 3.3 Software . . . 14 3.4 Device functionality . . . 14 4 Discussion 16 4.1 Obtained signal . . . 16 4.2 Signal processing . . . 16 4.3 Software . . . 17 4.4 Device functionality . . . 17 5 Conclusion 18 6 References 19 7 Appendix 20 7.1 Circuits . . . 20

7.2 Code - main controller unit . . . 23

(4)

1

Introduction

There are four main types of neural oscillations, or brain waves, alpha, beta, delta and theta. The reason these waves exist is because neurons commu-nicate through small electrical impulses. These impulses form electric fields that look like wave like patterns when viewed through EEG-electrodes. The frequencies of these wave patterns varies from 1 to 30 Hz. In this project the focus was on alpha and beta waves, since they are the dominating waves in an awake human being. The delta and theta waves are generally only present during sleep or a coma. In previous experiments the measured amplitude of alpha waves varied between 20 and 200 µV and the amplitude of beta waves between 5 and 10 µV. The relevant frequencies varies between 8 and 30 Hz, alpha being in the lower part of the spectrum and beta in the higher part. If multiple EEG-electrodes are used to monitor the entire brain patterns can be found and interpreted. These patterns can then be used to control for example movement aids for paralysed people. Since every living human has brain activity it is something everyone can use, regardless of the state of their body.

Figure 1: The four main types of brainwaves[1]

The goal of this project is to investigate this technology and apply it to a device with a competitive function. Thereby giving something as abstract as brain activity a physical representation. This will be achieved by creating a game where two players compare which one has the most brain activity.

(5)

1.1 System overview

In order to create a functioning gaming device, the system needs to complete the following steps:

• Gather signals from each participant through EEG-electrodes. • Amplify and filter the acquired signals.

• Compare and sort the signals with a micro controller.

• Use the motor as a physical representation of the superior signal through a mechanical apparatus, in this case the motor will propel a magnet which in turn will move a metal ball across the playfield.

1.2 Reference works

The science to decipher our brain and interpret movements is a growing subject in the scientific community. Folowing Ian Burkhart gives you insight in how EEG technology can affect our daily lives. In 2010 Ian was involved in an accident resulting in a broken neck and paralysis from the elbows and down. Today however with the help of a research team from Battelle, a nonprofit research organisation that invented the technology and scientists at Ohio State’s Wexner Medical Center assisting the continued development, Ian is able to regain his parts of his movement. Not only were they able to find those signals in the brain and decipher them for individual finger movements, but they were also able to link those signals to Ian’s muscles and allow that kind of movement to be regained. This is fundamental for daily activities, such as feeding, and having the patient be able to clothe themselves.

This type of procedure is called a neural bypass and is based on, as the name suggests, an alternative route for the movement signal to take since the usual route is damaged and therefore no longer available. Instead an implant in the motor cortex sends signals through a cable to a computer which learns to interpret Ians thoughts into potential movement. Signals are thereafter sent to a device on his forearm containing 130 electrodes which stimulates the muscles Ian intend to move.

Researches are now looking for further ways to make these kind of sys-tems more portable and possible to use outside the hospital walls. Similar techniques and solutions could potentially be sent wirelessly to a control unit for processing, and then onwards to the specific muscle.

The team associated with Ian is working on making the system smaller and useful for a broader range of patients. They think that this can be applied to other motor impairments, not just spinal cord injuries, ruling on that this is just the beginning.

(6)

Details of the latest results regarding Ian are published in N ature[2], while the story[3],[4] about Ian and his tale can be found in the references.

2

Method and Materials

2.1 Main components

The project was built up of a few key elements which all played their funda-mental role in the final system. At first the brain activity had to be measured, the signal from the electrodes had to be shielded from unwanted noise and the signal had to be amplified in order to be possible to read. Then the signal had to be processed in code and some sort of physical representation of the signal had to be constructed.

2.1.1 EEG Electrodes

Electroencephalography is an electrophysiological monitoring method to record the electrical activity in our brain. What made it optimal for our project was it is noninvasive ability. EEG electrodes measure the voltage fluctua-tions resulting from ionic current within the neurons of the brain and is most often used to diagnose sleep disorders, coma, brain death and epilepsy which all causes abnormalties in the EEG readings.

Figure 2: The snap-on electrodes with associated cord

The electrodes used in this project were made from two parts, the wire with a snap-on adapter and the actual electrode which contained a polymer Ag/AgCl compound. They were also covered with a conductive gel to let them stick to the skin without having to apply anything first. This made them easy to change and fairly cheap but still good at their job.

Two electrodes were used, one was placed on the temple because that is the thinnest part of the skull. The other electrode was placed on the bony part behind the ear because that it is below the brain, meaning it should not pick up any brain activity there. The placement can be seen in figure 3.

(7)

Figure 3: The placement of the electrodes.

2.1.2 Filters and amplifiers

Brain waves are sensitive to electrical noise because of their low amplitude and the EEG-electrodes sensitivity. The main disturbance was the 50 Hz grid noise. Thus the 50 Hz noise exist in every power socket and has a greater signal amplitude than the brain wave signals. The 50 Hz noise had to be eliminated in order to be able to read the brain wave signals. The problem with the 50 Hz noise is that it lies close the the brain waves frequencies which makes a high order filter process needed to remove the 50 Hz noise. In addition to the filtering process the signal also needed to be amplified so that the MyDAQ could register the signal. This chapter will present and explain the amplifying- and filter process in the project. A problem with a low order filter is that the cut off-response is slow. A first order filter suppresses a signal with 20 dB/decade, a second order suppresses with at rate of 40 dB/decade and so on. The relevant frequencies have a range from 8-30 Hz. This means that the filter has a small margin to suppress the 50 Hz noise.

Two types of filters were introduced as candidates. The first one was a 50 Hz notch filter and the second one was a higher order low pass filter. The advantage with the notch filter was that it worked on a narrow margin and suppressed the 50 Hz noise at lower order rates but the project ended up using the low pass filter. The main reason for this was the low pass filter’s reliability for working even if its components had high tolerance values which

(8)

was a drawback on the notch filter which required exact values to be able to work properly. The low pass filter on the other hand demanded a wide fre-quency margin before 50 Hz in order to suppress the 50 Hz noise enough for it to be irrelevant. To tackle this problem a 5th order low pass filter was used. A 5th order low pass filter suppresses a signal at a rate of 100 dB/decade which is enough for the low pass filter to work properly between 30 Hz and 50 Hz. At the same time is it low enough to avoid a ripple effect were the filter start to counter work itself which is a possibility at higher orders. As previously mentioned the brain wave signals were weak (expected range 5-200 µV) and had to be amplified in order to read the signal. The approach was to amplify the signals, then eliminate the 50 Hz noise with filters and then amplify the remaining signal again. This was done because of the difference in signals strengths of the 50 Hz noise and the relevant signals. The first amplification boosted the 50 Hz noise to 5 V which was the maximum input voltage that the filter could handle. The brain wave signals was boosted with the same gain but was less than the 50 Hz noise. After the filtering process the remaining and weak brain wave signals were boosted to 5 V which became the input signal for the myDAQ. The myDAQ was set to acquire an array of 10000 values at a frequency of 5 kHz. The array was plotted and sent to a 25th order Butterworth low pass filter with cutoff frequency at 20 Hz. This would remove any remaining noise that was too small for the analog filter to handle.

2.1.3 Fast Fourier Transform

After the filter- and amplifying process the project needed an easy way to determine what frequencies remained and what amplitude they had because the amplitude of the right frequencies was the input value to the game. The solution was to use a fast fourier transform (FFT). A FFT is a numerical easier method of a fourier transform and is used to determine the amplitudes of frequencies in the frequency domain. The information given by the FFT is then sent to the micro controller that contains the game software. The micro controller’s input resolution is a 10 bit A/D-converter which gives a minimum input of 9,7 mV. This was not sufficient because of the low signal amplitude from the brain waves, even with amplifiers. A 16 bit worked better with a minimum resolution of 0,3 mV. A myDAQ was chosen as the 16 bit A/D-converter.

2.1.4 Integrated circuits and shielding

A mixture of weak signals, long wires and EEG-electrodes that picked up all electrical fields surrounding them made everything up to the myDAQ of the system sensitive to electrical noise.

(9)

Figure 4: The metal capsule aiding as a shield against electromagnetic interference

To counter this issue all sensitive parts in the system were put in a self made Faraday cage. This was made by using shielded wires and putting the relevant part of the system in a metal casket. The shielded wires were isolated with aluminum that surrounded the cables. The aluminum was grounded to the metal box which made everything shielded except for the EEG-electrodes and and small portion of the power supply. This did not completely remove every undesired signal but suppressed them enough to be able to ignore them afterwards. As a final safety precaution the inputs to the amplifier were grounded via large resistors to stabilize the input signal from the EEG-electrodes.

The wires used between the electrodes and the amplifier were shielded, of the model Alpha Wire H1 5773C. The protective coating of the wires was grounded to a metal case containing the amplifying circuits, the filters and the myDAQ. Thus protecting the raw signal from noise as much as possible. The shielded wires together with the metal case allowed the signal to be processed without drowning in noise.

2.1.5 Motor

For this project a stepper motor was used to give a visual representation of the acquired signals. A stepper motor converts a sequence of input impulses precise movements. For each impulse it moves the rotor a fixed angle.

Figure 5: The motor with wheel mounted on the rotat-ing axis.

The main reason why this precise movement is possible is its toothed electromagnets placed around a centered geared piece of iron. The mo-tor was connected to an associated driver cir-cuit, which in turn got inputs from the micro controllers. The driver circuit for this specific motor was the PowerDIP24. This circuit al-lows a simple algorithm to control the motor. It takes a PWM as input and makes the mo-tor take one step for every logic high. A high or low signal controls the direction of the mo-tor and the circuit disperses the supply voltage evenly over the motor’s phases.

(10)

2.1.6 Locating the ball

To make sure the motor started at the same place every time the game started up a photoelectric distance sensor was used. For this project the model was cy-192b-p-z. The transmitter produces pulses of light which reflects on a reflective area opposite to the sensor. This means it triggers a response when something breaks the path of the light, in the case of this project it was the magnet that makes the ball move. Every time the game starts the motor would step until it triggers the distance sensor, then it steps back to the middle of the game field. This way together with counting steps in the code the program would always know where the ball was. The sensor also worked as a fail-safe, in case the string holding the magnet would slip or in case one of the players would somehow try to alter the game. This would only work in one direction however.

2.1.7 Micro controllers

In order to get a functioning game that were able to communicate with the different parts of the system a micro controller had to be used. In this project a control unit called Arduino Nano was chosen.

This device was chosen because of its quick and powerful processor and with a wide range of communicative possibilities and its low price. The fact that the programming language is C-based made it even more desirable for our project since it is a language the group is familiar with. Because of the small and breadboard friendly design the Arduino Nano could be used without soldering during the trial phase of the project.

2.2 Arduino programming

2.2.1 Overview

The entire set-up consists of a two part control system, each one with its key role working as a interacting subsystem. Each part also has its own control unit of type Arduino Nano. The reason for this part based system was to get a smooth running software with good communicative abilities

2.2.2 Subsystem - Main

This controller unit was as the name suggests the main controller and its fundamental purpose was to communicate with all the rest, essentially the motor controller unit. Inputs/outputs for this controller consisted of:

• Filtered brain activity signal input from Filter control unit • Compared brain activity signal output to Motor control unit

(11)

• Maintaining an active interaction with the distance sensors as an input, able to instantaneously alert the Motor controller unit with a reset output

2.2.3 Subsystem - Motor

This controller unit is dedicated to the stepper motor control. Because the Main control did all the analog calculation this unit could focus on keeping track of the motor and its steps. Depending on which signal it gets from the Main control unit, two outputs will be sent to the motor. The first output is a pulse wave, with varying frequency depending on the compared signal from the Main unit. The second output is a logic high or low, this signal decides if the motor shall rotate clockwise or counterclockwise. The motor control unit also contains the reset function, that makes sure the ball ends up in the same place after every goal or startup. Inputs/outputs for this controller consisted of:

• Compared signals from the main unit • A PWM to the motor control circuit

• A logic high or low to control CW/CCW rotation

2.3 The game device

The game consists of a rectangular frame built from acrylic glass put together with angle iron and associated bolts and screws. Both top and bottom of this frame also consists of acrylic glass, the difference however is a black coating on all sides in order to create a nontransparent base with its affiliated transparent top. This will create a visual effect to whoever is either playing or watching while it also lets everyone look at the full circuit and game dynamics while playing.

(12)

Figure 6: Visual representation of the gaming device configuration

On top of this box, however, is where the gaming takes place. Centered in the middle of the transparent surface is a metal ball, hold in place by a magnet beneath the glass. More about how this is possible comes later in this section.

2.3.1 Game dynamics

On startup the motor will step until it triggers the distance sensor. After that the motor will step back a set amount of steps until it reaches the center of the game plan. Once the game starts the rules are simple - think as little as you can. This is not as easy as it sounds though. And with an opponent trying to do the same thing, the outcome can result in quite intense gameplay. The EEG electrodes monitor the brain activity, sending it to the game algorithm which compare the two signals and then signals the motor which one that is the strongest. The motor will choose its rotation direction depending on which player has the highest activity. Points will be rewarded the player that manages to stay calm and think less than the other player until the metal ball had moved from the center of the board to the end of the opponents side. When a point has been made, the game will reset everything to its original positions and the game will continue.

Figure 7: The direction of the balls movement depends on which player got the highest brain activity

(13)

2.3.2 Mechanical construction

The motor was the element that would make the metal ball move, thus there had to be some kind of mechanical arrangement that make this possible. The guidelines in creating this specific part was to be an unobtrusive, easy to hide, yet reliable and functional apparatus in order to keep the mystical harmony of the moving ball.

Figure 8: The construction with the threaded rod

Two different solutions were made, one with a threaded rod and one with two wheels and a cradle. The solution with the threaded rod would be very accurate and reliable but rather slow. And the solution with the wheels would be faster than the threaded rod, but also more unreliable and sensitive.

The solution with the rod was based around a rotating threaded rod con-taining a nut. The rotation of the nut was disabled by the use of a smaller metal rod with a fixed horizontal alignment placed parallel to the threaded one, thus enabling the nut to only move in the direction of the rod when the rod itself rotates. The rotation was then enabled by soldering the endpoint to the motor and thereby complete a compact and robust mechanic for the ball’s movement.

(14)

Figure 9: The arrangement with the customized parts, cradle and thread

The other solution, with the wheel and cradle, was to 3D print a wheel for a thread to move on and a cradle to hold the permanent magnet while being attached to the string. One wheel would be glued to the stepper motor’s shaft and the other mounted on an angle iron on the opposite side of the playfield.

A thread was wired around the wheel connected to the motor to make it relatively fixed on the wheel. The cradle would be tied to both ends of the thread and the magnet would be fitted in it tight enough to keep it in place but not too tight so it can not be moved. The wire then was wrapped around the other wheel as well. The force between the magnet and the metal ball would counter the gravitational pull on the heavy cradle and magnet. This way the thread would only experience a force perpendicular to gravity, making it less likely to break. In the end the solution with the wheel and cradle was chosen because of its superior speed.

2.3.3 Design perspective

One of the fundamental aspects from a design perspective of this device was the mystic about the moving metal ball. Since the game was all about moving this using only the power of your mind, one of the key elements we wanted to implement was the mystic of how you are able to do it. In order to successfully accomplish this, we needed to hide the magnets mechanic beneath the top glass and yet keep the remaining transparent so the players

(15)

where still able to look through and enjoy the visually appealing part.

Figure 10: Actual device showing the transparent surface and the painted center to hide the mechanics

(16)

3

Results

3.1 Obtained signal

When connected to the scalp the signal measured by the myDAQ was a 50 Hz sine wave varying between approximately -7.67 V and -7.46 V. After the digital filter the 50 Hz noise was much smaller, but still present. The FFT showed a clear DC offset and a spike at 50 Hz. Apart from this there were not any obvious frequencies to observe. See figure 11.

These plots were compared to the plots in figure 12, when the electrodes were measuring the noise in the air. The only real difference was that there was a significantly smaller DC offset in the air compared to scalp measure-ments.

When the electrodes were placed on the biceps there was a smaller DC offset compared to the scalp, but larger than when they were not connected to anything. But no change in frequencies, the 50 Hz was still the dominating frequency. When the muscle was tense however, the 50 Hz noise was no longer the dominating part of the signal. Apart from the offset the dominating frequency is 10 Hz, but there were also smaller fluctuations between 15 and 30 Hz. This can be seen in figure 13.

Figure 11: LabVIEW plots of the signal when the electrodes were connected to the scalp.

Figure 12: LabVIEW plots of the signal when the electrodes were not connected to anything.

(17)

Figure 13: LabVIEW plots of the signal when the electrodes were connected to a tense biceps

3.2 Signal processing

The initial amplification of the signal was tunable, but in the final stage it was set to 8000 times. Right after the amplifier the final filter was placed. It was a fifth order lowpass filter with cutoff frequency at 20 Hz, this means the 50 Hz noise was almost erased together with other possibly high frequency noise. At the end a second tunable amplifier was connected, it was set to 1000 times.

Because the myDAQ was set to acquire 10000 samples at 5 kHz the program ran slow, but the resolution achieved was more important than the speed of the program. As seen in the figures above both the low pass filter and the FFT worked well. However the desired frequencies were nowhere to be observed, at least not at a readable amplitude.

3.3 Software

Two arduino units were used, one comparing the signals and one communi-cating with the motor. Both systems were shown functioning after testing all possible outcomes of the game and thereby declared solid.

3.4 Device functionality

The device itself worked as it was supposed to. The distance sensor gave off the expected signal when it was supposed to, the motor stepped well but had to be muffled in order to not give off too much sound. The mechanical solution with the rod ended up making too much noise and being too slow, so it was not used in the end. It also moved slightly awkwardly due to the friction between the rod and the nut.

However the solution with the wheel and cradle ended up working better than expected. It moved in sync with the motor perfectly without glitches. The 3D printed material ended up being very light, but still durable enough for the construction to work. The magnetic force mentioned earlier also relieved the string just as it was supposed to, however this was only possible

(18)

when the game was actually assembled because the top part of the game was the thing holding the ball up.

None of the results regarding the mechanical solutions were actually mea-sured. However the device was tested multiple times and the each time the same result was achieved. The force on the thread was also only observed and not measured. It was mounted slightly too low for the construction to be optimal, the magnet actually pulled the cradle slightly upwards towards the ball.

(19)

4

Discussion

4.1 Obtained signal

The signal obtained from the EEG electrodes when they were connected to the scalp was just noise. The reason this conclusion is drawn is partly because the signals that showed up were perfect sine waves. The other reason is because the expected signals should have been around 100 µV but even with a 8000 times amplification before the low pass filter, then another 1000 times after it the signal was still only around mV and looked nothing like the expected alpha or beta waves. One possible reason the brainwaves were not picked up may be the fact that the factory made wires were cut and replaced with shielded wires as an attempt to shield from noise. It is not impossible that the soldering could have added too much resistance for the brain waves to make it through to the amplifier. This was a must though, since the original cables picked up too much noise to make the signal readable.

At one stage of the project impulses from the jaw muscle were acciden-tally measured, so to make sure the circuits still worked the electrodes were once again connected to a muscle. There was a significant difference in the measured signal when the muscle was tensed compared to when it was re-laxed, however the signal was still much smaller than anticipated. Because of this it was concluded that the brain waves were not possible to pick up with the final setup. One possible reason the brain waves did not show up in the measurement is simply too clumsy equipment. Generally a special ana-log front end is used to gather the signal right after the electrodes. These sensors are also mainly used in hospitals, which are already shielded from surrounding noise, in this project the location was a busy electronics lab filled with noise. Another possibility is that too few sensors were used over all, in the USA you have to use at least 75[5] sensors to be classified as clin-ical. An increased number of sensors would allow for less risk of one being slightly misplaced or slightly faulty. In retrospect this result was probably to be expected, several teachers at the university expressed their concern regarding reading brain activity.

4.2 Signal processing

A possible reason the signal did not show up in the 16bit myDAQ may be because the resolution was too low, for example Texas Instruments is pro-ducing a 24 bit analog front end (ADS1299)for biopotential measurements. It is also possible that it was too difficult for the filter to plot the signal, since it plots the output with its clock frequency.

(20)

4.3 Software

The software worked as expected, however it was a bit set aside due to focus being moved to signal acquiring at the later stage of the project. The code worked the way it was supposed to both in the Arduino and the myDAQ, so it did not seem like a logical distribution of effort to try to fix an already working code. This resulted in a slightly sub optimal solution, this was not a problem in the end though. It would have been desirable to add more features and a proper scoring system, however due to reasons previously mentioned this was not done. The Arduino code could have been optimised, for example the pulse wave controlling the motor was constructed with a delay function. It did not affect the outcome, but if the Arduino units had to do more continuous readings the delay function may have caused problems. The steps were counted within the code only, it could have been done with sensors picking up the currents in the motor or by getting feedback from the motor control circuit, but this also seemed redundant in this very project because everything already worked the way it was supposed to. The code used in the myDAQ was simple, it utilised the build in FFT function and plotted the result in a graph. In retrospect perhaps the myDAQ should have been used to compare the signals as well, rather than sending them onward to the Arduinos, but since the desired signal was never acquired this did not seem like something important to implement.

4.4 Device functionality

The mechanical construction could have been made differently. One of the problems with the solution with the rod is that it was simply too slow, this could have been solved by adding gears to the motor. This would be a bit risky, because the gears would introduce a new problem. They would have to be precisely made to make sure every single step of the motor moved the ball. In the end this idea was decided against, because the noise issue would still remain even if the gears were made perfectly. Instead the solution with the wheel and cradle was built, this proved to be satisfactory. The doubts whether the thread would slide and create a miscalculation proved to be unnecessary. In the end some extra effort had to be made, since two different mechanical constructions were made to allow the motor to move the ball, but it was worth it because the final solution is much faster and quieter than the first one tried. It is also possible that the magnet should have had a track to follow, to relieve the thread even more, but once everything is assembled it would not really make that big of a difference, if the thread would break at some point it is easily replaced by another one.

(21)

5

Conclusion

The goal of the project was to construct a one versus one game controlled by the brain waves of each player. While the physical game was completed, as well as a working game algorithm, the final product of the project failed to gather the brain waves. The signal processing worked on muscles, but proved to be insufficient regarding the brain waves. A factory made analog signal processing unit could have been bought to complete the final product thus al-lowing us to move forward and focus on functions in the game device that had to be scrapped due to the circumstances around the signal processing. But because building a signal processing unit was part of the project and because a big part of the project was to give the participants better understanding about this topic, this was not done. It is difficult to make a working analog circuit that both filters and amplifies a very small signal, especially in an area with lots of electrical noise. Certain subjects often focus on one aspect and thus greatly simplifies theory against real world examples. A book about amplifiers only mentions how to build an amplifier but leaves the aspect of vulnerability of distortion or electrical background noise out of the picture. At the same time a book about electrical noise and shielding only uses 5 V input signals and never weak signals in the examples given by the book. As a result it is hard to predict how a combined practical appliance from sev-eral fields and subjects will result in contrast to the theoretical methodology. Another conclusion that can be drawn is that the electrical impulses in mus-cles are larger than the electrical impulses between the neurons in the brain. Another thing worth mentioning was how this project differed in scale compared to a genuine medical system. Using only 2 basic electrodes with a home made amplification circuit and associated filtration compared to a full scale medical instrumentation was not a fact to neglect. With requirements of at least 75 scalp electrodes instituted 1991 by the American EEG society as a part of the modified combinatorial nomenclature regarding EEG, a subtle amount of 2 electrodes proved elusive.

A recommendation considering the statements above is to use a more well-tried method to acquire the signals and keep in mind that it takes a lot of effort to create one from scratch. The outcome could have been different if the focus was on finishing the project rather than trying to build an analog circuit. However the project definitely gave the members a good educational experience.

(22)

6

References

1. Normal Adult Brain Waves.

http://thumbs.dreamstime.com/z/normal-brain-waves-eeg-29444815.jpg

[Accessed 19 May 2016].

2. Nature, 2016, Restoring cortical control of functional movement in a human with quadriplegia, Chad E. Bouton, Medical Devices and Neuromodulation, Battelle Memorial Institute.

http://www.nature.com/nature/journal/v533/n7602/full/nature17435.html

[Accessed 19 May 2016]

3. The Guardian, 2014, Technology bridges gap between brain and mus-cles for victim of paralysis, Jim Tankersley, Washington Post.

https://www.theguardian.com/science/2014/jul/04/gap-brain-muscles-paralysis-neurobridge-spinal-cord [Accessed 19 May 2016]

4. The Guardian, 2016, Brain implant helps paralysed man regain partial control of his hand, Ian Sample Science editor, Washington Post.

https://www.theguardian.com/science/2016/apr/13/brain-implant-paralysed-man-regain-partial-control-hand-neural-bypass [Accessed 19 May 2016]

5. Niedermeyer, E & Lopes da Silva, F (2005). Electroencephalography. 5th ed. USA: Lippincott Williams & Wilkins. p.140.

(23)

7

Appendix

7.1 Circuits

Figure 14: The complete filter and amplifying circuit consisting of two INA126p circuits and one LTC1062 filter circuit

(24)
(25)

Figure 16: The LabVIEW code used to filter and analyse the signal from the analog circuit.

(26)

7.2 Code - main controller unit

Note: All text below starting with "//" are comments of the code, allowing the reader an easier understanding of the code.

int Player1Pin = A0; //Analog inputs for each player, A1 and A0 int Player2Pin = A1; //represent the brain activity signal

int Player1; int Player2; int utPin = 7; int Speed; int diff; int slowPin = 2;

int mediumPin = 3; //The three different speed options int fastPin = 4;

String Amount; //The amount of voltage difference between players String P1string;

String P2string; void setup()

//During the setup the program compute the following line of code once, as a start-up or initialization. In this particular code the program go through all the outputs and inputs used by the controller unit and set what type of value it want to either receive as an input or send as an output.

pinMode(utPin, OUTPUT); pinMode(slowPin, OUTPUT); pinMode(mediumPin, OUTPUT); pinMode(fastPin, OUTPUT); Serial.begin(9600);

(27)

void loop()

//The loop-part of the program is the code that keeps computing in a lasting loop. Everything below will be computed in order as long as the controller unit receives power, thus allowing a continuous program that does not need supervision. As soon as the code reaches the last line of code, the program will restart from the beginning.

// Start everything by reading the analog values from each player and put the measured difference in the variable "diff".

Amount = String(analogRead(Player1Pin)-analogRead(Player2Pin)); diff = abs(analogRead(Player1Pin)-analogRead(Player2Pin)); Player1 = analogRead(Player1Pin); Player2 = analogRead(Player2Pin); Player1string = String(Player1); Player2string = String(layerP2);

//Following code examine how big the difference in signal is and activate the speed-pins accordingly. These pins are then checked by the motor con-trol unit so the this unit know how fast the motor should turn. First up is to see if it is the slow pin that should be activated.

if (diff < 150)

digitalWrite(slowPin, HIGH); digitalWrite(mediumPin, LOW); digitalWrite(fastPin, LOW);

//If not the slow pin, the program check if the medium pin should be acti-vated.

if (diff > 150)

digitalWrite(slowPin, LOW); digitalWrite(mediumPin, HIGH); digitalWrite(fastPin, LOW);

//And last up the program check if it is the fast pin that should be ac-tivated.

if (diff > 300)

digitalWrite(slowPin, LOW); digitalWrite(mediumPin, LOW); digitalWrite(fastPin, HIGH);

(28)

//This last part control which direction the motor should take, is player1 the superior signal or player2? and activates the direction-pin accordingly.

if (Player1 > Player2) digitalWrite(utPin, HIGH);

else

(29)

7.3 Code - motor controller unit

int step = 0; //Starts the program by defining number of steps taken boolean CW;

const int sensorpin =A0; //The pin that receives the sensor value void setup()

pinMode(2, INPUT); //Input pin monitoring the direction pinMode(3, INPUT); //Pin representing the slow speed pinMode(4, INPUT); //Pin representing the medium speed pinMode(5, INPUT); //Pin representing the fast speed pinMode(6, INPUT); //Pin activating the reset function

pinMode(12, OUTPUT); //PWM signal to received by the motor pinMode(10, OUTPUT); //Output pin for the direction

pinMode(sensorpin, INPUT); //Activating the sensor pin as a input //The setup software in the motor controller unit contains the initial setup where the program define where the center of the board is by help of the sensor. The ball roll towards the sensor until this activates and send a signal to the controller unit. As soon as the unit receive this signal, the program know that it is exactly 290 steps to the middle and therefore starts stepping back 290 steps until the program enters the loop() and start the gaming session.

int sensorvalue = analogRead(sensorpin); digitalWrite(10, HIGH); while(sensorvalue < 300) sensorvalue = analogRead(sensorpin); digitalWrite(12, HIGH); delay(10); digitalWrite(12, LOW); delay(10); digitalWrite(10, LOW); for(int i=0; i < 290 ; i++) digitalWrite(12, HIGH); delay(10);

digitalWrite(12, LOW); delay(10);

(30)

void loop()

//Start the loop by checking which direction the motor should turn. If pin 2 is activated, the motor turns clockwise and if it is not activated, counter clockwise. if(digitalRead(2) == HIGH) CW=HIGH; digitalWrite(10, CW); else CW=LOW; digitalWrite(10, CW);

//Next up the program check which speed it should rotate with. If pin 3 is activated the motor goes slow, If pin 4 is activated, the motor goes medium speed and If pin 5 is activated, the motor goes fast. The speed is set by the amount of delay between turns. The step++; and step–; repre-sent the monitoring of number of steps the ball have taken towards a player depending on direction.

if(digitalRead(3)==HIGH) digitalWrite(12, HIGH); //Slow delay(50); digitalWrite(12, LOW); delay(50); if(CW==HIGH) step++; else step–; if(digitalRead(4)==HIGH)

digitalWrite(12, HIGH); // Medium delay(25); digitalWrite(12, LOW); delay(25); if(CW==HIGH) step++; else step–; if(digitalRead(5)==HIGH) digitalWrite(12, HIGH); // Fast

(31)

delay(10); digitalWrite(12, LOW); delay(10); if(CW==HIGH) step++; else step–;

//At the end of the loop we check if the ball has reached its goal by en-tering a players endzone.

reset();

void reset(void)

//Below the program check if the end zone is reached by monitoring the amount of steps taken towards both players and checking which direction that is currently activated. If the number of steps surpass 250 in any di-rection a point is obtained for the other player and the game will reset by returning the balls position at the center of the board.

if(step>250) CW=LOW; delay(2000);

digitalWrite(10, CW); for(int i=0; i < 250 ; i++) digitalWrite(12, HIGH); delay(10); digitalWrite(12, LOW); delay(10); step–; delay(2000); if(step<-250) CW=HIGH; delay(2000); digitalWrite(10, CW); for(int i=0; i < 250 ; i++) digitalWrite(12, HIGH); delay(10); digitalWrite(12, LOW); delay(10); step++; delay(2000);

(32)

References

Related documents

In this chapter, a parameter estimation algorithm called EASI- SM is compared to the non-negative least squares (NNLS) spectrum approach commonly used in the context of MRI.

the company should prepare targets and guide values for all energy use on the basis of the results of a first energy analysis FEA of the building; the targets are in respect of

[r]

Again, the neck pain risk we found from rotation in a group of forklift operators (OR 3.9, Table 2 ) seems reason- able given that forklift operators are more exposed to un-

O’Boyle (2016) går däremot emot DeNisi och Pritchards (2006) åsikt och hävdade i sin meta-studie att mindre kontrollerande parametrar som binds till organisationens

Radu Beller 25, Bucharest, Romania † Electronic supplementary information (ESI) available: Additional information regarding the TQ–PC 71 BM models and the methods; the excited

Keywords: Autonomous Driving, Deep Learning, Image Processing, Convolutional Neural Networks, Recurrent Neural Networks, Generative Adversarial Networks... 4

The radio wave propagation prediction is one of the key elements for designing an efficient radio network system. WRAP International has developed a software for