+ All Categories
Home > Documents > RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!!...

RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!!...

Date post: 25-May-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
31
Raman Research Institute, Bangalore SSVEP Based BCI System Krishna Prasad S Visiting Student (June 2013 – February 2014) An Internship report on
Transcript
Page 1: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

   

         

   

R a m a n   R e s e a r c h   I n s t i t u t e ,   B a n g a l o r e  

SSVEP  Based  BCI  System  Krishna  Prasad  S  Visiting  Student  (June  2013  –  February  2014)  

08  Fall  

An  Internship  report  on  

Page 2: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  2  

Contents    

EXECUTIVE  SUMMARY  ...................................................................................................................................................  3  1.  ACKNOWLEDGEMENTS  .............................................................................................................................................  4  2.  INTRODUCTION  AND  OVERVIEW  ..........................................................................................................................  5  2.1   WHAT  IS  BCI?  ............................................................................................................................................................................  5  2.2   WHY  BCI?  ...................................................................................................................................................................................  5  2.3   INTRODUCTION  TO  SSVEP  ......................................................................................................................................................  5  2.4   BCI  AT  RRI  .................................................................................................................................................................................  6  

3.  AN  OVERVIEW  OF  THE  RRI-­‐BCI  SYSTEM  .............................................................................................................  6  3.1   BLOCK-­‐DIAGRAM  OF  THE  COMPLETE  SSVEP  BASED  BCI  SYSTEM  ..................................................................................  6  

4.   THE  RRI-­‐BCI  SYSTEM  IN  DETAIL  ........................................................................................................................  7  4.1   THE  ALTERNATE  VISUAL  INPUT  DEVICE  (AVID)  ................................................................................................................  7  4.2   THE  MINIATURIZED  RRI  EEG  AMPLIFIER  (BIO-­‐AMP  V2)  ...............................................................................................  8  4.2.1   Operating  Characteristics  ..............................................................................................................................................  8  4.2.2   Utility  .......................................................................................................................................................................................  9  4.2.3   Components  Used  ...............................................................................................................................................................  9  4.2.4   Distinct  Circuits  present  ..................................................................................................................................................  9  4.2.5   Simulation  Software  and  Parameters  .......................................................................................................................  9  4.2.6   Simulation  Circuits  ..........................................................................................................................................................  10  4.2.7   Simulation  Output  ...........................................................................................................................................................  14  4.2.8   PCB  Schematic  and  Layout  Design  ...........................................................................................................................  15  4.2.9   How  they  look  ....................................................................................................................................................................  18  4.2.10   Testing  and  Results  .......................................................................................................................................................  18  4.3.11   Planned  Enhancements  ..............................................................................................................................................  19  

4.3   DIGITIZER  ..................................................................................................................................................................................  19  4.4   SIGNAL  PROCESSOR  .................................................................................................................................................................  21  4.4.1   Objective  ...............................................................................................................................................................................  21  4.4.2   Theory  ...................................................................................................................................................................................  21  4.3.3   Implementing  the  Matched  Filter  .............................................................................................................................  22  

5.   TAKEAWAYS  ..........................................................................................................................................................  24  6.   APPENDIX  ...............................................................................................................................................................  25  6.1   THE  AVID  ARDUINO  CODE  FOR  3  LEDS  .............................................................................................................................  25  6.2   4-­‐CHANNEL  ARDUINO  DIGITIZER  .........................................................................................................................................  27  6.3   MATCHED  FILTER  PROGRAM  ON  ARDUINO  .........................................................................................................................  27  

                       

Page 3: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  3  

Executive  Summary    My  internship  at  Raman  Research  Institute,  Bangalore  under  the  Visiting  Students  Program  was   to  build   a  Brain-­‐‑Computer   Interface   (BCI)   System  using  Steady  State  Visually  Evoked  Potentials  (SSVEP),  the  details  of  which  are  covered  in  this  report.      My  9-­‐‑month  long  internship  at  RRI  under  the  BCI  group  headed  by  Dr.  HemaRamachandran  and   Dr.   Ramesh   Balasubramaniam   involved   working   in   some   key   areas   of   the   project   as  listed  below:    

i. Visual   Input   Device:   An   ArduinoTM   powered   hand-­‐‑held   LED   stimulator   panel  capable  of  firing  4  independent  LEDs  at  different  frequencies.  

ii. EEG  Amplifier:  A   2-­‐‑channel   EEG   amplifier,  which  was   simulated   first   using  NI  Multisim   13.0   and   then   fabricated   using   Cadence   Allegro   PCB   suite.   The   EEG  Amplifier   comprises   of   a   50Hz   Notch   Filter,   a   Low   Pass   Filter   at   200Hz   and   a  Variable  Gain  Stage  in  addition  to  Instrumentation  Amplifiers.  

iii. Digitizer:  A  4-­‐‑channel  digitizer  operating  at  256Hz  was  developed  on  ArduinoTM  Platform.  

iv. Signal   Processor:   A   Matched   Filter   was   implemented   on   Java   and   then   on  ArduinoTM  (2-­‐‑Channels),  which  now  can  sample  and  look  for  the  signal  frequency  at  the  same  time.    

   I  acquired  many  new  technical  skills  throughout  my  work  term.  The  internship  was  helpful  in  brushing  up  my  basics  in  Analog  Electronics  and  Signal  Processing.  Besides,  I  got  hands-­‐‑on  experience  in  fabricating  Printed  Circuit  Boards  and  populating  them  with  Surface-­‐‑Mount  devices.      Additionally,   I   got   introduced   to   the   area   of   research   and   how   to   approach   it.   Most  importantly,   the   work   experience   was   very   valuable   which   included   good   fellowship,  cooperative  teamwork,  accepting  responsibilities,  how  to  make  and  meet  deadlines,  manage  time   and   most   importantly,   deal   with   situations   even   when   desired   results   are   not  forthcoming.  Additionally,  the  poster  and  the  talk  delivered  during  the  In-­‐‑House  2014  event  at  RRI  improved  my  presentation  skills  and  greatly  boosted  my  confidence.      This  report  concludes  with  my  overall  impressions  of  my  work  experience.              

Page 4: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  4  

1.  Acknowledgements        Firstly,   I   am   extremely   thankful   to  my   guides:  Dr.  Hema  Ramachandran   and  Dr.   Ramesh  Balasubramaniam   for   providing   me   an   opportunity   to   contribute   and   for   their   valuable  guidance.        I   am   extremely   grateful   to  Mrs.   Sujatha.   S   of   RAL   (and   the   BCI   Team),   without  whom,   I  cannot  imagine  how  my  internship  term  at  RRI  would  have  been.        It  was  indeed  a  pleasure  working  with  Mr.  James  Matthew  of  LAMP,  for  his  helpful  technical  inputs  and  signal  processing  expertise.      I  am  also  thankful  to  RAL  Staff,  especially  Mr.  K.B.  Raghavendra  Rao,  Mr.  Somashekar,  Mrs.  Arasi  and  Mr.  Ibrahim  of  the  RRI  Workshop  for  their  constant  guidance  and  support.        Also,  I  am  very  thankful  to  my  'ʹgang'ʹ  of  friends  from  the  A&A  and  LAMP  group  for  making  my  stay  at  RRI  and  in  Bangalore  a  pleasant  and  a  memorable  one.                                              

Page 5: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  5  

2.  Introduction  and  Overview    

2.1   What  is  BCI?    A   brain   computer   interface   (BCI)   is   a   new   way   of   communication   between   humans   and  computers.  It  utilizes  a  very  uncommon,  but  on  the  other  hand  probably  the  most  direct  way  of  access  to  the  intentions  of  a  person.  The  will  /  intention  of  the  person  gets  communicated  directly  to  the  computer  from  the  origin  of  the  intention  itself  –  the  brain.    With  BCI,  a  person   ideally  does  not  have   to  make  use  of   the  common  output  pathways  of  peripheral   nerves   and   muscles.   Typically   the   input   to   a   BCI   system   uses   the   electrical  brainwaves   of   the   person,   measured   with   the   well-­‐‑known   electroencephalography   (EEG),  which  was  primarily  used  for  clinical  purposes  only  in  the  past.  This  EEG  is  then  amplified  and  fed  into  a  computing  device,  which  processes  them  with  appropriate  algorithms  to  give  the  person  a  new  kind  of  communication  channel.    

2.2   Why  BCI?    The  main  motivation  behind  BCI  research  all  over  the  world  is  to  restore  independence  and  mobility   for   people  with   paralysis   or   limb   loss.   A   BCI-­‐‑system   provides   a   completely   new  output   pathway   and   this   is   perhaps   the   only   way   a   person   can   express   herself   if   he/she  suffers   from   disorders   like   amyotrophic   lateral   sclerosis   (ALS),   brainstem   stroke,   brain   or  spinal   cord   injury   or   other   diseases   which   impair   the   function   of   the   common   output  pathways,   responsible   for   the   control   of  muscles.For   a   quadriplegic,   something   as   basic   as  controlling   a   computer   cursor   via   mental   commands   would   represent   a   revolutionary  improvement  in  quality  of  life.    

2.3   Introduction  to  SSVEP    At  RRI,  the  aim  is  to  build  a  BCI  system  utilizing  a  neurological  phenomenon  called  steady  state   visual   evoked   potential   (SSVEP)   to   control   action   devices   for   the   disabled,   like   a  wheelchair   and   a   robotic   arm.  A  visually   evoked  potential   (VEP)   is   an   electrical   potential-­‐‑difference,   which   can   be   derived   from   the   scalp   after   a   visual   stimulus,   for   example   a  flashlight.  VEPs   after   stimuli  with   a   frequency   <   3.5  Hz   are   called   “transient”  VEPs.   If   the  stimulation  frequency  is  >  3.5  Hz  they  are  called  “steady  state”  VEPs  because  the  individual  responses  overlap  and  result   in  a  quasi-­‐‑sinusoid  oscillation  with  the  same  frequency  as   the  stimulus.  The  goal  is  to  detect  this  frequency  reliably  with  high  accuracy  and  also  to  detect  when  the  frequency  is  not  present,  thus  when  the  person  does  not  look  at  the  stimulus.          

Page 6: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  6  

2.4   BCI  at  RRI    The   motivation   behind   carrying-­‐‑out   BCI   Research   at   RRI   is   to   engineer   individual  components  required  for  building  a  complete  SSVEP  based  BCI  system  indigenously  so  that  the   cost   of   an   end-­‐‑to-­‐‑end   BCI   based   system   like   a   Wheelchair   comes   down   drastically,  making  it  more  affordable  to  people  of  all  economic  strata.        

3.  An  Overview  of  the  RRI-­‐‑BCI  System    

3.1   Block-­‐‑Diagram  of  the  complete  SSVEP  based  BCI  System      

     As  shown,  in  the  SSVEP  based  BCI  system  being  built  at  RRI  the  following  are  being  engineered  in-­‐‑house:    

a. RRI  Visual  Input  Device  b. RRI  Electrodes  c. RRI  EEG  Amplifier  d. ArduinoTM  based  Digitizer  &  Signal  Processor  e. RRI  Action  Devices:  Wheelchair  and  Robotic  Arm  

 RRI  Visual  Input  Device

RRI  Cup  Electrodes

 EEG  Amplifier

 

Digitizer  &  Signal              Processor

 

RRI  Action  Devices

Figure  1.  The  RRI  BCI  System  Block  Diagram  

Page 7: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  7  

4.   The  RRI-­‐‑BCI  System  in  Detail    My  contribution  to  the  RRI  BCI  system  has  been  mainly  in  the  ArduinoTM  based  Digitizer  and  Signal   Processor   part   and   in   the   Development   and   Testing   of   the   Miniaturized   EEG  Amplifier   (popularly  known  as  BioAmpV2)   together  with  Mrs.  Sujatha  S  of  RAL,  although  we  also  made  a  mini,  hand-­‐‑held,  ArduinoTM  powered  Visual  input  device  (popularly  known  as  the  Alternate-­‐‑VID).    In  this  section,  every  component  of  the  system,  I  have  contributed  to,  is  discussed  in  detail.      

4.1   The  Alternate  Visual  Input  Device  (aVID)    Although   a   full-­‐‑fledged   Visual   Input   Device   is   being   made   by   Mr.   Somashekar   and   his  students   –   Ms.   Pavithra,   Mr.   Nikhil   and  Mr.   Chandan,   the   necessity   for   a   mini,   portable  visual  input  device  was  inevitable.  Prior  to  the  aVID,  a  cardboard  box  with  a  set  of  3-­‐‑LEDs,  powered  using   a   signal   generator  was  used  as   a   stimulus   for   the   SSVEP  Experiments.  But  since  it  required  a  dedicated  signal  generator  just  for  blinking  a  set  of  LEDs  and  since  some  spurious  signal  was  also  detected  when  the  subject  came  in  physical  contact  with  the  box,  a  compact,  plastic  cased,  programmable,  visual  stimulus  was  certainly  needed.      The  aVID  was  designed  with  the  following  considerations:      

a. No  spurious  signal  pick-­‐‑up  when  the  subject  comes  in  contact  with  the  stimulator  b. To  accommodate  more  than  1  LED  blinking  at  different  frequencies  simultaneously  c. To  enable  SSVEP  testing  with  small  although  fixed  distance  of  separation  between  

the  LEDs  d. Ability  to  change  the  blinking  frequencies  of  the  LEDs  

 The  aVID  was  then  designed,  within  just  a  day  by  Mrs.  Sujatha  and  I,  on  a  general-­‐‑purpose  circuit  board  with  four  LEDs  at  top,  bottom,  left  and  right  respectively  as  shown.  This  board  was   designed   to   be   an   add-­‐‑on   shield   that  would   get   fixed   atop   an  ArduinoTM  Uno   board.  Thus   the   presence   of   a  microcontroller  makes   it   programmable   to   any   desired   frequency.  Later,  with  Mr.  Ibrahim’s  help,  the  Shield  and  the  controller  was  covered  with  a  plastic  case  to  avoid  spurious  signal  pick-­‐‑up.      

 (a)   (b)   (c)  

Figure  2.  The  3D  model  of  the  aVID  Shield    

a. Front  View  b. Right-­‐‑side  view  c. Left-­‐‑side  view  

Page 8: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  8  

 The   pin   numbers   to   which   the   LEDs   are   connected   are   displayed   in   Figure   2(a).  Programmable   Timers   are   used   to   get   the   LEDs   blinking   at   the   desired   frequency.   The  ArduinoTM  code  for  the  Visual  Input  device   is   included  in  the  Appendix  of   this  report.  The  fabricated  aVID  looks  like  this:    

   

 

4.2   The  Miniaturized  RRI  EEG  Amplifier  (Bio-­‐‑Amp  V2)    The  Human  brain  is  enclosed  within  a  highly  protected  cage  -­‐‑  the  Skull  and  the  signals  that  are  tapped  non-­‐‑invasively  (from  the  scalp)  are  highly  attenuated,  which  explains  the  need  for  an   EEG   amplifier.   This   amplifier   is   responsible   for   amplifying   such   faint   brain   signals  collected  non-­‐‑invasively  from  electrodes  attached  to  the  subject'ʹs  scalp,  preserving  signals  of  frequencies  within  the  operating  range  while  rejecting  unwanted  frequencies.    Following   the   successful   fabrication   and   testing   of   the   Bio-­‐‑Amp   V1   by   Mrs.   Sujatha   and  integration  with   the   50Hz  Notch  and   the  High  Pass  Filter   board  by  Mr.   Sashi  Raj   (Visiting  Student:  April  2013  –  August  2013),  it  was  decided  to  integrate  and  miniaturize  these  separate  entities   into   just   one   PCB   with   SMD   components.   Following   this   decision,   the   work   for  fabrication   the   miniaturized   EEG   Amplifier   began   with   simulation   using   National  Instruments  Multisim  v13.0.      

4.2.1   Operating  Characteristics    Operating  Frequency  Range   1  -­‐‑  125  Hz  Gain   7000  -­‐‑  15000  Notch   50  Hz  Input  Voltage  Levels   1-­‐‑100µμV  Output  Voltage  Levels   Typically,  0.5-­‐‑2.0  V  (peak  to  peak)  DC  Offset  in  output   ~  2.5  V        

Figure  3.  The  aVID        

Page 9: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  9  

4.2.2   Utility    The  amplified  output  of   the  brain  signals  will  be  subjected   to  various  analyses  working  on  digital   logic,  which   require   signals  as  data   (bits).  This   conversion  will  be  possible  with   the  help   of   Analog   to   Digital   Converter   (ADC)   circuits.   The   RRI   EEG   Amplifier   aims   at  amplifying  the  brain  signals  to  levels  usable  by  an  ADC  module,  implemented  on  ArduinoTM  Platform.      

4.2.3   Components  Used    S.No   Component     Description   Package   Quantity  1   INA114   Instrumentation  Amplifier   SOL-­‐‑16   2  Nos.  2   LM7805C   Voltage  Regulator  (5V)   SOT-­‐‑223   1  No.  3   1N5819   Schottky  Barrier  Rectifier   SOD-­‐‑123    4   AP358   Low  Power  Dual  Op-­‐‑Amps   SOP-­‐‑8L    5   BAV199   Dual  Diode  (Low  Leakage)   SOT-­‐‑23    6   PGB1010603   ESD  Suppressor   0603    7   TMV  0505S   DC-­‐‑DC  Converter     1  No.  8   3.5mm  Jack   Input  /  Output  Connectors   SMD   7  Nos.      

4.2.4   Distinct  Circuits  present    S.No   Circuit   Remarks   No.  present  1   Power  Supply  Circuit   Consumes  9V  DC  from  Battery  and  supplies  

5V,  2.5V  and  GND  terminals  1  No.  

2   Instrumentation  Amplifier  Circuit  

Input   from   3.5MM   jack   is   supplied   to  Instrumentation   amplifier   present   in   each  channel   to   improve   CMRR   and   Gain   by   a  factor  of  12.36  

1  per  channel  

3   50Hz  Notch   Output   of   Instrumentation   Amp   is   stripped  of  50Hz  hum.  Gain  is  Unity.  

1  per  channel  

4   Low  Pass  Filter    (1-­‐‑125  Hz)  

Rejects   signals   of   Frequencies   >   125Hz;                    Unity  Gain  

1  per  channel  

5   Gain  Stage   Improves  the  Gain  of  the  incoming  signal  to  a  final  variable  factor  of  7000  -­‐‑  15000,  making  it  usable  for  Analog-­‐‑Digital  Converter  modules  

1  per  channel  

   

4.2.5   Simulation  Software  and  Parameters    National  Instruments  MultiSim  v13.0  (Trial  Version)  was  used  for  simulating  the  Bio-­‐‑signal  Amplifier  Circuit.  AC  Analysis  was  carried  out  and  the  frequency  response  was  obtained  to  satisfy  the  requirements.  Throughout  this  simulation,  TLC277  Dual  Op-­‐‑Amp  is  used  in  place  

Page 10: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  10  

of  AP358.  The  simulation  is  performed  for  a  single  channel.  Throughout  the  document,  the  X  and  Y  axes  in  the  output  graphs  are  in  logarithmic  and  decibel  scales  respectively.        

4.2.6   Simulation  Circuits    A.  Power  Supply  Circuit    

 The  power  supply  circuit  consists  of  a  5V  input,  which  is  assumed  to  have  come  from  a  9V  Battery   /   Voltage   Regulator   /   DC-­‐‑DC   Converter   circuit.   The   output   of   the   power   supply  circuit   provides   three   terminals:   Vcc,   VGND   and   AGND.   AGND   is   Actual   Ground   or  negative  terminal  of  the  battery.  VGND  is  a  virtual/lifted  ground  that  caters  as  the  0V  level  for   all   components   in   the   board.   Since   Op-­‐‑Amps   in   the   board   require   a   negative   power  supply,  AGND  acts  as  a  negative  supply  source  (-­‐‑Vcc)  while  VGND  acts  as  0V  source  (GND).                  

   

Page 11: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  11  

B.  Instrumentation  Amplifier  Stage    The   input   (differential   mode)   signals   from   electrodes   are   sent   to   the   Instrumentation  Amplifier   for  Common  Mode  noise   reduction   and   amplification   and   through  Dual  Diodes  and  ESD  suppressors.  The   instrumentation  amplifier   chip   INA114  amplifies   the   input  by  a  factor  of  12.36.  The  output  of  this  stage  is  fed  to  the  50Hz  notch  filter  for  eliminating  the  50Hz  hum  seen  in  the  signals  because  of  power  lines.      

 

 As  seen  in  the  response  below,  the  output  signal  (red)  is  12.36  times  the  input,  represented  in  Decibel  scale  (  20  log  (12.36)  =  21.8  ).  The  red  cursor  indicates  the  gain  at  -­‐‑3dB  point,  which  is  18.8  dB  at  3.5  kHz.    

   

Page 12: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  12  

C.  50Hz  Notch  filter    As  the  name  goes,  the  notch  filter  rejects  50Hz  waves  from  the  signal.  The  value  50  Hz  is  determined  by  the  RC  Combination.  The  gain  is  Unity.        

       The  plot  below  shows  the  response  of  the  notch  filter.  At  50  Hz,  the  attenuation  is  30  dB.  The  -­‐‑3dB  bandwidth  is  approximately  12  Hz  (FH  -­‐‑  FL)  where  FL  is  40  Hz  and  FH  is  62  Hz.      

                       

Page 13: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  13  

D.  Low  Pass  Filter    The  Unity  Gain  Low  Pass  filter  is  a  3-­‐‑stage  active  filter  intended  to  cut-­‐‑off  at  125Hz.      

 

 The  -­‐‑3  dB  point  of  the  low  pass  filter,  as  shown  below,  is  situated  at  70  Hz  and  it  continues  to  attenuate  the  signals  at  frequencies  beyond  70Hz.      

     E.  Gain  Stage    The   gain   stage   improves   the   gain   of   the   input   signal   by   a   factor   of   103(Vo/Vin)   to  make   it  usable   by   ADC   stages   that  may   follow   the   Bio-­‐‑Amp.   Typically   the   output   signals   have   a  peak-­‐‑to-­‐‑peak  magnitude   of   0.5   to   2V.   The  R&C  values  determine   the   characteristics   of   the  outputwaveform.  

10k 8.2µμ

Page 14: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  14  

 The  gain  of  this  stage  as  seen  in  the  circuit  is  variable.  The  plot  below  shows  VOUT  =  55  dB,  which  is  1000  times  the  input  as  seen  in  the  circuit  (  20  log  (10M/10.1k)  ).    

     

4.2.7   Simulation  Output    The  output  of  GainStage1   (Vo/Vin),   the   final   stage   in   the  Bio-­‐‑Amp   is  plotted  on  y-­‐‑axis  with  Frequency   on   x-­‐‑axis,   in   logarthmic   scale.  As   shown,   the   gain   begins   to   roll-­‐‑off   completely  after  125Hz  and  is  also  notched  at  50Hz.  The  gain  in  the  operating  range  is  shown  as  9500,  which  is  actually  variable  from  7000  to  15000.      

     

Page 15: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  15  

4.2.8   PCB  Schematic  and  Layout  Design    Following   the  simulation,  PCB  schematic  was  designed   to  accommodate  2  channels   in  a  2-­‐‑Layer  Bio-­‐‑Amp  card  of  10cm  x  5cm  dimension.  The  PCB  schematic  was  done  with  Cadence  Allegro  Design  Entry  CIS  and  PCB  Layout  was  done  with  Cadence  Allegro  PCB  Editor  Suite  v16.6.  PCB  Design,  Layout  and  Populationwere  done  in-­‐‑house  while  fabrication  was  done  by  3rd  party  vendors.      The   schematic   for   PCB  was   done   for   two   channels.   SMD  packages   of   ICs   have   been   used  along  with  resistors  and  capacitors  of  0805  package.  The  Gerber  file  circuits  of  different  layers  of   the   final  PCB  Layout  of   the  Bio-­‐‑Amp  board   that  was   sent   to   the  manufacturer  has  been  presented.  The  Gerber  files  are  of  RS-­‐‑274X  format.    Layout  Design  Data    Etch  Track  Parameters:     Minimum   Maximum  Etch  Track  width  (all  nets)   0.5  mm   0.6  mm  VCC,  VCC1,  VGND  line  width  

0.75  mm   1  mm  

 Min  neck  width  (all  nets)   0.38  mm  VCC,  VCC1,  VGND  min  neck  width   0.43  mm  Max  Neck  length  (all)   20mm    Spacing  Parameters  Line  to  line  spacing   0.38  mm  Line  to  Thru  pin  spacing   0.38  mm  Line  to  SMD  pin  spacing       0.38  mm  Thru  pin  to  Thru  Via  spacing   0.40  mm  SMD  pin  to  Thru  Via    spacing   0.40  mm    Drill  dimensions  VIA  Drill  diameter   0.6096  mm  VIA  Regular  pad  diameter   1  mm  Thru  Pin  Drill  diameter   0.9  mm  Thru  Pin  Regular  pad  diameter   1.8  mm  

 All  other  parameters  that  are  not  mentioned  above  have  their  respective  default  values,  given  by  the  software.            

Page 16: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  16  

A. Etch-­‐‑Top  

   

B. Etch-­‐‑Bottom  

   

C. Soldermask-­‐‑Top    

 

Page 17: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  17  

 D. Soldermask-­‐‑Bottom  

   

E.  Silkscreen-­‐‑Top  

   

E. Silkscreen-­‐‑Bottom  

       

Page 18: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  18  

4.2.9   How  they  look    

       

4.2.10   Testing  and  Results    Bio-­‐‑Amp  v2  was  extensively  tested  and  its  performance  was  constantly  compared  with  Bio-­‐‑Amp  v1.  It  was  found  that  the  Bio-­‐‑Amp  v2  was  equipped  with  a  simpler  Notch  filter,  which  does  not  sufficiently  remove   the  50Hz  pickup.  The  presence  of   this  power-­‐‑line   interference  impairs  the  SSVEP  signal  quality.  The  reason  for  this  insufficiency  in  Notching  of  the  50Hz  signal  may  be  attributed  to  the  simulation  results  which  although  clearly  shows  considerable  performance,   at   very   low   voltage   levels   (~   <   10uV),   the   attenuation   of   50Hz   pickup   is  insufficient.  Some  of  the  plots  of  the  Bio-­‐‑Amp  v2  are  presented  below.  Apart  from  the  signal,  frequency  levels  of  43  Hz,  50  Hz,  56  Hz  and  100  Hz  signals  are  almost  always  seen.          

 

Figure  4.  EEG  Amplifier  V1  and  V2  together      

Figure  5.  EEG  Amplifier  V2  Board    

Figure  6.  13Hz  signal  pickup  after  30  seconds  of  data  acquisition  with  aVID  stimulator.    

Page 19: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  19  

 

 While  the  signal  is  picked  up  in  most  of  the  cases,  during  some  trials,  heavy  noise  pickup  at  all   frequencies  <  40  Hz   is  also  seen  sometimes.  While   the  cause   for   this   remains  unknown,  one  of  the  suggested  solutions  is  to  eliminate  the  DC  in  the  output  so  that  the  entire  signal  is  amplified  to  the  levels  of  0-­‐‑5  V  and  input  to  the  digitizer  for  better  signal  detection.    

 

 

4.3.11   Planned  Enhancements    Since  the  signal  is  measured  with  AGND  in  the  output  side,  instead  of  VGND,  an  additional  DC  voltage  of  ~  2.5V  is  always  present  in  the  output.  Since  this  does  not  contribute  to  signal  detection  much,   apart   from   lifting   the   signal   from   falling   below   0   V,   a   Buck-­‐‑off   circuit   is  being  implemented,  at  the  time  of  writing  this  report,  to  avoid  this  quantization  noise  being  introduced  because  of  the  presence  of  this  DC  Voltage.      

4.3   Digitizer    The  analog   signals  obtained   from   the  amplifier   are   set   to  be   around  2-­‐‑4  V   (by  varying   the  gain)  making  it  viable  for  the  10-­‐‑bit  ADC  in  Arduino  to  sample  the  analog  signals.  Since  the  operating   frequency   range   of   the   SSVEP   Experiments   is   less   than   40   Hz,   a   sampling  frequency   of   256   Hz   was   more   than   sufficient   for   faithfully   digitizing   &   reproducing   the  signal.  Program  for   sampling  and  digitizing   the  analog  signals  was  written,  making  use  of  one  of   the   inbuilt   timers   that   is   invoked  256   times  a   second.  The  code  can  be   found   in   the  appendix  of  the  report.  

Figure  7.  17Hz  signal  pickup  after  30  seconds  of  data  acquisition  with  aVID  stimulator.    

Figure  8.  17Hz  signal  amongst  heavy  noise  pickup.    

Page 20: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  20  

 Pure   tones   from  signal  generator  were  fed   into   the  Arduino  Digitizer  and  the  time-­‐‑domain  and   frequency   domain   spectra   were   analyzed.   Two   channels   were   simultaneously   tested  with   10   Hz   and   20   Hz   tones   respectively   and   were   sampled   at   256   Hz.   The   plots   are  presented  below.  This  program  was   later  modified   to  simultaneously  sample  4  channels  at  256  Hz  and  at  a  data  transfer  rate  of  115200  baud.        

 

 

Figure  9.  Pure  tones  of  20  Hz  &  10  Hz:  Their  time  domain  and  frequency  domain  responses.  The  last  picture  is  a  small  section  of  the  time-­‐‑domain  response  of  the  super-­‐‑imposed  tones.    

Page 21: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  21  

 

4.4   Signal  Processor  

4.4.1   Objective    The  ultimate   aim  of  digitization  was   to   extract  useful   information  out  of   the   signals.   Since  EEG  data  obtained  from  SSVEP  experiments  contains  signals  of  the  frequency-­‐‑coded  LEDs,  it  is   important   to   extract   this   frequency   information.   A   typical   approach   to   decipher   the  frequency  of  the  signals  is  to  employ  Fast  Fourier  Transform  (FFT).  But  since  implementing  an   FFT   algorithm   on   embedded   microcomputers   may   be   computationally   intensive,   an  alternate   approach   suggested   by   Dr.   Ramesh   was   to   implement   a   Matched   Filter   for  frequency  determination.      

4.4.2   Theory    In   Matched   filter,   the   unknown   incoming   signal   is   multiplied   with   Sine   and   Cosine  components   of   a   known   frequency.   Following   the   multiplication,   the   signals   are   time  averaged   over   one   full   time   period,   which   eliminates   all   undesired   frequencies.   These  individual,  time  averaged  signals  are  then  squared  and  resulting  in  a  correlation  co-­‐‑efficient.  Since  the  signal  is  multiplied  and  time  averaged  with  both  the  orthogonal  components,  phase  dependency   is   eliminated.  What   is   obtained   is   a   correlation   coefficient,   whose   strength   is  high  when  the  signal  frequency  matches  with  frequency  of  the  multiplied  signal.  This  is  used  to  decide  the  threshold  and  eventually  in  decision  making.      Let  us  consider  that  the  incoming  signal  is  represented  as  

 f(t)=Σ (An  sin  wnt  +  Bncoswnt  )  

 Let  the  desired  frequency  that  is  being  looked  for  bewo.  In  correlation  matched  filtering,  the  incoming   signal   f(t)   is   multiplied   with   the   Sine   and   Cosine   components   of   woand   time  averaged  from  0  to  π.      

S  =  ∫  f(t)    sin  (wot)  dt                      from  0  to  π                    =  ∫  A  sin(wt)  sin  (wot)  dt                +                      ∫  B  cos(wt)  sin  (wot)  dt  

                 =  Aπ/2    if  w=wo  ;  or  else  S  <  Aπ/2    

           C  =  ∫  f(t)    cos  (wot)  dt                    from  0  to  π                      =  ∫  A  sin(wt)  cos  (wot)  dt                +                      ∫  B  cos(wt)  cos  (wot)  dt                      =  Bπ/2    if  w=wo  ;  or  else  C  <  Bπ/2  

 Correlation  of  a  signal  f(t)  to  a  frequencywo  is  given  by,    

Page 22: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  22  

Correlation  Coefficient  =  ∫  f(t)  ejwtdt  =  F(wo)  =  C  (wo)  +  j  S(wo)[since  ejwt    =  cos  (wt)  +  jsin  (wt)]    

∫  f(t)  sin  (wot)  dt=  S(wo)                  ∫  f(t)  cos(wot)  dt=  C(wo)  

 Therefore,  Correlation  Co-­‐‑efficient,  

F(wo)  =  √  [  C2(wo)  +  S2(wo)]      =    √  (π2/4)[A2  +B2]    This  value,  F(wo)   is   the  correlation  co-­‐‑efficient   that   is  computed   in  real-­‐‑time   to  check   if   the  frequency  of   the   incoming   signal  matches   any  one  of   the   stimulus   frequencies  used   in   the  SSVEP  experiment.      

4.3.3   Implementing  the  Matched  Filter    Matched   filter   was   first   simulated   as   a   Proof-­‐‑of-­‐‑Concept   on   MATLAB,   followed   by   its  programmatic   implementation   on   Java.   Initially,   pure   tones   generated   from   the   signal  generator  were  used  to  check  the  correctness  of  the  algorithm  implemented.  Following  this,  the   Matched   filter   for   2   channels   was   implemented   on   Arduino   Uno,   which   could   then  sample   and   process   the   signals   by   itself.   From   then   on,   since   I   got   involved   with   the  fabrication   of   the   RRI   Bio-­‐‑Amp   v2,   enhancing   the   signal   processing   code   on   Arduino   to  multiple-­‐‑channels   and   developing   a  MATLAB  GUI  was   taken   care   of  Mr.   James  Mathew  (JRF,  LAMP).  The  flowchart  of  the  Matched  filter  program  on  Arduino  is  presented  below.              

   

     

   

Generate  &  store  look-­‐‑up  tables  of  stimulus  

frequencies  

   

TIMER  Loop  @  256  Hz  Sample  data  and    Map  to  8  bits  

Multiply  incoming  data  f(t)  sin  wt  &    f(t)  cos  wt  

Accumulate  multiplied  data  until  

one  T  

After  one  T,  determine  the  

average  Square  and  add  Sine  &  Cosine  averages  

Check  correlation  coef_icient  threshold  &  make  decision  

   

Drive  Wheelchair  

Page 23: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  23  

 Later,   moving   average   was   also   implemented   where   the   final   output   of   the   correlation  coefficient  would  be  the  average  of  the  correlation  co-­‐‑efficients  of  the  previous  4  cycles.  Since  after  one  T,  the  correlation  co-­‐‑efficient  is  calculated  and  a  decision  is  made,  the  data  can  be  discarded   and   the   operation   begins   on   fresh   set   of   data.   The   complexity   increases   with  multiple  channels  and  multiple  frequencies  to  be  checked  with  each  channel.  The  code  was  extensively  tested  with  Arduino  Uno  and  Arduino  Mega  by  Mr.  James  Mathew  and  upto  7  individual  frequencies  could  be  checked  with  2  channels  on  Arduino  Mega.  Since  sampling  and  computation  are  done  simultaneously,  sampling  rate  of  not  more   than  256  Hz   is  used.  Program  for  the  Matched  filter  implemented  on  Arduino  is  included  in  the  Appendix.        

 

                 

Figure  10.  Correlation  co-­‐‑efficient  plot  indicating  the  presence  of  10  Hz  signal  with  Gaussian  Noise    

Page 24: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  24  

5.   Takeaways      The  internship  provided  me  the  opportunity  to  work  on  an  end-­‐‑to-­‐‑end  instrumentation  system  for  the  BCI  SSVEP  Experiment.  It  helped  me  in  improving  my  technical  skills  and  enhanced  my  knowledge  in  new  areas.  Specifically,      

• I  gained  new  knowledge  about  working  with  Bioelectronics.  Various  specific  aspects  of  working  with   electronics   for  Bio-­‐‑systems   is   one  of   the  major   takeaways   from  my  internship.    

• Gained   hands-­‐‑on   experience   in   the   one   of   the  most   coveted   research   areas:   ‘Brain-­‐‑computer  Interface’.  This  helped  me  explore  the  current  research  in  this  domain  and  realize  the  possibilities.      

• Working  on  Analog  Electronics  helped  me  brush  up  all  the  basic  knowledge  obtained  during  my  Undergraduate   degree   and  more   importantly,   put   all   that   knowledge   to  good  use.  Additionally,  I  got  to  learn  working  with  latest  software  and  tools  used  in  the  industry.  

 • Working  on  some  of  the  core  modules  of  the  BCI  system  made  me  feel  responsible  and  

committed  and  also  kept  me  motivated  especially  when  desired  results  were  not  forth-­‐‑coming.      

• My  programming  skills  were  extensively  used  in  Bio-­‐‑signal  processing,  a  domain  on  which  I  had  never  worked  before.    

 • My  participation  in  In-­‐‑House  2014  event  gave  me  the  opportunity  to  represent  the  BCI  

team  amidst  other  eminent  scientists,  professors  and  students,  besides  contributing  to  my  presentation  skills.    

                           

Page 25: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  25  

6.   Appendix    

6.1   The  aVID  Arduino  Code  for  3  LEDs    //http://www.instructables.com/id/Arduino-Timer-Interrupts/ //This code will enable all three arduino timer interrupts. //timer0 will interrupt at 2kHz (and then arithmetically divide to get 17 Hz) //timer1 will interrupt at 13Hz //timer2 will interrupt at 15Hz //storage variables boolean toggle0 = 0; boolean toggle1 = 0; boolean toggle2 = 0; int timer2_count=0; int timer0_count=0; void setup(){ //set pins as outputs pinMode(8, OUTPUT); pinMode(10, OUTPUT); pinMode(12, OUTPUT); cli();//stop interrupts //set timer0 interrupt at 2kHz TCCR0A = 0;// set entire TCCR2A register to 0 TCCR0B = 0;// same for TCCR2B TCNT0 = 0;//initialize counter value to 0 // set compare match register for 2khz increments OCR0A = 123;// = (16*10^6) / (1024*100) - 1 (must be <256) // turn on CTC mode TCCR0A |= (1 << WGM01); // Set CS02 and CS00 bits for 1024 prescaler TCCR0B |= (1 << CS01) | (1 << CS00); // enable timer compare interrupt TIMSK0 |= (1 << OCIE0A); //set timer1 interrupt at 13Hz TCCR1A = 0;// set entire TCCR1A register to 0 TCCR1B = 0;// same for TCCR1B TCNT1 = 0;//initialize counter value to 0 // set compare match register for 13Hz increments //OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536) OCR1A = 600;// = (16*10^6) / (13*1024) - 1 (must be <65536) // turn on CTC mode TCCR1B |= (1 << WGM12); // Set CS12 and CS10 bits for 1024 prescaler TCCR1B |= (1 << CS12) | (1 << CS10); // enable timer compare interrupt TIMSK1 |= (1 << OCIE1A); //set timer2 interrupt at 15Hz TCCR2A = 0;// set entire TCCR2A register to 0 TCCR2B = 0;// same for TCCR2B TCNT2 = 0;//initialize counter value to 0 // set compare match register for 15Hz increments OCR2A = 248;// = (16*10^6) / (1005*64) - 1 (must be <256) // turn on CTC mode TCCR2A |= (1 << WGM21); // Set CS21 bit for 8 prescaler

Page 26: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  26  

TCCR2B |= (1 << CS22); // enable timer compare interrupt TIMSK2 |= (1 << OCIE2A); sei();//allow interrupts }//end setup // Timer-Interrupt Service routine to toggle LED at pin 8 ISR(TIMER0_COMPA_vect){ if(timer0_count==58) { if (toggle0){ digitalWrite(8,HIGH); toggle0 = 0; } else{ digitalWrite(8,LOW); toggle0 = 1; } timer0_count=0; } else {timer0_count++;} } // Timer-Interrupt Service routine to toggle LED at pin 10 ISR(TIMER1_COMPA_vect){ if (toggle1){ digitalWrite(10,HIGH); toggle1 = 0; } else{ digitalWrite(10,LOW); toggle1 = 1; } } // Timer-Interrupt Service routine to toggle LED at pin 12 ISR(TIMER2_COMPA_vect){ if(timer2_count==32) { if (toggle2){ digitalWrite(12,HIGH); toggle2 = 0; } else{ digitalWrite(12,LOW); toggle2 = 1; } timer2_count=0; } else {timer2_count++;} } void loop(){ //do other things here }

   

Page 27: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  27  

6.2   4-­‐‑Channel  Arduino  Digitizer  

//Arduino 4-Channel Digitizer void setup(){ Serial.begin(115200); cli();//stop interrupts //set timer1 interrupt at 256Hz TCCR1A = 0;// set entire TCCR1A register to 0 TCCR1B = 0;// same for TCCR1B TCNT1 = 0;//initialize counter value to 0 // set compare match register for 1hz increments OCR1A = 60;// = (16*10^6) / (100*1024) - 1 (must be <65536) // turn on CTC mode TCCR1B |= (1 << WGM12); // Set CS12 and CS10 bits for 1024 prescaler TCCR1B |= (1 << CS12) | (1 << CS10); // enable timer compare interrupt TIMSK1 |= (1 << OCIE1A); sei();//allow interrupts }//end setup //Timer-1 interrupt service routine //Samples analog signals from A0, A1, A2 and A3, downconverts to 8bits and serially sends it with start and stop characters (A and Z) ISR(TIMER1_COMPA_vect){ intval=0; Serial.write("A"); val = map(analogRead(A0), 0, 1024, 0, 255); Serial.write(val); val = map(analogRead(A1), 0, 1024, 0, 255); Serial.write(val); val = map(analogRead(A2), 0, 1024, 0, 255); Serial.write(val); val = map(analogRead(A3), 0, 1024, 0, 255); Serial.write(val); Serial.write("Z"); } void loop(){ //do other things here }

   

6.3   Matched  Filter  program  on  Arduino   //This is a 1-Channel Matched filter that can check 4 individual frequencies // 1 Channel 4 MF Correlation Values #define N 24 #include<Math.h> int v1=0; int v2=0; int v3=0; int v4=0; int V=0; int data1 = -1; double LUT_sin1[24];

Page 28: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  28  

double LUT_cos1[24]; double LUT_sin2[18]; double LUT_cos2[18]; double LUT_sin3[16]; double LUT_cos3[16]; double LUT_sin4[12]; double LUT_cos4[12]; double mul_ch1_sin1[24]; double mul_ch1_cos1[24]; double mul_ch1_sin2[18]; double mul_ch1_cos2[18]; double mul_ch1_sin3[16]; double mul_ch1_cos3[16]; double mul_ch1_sin4[12]; double mul_ch1_cos4[12]; int f1 = 12;//Matched frequency to be checked int f2 = 16;//Matched frequency to be checked int f3 = 18;//Matched frequency to be checked int f4 = 24;//Matched frequency to be checked int Fs = 256; int k1=0; int k2=0; int k3=0; int k4=0; double accum1_ch1 = 0.0; double accum2_ch1 = 0.0; double accum3_ch1 = 0.0; double accum4_ch1 = 0.0; double CorrCoef1_ch1=0.0; double CorrCoef2_ch1=0.0; double CorrCoef3_ch1=0.0; double CorrCoef4_ch1=0.0; double S1_ch1=0; double C1_ch1=0; double S2_ch1=0; double C2_ch1=0; double S3_ch1=0; double C3_ch1=0; double S4_ch1=0; double C4_ch1=0; // Populating Look-up tables at required frequencies void setup() { Serial.begin(115200); pinMode(12, OUTPUT); //for LED control for(int i=0;i<24;i=i++) { LUT_sin1[i] = sin(2*3.14159*f1*i/Fs); LUT_cos1[i] = cos(2*3.14159*f1*i/Fs); Serial.print(" --LUT-sine- "); Serial.print(LUT_sin1[i],4); Serial.println("**********"); } for(int i=0;i<18;i=i++) { LUT_sin2[i] = sin(2*3.14159*f2*i/Fs); LUT_cos2[i] = cos(2*3.14159*f2*i/Fs); } for(int i=0;i<16;i=i++) {

Page 29: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  29  

LUT_sin3[i] = sin(2*3.14159*f3*i/Fs); LUT_cos3[i] = cos(2*3.14159*f3*i/Fs); } for(int i=0;i<12;i=i++) { LUT_sin4[i] = sin(2*3.14159*f4*i/Fs); LUT_cos4[i] = cos(2*3.14159*f4*i/Fs); } cli();//stop interrupts //set timer1 interrupt at 256Hz TCCR1A = 0;// set entire TCCR1A register to 0 TCCR1B = 0;// same for TCCR1B TCNT1 = 0;//initialize counter value to 0 OCR1A = 60;// = (16*10^6) / (Fs*1024) - 1 (must be <65536) TCCR1B |= (1 << WGM12); TCCR1B |= (1 << CS12) | (1 << CS10); TIMSK1 |= (1 << OCIE1A); sei();//allow interrupts } // Correlation co-efficients are computed here void loop() { if(data1!=-1) { double d1 = data1; data1 = -1; V=V+1; //************************************************************************** //1st frequency check******************************************************* mul_ch1_sin1[v1] = LUT_sin1[v1]*d1; mul_ch1_cos1[v1] = LUT_cos1[v1]*d1; if (v1==23) { for(int i=0;i<24;i++) { S1_ch1 = S1_ch1 + mul_ch1_sin1[i] ; C1_ch1 = C1_ch1 + mul_ch1_cos1[i] ; } k1=k1+1;v1=-1; } if(k1==12) { accum1_ch1=(S1_ch1*S1_ch1 + C1_ch1*C1_ch1); CorrCoef1_ch1=accum1_ch1/1000; k1=0;S1_ch1=0;C1_ch1=0; } //*************************************************************************** //2nd frequency check******************************************************** mul_ch1_sin2[v2] = LUT_sin2[v2]*d1; mul_ch1_cos2[v2] = LUT_cos2[v2]*d1; if (v2==17) { for(int i=0;i<18;i++) { S2_ch1 = S2_ch1 + mul_ch1_sin2[i] ; C2_ch1 = C2_ch1 + mul_ch1_cos2[i] ;

Page 30: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  30  

} k2=k2+1;v2=-1; } if(k2==16) { accum2_ch1=(S2_ch1*S2_ch1 + C2_ch1*C2_ch1); CorrCoef2_ch1=accum2_ch1/1000; k2=0;S2_ch1=0;C2_ch1=0; } //************************************************************************** //3rd frequency check****************************************************** mul_ch1_sin3[v3] = LUT_sin3[v3]*d1; mul_ch1_cos3[v3] = LUT_cos3[v3]*d1; if (v3==15) { for(int i=0;i<16;i++) { S3_ch1 = S3_ch1 + mul_ch1_sin3[i] ; C3_ch1 = C3_ch1 + mul_ch1_cos3[i] ; } k3=k3+1;v3=-1; } if(k3==18) { accum3_ch1=(S3_ch1*S3_ch1 + C3_ch1*C3_ch1); CorrCoef3_ch1=accum3_ch1/1000; k3=0;S3_ch1=0;C3_ch1=0; } //******************************************************************************* //4th frequency check************************************************************ mul_ch1_sin4[v4] = LUT_sin4[v4]*d1; mul_ch1_cos4[v4] = LUT_cos4[v4]*d1; if (v4==11) { for(int i=0;i<12;i++) { S4_ch1 = S4_ch1 + mul_ch1_sin4[i] ; C4_ch1 = C4_ch1 + mul_ch1_cos4[i] ; } k4=k4+1;v4=-1; } if(k4==24) { accum4_ch1=(S4_ch1*S4_ch1 + C4_ch1*C4_ch1); CorrCoef4_ch1=accum4_ch1/1000; k4=0;S4_ch1=0;C4_ch1=0; } //******************************************************************************** // Serial.println(d1); //Control LED if(CorrCoef1_ch1>50) { digitalWrite(12,HIGH); digitalWrite(11,LOW); digitalWrite(10,LOW);} else if(CorrCoef2_ch1>50) {digitalWrite(11,HIGH); digitalWrite(12,LOW); digitalWrite(10,LOW);} else if(CorrCoef3_ch1>50)

Page 31: RRI VSP Report - Amazon S3 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh …! 4! 1.’Acknowledgements’!!! Firstly,I!am!extremely!thankfulto!my!guides:Dr.HemaRamachandranand!Dr.Ramesh

  31  

{digitalWrite(10,HIGH); digitalWrite(11,LOW); digitalWrite(12,LOW);} else {digitalWrite(10,LOW); digitalWrite(11,LOW); digitalWrite(12,LOW);} if(V==288) { Serial.println(CorrCoef1_ch1); Serial.println(CorrCoef2_ch1); Serial.println(CorrCoef3_ch1); Serial.println(CorrCoef4_ch1); V=0;} v1++; v2++; v3++; v4++; } } //Timer to sample & digitize data at Fs = 256Hz ISR(TIMER1_COMPA_vect){ data1 = map(analogRead(A0), 0,1024, 0, 255);}


Recommended