Limit Switches for the ShapeOko

I don’t know why it took me so long, but I finally got around to installing the limit switches on my ShapeOko.

I bought the switches when I bought the machine, but never wired them up. I suppose my hesitance was related to all the people on the forum posting about issues with limit switches. But once I figured out how they worked, it was pretty easy. The mechanics of triggering them was more difficult to figure out than the wiring.

I bought some Sharp GP1A75E optical switches from DigiKey (part number 425-1954-5-ND). They were all of $1.44 each. I had to actually call DigiKey to find the correct connectors for these switches – part number 2-179694-3-ND. They set me back a whole $0.33 each.

These are 5V logic level switches. You attach 5V and GND and the third wire is High (5V) until you block the sensor, then it goes Low (0V.) I hooked one up to my multimeter to verify that this is what happens, and sure enough, it is.

The next step was to hook up some wires to the GRBLShield and attach a switch and see what happens. This caused my first issue. I was not sure which pins on the GRBLShield to use so I poked around on the forum for a while and found some drawings that seemed to indicate that you should use pins 8, 9 and 10. Unfortunately, this is wrong. When you attach a limit switch to pin 8, it gets pulled low no matter what you do. I spent longer than I like to admit trying to add a pull-up resistor to the switch with no luck. Finally I stuck my multimeter on the pins and realized that pin 8 was low all the time, while 9, 10 and 11 were high. So I went back to Teh Google and found the real pinout for the GRBLShield and sure enough, the limit switches go on pins 9, 10 and 11. Once I figured that out, it worked as expected!

The next hurdle was mounting the switches and figuring out how to trip them. The switches are designed to mount using a screw and have tabs that are supposed to fit in a slot. I didn’t feel like tearing down the whole machine to drill mounting holes, so I cut off the tabs and put some double-stick foam tape on the back. There is no real load or force on the switches, so they should stay attached (I hope.)

Next came the flags to trip them. I cut some 3/8″ wide pieces of aluminum angle and applied foam tape to the back – again, no load. This is what the Y Axis ended up looking like.

y_switch_1That worked out pretty well, so I repeated it on the other end. Unfortunately, those won’t work on the X or Z axis, so back to the drawing board.

The Z axis actually turned out kind of slick – I ended up only using one switch. I mounted the switch in the middle of the plate and made two flags that can be positioned on the Z rail. The flags are bent out of plumbers strapping.

z_lower_limit z_upper_limit

For the X Axis I bent some more flags out of plumbers strapping, but I had to put a 90 degree twist in them.

x_switch_1 x_switch_2 The second flag is mounted to the rail since the spindle hangs on that side so the machine has to stop well before the end of the rails.

After I got the mechanics all sorted out, it was time to do the wiring.

I used a cat 5 network cable that had stranded wires in it. The connectors are the IDC (insulation displacement contacts) type, so I just used a small screwdriver to push the wires into the contacts.

sw_connectorsThe cat 5 cable has 4 twisted pairs in it. I used one pair to run 5V and then used one wire from each remaining pair to run a signal line for each axis. At the Arduino end I connected all the unused wires to the ground – I think this will help with shielding the signal, but I could be wrong.

On the X and Y axis the signal lines for both switches are tied together in parallel. When one switch gets tripped it will pull the other low. (I tested this.)

I also added a .1µf capacitor across the power lines near the X and Y axis switches. I didn’t put one on the Z since it’s just a few inches down the line from the Y and the Y capacitor should be close enough.

x_wiringThis is the wiring on the X axis motor plate.

Once the wiring was all done, I fired off a homing cycle. It worked great!

I like to have zero in the lower left of the machine so all movement is in the positive direction, so I flipped the X axis bit by setting $18=128. I seem to have forgotten that the Y axis needs inversion also, so I’ll have to change that the next time I use the machine (tonight most likely.)

One thing left to do is see if there is motor interference with the switch wires. I did fire up the spindle and move the X and there were no issues, but I need to fire up the spindle and the vacuum and then run a program to make sure.

Over all, adding limit switches wasn’t nearly as much hassle as I expected and it should make using the machine much simpler since I’ll have a repeatable automatic zero. The switches have a repeatability rating of .3mm (.012″) which is pretty good. Probably good enough for most of what I do, though I might run some tests later to see what actually happens.

One possible issue will be if I get false limit switch trips due to swarf getting into the switches. The switches are all mounted on the back sides so hopefully this won’t be a huge issue. We’ll see.


Running total costs.

All Shapeoko CNC Mill Posts.