{"id":432,"date":"2019-06-14T23:30:48","date_gmt":"2019-06-14T21:30:48","guid":{"rendered":"http:\/\/oussamaameur.fr\/?p=432"},"modified":"2021-12-06T00:30:46","modified_gmt":"2021-12-05T23:30:46","slug":"theremin","status":"publish","type":"post","link":"https:\/\/oussamaameur.fr\/index.php\/2019\/06\/14\/theremin\/","title":{"rendered":"Theremin"},"content":{"rendered":"\n<div class=\"wp-block-cover alignfull has-background-dim has-parallax\" style=\"background-image:url(https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre.jpg);min-height:679px\"><div class=\"wp-block-cover__inner-container\">\n<p class=\"has-text-align-center has-huge-font-size\">Theremin<\/p>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\">The theremin is an instrument you play by hovering your hands around its two antennas, one for the volume of the sound emitted by the instrument, and the other one for its frequency. It works thanks to the capacitor-like characteristic of the human body. This project was one of our hardest because we needed to be thorough and precise for the theremin to work. We\u2019re going to approach this from 3 axis :<br>&#8211; The volume variation<br>&#8211; The frequency variation<br>&#8211; The building of the instrument<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-bcce3287\"><h2 class=\"uagb-heading-text\">Volume Variation<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/11\/tof.png\" alt=\"\" class=\"wp-image-669\" width=\"219\" height=\"159\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/11\/tof.png 600w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/11\/tof-300x218.png 300w\" sizes=\"(max-width: 219px) 100vw, 219px\" \/><figcaption>Time of flight sensor<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\">The volume variation is done numerically by using a time of flight sensor connected to an STM32 board. The distance information is sent to the STM32 and we can program the output volume accordingly.<br>The time of flight used is a VL53L1A1, it works by sending and receiving an infrared laser, it allows to get a distance in nanometers stored in 32 bits. Then the STM32 processes the 32 bits distance and outputs a value between 0 and 2048 that we send to the Digital Analog Converter (DAC) to convert the numeric value into a voltage that will arrive at the gate of the transistor (2N3820).<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/11\/circuit_bipo.png\" alt=\"\" class=\"wp-image-667\" width=\"177\" height=\"137\"\/><\/figure><\/div>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\"><br>According to the gate voltage, the output will vary between 0V and 9V and it will power the speaker. The loudness of the speaker depending on the input voltage, the volume of the speaker varies from mute to full volume. We originally wanted to wire the STM32 to the audio amplifier but doing so would saturate the sound since we&#8217;re lowering the maximum voltage of the output instead of lowering the input. <\/p>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\"><br>We encountered several problems with the Time-of-flight sensor, but they were all related to the fact that it\u2019s a proprietary sensor and board, and they were not made for one another. For example, the library is not made for our STM32 board. The code is made for Cortex M4 instead of our Cortex M3, so we had a different register than the datasheet. So, when we wanted to access a certain register, we had to make a loop that would check every address. We also had to edit some files to make the drivers compatible with the time-of-flight API.<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-893c461e\"><h2 class=\"uagb-heading-text\">Frequency Variation<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\">The frequency variation, contrary to the volume variation, is done analogically. The system is made of two oscillators&nbsp;: a fixed one and a variable one. The variable one is controlled by the hand of the player which acts as a variable capacitor relative to the distance of the hand.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusoscishort-edited.png\" alt=\"\" class=\"wp-image-521\" width=\"459\" height=\"286.875\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusoscishort-edited.png 1450w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusoscishort-edited-300x188.png 300w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusoscishort-edited-1024x641.png 1024w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusoscishort-edited-768x480.png 768w\" sizes=\"(max-width: 1450px) 100vw, 1450px\" \/><figcaption>Variable oscillator with the antenna (ANT1) at the bottom<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\">The frequency variation works this way :<br>We have two oscillators linked to two amplifiers. A fixed oscillator  and a variable one with an antenna. The fixed oscillator emits a 520kHz sinewave whereas the variable one can emit a sinewave between 500kHz and 520kHz. The hand acts as a capacitor and its movement around the instrument is caught by the antenna and changes the frequency of the oscillator.<br>We used several oscillator architectures, including a Colpitts oscillator, made from resistors, capacitors and inductors, but we didn&#8217;t have a satisfying enough sine. So we modified the Colpitts one empirically to get what we wanted.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img alt=\"\"\/><\/figure>\n\n\n\n<section class=\"wp-block-uagb-columns uagb-columns__wrap uagb-columns__background-none uagb-columns__stack-none uagb-columns__valign-undefined uagb-columns__gap-10 alignwide uagb-block-3787f31c\"><div class=\"uagb-columns__overlay\"><\/div><div class=\"uagb-columns__inner-wrap uagb-columns__columns-2\">\n<div class=\"wp-block-uagb-column uagb-column__wrap uagb-column__background-undefined uagb-block-ee897708\"><div class=\"uagb-column__overlay\"><\/div><div class=\"uagb-column__inner-wrap\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"781\" height=\"488\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusmulti-1-edited.png\" alt=\"\" class=\"wp-image-523\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusmulti-1-edited.png 781w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusmulti-1-edited-300x187.png 300w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/circuitfocusmulti-1-edited-768x480.png 768w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><figcaption>Analog multiplier (AD633AN)<\/figcaption><\/figure>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\">Once we have the modulated signal with the envelope being equal to the difference between the fixed signal and the variable signal, we extract said envelope thanks to an active low-pass filter which removes the carrier wave&#8217;s signal to keep only the envelope.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/passebas.png\" alt=\"\" class=\"wp-image-552\" width=\"391\" height=\"397\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/passebas.png 820w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/passebas-295x300.png 295w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/passebas-768x782.png 768w\" sizes=\"(max-width: 391px) 100vw, 391px\" \/><figcaption>Active low-pass filter<\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-uagb-column uagb-column__wrap uagb-column__background-undefined uagb-block-0756d147\"><div class=\"uagb-column__overlay\"><\/div><div class=\"uagb-column__inner-wrap\">\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\">We then modulate the two signals in order to substract the two frequencies by sending them to an analog multiplier. The fixed oscillator emitting 520kHz minus a variable one emitting between 500kHz and 520kHz allows us to have a sinewave between 0Hz and 20kHz, within the range of hearable sounds.<br>When modulating a signal, the carrier wave&#8217;s frequency is the sum of the signals&#8217; frequency whereas the envelope&#8217;s frequency is the difference between the two signals&#8217; frequency.<\/p>\n\n\n\n<section class=\"wp-block-uagb-columns uagb-columns__wrap uagb-columns__background-undefined uagb-columns__stack-mobile uagb-columns__valign-undefined uagb-columns__gap-10 alignundefined uagb-block-b3bd8ed2\"><div class=\"uagb-columns__overlay\"><\/div><div class=\"uagb-columns__inner-wrap uagb-columns__columns-1\">\n<div class=\"wp-block-uagb-column uagb-column__wrap uagb-column__background-undefined uagb-block-99ca3bb9\"><div class=\"uagb-column__overlay\"><\/div><div class=\"uagb-column__inner-wrap\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"266\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/module-1024x266.png\" alt=\"\" class=\"wp-image-543\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/module-1024x266.png 1024w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/module-300x78.png 300w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/module-768x199.png 768w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/module-1536x399.png 1536w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/module-2048x532.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Input signal<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"294\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/porteuse-1024x294.png\" alt=\"\" class=\"wp-image-542\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/porteuse-1024x294.png 1024w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/porteuse-300x86.png 300w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/porteuse-768x220.png 768w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/porteuse-1536x440.png 1536w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/porteuse-2048x587.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Carrier wave<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"210\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/modulation-1024x210.png\" alt=\"\" class=\"wp-image-544\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/modulation-1024x210.png 1024w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/modulation-300x62.png 300w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/modulation-768x158.png 768w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/modulation-1536x315.png 1536w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/10\/modulation-2048x421.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Modulated signal (blue)<\/figcaption><\/figure>\n<\/div><\/div>\n<\/div><\/section>\n<\/div><\/div>\n<\/div><\/section>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/decoupling.png\" alt=\"\" class=\"wp-image-683\" width=\"266\" height=\"313\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/decoupling.png 824w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/decoupling-255x300.png 255w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/decoupling-768x904.png 768w\" sizes=\"(max-width: 266px) 100vw, 266px\" \/><figcaption>Decoupling Capacitor<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"has-text-color\" style=\"color:#dcdcdc\">We encountered several problems with the oscillators, most of which had to do with keeping the signal clean and stable. For example, the impedance of the signal generated by the oscillator was too weak and multiplying it would distort the output signal, so we added a resistor to increase the impedance. Moreover, the V<sub>DD<\/sub> and GND was retroactively affected by the oscillators since the signal is of high frequency. Indeed, the oscillator decreased the voltage of V<sub>DD<\/sub> and increased the voltage of GND through voltage spikes. So, we added a decoupling capacitor between V<sub>DD <\/sub>and GND to absorb the voltage variations. We should\u2019ve put a diode as well to block the current going back from the oscillator.<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-2538a0cb\"><h2 class=\"uagb-heading-text\">Prototype Construction<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:34% auto\"><figure class=\"wp-block-media-text__media\"><img src=\"https:\/\/cdn.discordapp.com\/attachments\/812637723047231488\/916366326505799750\/Theremine_brd.png\" alt=\"\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-text-color\" style=\"color:#dcdcdc\">Once the circuit was designed, we printed it on the PCB. We used Autodesk Eagle to design it and then our teacher made it into a PCB. We then pierced the holes to put the components. Due to some unpredictable outcomes, we had to modify the PCB ourselves by soldering wires that could then be connected to other components.<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_lumiere-1024x961.jpg\" alt=\"\" class=\"wp-image-817\" width=\"256\" height=\"240\" srcset=\"https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_lumiere-1024x961.jpg 1024w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_lumiere-300x282.jpg 300w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_lumiere-768x721.jpg 768w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_lumiere-1536x1442.jpg 1536w, https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_lumiere.jpg 2034w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><figcaption>Lit up theremin<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"has-text-align-justify has-text-color\" style=\"color:#dcdcdc\"><br>To build the prototype, we made a pyramidal box out of Plexiglas with a hole at the top in order for the time of flight sensor to sense the hand.\u00a0One of the pyramid side has a hole at its center to put the speaker and another one has a hole to place the antenna. The STM32 is placed at the bottom of the pyramid. There is a wood box under the pyramid in which we placed LEDs to light up the pyramid at night, we also etched music notes on the faces so that they shine brighter compared to the rest of the pyramid.<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-f8eed593\"><h2 class=\"uagb-heading-text\">Conclusion<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<p class=\"has-text-color\" style=\"color:#dcdcdc\">It is to this day our most difficult project, not much because of its complexity, but mostly because of the precision we needed to achieve to make two clean oscillations that could survive being multiplied. We also had a hard time adapting the Cortex-M4 code to a Cortex-M3 processor because we never learned to access the register ourselves and modify the driver&#8217;s files.<\/p>\n\n\n<p><iframe loading=\"lazy\" width=\"1196\" height=\"673\" src=\"https:\/\/www.youtube.com\/embed\/WfXY0a1QGLM\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We made an instrument played by hovering your hands around &hellip; <a href=\"https:\/\/oussamaameur.fr\/index.php\/2019\/06\/14\/theremin\/\" class=\"more-link\"><span class=\"readmore\">Continue reading<span class=\"screen-reader-text\">Theremin<\/span><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":685,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":5,"_editorskit_typography_data":[],"_editorskit_blocks_typography":"","_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}"},"categories":[2],"tags":[],"uagb_featured_image_src":{"full":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre.jpg",1920,768,false],"thumbnail":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-150x150.jpg",150,150,true],"medium":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-300x120.jpg",300,120,true],"medium_large":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-768x307.jpg",768,307,true],"large":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-1024x410.jpg",990,396,true],"1536x1536":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-1536x614.jpg",1536,614,true],"2048x2048":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre.jpg",1920,768,false],"post-thumbnail":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-640x640.jpg",640,640,true],"my-music-band-archive-top":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-990x556.jpg",990,556,true],"my-music-band-hero":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-960x720.jpg",960,720,true],"my-music-band-featured":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-640x480.jpg",640,480,true],"my-music-band-slider":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre.jpg",1920,768,false],"my-music-band-testimonial":["https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/12\/theremine_sombre-180x180.jpg",180,180,true]},"uagb_author_info":{"display_name":"AMEUR Oussama","author_link":"https:\/\/oussamaameur.fr\/index.php\/author\/admin4276\/"},"uagb_comment_info":0,"uagb_excerpt":"We made an instrument played by hovering your hands around &hellip; Continue readingTheremin","_links":{"self":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts\/432"}],"collection":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":39,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"predecessor-version":[{"id":1061,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts\/432\/revisions\/1061"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/media\/685"}],"wp:attachment":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}