Limit Switch Wiring?

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

Re: Limit Switch Wiring?

Post by cvoinescu » Tue Sep 22, 2015 12:31 pm

That diagram is correct, it's just not the best.

Here's my schematic (on a sample of letterhead I was playing with). It shows you how to wire two changeover switches together, so they appear as a single switch to the rest of the circuit. You can wire more than two: just repeat the switch in the middle of that diagram as many times as you need (I have four switches wired like that for the Y axis).
limit-switch-circuit.jpg
limit-switch-circuit.jpg (121.33 KiB) Viewed 3918 times
You have three options about filtering:
  • Do nothing: connect the switches directly to the input pin, with no other components. It's still an improvement over NO switches relying on the built-in pull-ups.
  • Use just the pull-up (R1) and low-pass filter (R2, C1), as shown in the top diagram.
  • Add a Schmitt trigger, as in the bottom diagram. The IC is a 74HC14, which has six inverters with Schmitt trigger inputs, so it's enough for three limit switch inputs and you have three spare inverters you can use for a probe and/or control buttons.
The wiring for the switches themselves is the same in all three cases, so you can start with the first option and see what happens.

I intentionally used weaker pull-ups and a shorter RC constant in my circuit (R1 = 1.2k, R2 = 1.2k, C1 = 10nF), because I was testing and trying to make it fail; I would recommend R1 = 680ohm, R2 = 2.2k, C1 = 47nF, but the values aren't critical.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

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

Re: Limit Switch Wiring?

Post by cvoinescu » Tue Sep 22, 2015 9:05 pm

Here's more or less how I have my limit switches wired. I'm leaving the three spare inverting buffers unused (they could be used for a probe, for instance). I've only shown the two X axis switches: Y and Z connect the same way.
Filter_bb.png
Filter_bb.png (120.03 KiB) Viewed 3903 times
Please note that the switches I found in Fritzing have their pins in this order: NO, common, NC. Most microswitches would be common, NO, NC. Almost all are labelled on the body of the switch. The red wire goes to NO on both switches, yellow is C on the left-hand switch, the black wire is NC on the right-hand switch, and orange connects NC of the left-hand switch to C of the other. This does not match my schematic exactly: I have flipped the +5V and GND connections to the switches, so that, after the 74HC14 inverts their signals, they appear normally open to GRBL.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

Auarhau
Posts: 243
Joined: Tue Feb 25, 2014 8:46 pm

Re: Limit Switch Wiring?

Post by Auarhau » Wed Sep 23, 2015 8:30 pm

I appreciate the help a lot Catalin. But I am sorry, I am having a hard time understanding. You said "that diagram is correct", which one did you refer to? There is quite a few in here.

I do not have capasitors or schmitt-triggers, but I have some resistors in a pack. And I might find the values you mentioned. If I need it I will have to order some caps from somewhere. I've looked long and hard on your drawn diagram, and the breadboard. I cant really tell what's going on in the bread board version even after looking through various youtube videos on how breadboards work. And I cant understand how it would look in a real life wiring with out a bread board.

The drawing I might understand, but I'm not entirely sure about that one either:) This one is also hard for me to imagine in real life wiring (some photographs would be gold), but I will try it in practice when I get the time and see how far i get.

I will need 5 switches I believe. One on the Y- side, Y + side, X- side and X+ side, and one for Z +. The Z negative switch does not make sense to me because of varying lengths of end mills.

So does this mean I need to build your diagram three times (minus a switch for Z)? I am using 4 pin Din connectors for my enclosure. Does this mean I need 9 wires IN to my enclosure? Or is there a way to wire it so that I can get away with just 1 connector like in one of the diagrams in this thread? My little enclosure is getting crowded, so less connectors is better.

Wiring R2 looks easy, I can just solder the resistor to the wire and then insert the other lead of the resistor in to the pin header on the shield? what about R1 and C1? I know this is probably a silly question, but I've never translated a diagram to real life wiring before :oops:

I wonder why switches is so mysterious and is lacking documentation from Invetables. Everything else is so straight forward, but this topic is a maze of different solutions and problems :| Hard to get your head around when you don't really know electronics. The type of instructions the GAUPS shield has was very easy to follow and idiot proof (which I need apparently :lol: )
ShapeOko 2. Nema 17 74 oz·in. GAUPS shield on Arduino Uno. DRV8825 Drivers x4 . Kress 1050 FME-1. Z Acme Screw. Threaded inserts table.

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

Re: Limit Switch Wiring?

Post by cvoinescu » Wed Sep 23, 2015 10:07 pm

Auarhau wrote:You said "that diagram is correct", which one did you refer to?
I'm referring to the "highly regarded diagram" from earlier in this very thread. It's correct, but it can be improved simply by adding a couple of wires and removing the resistors.

There are many ways of doing it. If you're not very sure how to begin, and the schematics don't "speak" to you, I'd say start with the simplest approach. It's just wires, no resistors or capacitors. It can be improved later without messing with the wiring on the machine (all the work will be in the electronics enclosure).

You are right, you need to repeat the two-switches-on-three-wires jiggery-pokery twice, for the X and Y axes, and a single switch (with three wires) for the Z axis. Here's what the wiring may look like for each of X and Y:
limit-switch-series-parallel.jpg
limit-switch-series-parallel.jpg (80.5 KiB) Viewed 3861 times
You need to connect a total of five signals: +5V, GND, and the three switch signals. However, to use just five connector pins, you'd have to splice the GND and +5V for the three axes somewhere outside the electronics box. If you have 4-pin DIN connectors, you could use one per axis and avoid splices, or you could wire two axes into one connector and the third into another connector. For the connector with two axes, simply run the cable from each axis into the connector, and solder the two +5V wires together to one pin, the two GND wires to another pin, and the switch wires each to its own pin. Like this (the connector pins, at the top, are shown in a line for clarity):
connector-splice.jpg
connector-splice.jpg (88.55 KiB) Viewed 3861 times
If you have a screw shield, the rest is easy: all +5V wires (orange in my drawings) go into the IOREF terminal of the Arduino, GND (blue) to one of the GND pins, and the limit switch signals (yellow) to D9, D10, and D12 (or D11). If you don't have a screw shield, splice wires with DuPont pins at the end of these wires, and plug those into the female headers. Or solder them to male pin headers, and plug those in. Or use a prototyping shield -- many possibilities.

Now if you want to add the pull-ups and filters, and maybe the Schmitt triggers, you can do it on a breadboard, or soldered on perforated board ("perf board"). You can also solder them "in air", but that can be a recipe for disaster: if you don't secure them, they may shift and touch a motor connection, which could fry everything.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

twforeman
Posts: 1351
Joined: Tue Jan 29, 2013 4:51 pm
Location: Minneapolis, MN
Contact:

Re: Limit Switch Wiring?

Post by twforeman » Thu Sep 24, 2015 4:10 pm

Nice drawings!
Ender 3 3D Printer
ShapeOko v3 serial #0004 - upgrade thread
All of my ShapeOko related blog posts

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

Re: Limit Switch Wiring?

Post by cvoinescu » Thu Sep 24, 2015 5:24 pm

Thank you.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

Auarhau
Posts: 243
Joined: Tue Feb 25, 2014 8:46 pm

Re: Limit Switch Wiring?

Post by Auarhau » Fri Sep 25, 2015 9:07 am

Yes very nice drawing. You'r an artist :) Thank you Catalin. I will give this a go in the weekend.
ShapeOko 2. Nema 17 74 oz·in. GAUPS shield on Arduino Uno. DRV8825 Drivers x4 . Kress 1050 FME-1. Z Acme Screw. Threaded inserts table.

rodcar125
Posts: 67
Joined: Fri Feb 06, 2015 5:00 pm

Re: Limit Switch Wiring?

Post by rodcar125 » Tue Oct 06, 2015 5:13 pm

Thanks everyone for the info! I did followed the cvoinescu diagram and i have the cables ready for final trimming, routing and connection but a question aroused... where do I connect the +5V and GND on the carbide motion board? In the arduino is easily identified by the printed labels but in the carbide? or do I need an external 5V power suppply and a jumper cable between carbide motion board GND and power supply GND?

Heres a picture of my limit switches ready (:
IMG_3688.JPG
Limit switches ready
IMG_3688.JPG (466.07 KiB) Viewed 3755 times

Beemer533
Posts: 25
Joined: Wed Feb 18, 2015 1:50 am
Location: Upstate NY

Re: Limit Switch Wiring?

Post by Beemer533 » Tue Oct 06, 2015 8:20 pm

rodcar125 wrote:Thanks everyone for the info! I did followed the cvoinescu diagram and i have the cables ready for final trimming, routing and connection but a question aroused... where do I connect the +5V and GND on the carbide motion board? In the arduino is easily identified by the printed labels but in the carbide? or do I need an external 5V power suppply and a jumper cable between carbide motion board GND and power supply GND?

Heres a picture of my limit switches ready (:

Nice wiring job!

Assuming you have an S03 with the CM board, you only need the C and NC terminals wired from each limit switch... No separate 5v connection.
Shapeoko 3 #0444

rodcar125
Posts: 67
Joined: Fri Feb 06, 2015 5:00 pm

Re: Limit Switch Wiring?

Post by rodcar125 » Tue Oct 06, 2015 8:54 pm

Beemer533 wrote:Nice wiring job!

Assuming you have an S03 with the CM board, you only need the C and NC terminals wired from each limit switch... No separate 5v connection.
Thanks, took me a while.
Yes, forgot to mention that, I have an S3 and CM board...

But as I mentioned, I followed cvoinecsu diagram (6 posts above) where it connects 5V, common and GND to the switches, wiring it that way makes the signal cable see 5V in a normal state and if either switch is tripped it sees GND but im confused as where to connect them... I'm thinking that all the 5V and GNDs could be connected to the 5V output connector at the top left of the image below and just connect the single signal wire from the switches to the left pin of the input pins for X, Y and Z but could please someone confirm?
Attachments
CM_board_pinout.jpg
CM_board_pinout.jpg (458.72 KiB) Viewed 3735 times

Post Reply