Adding limit switches.

Discussion about the arduino based g-code interpreter, grbl
twilliamson
Posts: 13
Joined: Thu Nov 15, 2012 3:48 pm

Adding limit switches.

Post by twilliamson » Thu Jan 03, 2013 3:19 am

I'm running the Latest Build of grbl 0.8c on a grblshield. I'm wanting to add some limit switches to the x and y axis. Is there any documentation on how this is done. ie wiring diagram.

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Adding limit switches.

Post by cvoinescu » Thu Jan 03, 2013 11:38 am

Connect normally-open switches between GND and pins 9, 10 and 11 (for X, Y and Z respectively). If you want switches at both ends of an axis, connect them in parallel to the same pin. It is not strictly necessary, but, to improve noise immunity, also connect three 1 Kohm resistors between VDD and pins 9, 10 and 11. Those supplement the weak internal pull-ups of the Arduino and help reject noise the limit switch wires may pick up from running along the stepper wires.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

levlandau2
Posts: 187
Joined: Tue Apr 17, 2012 1:52 am
Location: Minneapolis, MN, USA

Re: Adding limit switches.

Post by levlandau2 » Thu Jan 03, 2013 2:29 pm

Would the limit switches be the same thing as the homing switches? Or can these be combined somehow? Seems like they are the same thing....

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Adding limit switches.

Post by cvoinescu » Thu Jan 03, 2013 2:53 pm

The same physical switch does double-duty. During the homing cycle, one switch on each axis (you can pick which in the GRBL configuration) acts as a homing switch. After that, the machine backs off a little (also configurable) and now the switches act as limit switches.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

levlandau2
Posts: 187
Joined: Tue Apr 17, 2012 1:52 am
Location: Minneapolis, MN, USA

Re: Adding limit switches.

Post by levlandau2 » Thu Jan 03, 2013 7:38 pm

Awesome, that really makes me want to get the limit switches working even faster.

Does anyone have info on how much error can be expected from the homing switches? I am wondering, what the precision would be if let's say I used the homing switches to find the center of the X,Y axes multiple times? Do different types of homing switches allow for improved precision?

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Adding limit switches.

Post by cvoinescu » Thu Jan 03, 2013 8:33 pm

Of course different switches will perform differently. Optical switches can be very precise, if installed properly, but mechanical switches are not too shabby either. What you want is a very sharp cut-off, so no levers, rollers or anything that increases the travel, because those also amplify any variation in the switching point (and add errors of their own). Get a small microswitch and press its plunger directly; the total travel would be under a millimeter, and the make and break points would have repeatability better than 0.1 mm (likely much better, but it depends on the switch). With an optical interrupter, mount the LED and detector assembly on the frame and the tab on the carriage, or the other way round, in such a way that the motion of the tab is perpendicular to the long side of the interrupter's window (usually a thin rectangle) and its edge is straight, neat and parallel to the detector window. Choose a switch with a narrow detector window. The goal is to have a nice sharp transition between light and dark on the sensor, so that the make/break point depends as much as possible on the position of the tab within the detector, and as little as possible on the threshold voltage of the input pin, or on the supply voltage, or on other variables.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

PsyKo
Posts: 430
Joined: Thu Aug 30, 2012 8:42 pm
Location: France

Re: Adding limit switches.

Post by PsyKo » Thu Jan 03, 2013 11:32 pm

I'm currently working on home switch using Hall effect. As mentionned on other CNC forums, they can have a preicison around 0,01mm. I'm currently thinking about how to put them on the Shapeoko.
I've already designed and machined a magnet holder that goes into the Makerslide rail, but had no time to see if it actually fits the way I expect.

I'll let you know if I make any progress.
Shapeoko #736
Kress 800, Z Axis upgrade, dual Y, 600mm X&Y rails, metal spacers and V Wheels, home switches, 4th axis
Goko - Free CNC Control Software - http://www.shapeoko.com/forum/viewtopic ... 380#p44380

shachar85
Posts: 8
Joined: Wed Jan 09, 2013 9:32 pm

Re: Adding limit switches.

Post by shachar85 » Wed Jan 09, 2013 9:50 pm

cvoinescu wrote:Connect normally-open switches between GND and pins 9, 10 and 11 (for X, Y and Z respectively). If you want switches at both ends of an axis, connect them in parallel to the same pin. It is not strictly necessary, but, to improve noise immunity, also connect three 1 Kohm resistors between VDD and pins 9, 10 and 11. Those supplement the weak internal pull-ups of the Arduino and help reject noise the limit switch wires may pick up from running along the stepper wires.
Hi
I'm currently building my own CNC and was looking for how to connect the arduino to the stepper driver.
You wrote that the limit switches are connected to 9,10,11. I just read at Shapeoko wiki about GRBL, those lines:
#define X_LIMIT_BIT 1
#define Y_LIMIT_BIT 2
#define Z_LIMIT_BIT 3

Are those lines not updated?

potatotron
Posts: 135
Joined: Sun Apr 29, 2012 12:47 am
Location: Southern California
Contact:

Re: Adding limit switches.

Post by potatotron » Wed Jan 09, 2013 10:48 pm

shachar85 wrote:
cvoinescu wrote:Connect normally-open switches between GND and pins 9, 10 and 11 (for X, Y and Z respectively). If you want switches at both ends of an axis, connect them in parallel to the same pin. It is not strictly necessary, but, to improve noise immunity, also connect three 1 Kohm resistors between VDD and pins 9, 10 and 11. Those supplement the weak internal pull-ups of the Arduino and help reject noise the limit switch wires may pick up from running along the stepper wires.
Hi
I'm currently building my own CNC and was looking for how to connect the arduino to the stepper driver.
You wrote that the limit switches are connected to 9,10,11. I just read at Shapeoko wiki about GRBL, those lines:
#define X_LIMIT_BIT 1
#define Y_LIMIT_BIT 2
#define Z_LIMIT_BIT 3

Are those lines not updated?
No they're correct....you're looking at it the wrong way. The limit switches are bits 1, 2, & 3 on ATMega328 Port B, which maps to Arduino D8 - D13.

Here's the relevant section from GRBL config.h, it may explain it better:

Code: Select all

// NOTE: All limit bit pins must be on the same port
#define LIMIT_DDR       DDRB
#define LIMIT_PIN       PINB
#define LIMIT_PORT      PORTB
#define X_LIMIT_BIT     1  // Uno Digital Pin 9
#define Y_LIMIT_BIT     2  // Uno Digital Pin 10
#define Z_LIMIT_BIT     3  // Uno Digital Pin 11

PsyKo
Posts: 430
Joined: Thu Aug 30, 2012 8:42 pm
Location: France

Re: Adding limit switches.

Post by PsyKo » Thu Jan 10, 2013 8:21 am

cvoinescu wrote:The same physical switch does double-duty. During the homing cycle, one switch on each axis (you can pick which in the GRBL configuration) acts as a homing switch. After that, the machine backs off a little (also configurable) and now the switches act as limit switches.
Here is something that I can't figure.Let's say :
- I have my homing switch in the middle of my X/Y area (I know it's not the best, but let's say that's what I have).
- Besides I have limit switches at both side of my axis.
During homing cycle (and assuming, the cycle move toward the home switch everytime), the CNC will home at the center, perfect. But now that I have a home switch in the middle of my area, will this act as limit switch during actual milling ? As far as I understand yes.
So whenever the CNC is aligned with homing switch, the Grbl will goes to ALARM and stop. Right ?

Maybe I'm missing something important here...
Shapeoko #736
Kress 800, Z Axis upgrade, dual Y, 600mm X&Y rails, metal spacers and V Wheels, home switches, 4th axis
Goko - Free CNC Control Software - http://www.shapeoko.com/forum/viewtopic ... 380#p44380

Post Reply