Monday, October 12, 2020

CNC 3018 Makerbot Limit Switch Wiring

This is a continuation of my prior blog on limit switch mounting hardware design for the CNC3018.

There are plenty of resources on various limit switch wiring. As with most information on the internet: some is good, some not so good. One place to start for the desktop CNC is the gnea/grbl wiki: Wiring Limit Switches.

One of the first things to note is the Woodpecker board is designed such the the default switches are expected to be NO (Normally Open, High); The limit is triggered by pulling the signal low (short to ground).  This is unfortunate, as switches will typically fail in the open position. Worse: Perhaps they even become disconnected and stay apparently open during a limit-exceeded condition.

I ordered these switches from ebay. There are similar ones on Amazon. Here's a switch installed in the Y-Axis mount that I designed in Fusion360:


Although there's a wiki link on the board schematic, it has long since disappeared from the internet. Fortunately I was able to recover some key files from the wayback machine, and copied them here for reference (next 5 images credit: Makerbot):


Interface description:



The PCB layout:


Bill of materials:

PCB Render; "The Mechanical Endstop v1.2 is Open Source Hardware and is licensed under the GNU GPLv3":


I needed to measure and create my own mechanical drawing with dimensions:
The PCB supports are 5mm in diameter extrusions, 2.1mm high; The 2 holes are 3.1mm diameter (snug fit). The little nubs on the posts at the end near the connector are an addition 1mm high, 2.9mm diameter. 

I also ordered this Eccentric Work shop CNC optical limit switch isolator. Keep in mind that optical isolation does only that: isolate. This is not a switch debouncer. But then, we'll never need to debounce: the first limit trigger will freeze the controller board. All future signals, limit, G-Code, serial or otherwise will be ignored until the board is reset. 

See the EccentricWorkShop schematic:

At one point, I thought I might need two of these isolator boards, as there is a connection for only 1 wire for each axis. However when looking at the schematic, it appears the limit switch detection is also tied together on the PCB:

And sure enough:




So it appears that when limits are detected, there's no way for the software to determine which limit switch was triggered for a given axis. Although the software would of course know which direction it last send a g-code, so perhaps it could be inferred. Still, if there was a malfunction, it might be nice to know which switch actually triggered.


2* Limit-X-Axis
2* Limit-Y-Axis
2* Limit-Z-Axis
A5 = Probe
A4 =
A3 = Coolant Enable
A2 = Cycle Start/Resume
A1 = Feed Hold
A0 = Reset/About
A7 =
A6 =
D13 = Spindle Direction
RST
5V

And from electrokean:

X = D9 = PB1 = pin 13 via R20
Y = D10 = PB2 = pin 14 via R21
Z = D12 = PB4 = pin 16 via R22

My first test drive was rather disappointing. After all that design work for the limit switch mounts, when using the stand-alone controller, nothing happened when running the sample G-Code and the limit switches were manually pressed. I would have hoped the woodpecker board would be interrupt-driven to detect the switch closures regardless of how the g-code arrived. There's a GitHub discussion where rseijo claimed "Zen, Yen & Xen had no connection points to the Atmega328" (confirmed to not be the case for me) and posted this useful header diagram:



As it turns out, the switches are not enabled by default! Thanks Anyzy for this useful tidbit:


Reading the fine print in the text block, we see that hard limits are enabled with $21=1 (of course they are). My $21 was found to be set to zero. Manually setting this to a value of 1 and tada! Upon pressing the limit switch while even manually moving the axis with the external controller, and the motion immediately stopped! See also the grbl documentation wiki.

Of course, there's probably a reason for having the feature disabled by default. Once triggered, all bets are off and the machine can only continue by pressing reset. Any work in progress is lost. Thus if any sort of stray noise or interference triggers the signal, well - that would certainly fall into the "undesired features" category; for example:
The machine stop working randomly with the spindle still running
And sure enough, if you see the settings posted, the $21 is already set on! So stray noise triggering these limit switches is definitely undesired.

I sure wish I had first found the Hackaday article that referred to an informative blog by Shahada Abubakar. One of the things I learned there: the reset switch is only one option to restart after a limit switch has been triggered. The other option:
 "This can be done by sending Control-X followed by $X"
There are additional tips on GRBL setting there, too.


Resources, Inspiration, Credits, and Other Links:

 


















1 comment:

  1. One further annoyance I found is that when you hit a stop, you must manually move the offending axis by turning the leadscrew. I thought that was very inconvenient. So I modified my machine by adding a small 0.01uF capacitor in series with the switch sense lead. The capacitor also needs a small 10K resistor across it. Put this i n the sense lead,not the ground lead) for each axis and then when you reset the controller, you can jog away from the stop with a jog command instead of manually turning the screws.

    ReplyDelete

comments are welcome, but I prefer not to allow links to promotions or other unrelated services.

Find gojimmypi at gojimmypi.github.io

I'm currently working on my new blog home at  gojimmypi.github.io After implementing a variety of features such as dark mode , syntax hi...