lab!2:!optical!theremin! - pennsylvania state...

13
Lab 2: Optical Theremin Team 2 Flyback By Brian Pugh, Andrew Baker, and Michael Betts

Upload: dothuan

Post on 20-Apr-2018

224 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

         

Lab  2:  Optical  Theremin  Team  2  Flyback  

By  Brian  Pugh,  Andrew  Baker,  and  Michael  Betts      

Page 2: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

Table  of  Contents  

Abstract  .......................................................................................................................................  3  

Introduction  ..............................................................................................................................  3  Rationale  .....................................................................................................................................  4  

Implementation  .......................................................................................................................  5  Hardware  .............................................................................................................................................  5  Software  ...............................................................................................................................................  5  

Conclusion  ..................................................................................................................................  6  Appendix  A  .................................................................................................................................  6  

Bibliography  ...........................................................................................................................  13          

Page 3: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

Abstract    A  simple  optical  Theremin  is  designed  to  produce  sound  over  a  user-­‐defined  scale  and  with  optional  distortion  sound  effects.    The  hardware  consists  of  two  photodiodes  sensing  light  input.    The  signal  from  the  photodiodes  get  amplified  and  then  read  into  a  computer  by  a  Texas  Instruments  myDAQ.    A  LabVIEW  virtual  instrument  handles  all  calibrating,  auto-­‐tuning,  noise  generation,  and  user  parameter  input.  

Introduction  The  Theremin  is  an  electronic  musical  device  invented  by  Leon  Theremin  in  the  year  1928.    The  Theremin  operates  by  having  two  metal  antennas  that  sense  the  relative  positioning  of  the  operator’s  hands.    Bringing  a  hand  closer  to  one  antenna  changes  the  instrument’s  pitch,  and  bringing  a  hand  closer  to  the  other  antenna  changes  the  volume.    The  antennas  detect  the  hand’s  relative  location  by  precisely  measuring  capacitance;  the  hand  acts  as  the  ground  plate  of  the  capacitor  and  as  the  hand  gets  closer  to  an  antenna,  capacitance  increases.  [1]    A  conventional  Theremin  is  relatively  complex  to  design  and  construct.    Our  simple  optical  Theremin  uses  changes  in  ambient  light  to  measure  relative  hand  location  instead  of  capacitance.    A  transimpedance  amplifier  circuit  converts  a  photodiode’s  small  reverse  bias  current  into  a  useable  and  measureable  voltage  signal.    It  is  assumed  that  the  optical  Theremin  will  be  used  indoors  under  moderate  lighting  conditions;  this  assumption  is  made  so  that  the  amplification  circuit  can  be  tuned  for  the  correct  lighting  conditions.    Direct  sunlight  is  orders  of  magnitude  brighter  than  indoor  lighting  and  can  saturate  the  amplification  circuit.    When  a  hand  is  brought  close  to  a  photodiode,  some  ambient  light  is  blocked  and  consequently  changes  and  the  output  signal.    Unlike  a  conventional  Theremin,  much  of  the  heavy  lifting  is  done  in  easy-­‐to-­‐configure,  inexpensive  software  instead  of  complicated  and  expensive  analog  circuits.        This  amplified  signal  gets  converted  into  a  digital  signal  by  the  myDAQ  and  is  processed  in  LabVIEW  to  produce  musical  tones.  There  are  two  light  sensing  photodiodes,  one  control  pitch  and  the  other  controls  volume.    Other  parameters  such  as  pitch  range,  volume  range,  and  distortion  options  can  be  changed  by  the  user-­‐friendly  software  interface.    The  output  music  can  be  listened  to  through  the  myDAQ’s  3.5mm  TRS  jack.    With  a  bit  of  practice,  real  songs  can  be  played  on  this  implementation  of  a  Theremin.      

Page 4: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

Rationale    The  optical  Theremin  consists  of  two  distinct  parts:  hardware  and  software.    The  hardware  needs  to  detect  changes  in  light  and  transform  that  information  into  information  the  computer  and  software  can  understand.    The  software  (LabVIEW)  then  handles  the  calculations  and  sound  generation.    These  two  subsystems  are  further  broken  up  into  the  high-­‐level  block  diagram  in  Figure  1.    We  are  using  two  OP906  photodiodes  to  detect  light  due  to  availability.    These  photodiodes  generate  a  current  that  is  directly  proportional  to  the  amount  of  ambient  light;  the  max  current  output  from  these  photodiodes  is  35µA  under  very  bright  light.[2]    Unfortunately,  the  myDAQ’s  cannot  directly  measure  small  currents,  so  a  transimpedance  amplifier  needs  to  be  designed  to  amplify  the  signal  and  convert  it  into  a  measureable  voltage.    The  actual  output  currents  of  the  photodiodes  are  unknown,  but  we  know  the  max  output  current  is  35µA.    If  we  want  the  output  voltage  to  range  between  0  and  5  volts,  then  we  can  calculate  the  feedback  resistor  with  Equation  1.    A  100kΩ  feedback  resistor  was  calculated,  but  there  was  no  measureable  output  voltage  signal  under  ambient  lighting.    Through  experimentation,  we  determined  that  the  photodiode  output  current  is  much  lower  than  35µA  under  our  operating  conditions.    A  feedback  resistor  of  5.1MΩ  gave  a  satisfactory  3~5V  range  under  ambient  lighting.    

𝐸𝑞𝑢𝑎𝑡𝑖𝑜𝑛  1:  𝑉!"# = −𝐼!𝑅!       Transimpedance  amplifier  gain    We  used  the  commonly  available  TL074CN  quad-­‐opamp  for  the  transimpedance  amplifier  circuit.    This  opamp  works  well  in  this  amplification  because  it  has  very  high  (1012Ω)  input  resistance  and  very  low  input  offset  voltage  (~3mV).    These  two  parameters  make  the  TL074CN  very  attractive  for  amplifying  a  relatively  slow,  small  amplitude  signal.[3]    Other,  more  obscure  opamps  such  as  the  NJM4580  would  offer  better  performance  in  a  smaller  package  at  a  lower  price,  but  were  unavailable.    Two  of  the  four  opamps  in  the  TL074CN  are  currently  not  used.    With  no  additional  components  they  could  be  used  as  a  buffer  for  both  channels.    But,  the  myDAQ  has  a  very  large  (>10GΩ[4])  input  impedance,  making  any  loading  effects  completely  insignificant.    The  two  extra  opamps  will  not  be  used  as  buffers  because  they  increase  circuit  complexity,  points  of  failure,  and  add  no  benefit  for  this  application.    We  used  two  separate  loops  for  the  audio  generation  and  configured  it  so  that  the  inputs  and  outputs  could  occur  simultaneously.    Sub-­‐VIs  were  used  to  accomplish  modular  functions  that  were  separate  from  the  original  task  of  generating  an  audio  signal  from  the  input  data.    For  loops  with  case  structures  were  used  to  allow  quick  changes  between  states  and  configurations.    The  inputs  were  normalized  to  account  for  high  and  low  light  levels.    These  were  then  scaled  to  match  user  inputs;  in  order  to  provide  a  linear  relationship  between  light  levels  and  the  “note”,  the  output  

Page 5: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

frequency  was  generated  using  a  logarithmic  scale  to  account  for  the  frequency  doubling  that  occurs  between  octaves.    Both  the  software  and  hardware  can  be  designed  and  created  independently.    The  Gantt  chart  in  Figure  3  illustrates  how  our  team  divided  up  the  work  into  as  many  parallel  tasks  as  possible  to  reduce  project  time.    The  hardware  is  considerably  less  complex  than  the  software,  so  while  the  software  was  still  being  programmed  and  debugged,  this  report  was  written.  

Implementation  

Hardware  The  finalized  schematic  used  is  available  in  Figure  2.    The  myDAQ  supplies  the  ±15V  rails  to  the  TL074CN  opamp.    Both  A0  and  A1  are  used  to  measure  the  transimpedance  amplifiers’  outputs;  the  negative  inputs  for  both  channels  need  to  be  grounded  to  get  meaningful  results.    For  brighter  environments,  a  smaller  feedback  resistor  should  be  used  for  both  channels.    Similarly,  in  a  dimmer  environment  a  larger  feedback  resistor  should  be  used  to  give  the  myDAQ  the  greatest  voltage  range  possible.    

Software    The  LabVIEW  code  consists  primarily  of  two  while  loops  on  the  main  block  diagram  (one  for  the  input  from  the  photodiodes  and  the  associated  signal  processing  and  one  for  controlling  and  outputting  a  waveform  to  the  myDAQ)  as  well  as  several  sub  vis.    Each  of  the  while  loops  in  the  main  vi  have  nested  loops  and  case  structures.    When  the  code  is  initialized,  it  begins  by  setting  minimum  and  maximum  values  for  volume  and  frequency.    It  then  moves  to  the  signal  processing  loop  within  which  it  creates  a  waveform  chart  for  both  volume  and  frequency  as  well  as  contains  the  option  for  calibrating  the  entire  system  for  both  high  and  low  light  levels.    It  then  proceeds  to  read  from  channels  A0  and  A1  on  the  myDAQ  which  are  then  normalized  before  plotting  and  calculating  the  corresponding  volume  and  frequency  in  such  a  way  as  to  distribute  it  across  the  entire  selected  range.    Once  this  has  been  accomplished  and  if  auto-­‐tune  is  enabled,  it  is  passed  to  the  auto-­‐tune  sub  vi  where  the  frequency  is  then  coerced  into  a  key  of  F#,  G,  C  majors  or  the  chromatic  scale  depending  on  the  users  preference  before  passing  this  information  to  the  output  waveform  loop.    Once  there,  the  output  volume  can  be  adjusted  manually  and  both  soft  and  hard  clipping  can  be  turned  on  and  off  by  a  Boolean  controlling  the  clipping  sub-­‐VI.    This  waveform  is  then  converted  into  a  format  readable  by  the  myDAQ  and  is  output  on  the  audio  out  channel.    It  should  also  be  noted  that  whatever  controls  on  the  front  panel  are  not  affecting  operation  are  removed  until  they  are  again  required.  

Page 6: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

Conclusion  The  end  goal  of  this  project  was  to  design  and  construct  an  optical  Theremin.    The  optical  Theremin  was  required  to  generate  user-­‐controllable  tones  and  volume  through  varying  light  intensity.    The  software  was  required  to  have  a  friendly  front  panel  user  interface,  user  configurable  volume  and  pitch  ranges,  and  to  display  both  graphically  and  numerically  the  measured  light  intensities  from  the  photodiodes.    The  realized  final  optical  Theremin  design  met  all  design  requirements  and  can  be  easily  replicated  by  others  through  this  final  documentation.    Further  research  can  be  done  to  improve  responsiveness,  increase  user  sensitivity,  and  add  additional  effects.    

Appendix  A      

 Figure  1:  High  Level  N=1  Block  Diagram  

 

 Figure  2:    Transimpedance  Amplifier  Schematic  

   

Page 7: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

Week   1   2   3   4  Circuit  Design  and  Construction          

Circuit  Debugging          LabVIEW  Coding          

LabVIEW  Debugging          Design  Verification/Validation          Design  Review  Document          

Figure  3:    Gantt  Chart    

Component   Quantity   Unit  Price  ($)   Supplier  NI  myDAQ   1   179.00   Studica  

OP906  Photodiode   2   0.59   Mouser  TL074CN  PDIP-­‐14   1   0.61   Mouser  

  5.1MΩ,  5%  Metal  Film  Resistor     2   0.09   Mouser  170  Tie  Point  Breadboard   1   1.93   Deal  Extreme  Breadboard  Solid  Wire   -­‐   -­‐   -­‐  

  TOTAL:   182.90        

Figure  4:    Bill  of  Materials      

     

Figure  5:  Front  Panel      

Page 8: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

   

Figure  6:  Clipping  Block  Diagram  

                     

   

Figure  7:  Autotune  Block  Diagram  

Page 9: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

 Figure  8:  Main  Block  Diagram  

 

 Figure  8a:  Inputs  to  loops  

   

   

Page 10: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

   

 Figure  8b:  Bottom  Loop  (Sound  Generation  and  Output)  

   

   

Figure  8c:  Setup  of  Inputs  in  Top  Loop          

Page 11: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

                                                                                           

Figure  8d:  Outer  Case  Structure  False  (Top  Loop)  

 

Page 12: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

   

Figure  8e:  Outer  Case  Structure  True  (Top  Loop)  

Page 13: Lab!2:!Optical!Theremin! - Pennsylvania State Universitysites.psu.edu/.../uploads/sites/8810/2015/04/CDR_4_Fly… ·  · 2016-07-14Microsoft Word - Lab Report.docx Created Date:

Bibliography  [1] Glinsky, Albert. Theremin: Ether Music and Espionage. Urbana: U of

Illinois, 2000. Print. [2] Optek Technology. PIN Silicon Photo Diode OP906. June 1996. [3] Texas Instruments. TL07x Low-Noise JFET-Input Operational

Amplifiers. Feb. 2014. [4] National Instruments. NI MyDAQ Specifications. Aug. 2014.