Good day to you all,
please could someone provide me with a wiring diagram to install X, Y and Z NC limit switches on a UNO board. I have found the NO version but would prefer the NC system.
John_A72:
Good day to you all,
please could someone provide me with a wiring diagram to install X, Y and Z NC limit switches on a UNO board. I have found the NO version but would prefer the NC system.
Good day to you, also, and welcome to the Arduino forum.
There is no difference in wiring, except to change to switches to the NC connection. Connect to the same Arduino pins.
But, invert the logic of your Arduino program where the pins are read for the status of the limit switches.
Paul
Due to the interference around a CNC machine from all the stepper motor wiring and spindle, I'd suggest using
physical pull-up resistors of 2k2 or even 1k for reliable operation, not just the built-in pullups which are weak.
Connect each switch between a pin and ground, pullup from pin to Vcc.
In the code you can use defines to determine the NO / NC sense:
// For NO switches:
#define LIMIT_ACTIVE LOW
#define LIMIT_INACTIVE HIGH
// For NC switches:
#define LIMIT_ACTIVE HIGH
#define LIMIT_INACTIVE LOW
...
if (digitalRead (x_limit) == LIMIT_ACTIVE) // the business logic doesn't need to know details of switch polarity
{
x_motor.stop() ;
...
}
...
John_A72:
please could someone provide me with a wiring diagram to install X, Y and Z NC limit switches on a UNO board. I have found the NO version but would prefer the NC system.
Yes, a NC contact should be 'safer' for an end switch (a bad 'signal' switch fails open circuit).
I use 3-pin microswitches (NO and NC) with roller-lever for that (ebay).
Roller for less friction and a more precise end position.
Connect the NC (normally closed) to a digital pin, and the CO (common) to ground.
Then use internal pull up on the pin with pinMode.
pinMode(switchPin, INPUT_PULLUP);
With this configutation, pull up resistor value become irrelevant (no resistors used).
The pin is/becomes HIGH when the end switch is activated.
Leo..
Industrial microswitches should be reliable if a known-brand product, eBay cheapies might be OK, might be junk.
[ I recently bought some push switches from eBay that actually melted when soldering the wires to the solder tags... Caveat emptor! ]
I repeat my recommendation to use an external pullup resistor of something like 2k2 or 1k for protection
from interference, the built-in pullups are too weak for reliable use with remote switches at the other end of a cable running through some machinery. A small capacitor to ground on the input pin can also help snub out
interference (10 to 100nF range should be good).
A NC contact is ZERO ohm pull down. Can't be any lower/better than that.
And in my experience all switches eventually fail when switching low current.
Better failing to a safe state than to a potentially dangerous state.
Leo..
MarkT:
Due to the interference around a CNC machine from all the stepper motor wiring and spindle, I'd suggest using
physical pull-up resistors of 2k2 or even 1k for reliable operation, not just the built-in pullups which are weak.Connect each switch between a pin and ground, pullup from pin to Vcc.
In the code you can use defines to determine the NO / NC sense:
// For NO switches:
#define LIMIT_ACTIVE LOW
#define LIMIT_INACTIVE HIGH
// For NC switches:
#define LIMIT_ACTIVE HIGH
#define LIMIT_INACTIVE LOW
Good day to you,
please could you tell me which $ line numbers are for the limit settings as given above.
John Attwell
...
if (digitalRead (x_limit) == LIMIT_ACTIVE) // the business logic doesn't need to know details of switch polarity
{
x_motor.stop() ;
...
}
...
Good day to you,
please could you tell me which $ line numbers are for the limit settings as given above.
John Attwell
MarkT has it correct; Simple rule of thumb (from way back when) if the switch is not designed with dry contacts you need a minimum of 1mA of current to keep the contact clean, anything under 5K works. This is called the wetting current, this changes from switch to switch, and is a parameter you should check, if not published the manufacturer can give it to you. Whether you use NO or NC is application dependent and is one of the many design decisions that will have to be made. Most of my designs were at 24VDC, giving me a lot more noise margin.
Good Luck & Have Fun!
Gil