{"id":255,"date":"2013-12-16T19:03:55","date_gmt":"2013-12-16T19:03:55","guid":{"rendered":"http:\/\/greg-kennedy.com\/wordpress\/?p=255"},"modified":"2019-05-04T00:43:06","modified_gmt":"2019-05-04T05:43:06","slug":"teeny-tiny-midi-controller","status":"publish","type":"post","link":"https:\/\/greg-kennedy.com\/wordpress\/2013\/12\/16\/teeny-tiny-midi-controller\/","title":{"rendered":"Teeny Tiny MIDI Controller"},"content":{"rendered":"<p>I&#8217;ve been working sporadically on this tiny MIDI controller.\u00a0 It targets the smallest PIC microcontroller available with onboard A\/D converter &#8211; the <a title=\"PIC10F220\" href=\"http:\/\/www.microchip.com\/wwwproducts\/Devices.aspx?dDocName=en023673\">PIC10F220<\/a>.<\/p>\n<p>Currently it reads two potentiometers and a button input using three of the GPIO pins, and it bitbangs the remaining output pin to produce MIDI-Out at 31250hz using cycle-counted delays.\u00a0 Since practically everything is already on-chip, this thing could just be epoxied straight to the enclosure.\u00a0 There are only two or three more components &#8211; no PCB required!<\/p>\n<p><a href=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/schem.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-259 size-full\" src=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/schem.png\" alt=\"schem\" width=\"725\" height=\"502\" srcset=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/schem.png 725w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/schem-300x207.png 300w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/schem-624x432.png 624w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/a>This microcontroller sports a whopping 256 instructions and 16 bytes of RAM.\u00a0 Even so, the MIDI controller code consumes less than half the available resources after a modest amount of optimization for size.\u00a0 One might see this as my response to using a certain 32k ROM \/ 2k RAM microcontroller to blink some lights, but I won&#8217;t admit to being that petty.<\/p>\n<p><a href=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/mplab.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-257 size-large\" src=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/mplab-1024x603.png\" alt=\"mplab\" width=\"625\" height=\"368\" srcset=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/mplab-1024x603.png 1024w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/mplab-300x176.png 300w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/mplab-624x367.png 624w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/mplab.png 1304w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a>What to do with the remaining space?\u00a0 An easter egg isn&#8217;t a bad idea&#8230;\u00a0 Hold the button down on boot, and the controller will dump &#8220;HTTP:\/\/WWW.HACKADAY.COM&#8221; as a series of MIDI note-on messages.<\/p>\n<p>Unfortunately I haven&#8217;t built the thing yet, but I did simulate it.\u00a0 Here&#8217;s the logic analyzer input, showing MIDI messages being sent (delays removed):<\/p>\n<p><a href=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/plot_edit.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-258 size-large\" src=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/plot_edit-1024x284.png\" alt=\"plot_edit\" width=\"625\" height=\"173\" srcset=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/plot_edit-1024x284.png 1024w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/plot_edit-300x83.png 300w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/plot_edit-624x173.png 624w, https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/plot_edit.png 1233w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><strong>You can listen to the result here: <a href=\"https:\/\/greg-kennedy.com\/wordpress\/wp-content\/uploads\/2013\/12\/egg.mid\">EasterEgg.mid<\/a><\/strong><\/p>\n<p>Code follows.<\/p>\n<p><!--more--><\/p>\n<pre>;\n;\n; Easter Egg: hold button on startup ;-)\n    btfsc\u00a0\u00a0 \u00a0GPIO,GP3\u00a0\u00a0 \u00a0; 2-3\n    goto skip_egg\n\n; \"note on\" running mode\n    movlw\u00a0\u00a0 \u00a0(0x90 | midi_channel)\n    movwf output\n    call serial_bitbang\n\n; reset pointer\n    clrf\u00a0\u00a0 \u00a0egg_timer\n\n; \"HTTP:\/\/WWW.HACKADAY.COM\" -&gt; \"48 54 54 50 3a 2f 2f 57 57 57 2e 48 41 43 4b 41 44 41 59 2e 43 4f 4d\"\negg_loop:\n; load ptr into w reg\n    movfw egg_timer\n; go get the next ascii value\n    call egg_table\n\n; done?\n    iorlw\u00a0\u00a0\u00a0 0x00\n    btfsc STATUS,Z\n    goto skip_egg\n\n; send note (on)\n    movwf output\n    call serial_bitbang\n; send note volume\n    movlw 0x7F\n    movwf output\n    call serial_bitbang\n\n; delay\n    movlw 0x7F\n    movwf output\negg_delay_outer:\n    movlw 0x7F\n    movwf temp\negg_delay_inner:\n    nop\n    nop\n    nop\n    nop\n    decf\u00a0\u00a0 \u00a0temp\n    btfss\u00a0\u00a0 \u00a0STATUS,Z\n    goto egg_delay_inner\n    decf\u00a0\u00a0 \u00a0output\n    btfss STATUS,Z\n    goto egg_delay_outer\n\n; send note (off) - again\n    movlw egg_timer\n    call egg_table\n    movwf output\n    call serial_bitbang\n; send note volume 0x00 == off\n    clrf output\n    call serial_bitbang\n\n; next ASCII char\n    incf egg_timer,f\n\n    goto egg_loop\n\nskip_egg:\n; Send the first MIDI CC message.\n; ...\n\n; ...\n; rest of project code...\n; ...\n\n; lookup table for hackaday URL\negg_table:\n\u00a0\u00a0 \u00a0addwf\u00a0\u00a0 \u00a0PCL,F\u00a0\u00a0 \u00a0;add offset to pc to\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0;generate a computed goto\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x48\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x54\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x54\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x50\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x3a\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x2f\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x2f\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x57\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x57\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x57\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x2e\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x48\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x41\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x43\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x4b\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x41\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x44\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x41\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x59\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x2e\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x43\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x4f\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x4d\n\u00a0\u00a0 \u00a0retlw\u00a0\u00a0 \u00a00x00\n\u00a0\u00a0 \u00a0END<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working sporadically on this tiny MIDI controller.\u00a0 It targets the smallest PIC microcontroller available with onboard A\/D converter &#8211; the PIC10F220. Currently it reads two potentiometers and a button input using three of the GPIO pins, and it bitbangs the remaining output pin to produce MIDI-Out at 31250hz using cycle-counted delays.\u00a0 Since practically [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,11],"tags":[],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-hardware","category-music"],"_links":{"self":[{"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":4,"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":384,"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/posts\/255\/revisions\/384"}],"wp:attachment":[{"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greg-kennedy.com\/wordpress\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}