Opto-isolators for CNC limit switch noise - Page 1
Forum section: electronics / projects

author: scott216
author_rank: Regular Contributor
timestamp: May 13, 2014, 04:39:16 pm
content: I've got aShapeOko CNC routerthat uses and Arduino UNO with agshield stepper controllerboard plugged into it. I noticed my limit switch inputs have quite a bit of noise on them (see myShapeoko forum postif you're interested in oscilloscope screenshots). I'm using shielded wire on the limit switches.My plan is to build an Arduino shield that would sandwhich between the Uno and gshield. It would have optocouplers to isolate the limit switches. I'm thinking of usingHCPL2631 logic level isolator. I chose the HCPL2631 because it's used by aRepRap Opto-Isolator board. This design seemed like a good starting point for me.I have a few questions:Is using a logic level optocoupler the right choice or should I use a transistor optocoupler like aLTV-826?Currently I have ground going out to the limit switch and when the switch closes, it pulls the input pin to ground. Since the HCPL2631 optocoupler inverts the signal, I was planning on having +5v go to the limit switch instead of ground. Any reason not to do this?Couldn't noise on the line cause the optocoupler to turn on? Should I also use an R-C low-pass filter in the circuit? If so, are there any special considerations I need to take into account if I'm using a low-pass filter together with an optocoupler?

author: Fank1
author_rank: Regular Contributor
timestamp: May 13, 2014, 09:57:27 pm
content: You have a classic ringing problem and need a snubber circuit on your stepper motor leads.Google NXP application note AN11160.It's for mosfet's but the information still applies..

author: scott216
author_rank: Regular Contributor
timestamp: May 13, 2014, 10:24:26 pm
content: Quote from: Fank1 on May 13, 2014, 09:57:27 pmI love the classics. Thanks! I'l check out the app note.

author: scott216
author_rank: Regular Contributor
timestamp: May 15, 2014, 05:11:12 pm
content: I ordered some 10 ohm resistors and 470nF caps from Digikey. We'll see what that does. I am still interested in an answer to my question about logic vs transistor optocoupler. Even if I get rid of the ringing with a snubber, I'd like to use the optocouplers.

author: dannyf
author_rank: Super Contributor
timestamp: May 15, 2014, 05:19:19 pm
content: QuoteDoesn't really matter here. Logic couplers are considerably faster than a typical optocoupler. But both are more than fast enough here.QuoteIf you could put that on a piece of paper, i tmay help people understand what you are trying to do.QuoteThe ringing seems to be periodic and could be due to poor coupling. I would put an inductor / diode + capacitor on the low-power digital stuff to isolate it from the motors.

author: scott216
author_rank: Regular Contributor
timestamp: May 15, 2014, 05:41:24 pm
content: Attached is a schematic of what I'm considering.

author: dannyf
author_rank: Super Contributor
timestamp: May 15, 2014, 05:45:06 pm
content: It will work - read the datasheet to see if you need a pull-up. If you are concerned about the polarity, you can change the code, or the wiring so the led is active low or active high, depending on what it was before: your driver circuit would be sinking / sourcing current, respectively.

author: scott216
author_rank: Regular Contributor
timestamp: May 15, 2014, 06:29:33 pm
content: Quote from: dannyf on May 15, 2014, 05:45:06 pmNormally you'd have ground going out to the limit switch with a pull-up resistor on the inputs. But since the opto-coupler inverts the signal, I have +5v going to the limit switch.Could noise in the line cause the opto-coupler to energize? Should I add a low-pass filter to the circuit?

author: dannyf
author_rank: Super Contributor
timestamp: May 15, 2014, 06:59:44 pm
content: QuoteCould, but not likely.QuoteI would put a probe on the led line before attempting a cure. The issue could be switch bounces or supply coupling, or interference....No point in implementing a cure before the problem is identified.

author: scott216
author_rank: Regular Contributor
timestamp: May 18, 2014, 03:06:26 am
content: Quote from: dannyf on May 15, 2014, 05:45:06 pmI've only got one power source (from the Arduino Uno), is that going to defeat the purpose of the opto-couplers?

author: retrolefty
author_rank: Super Contributor
timestamp: May 18, 2014, 04:05:20 am
content: QuoteAn opto's input (an LED) is a pretty low impedance device, it takes several milliamps to turn on the lead and 'noise voltage' typically does not have enough energy/power to trigger the opto's led to on from off or off to on. i don't think you will need to do any special filtering if your using optos for the switch inputs.As far as powering the switch contacts from the arduino 5V pin, that does eliminate/defeats the galvanic isolation that the opto provides, which is normally why they are selected for use.

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 18, 2014, 04:31:47 am
content: Quote from: scott216 on May 18, 2014, 03:06:26 amYes, that defeats the whole purpose. We use opto-couplers (and other similar devices) because the power is DIFFERENT on either side, or there is some other reason to ISOLATE the source from the destination. The initial premise that a noise problem can be fixed with opto-isolators is faulty.

author: scott216
author_rank: Regular Contributor
timestamp: May 18, 2014, 04:35:52 am
content: Quote from: Richard Crowley on May 18, 2014, 04:31:47 amI thought that might be the case. I'll see what a low-pass RC filter and some ferrite beads do.

author: LukeW
author_rank: Frequent Contributor
timestamp: May 18, 2014, 11:12:30 am
content: How do you know optocouplers are going to make your noise go away? What is the usual purpose of optocouplers? Where does your noise in these signals come from?Optocouplers are usually used to provide galvanic isolation, not to remove noise, which usually involves some sort of snubber or filter.An optocoupler is intended to transmit the signal supplied to it with as much fidelity as possible, subject to realistic speed/bandwidth limitations, not to act as a filter.These are useful things to think about. Is an optocoupler actually the right choice for what you want to achieve?

author: scott216
author_rank: Regular Contributor
timestamp: May 18, 2014, 02:31:51 pm
content: Quote from: LukeW on May 18, 2014, 11:12:30 amArticles like these lead me to believe opto-couplers help reduce noise:http://www.eetimes.com/document.asp?doc_id=1272337http://www.vishay.com/docs/83702/appnot83.pdfhttp://www.electronics-tutorials.ws/blog/optocoupler.htmlI'm not saying opto-couplers are the right choice for my current problem, that's why I ask questions in this forum and others, so I can learn from people who know more about this than me. I haven't dived into noise issue before; I'm trying to figure it out.I do have parts for a snubber on order, so I'll see what that does when they arrive. I tried an RC filter (see attached schematic), but that didn't seem to make a difference. Someone on the Arduino forum said this circuit would actually make it worse, but he didn't explain why. So I'm not sure what's wrong with the circuit. Maybe I need to be switching +5V at the limit switch instead of ground?