{"id":452,"date":"2016-05-27T09:11:18","date_gmt":"2016-05-26T23:11:18","guid":{"rendered":"https:\/\/mindbleach.com\/words\/?p=452"},"modified":"2016-05-27T09:11:18","modified_gmt":"2016-05-26T23:11:18","slug":"all-the-switches","status":"publish","type":"post","link":"https:\/\/mindbleach.com\/words\/2016\/05\/27\/all-the-switches\/","title":{"rendered":"All the Switches"},"content":{"rendered":"<p>I recently bought a heap\u00a0of <a href=\"http:\/\/www.aliexpress.com\/item\/New-100PCS-Lot-7X7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off-button-Latching\/32446939154.html\">these<\/a>\u00a0switches &#8211; small DPDT toggle buttons &#8211; for $0.07\u00a0ea.<\/p>\n<p><div id=\"attachment_453\" style=\"width: 372px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.aliexpress.com\/item\/New-100PCS-Lot-7X7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off-button-Latching\/32446939154.html\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-453\" class=\"wp-image-453 \" title=\"Quantity over Quality\" src=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/New-20PCS-Lot-7X7mm-7-7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off.jpg_640x6401.jpg\" alt=\"New-20PCS-Lot-7X7mm-7-7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off.jpg_640x640[1]\" width=\"362\" height=\"362\" srcset=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/New-20PCS-Lot-7X7mm-7-7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off.jpg_640x6401.jpg 640w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/New-20PCS-Lot-7X7mm-7-7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off.jpg_640x6401-150x150.jpg 150w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/New-20PCS-Lot-7X7mm-7-7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off.jpg_640x6401-300x300.jpg 300w\" sizes=\"(max-width: 362px) 100vw, 362px\" \/><\/a><p id=\"caption-attachment-453\" class=\"wp-caption-text\">Quantity over Quality<\/p><\/div>These switches are not that large, the <strong>on<\/strong> vs <strong>off<\/strong>\u00a0height difference is only about a millimetre, and I hate to think what the\u00a0&#8216;rated cycles&#8217; or debounce graph looks like.<br \/>\nRegardless of their shortcomings, the prospect of\u00a0having some silly project use literally <em>THOUSANDS<\/em> of switches on the cheap is\u00a0enticing.<\/p>\n<p>&#8230;but how to read them all?<\/p>\n<h1>The Problem<\/h1>\n<p>First of all, forget &#8216;one I\/O\u00a0per switch&#8217;, it will not scale well.<\/p>\n<p>The most\u00a0common method to wire up many switches is in a matrix.<br \/>\nEach row uses\u00a0an I\/O, each column uses an I\/O, and pressing the switch connects\u00a0that row and column together.<br \/>\n16\u00a0switches need 8 I\/O, 64 switches need 16 I\/O, it scales well. (and with a demux on one side, even fewer are needed)<\/p>\n<div id=\"attachment_455\" style=\"width: 427px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/core-electronics.com.au\/keypad-12-button.html\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-455\" class=\" wp-image-455\" src=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/keypad_-_12_button__com-08653__011.jpg\" alt=\"Nobody can be told what the matrix is, you have to see it for yourself. (see above)\" width=\"417\" height=\"417\" srcset=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/keypad_-_12_button__com-08653__011.jpg 600w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/keypad_-_12_button__com-08653__011-150x150.jpg 150w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/keypad_-_12_button__com-08653__011-300x300.jpg 300w\" sizes=\"(max-width: 417px) 100vw, 417px\" \/><\/a><p id=\"caption-attachment-455\" class=\"wp-caption-text\">Nobody can be told what the matrix is, you have to see it for yourself. (see above)<\/p><\/div>\n<p>However, switches are only simple electrical devices. When a switch is closed current can freely flow in either direction. If only one or two are closed, the patterns are unique.\u00a0As soon as three or more switches are closed, a simple matrix can no longer read the switches with certainty. For example, there\u00a0is no way to distinguish between these five switch\u00a0states:<\/p>\n<div id=\"attachment_456\" style=\"width: 610px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-456\" class=\"size-full wp-image-456\" src=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/Figure61.png\" alt=\"Which switch is which?\" width=\"600\" height=\"339\" srcset=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/Figure61.png 600w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/Figure61-300x170.png 300w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/Figure61-500x283.png 500w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><p id=\"caption-attachment-456\" class=\"wp-caption-text\">Indistinguishable patterns &#8211; Which switch is which?<\/p><\/div>\n<p>The matrix option will\u00a0not\u00a0be able to read\u00a0all the switches.<\/p>\n<h1>The Not-So-Great Solution<\/h1>\n<p>This is a common problem faced by designers. What is\u00a0the common solution?<br \/>\nA\u00a0diode can be placed next to each switch to allow current only in one direction.<\/p>\n<div id=\"attachment_457\" style=\"width: 594px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-457\" class=\"size-large wp-image-457\" src=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/matrix-1024x908.png\" alt=\"I've got pain in the diodes down my left hand side...\" width=\"584\" height=\"518\" srcset=\"https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/matrix-1024x908.png 1024w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/matrix-300x266.png 300w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/matrix-768x681.png 768w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/matrix-338x300.png 338w, https:\/\/mindbleach.com\/words\/wp-content\/uploads\/2016\/05\/matrix.png 1115w\" sizes=\"(max-width: 584px) 100vw, 584px\" \/><p id=\"caption-attachment-457\" class=\"wp-caption-text\">I&#8217;ve got pain in the diodes down my left hand side&#8230;<\/p><\/div>\n<p><em>&#8220;What&#8217;s wrong with that?&#8221;<\/em> Well,\u00a0<strong>every<\/strong> switch needs a diode.<br \/>\nSo now there are twice as many parts on the board, and you&#8217;ve got to find space for them, pay for them, solder them in&#8230;not great at all.<\/p>\n<h1>Other Solutions?<\/h1>\n<p>What other options are there?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently bought a heap\u00a0of these\u00a0switches &#8211; small DPDT toggle buttons &#8211; for $0.07\u00a0ea. These switches are not that large, the on vs off\u00a0height difference is only about a millimetre, and I hate to think what the\u00a0&#8216;rated cycles&#8217; or debounce &hellip; <a href=\"https:\/\/mindbleach.com\/words\/2016\/05\/27\/all-the-switches\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[79,80,81,78],"class_list":["post-452","post","type-post","status-publish","format-standard","hentry","category-electronics","tag-button","tag-diode","tag-matrix","tag-switch"],"_links":{"self":[{"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/posts\/452"}],"collection":[{"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":2,"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/posts\/452\/revisions"}],"predecessor-version":[{"id":458,"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/posts\/452\/revisions\/458"}],"wp:attachment":[{"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/media?parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/categories?post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mindbleach.com\/words\/wp-json\/wp\/v2\/tags?post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}