How to wire an endstop (limit switch) to an LED

Thread Starter

Baldwij7

Joined May 19, 2014
9
Hello! I have a project in mind that I need some assistance with. I am looking at purchasing these UV LEDs.

I want to connect it to this endstop. It is a switch from a 3D printer.

I only need to wire up a single LED. The power source would ideally be as compact as possible.

Also, if anyone knows the name for the connector on the endstop, that would also be helpful. I am open to other options for switches/UV LEDS. For additional information, the idea is to have this mounted on a 3D printer, so that the switch will be activated to turn on the LED at certain points.
 

Attachments

crl12

Joined Nov 22, 2020
3
I guess this question is part of a whole set of questions around the popular field of inexpensive or home-built 3-D printers, CNC milling machines and so on. Users may be more expert in mechanical engineering than in what's in fact a difficult area of electronics. There are reports on the web of machines not working or going dangerously wild, and there's too much bad and contradictory advice. For reasons of cost there are too many design compromises. Perhaps we could develop a source of reliable information around the subject.

To keep the cost down, stepper-motor and PWM drivers may be on the microcontroller board (for example Smoothieware), or on an Arduino shield. There are also external driver boards, for example with an optically-isolated TB6600 driver. Communication between the software and microcontroller is via a USB-serial port, usually with the driver that comes with Arduino; not everyone can afford a USB isolator. The result, specially with on-board drivers, is a nightmare of ground loops, ungrounded mechanical parts, EMI, and bus drivers driving long lines. There's also lack of respect for noise margins, component specifications... and the age of the workshop computer!

End stops and other position detectors are a constant source of difficulty, and I can understand why Baldwj7 wants to opto-isolate; the connecting wires make great radio aerials. The standard way should be to power the switch with a battery or separate wall-wart, with one side grounded, and wire this to an opto-isolator mounted close to the digital input. Operate the LED at at least 10mA to keep the impedance low. Examples can be found on the Arduino ecosystem.

As a precaution against EMI I use old wall-warts that have a transformer, and renew the rectifier and electrolyic capacitor.

Many people still use conventional analog opto-isolators, and hope the rise-time is short enough for the digital input. A TB6600 stepper driver I bought from an unknown source was specified as analog, with a 330 ohm resistor in series (OK for 5 V). When I examined it, the isolators were ordinary analog types, but in fact they were in series with a 15mA current source which saturated at 2V input (OK for a 3.3V controler). You can also buy digital isolators with trigger circuitry incorporated. Perhaps someone more competent than me could recommend the best approach.
 

crl12

Joined Nov 22, 2020
3
I guess this question is part of a whole set of questions around the popular field of inexpensive or home-built 3-D printers, CNC milling machines and so on. Users may be more expert in mechanical engineering than in what's in fact a difficult area of electronics. There are reports on the web of machines not working or going dangerously wild, and there's too much bad and contradictory advice. For reasons of cost there are too many design compromises. Perhaps we could develop a source of reliable information around the subject.

To keep the cost down, stepper-motor and PWM drivers may be on the microcontroller board (for example Smoothieware), or on an Arduino shield. There are also external driver boards, for example with an optically-isolated TB6600 driver. Communication between the software and microcontroller is via a USB-serial port, usually with the driver that comes with Arduino; not everyone can afford a USB isolator. The result, specially with on-board drivers, is a nightmare of ground loops, ungrounded mechanical parts, EMI, and bus drivers driving long lines. There's also lack of respect for noise margins, component specifications... and the age of the workshop computer!

End stops and other position detectors are a constant source of difficulty, and I can understand why Baldwj7 wants to opto-isolate; the connecting wires make great radio aerials. The standard way should be to power the switch with a battery or separate wall-wart, with one side grounded, and wire this to an opto-isolator mounted close to the digital input. Operate the LED at at least 10mA to keep the impedance low. Examples can be found on the Arduino ecosystem.

As a precaution against EMI I use old wall-warts that have a transformer, and renew the rectifier and electrolyic capacitor.

Many people still use conventional analog opto-isolators, and hope the rise-time is short enough for the digital input. A TB6600 stepper driver I bought from an unknown source was specified as analog, with a 330 ohm resistor in series (OK for 5 V). When I examined it, the isolators were ordinary analog types, but in fact they were in series with a 15mA current source which saturated at 2V input (OK for a 3.3V controler). You can also buy digital isolators with trigger circuitry incorporated. Perhaps someone more competent than me could recommend the best approach.
I forgot to reply to the specific question about communicating a contact closure optically through space. This would probably not be safe with a machine tool.

Usually you would use IR, not UV. Because of ambient light, the source would need to be modulated, perhaps at a constant frequency; you would have to detect the frequency at the detector. That would require transmitter and receiver circuits, each with its power supply. A simpler way would be to use an IR remote controller as transmitter (small simple ones are very cheap) and the powerful and well-documented Arduino IRremote library, which can both transmit and receive standard codes. We use this for controlling toy robots and so on. The difficulty for the 3-D printer would be the need for a separate Arduino as receiver, because it isn't really practical to modify the existing microcontroller code, though one Arduino could handle all your switches
 

Thread Starter

Baldwij7

Joined May 19, 2014
9
I forgot to reply to the specific question about communicating a contact closure optically through space. This would probably not be safe with a machine tool.

Usually you would use IR, not UV. Because of ambient light, the source would need to be modulated, perhaps at a constant frequency; you would have to detect the frequency at the detector. That would require transmitter and receiver circuits, each with its power supply. A simpler way would be to use an IR remote controller as transmitter (small simple ones are very cheap) and the powerful and well-documented Arduino IRremote library, which can both transmit and receive standard codes. We use this for controlling toy robots and so on. The difficulty for the 3-D printer would be the need for a separate Arduino as receiver, because it isn't really practical to modify the existing microcontroller code, though one Arduino could handle all your switches
Sorry if I wasn’t clear. I am going to have the printer move into position to physically trigger the limit switch. I know how to do all of that.
I just need to know, given this switch and the linked LEDs, what minimal power source would work, and how would I wire those three things together.
 

Hemi

Joined Mar 17, 2012
22
Okay, so you're going to add this switch, power source, and LEDs to your printer as a seperate 'system' to what's currently on the printer, correct? Without specs/model number of the LEDs you wish to use, we can't recommend a suitable power supply and current limiting resistor values.

Use your multimeter to test continuity between the terminal labeled "s" (sense) and the other terminals labeled "g" (ground) and "v" (positive voltage). If there's continuity between "s" and "v" while the switch is pressed, then connect the anode of your LED to the "s" (make sure to use current limiting resistor!) and the cathode to "g". Connect your battery or wall-wart to the "g" and "v" terminals.
 

Thread Starter

Baldwij7

Joined May 19, 2014
9
Okay, so you're going to add this switch, power source, and LEDs to your printer as a seperate 'system' to what's currently on the printer, correct? Without specs/model number of the LEDs you wish to use, we can't recommend a suitable power supply and current limiting resistor values.

Use your multimeter to test continuity between the terminal labeled "s" (sense) and the other terminals labeled "g" (ground) and "v" (positive voltage). If there's continuity between "s" and "v" while the switch is pressed, then connect the anode of your LED to the "s" (make sure to use current limiting resistor!) and the cathode to "g". Connect your battery or wall-wart to the "g" and "v" terminals.
This is great info, thank you! I plan on trying to use a single one of these LEDs https://www.amazon.com/EDGELEC-LED-...=1&keywords=UV+LED&qid=1625667249&sr=8-5&th=1
 

crl12

Joined Nov 22, 2020
3
I should have looked up the LEDs you mentioned. They have the resistor incorporated, which gives the rated current with 12 volts. The connector (3-pin header) on the limit switch isn't likely to be of any particular make and any 10th inch connector like the hookup connectors from hobby suppliers would fit. They're usually referred to as Dupont connectors. You can cut off the plastic shroud of the header if necessary.

The current is only 20mA, so you could use 8 AAA or AA dry batteries (two 4-cell holders from Sparkfun or elsewhere). You could use a lower voltage if you buy the LED and limiting resistor separately, though you don't want to do that. The alternative for power supply is any type of 12V wall-wart. 9V should work but the LED would be less bright.

The markings on the limit switch don't mean anything to me - the device may be a surplus item intended for a particular appliance. But you only need to find the two of the 3 pins that connect when you press the switch (may be marked Normally Open and Common on the microswitch body). The other components (a LED and for noise supression) don't seem to be installed, you don't need them here and so polarity doesn't matter except for your UV LED. You connect supply positive to one pin (for example normally open), and the other pin to anode (purple). The cathode of the UV led (black) goes to power negative. You don't need to put an on/off switch in the circuit, unless you're using batteries and the limit switch might be activated when the printer isn't in use (need to think of eye safety...). Cell holders usually have a switch.
 

Hemi

Joined Mar 17, 2012
22
I should have looked up the LEDs you mentioned. They have the resistor incorporated, which gives the rated current with 12 volts.
I missed seeing the link to the LEDs in the OP as well. *blush*

12V power supplies are easy to find on Amazon, just make sure what you pick is rated for at least 50% more current than you'll need so it'll last a while. If you use all 30 of the LEDs, that's 600mA, so I'd buy at least a 1A power supply for that extra ~50% margin. But just using one LED, pretty much any 12V power supply will do. I don't like using batteries if I can help it. Four 3V lithium coin cells (like Cr2032) stacked would power it for a few hours though.

And get a pair of UV safety glasses so you don't trash your eyesight.
 

Thread Starter

Baldwij7

Joined May 19, 2014
9
I should have looked up the LEDs you mentioned. They have the resistor incorporated, which gives the rated current with 12 volts. The connector (3-pin header) on the limit switch isn't likely to be of any particular make and any 10th inch connector like the hookup connectors from hobby suppliers would fit. They're usually referred to as Dupont connectors. You can cut off the plastic shroud of the header if necessary.

The current is only 20mA, so you could use 8 AAA or AA dry batteries (two 4-cell holders from Sparkfun or elsewhere). You could use a lower voltage if you buy the LED and limiting resistor separately, though you don't want to do that. The alternative for power supply is any type of 12V wall-wart. 9V should work but the LED would be less bright.

The markings on the limit switch don't mean anything to me - the device may be a surplus item intended for a particular appliance. But you only need to find the two of the 3 pins that connect when you press the switch (may be marked Normally Open and Common on the microswitch body). The other components (a LED and for noise supression) don't seem to be installed, you don't need them here and so polarity doesn't matter except for your UV LED. You connect supply positive to one pin (for example normally open), and the other pin to anode (purple). The cathode of the UV led (black) goes to power negative. You don't need to put an on/off switch in the circuit, unless you're using batteries and the limit switch might be activated when the printer isn't in use (need to think of eye safety...). Cell holders usually have a switch.
Thank you! Got the circuit working, following what you said, and a single UV LED run off of a 9V supply is enough to trigger the light sensor so, exactly what I needed.
 
Top