{"id":8230,"date":"2018-08-07T20:03:11","date_gmt":"2018-08-07T20:03:11","guid":{"rendered":"http:\/\/localhost:8105\/?p=8230"},"modified":"2021-12-07T06:36:12","modified_gmt":"2021-12-07T06:36:12","slug":"adding-end-stops-limit-switches-to-the-3018-woodpecker-cnc-router","status":"publish","type":"post","link":"https:\/\/blog.shahada.abubakar.net\/?p=8230","title":{"rendered":"Adding End-Stops \/ Limit Switches to the 3018 &#8220;Woodpecker&#8221; CNC Router"},"content":{"rendered":"<div>In its original design, the 3018 &#8220;Woodpecker&#8221; CNC Router, a cheap entry-level unit found on eBay and AliExpress, will happily tell the stepper motors to keep moving along the axis, even if the work bed or spindle carrier is bumping against the end of its range of movement. This is because the router doesn&#8217;t actually have any absolute measurement of where it&#8217;s current position on the axis is. It assumes it is at the &#8220;home&#8221; position (machine coordinates 0,0) whenever it is powered on, and will allow any movement relative to that position.<\/div>\n<div>\u00a0<\/div>\n<div>This is not such a big deal with CNC machines as they are with 3D printers: CNC&#8217;s usually operate on material placed somewhere on the bed, so it is more important that operations are performed relative to the work piece rather than the work surface. Most jobs begin by manually positioning the bit on the bottom left corner of the work piece, rather than the work surface, and setting this as the &#8220;work&#8221; home position.<\/div>\n<div>\u00a0<\/div>\n<div>You&#8217;ve also probably heard the awful sound that happens when you&#8217;ve accidentally sent the bit beyond an axis, the stepper motor is trying to turn the lead screw, but the screw is not able to turn.<\/div>\n<div>\u00a0<\/div>\n<div>They way to prevent this from happening, and also to tell the router where &#8220;home&#8221; is, is to add what are called &#8220;end stop&#8221; switches to your CNC. These are mechanical switches that are placed strategically so that when the lead screw is reaching the end of its range, some moving part along the axis causes the switch to be closed.<\/div>\n<div>\u00a0<\/div>\n<div>The woodpecker controller that comes with the router already has support for end stops. If you look at the pins at the bottom:<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8951\" rel=\"attachment wp-att-8951\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8951\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180728_221611-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1019\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180728_221611-scaled.jpg 2560w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180728_221611-300x119.jpg 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180728_221611-1024x408.jpg 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180728_221611-768x306.jpg 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180728_221611-1536x612.jpg 1536w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180728_221611-2048x815.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/div>\n<div>\u00a0<\/div>\n<div>The last 6 pins are labelled &#8220;Zen&#8221;, &#8220;Yen&#8221;, and &#8220;Xen&#8221;. Those aren&#8217;t the surnames of the designers of the board, but rather they stand for &#8220;Z-Axis Enable&#8221;, &#8220;Y-Axis Enable&#8221;, and &#8220;X-Axis Enable&#8221;. Movement along that axis is only allowed when the two pins are &#8220;Not Connected&#8221;, as it is by default. So the job of the endstop switch is to close that circuit when the end of travel is reached.<\/div>\n<div>\u00a0<\/div>\n<div>End stop switches look like this:<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8952\" rel=\"attachment wp-att-8952\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8952\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/2pcs-kw12-3-micro-roller-lever-arm-open-close-limit-switch-npstore-1807-07-NPSTORE@7.jpg\" alt=\"\" width=\"704\" height=\"516\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/2pcs-kw12-3-micro-roller-lever-arm-open-close-limit-switch-npstore-1807-07-NPSTORE@7.jpg 704w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/2pcs-kw12-3-micro-roller-lever-arm-open-close-limit-switch-npstore-1807-07-NPSTORE@7-300x220.jpg 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/a><\/div>\n<div>\u00a0<\/div>\n<div>The lever, when pushed down closes a switch. There are three sets of pins. One pair is &#8220;normally open&#8221; and the other pair is &#8220;normally closed&#8221;. For each position where we wish to place and end-stop, we need to join the two wires on the Woodpecker header to the &#8220;Normally Open&#8221; pair of the end stop switch.<\/div>\n<div>\u00a0<\/div>\n<div>I bought a pack of 10 of these end stop switches on eBay (search for &#8220;KW12-3&#8221;) for a grand total of USD1.19 with free shipping.<\/div>\n<div>\u00a0<\/div>\n<div>To attach them to the printer, I designed some 3D-printed mounting brackets for the switches.<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8953\" rel=\"attachment wp-att-8953\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8953\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-02-33-57.png\" alt=\"\" width=\"1920\" height=\"1200\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-02-33-57.png 1920w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-02-33-57-300x188.png 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-02-33-57-1024x640.png 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-02-33-57-768x480.png 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-02-33-57-1536x960.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/div>\n<div>\u00a0<\/div>\n<div>They can be found here: https:\/\/www.tinkercad.com\/things\/5txOc53Eftp-3018-cnc-limit-switch-end-stop-mounts<\/div>\n<div>\u00a0<\/div>\n<div>There a total of 5 &#8212; two each for the X and Y axis, and one for the Z. Here they are in place on the CNC Router:<\/div>\n<div>\u00a0<\/div>\n<div style=\"text-align: center;\"><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8954\" rel=\"attachment wp-att-8954\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8954\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175308-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1244\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175308-scaled.jpg 2560w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175308-300x146.jpg 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175308-1024x498.jpg 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175308-768x373.jpg 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175308-1536x747.jpg 1536w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175308-2048x996.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/div>\n<div style=\"text-align: center;\"><em>Y Axis (Front)<\/em><\/div>\n<div>\n<div>\u00a0<\/div>\n<div><br clear=\"none\" \/><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8955\" rel=\"attachment wp-att-8955\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8955\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024503-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1244\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024503-scaled.jpg 2560w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024503-300x146.jpg 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024503-1024x498.jpg 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024503-768x373.jpg 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024503-1536x747.jpg 1536w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024503-2048x996.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/div>\n<\/div>\n<div style=\"text-align: center;\"><em>Y-Axis (Rear)<\/em><\/div>\n<div>\u00a0<\/div>\n<div>\u00a0<\/div>\n<div style=\"text-align: center;\"><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8956\" rel=\"attachment wp-att-8956\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8956\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175322-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1244\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175322-scaled.jpg 2560w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175322-300x146.jpg 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175322-1024x498.jpg 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175322-768x373.jpg 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175322-1536x747.jpg 1536w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175322-2048x996.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/div>\n<div style=\"text-align: center;\"><em>X-Axis (Left)<\/em><\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8957\" rel=\"attachment wp-att-8957\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8957\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175314-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1244\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175314-scaled.jpg 2560w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175314-300x146.jpg 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175314-1024x498.jpg 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175314-768x373.jpg 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175314-1536x747.jpg 1536w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180807_175314-2048x996.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/div>\n<div style=\"text-align: center;\"><em>X-Axis (Right)<\/em><\/div>\n<div><br clear=\"none\" \/><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8958\" rel=\"attachment wp-att-8958\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8958\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024534-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1244\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024534-scaled.jpg 2560w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024534-300x146.jpg 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024534-1024x498.jpg 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024534-768x373.jpg 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024534-1536x747.jpg 1536w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/20180808_024534-2048x996.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/div>\n<div style=\"text-align: center;\"><em>Z-Axis (Top)<\/em><\/div>\n<div>\u00a0<\/div>\n<div>For the Front, Rear and Left I was able to use the smaller of the brackets I designed. The Right side however, needs a slightly longer reach as the limit is further away, due to the motor coupler.<\/div>\n<div>\u00a0<\/div>\n<div>For the Top limit switch, there was nowhere to attach the mount. So I ended up designing a holder for the switch that was super-glued to the fixed part of the spindle module. I also made a block that is superglued to the moving part of the spindle module. This holds a m3x25 bolt, held in place with a captive square-nut and a regular nut for tightening. It is the bolt that presses against the limit switch, it is possible to adjust it&#8217;s height it until it only clicks towards the very end of the range of travel.<\/div>\n<div>\u00a0<\/div>\n<div>Note: For the superglue to work well on PLA, I applied a liberal amount of it, and also clamped the parts down and letting the glue set for a few hours.<\/div>\n<div>\u00a0<\/div>\n<div>On the other end of the cable, I simply crimped them onto pins and inserted them into a 2-pin <a href=\"http:\/\/blog.shahada.abubakar.net\/post\/how-to-crimp-dupont-connector-pins\" target=\"_blank\" rel=\"noopener\" shape=\"rect\">DuPont<\/a> <a href=\"https:\/\/www.ebay.com\/sch\/i.html?_from=R40&amp;_trksid=m570.l1313&amp;_nkw=dupont+2P+shroud&amp;_sacat=0&amp;LH_TitleDesc=0&amp;_osacat=0&amp;_odkw=dupont+2-pin+shroud&amp;LH_TitleDesc=0\" target=\"_blank\" rel=\"noopener\" shape=\"rect\">shroud<\/a>. The woodpecker board already has pull-up resistors enabled and also capacitors to minimize the effects of noise, so these wires can connect directly to the appropriate header (X, Y, Z) on the woodpecker&#8217;s pins (You may also want to add additional <a href=\"https:\/\/github.com\/gnea\/grbl\/wiki\/Wiring-Limit-Switches\" target=\"_blank\" rel=\"noopener\" shape=\"rect\">buffer<\/a>ing of the signals. I went without). It doesn&#8217;t matter which of the two pins of the axis you connect a limit switch to, they are considered the same to GRBL, and it knows which one is triggered because it knows which direction the head was moving in when the limit switch triggered.<\/div>\n<div>\u00a0<\/div>\n<div>Finally, secure all the wiring with cable wrap, so they don&#8217;t get in the way. Make sure the Top switch wire has enough slack so the spindle module can still move\u00c2\u00a0to the extremes the X-carriage.<\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-size: 18px;\"><strong>GRBL Settings<\/strong><\/span><\/div>\n<div>\u00a0<\/div>\n<div>The limit switches do not work immediately; you have to enable them first. To do this, I used the console panel inside <a href=\"https:\/\/github.com\/cncjs\/cncjs\/wiki\" target=\"_blank\" rel=\"noopener\" shape=\"rect\">cncjs<\/a>.<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8959\" rel=\"attachment wp-att-8959\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8959\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-03-37-48.png\" alt=\"\" width=\"1299\" height=\"741\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-03-37-48.png 1299w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-03-37-48-300x171.png 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-03-37-48-1024x584.png 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-03-37-48-768x438.png 768w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/div>\n<div>\u00a0<\/div>\n<div>There are a number of GRBL (the firmware that runs in the woodpecker board) settings that apply. You can see the current settings when cncjs first connects to the woodpecker. To see the current settings at any other time, type &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">$$<\/span>&#8221; followed by enter in the console panel.<\/div>\n<div>\u00a0<\/div>\n<div>Here are what my settings look like:<\/div>\n<div>\u00a0<\/div>\n<div>\n<table style=\"border-collapse: collapse; table-layout: fixed;\" border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td style=\"padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;\" colspan=\"1\" rowspan=\"1\" valign=\"top\"><span style=\"font-family: 'courier new', courier, monospace;\">&gt; $$<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$0=10 (step pulse, usec)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$1=25 (step idle delay, msec)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$2=0 (step port invert mask:00000000)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$3=5 (dir port invert mask:00000101)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$4=0 (step enable invert, bool)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$5=0 (limit pins invert, bool)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$6=0 (probe pin invert, bool)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$10=3 (status report mask:00000011)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$11=0.010 (junction deviation, mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$12=0.002 (arc tolerance, mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$13=0 (report inches, bool)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$20=0 (soft limits, bool)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$21=1 (hard limits, bool)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$22=1 (homing cycle, bool)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$23=3 (homing dir invert mask:00000011)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$24=25.000 (homing feed, mm\/min)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$25=500.000 (homing seek, mm\/min)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$26=250 (homing debounce, msec)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$27=2.000 (homing pull-off, mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$100=800.000 (x, step\/mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$101=800.000 (y, step\/mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$102=800.000 (z, step\/mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$110=800.000 (x max rate, mm\/min)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$111=800.000 (y max rate, mm\/min)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$112=800.000 (z max rate, mm\/min)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$120=10.000 (x accel, mm\/sec^2)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$121=10.000 (y accel, mm\/sec^2)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$122=10.000 (z accel, mm\/sec^2)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$130=200.000 (x max travel, mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$131=200.000 (y max travel, mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$132=200.000 (z max travel, mm)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\u00a0<\/div>\n<div>To enable the limit switches, you have to set $21 to &#8220;1&#8221;. This is done by issuing the command:<\/div>\n<div>\u00a0<\/div>\n<div style=\"text-align: center;\"><span style=\"font-family: 'courier new', courier, monospace;\">$21=1<\/span><\/div>\n<div>\u00a0<\/div>\n<div>and pressing enter. The settings you make will remain set even if the CNC is switched off.<\/div>\n<div>\u00a0<\/div>\n<div>Once you have set this, the limit switches are monitored. If you now use the cursor in CNCjs to move the bit to one of the extremes, you will see the following in the\u00c2\u00a0console window when this happens:<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8960\" rel=\"attachment wp-att-8960\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8960\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-04-13-44.png\" alt=\"\" width=\"351\" height=\"223\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-04-13-44.png 351w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Screenshot-from-2018-08-08-04-13-44-300x191.png 300w\" sizes=\"auto, (max-width: 351px) 100vw, 351px\" \/><\/a><\/div>\n<div>\u00a0<\/div>\n<div>Once a limit switch is triggered, the spindle is automatically stopped and the woodpecker board goes into a locked state to prevent any damage from occuring. You will know this because the\u00c2\u00a0movement buttons will be greyed out. To resume using the CNC again, you need to do to things, (a) Reset and (b) Unlock. This can be done by sending Control-X followed by $X, or just press the coloured buttons on the top of the cncjs window.<\/div>\n<div>\u00a0<\/div>\n<div>On my machine, the first movement away from the limit switch position may trigger the cnc to become locked again, in which case I just need to Reset and Unlock it again.<\/div>\n<div>\u00a0<\/div>\n<div>This is a good time to check if your steppers are turning the right way &#8230; I look at my CNC with the gantry at the back, and I expect my axes to be laid out as follows:<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8961\" rel=\"attachment wp-att-8961\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8961\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Untitled-presentation.png\" alt=\"\" width=\"960\" height=\"720\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Untitled-presentation.png 960w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Untitled-presentation-300x225.png 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/Untitled-presentation-768x576.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/div>\n<div>\u00a0<\/div>\n<div>The front, top, left is considered the &#8220;Home&#8221; or &#8220;0,0,0&#8221; position for me, with the coordinates increasing in value as you move the bit right, back, and up (since 0 is at the &#8220;top&#8221;, you can&#8217;t move up, only down, so all the Z-level work is done in the negative range).<\/div>\n<div>\u00a0<\/div>\n<div>Not everybody agrees on this, so the cnc has options to change these assumptions.<\/div>\n<div>\u00a0<\/div>\n<div>If moving the spindle bit using the cursor controls in cncjs moves them in the &#8220;wrong&#8221; direction that you expect, you most likely have to invert that particular axis. This can be done using the $3 variable, using the following values:<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8962\" rel=\"attachment wp-att-8962\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8962\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/z.png\" alt=\"\" width=\"495\" height=\"348\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/z.png 495w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/08\/z-300x211.png 300w\" sizes=\"auto, (max-width: 495px) 100vw, 495px\" \/><\/a><\/div>\n<div>\u00a0<\/div>\n<div>It is important that this is set correctly before you try to enable &#8220;Homing&#8221;, as everything will be messed up otherwise. On my CNC, I used a value of <span style=\"font-family: 'courier new', courier, monospace;\">$3=5<\/span> (Invert Z and X) to get the axis laid out according to the photo above.<\/div>\n<div>\u00a0<\/div>\n<div>To enable Homing, set <span style=\"font-family: 'courier new', courier, monospace;\">$22=1<\/span> (Homing cycle, enabled). Now when you send the <span style=\"font-family: 'courier new', courier, monospace;\">$H<\/span> command, or press the &#8220;Homing&#8221; button at the top of cncjs, the cnc should raise the bit, and seek to the home position.<\/div>\n<div>\u00a0<\/div>\n<div>If you find it is seeking in the wrong direction, you can tell it to invert an axis for homing, by setting the value of $23 (use the same table as $3 above). To get the Home in the top, Left, Front position, I needed to set <span style=\"font-family: 'courier new', courier, monospace;\">$23=3<\/span> (Invert Z and X).<\/div>\n<div>\u00a0<\/div>\n<div>There is another setting, $27, homing &#8220;pull-off&#8221;. after detecting the home position, the cnc can move forward along the axis by a certain mm. This is to prevent the limit switches from triggering again with the next movement. On my cnc, I needed to set <span style=\"font-family: 'courier new', courier, monospace;\">$27=2<\/span> (homing pull-off of 2mm).<\/div>\n<div>\u00a0<\/div>\n<div>With these set correctly, issuing $H or pressing the cncjs Homing button will cause the spindle head to move to the Home position, and set work coordinates to 0,0,0.<\/div>\n<div>\u00a0<\/div>\n<div>It should also set the machine coordinates to 0,0,0; however it&#8217; doesn&#8217;t. Traditionally, CNC machines have their machine coordinates set to operate in &#8220;negative space&#8221;, and therefore Home is defined as the most negative position in the workspace (i.e. it assumes machine coordinates 0,0,0 is at the back, right, top). The CNC\u00c2 can be changed to work in &#8220;positive space&#8221; by\u00a0<a href=\"https:\/\/github.com\/winder\/Universal-G-Code-Sender\/issues\/435#issuecomment-230356406\" target=\"_blank\" rel=\"noopener\" shape=\"rect\">uncommenting<\/a> the HOMING_FORCE_ORIGIN option in config.h when compiling the GRBL firmware. Unfortunately, the GRBL in my woodpecker board was set to work in &#8220;negative space&#8221; when it was compiled, so I am stuck with it until I figure out how to reflash the firmware in my woodpecker board.<\/div>\n<div>\u00a0<\/div>\n<div>T<span style=\"text-decoration: line-through;\">o make things worse, it seems the woodpecker board has a generic firmware, and it thinks that my home is at -198.0, -198.0, -2, i.e. that my board is 200mm by 200mm (adjusted by 2mm of &#8220;Homing Pull-Off&#8221;). Hrmph. This means I need to go through a set of corrections if I want to know where exactly in machine coordinates a particular spot in my work surface is. The coordinates are still valid and usable, i.e. if I home and then tell the cnc to go to those machine coordinates, it will consistently go to the same place, it&#8217;s just that they&#8217;re offset by weird values.<\/span><\/div>\n<div><span style=\"text-decoration: line-through;\">\u00a0<\/span><\/div>\n<div>For GRBL to know what the maximum negative space is, it needs to know the size of your workspace. These are defined in the following GRBL variables:<\/div>\n<div>\u00a0<\/div>\n<div>\n<table style=\"border-collapse: collapse; table-layout: fixed;\" border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td style=\"padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;\" colspan=\"1\" rowspan=\"1\" valign=\"top\"><span style=\"font-family: 'courier new', courier, monospace;\">$130=200.000 (x max travel, mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$131=200.000 (y max travel, mm)<\/span><br clear=\"none\" \/><span style=\"font-family: 'courier new', courier, monospace;\">$132=200.000 (z max travel, mm)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\u00a0<\/div>\n<div>So for my 3018 CNC router, I set these to:<\/div>\n<div>\u00a0<\/div>\n<div>\n<table style=\"border-collapse: collapse; table-layout: fixed;\" border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td style=\"padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;\" colspan=\"1\" rowspan=\"1\" valign=\"top\">\n<div><span style=\"font-family: 'courier new', courier, monospace;\">$130=300.000<\/span><\/div>\n<div><span style=\"font-family: 'courier new', courier, monospace;\">$131=180.000<\/span><\/div>\n<div><span style=\"font-family: 'courier new', courier, monospace;\">$132=50.00<\/span><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\u00a0<\/div>\n<div>With these set, when I home CNC machine at the start of each usage, both the machine and work the coordinate systems becomes consistent and repeatable. In fact, once you enable homing, the first operation you always must do when first powering on the cnc machine is to home the system, as the GRBL will not accept any other operations until this is done.<\/div>\n<div>\u00a0<\/div>\n<div>Here it is in action:<\/div>\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"video-container\"><iframe loading=\"lazy\" title=\"Homing sequence - 3018 CNC with Limit Switches\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/Kcz6-D0iAO4?feature=oembed&#038;wmode=opaque\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p>Notes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The GRBL in the woodpecker board is version 0.9j.&nbsp;<\/li><li>A list of all the settings and also the commands in GRBL 0.9, and detailed explanations of what they do, can be found here : <a href=\"https:\/\/github.com\/grbl\/grbl\/wiki\/Configuring-Grbl-v0.9\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/grbl\/grbl\/wiki\/Configuring-Grbl-v0.9<\/a>.<\/li><li>In the Axes panel, under machine position, there are buttons to zero-out and return to home for each axis. These don&#8217;t work on the woodpecker,&nbsp; as it uses commands from GRBL 1.1.\u00c2&nbsp;<\/li><li>Once home&#8217;d, you may find a gap between where the bit is and the corner of your work surface. If this is the X-axis, you can loosen the mounts below the work surface and slide the work surface to the left or right. If it is the Y-axis, you may need to adjust the mounting holes for the limit switch by editing the 3D-model of the mounting bracket, to make it trip closer or further away.<\/li><\/ul>\n\n\n\n<p><em>Originally created with EverNote at 20180807T200311Z<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In its original design, the 3018 &#8220;Woodpecker&#8221; CNC Router, a cheap entry-level unit found on eBay and AliExpress, will happily tell the stepper motors to keep moving along the axis, even if the work&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":8951,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[212],"tags":[],"class_list":["post-8230","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cnc"],"_links":{"self":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/8230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8230"}],"version-history":[{"count":2,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/8230\/revisions"}],"predecessor-version":[{"id":8963,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/8230\/revisions\/8963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/media\/8951"}],"wp:attachment":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}