{"id":90,"date":"2015-07-24T20:14:25","date_gmt":"2015-07-24T19:14:25","guid":{"rendered":"http:\/\/watchdiana.fail\/blog\/?p=90"},"modified":"2015-07-24T20:14:25","modified_gmt":"2015-07-24T19:14:25","slug":"sparky-redesign-in-software","status":"publish","type":"post","link":"https:\/\/watchdiana.fail\/blog\/2015\/07\/24\/sparky-redesign-in-software\/","title":{"rendered":"Sparky, redesign in software"},"content":{"rendered":"<p>So, I&#8217;ve probably learned everything I can about electronics from this particular TTL build.  For example, I now know what TTL stands for, what 5 volts tastes like, and what a pull-up resistor is.  Mat knows that explaining things to a non-expert is haaaaard and that left alone I will do crazy things.  So we&#8217;ve both learned.<\/p>\n<p>The main board of Sparky is a horror of add-ons, re-mapping, remaking and coloured wires.  At least the coloured wires are consistent.  Orange for one side of the level we want, green for the other.  However, I need to replace most of the bits of the main board with the Arduino.<\/p>\n<p>The step-down needs to be done in hardware.  I&#8217;m not running 40 volts through an Arduino, even to see what happens[0].  The level comparisons can be done at 5 volts, and indeed it&#8217;ll be easier to do that then to twiddle analogue knobs.  The first thing we&#8217;ll be finding out is whether we&#8217;re grounded.  If the probe is touching the material, we want to move up.  (If we can&#8217;t move up, for example because we just hit a switch and the material fell over on the probe, we probably want to cut off the spark circuit, but I&#8217;m not building relays into this.)<\/p>\n<p>We want to avoid false positives, so we check a smoothed version of LVL.  That smoothing is also done in hardware, with a capacitor.<\/p>\n<p>If the probe isn&#8217;t touching the material, then we test to see if the smoothed LVL (see, we&#8217;re using the function, or at least a value we passed along) is 0.  If so, we move down.<\/p>\n<p>If neither of those things is the case, we leave well alone for Tau, where Tau is the period of the spark capacitor charging.  Then we loop again.<\/p>\n<p>&#8216;move&#8217; here is a function, which tells the stepper chip DIR, and then hits the STEP pin.  I&#8217;m guessing we can do that in two lines of code, and the pause between them will be enough, but DIR might take a moment to wake up, and if that happens it can be dealt with.<\/p>\n<p>&#8212;<\/p>\n<p>So, the shape of it:<\/p>\n<pre>\nLVL +\n    |\n    +--Check not grounded -- if grounded move up then start loop again.\n         |\n         + Check not high -- if high, move down then start loop again.\n             |\n             + If nothing else, stay where you are for Tau then start loop again.\n\n<\/pre>\n<p>Things I&#8217;ll need:<\/p>\n<ul>\n<li>LVL measurement &#8211; this will expand the timing loop if we end up sampling repeatedly<\/li>\n<li>comparator function &#8211; \/U and \/D variables, vs LVL.  Check that \/U and \/D are different and in the correct order &#8211; if no space between them, abort and complain.<\/li>\n<li>spark delay calculator\/outer timing loop<\/li>\n<li>movement function<\/li>\n<li>tea<\/li>\n<\/ul>\n<p>On the wishlist:<\/p>\n<ul>\n<li>Serial.print output in various formats<\/li>\n<li>M0 M1 M2 pins to be isolated with dipswitches.  Whatever they are.<\/li>\n<li>more tea<\/li>\n<\/ul>\n<p>[0] If I were going to be doing that, I&#8217;d use considerably higher voltage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I&#8217;ve probably learned everything I can about electronics from this particular TTL build. For example, I now know what TTL stands for, what 5 volts tastes like, and what a pull-up resistor is. Mat knows that explaining things to a non-expert is haaaaard and that left alone I will do crazy things. So we&#8217;ve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,30,29],"tags":[7,9,31,32,12,6,23,13],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-coding","category-electronics","category-sparky","tag-c","tag-coding","tag-fun-with-arduinos","tag-fun-with-electronics","tag-sparky","tag-starting","tag-things-i-do-at-makespace","tag-things-i-do-because-im-stubborn","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":0,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}