opto-coupler: transistor vs logic

I'm using an Arduino Uno on my CNC router with some limit switches. I want to optically isolate the limit switches so noise on the line doesn't cause problems (the wires are already shielded). I noticed there a couple styles of opto-couplers: transistor and logic. It seems like the logic would be a good choice since I'm only interested in on or off, but I don't know much about either type. The opto-couplers I've been looking at are: Logic: Digikey HCPL2631QT-ND (I picked this because it was used in a reprap isolation board schematic I found) Transistor: Digikey 160-1362-5-ND

Which is the best choice for my application?

2nd one needs some extra wiring that the 1st one includes in the package. Both need pullup resistor on the open collector output for the next stage to see valid hig out. 1st expectst to have 0-5V output. 2nd supports higher voltage.

The logic optocouplers are high speed, have hysteresis and generate fast edges on the output, standard ones (transistor) can take ~5us or so to switch. For limit switches this shouldn't make any difference

You do know that you will need a totally different and separate power supply for the switch side of the circuit. Personally I don't see why you think you will have problems with noise on the line. Just use a strong pull up resistor.

+1 on Grumphy Mike With correct shielding and filtrering there could not be any problem with noise.

Or the optocoupler acts as an expensive filter.

Pelle

Grumpy_Mike: You do know that you will need a totally different and separate power supply for the switch side of the circuit. Personally I don't see why you think you will have problems with noise on the line. Just use a strong pull up resistor.

I don't have a 2nd power supply, I'm planning on just using the Arduino power. My CNC router is a ShapeOko 2. Noise problems on the limit switch cables are a pretty common problem, even with shielded cable. The limit switches are an owner DIY upgrade, they are not part of the factory kit. I was initially thinking of using R/C low-pass filter, but then I thought the opto-coupler would be better.

CrossRoads: Both need pullup resistor on the open collector output for the next stage to see valid high out.

The data sheet says the HCPL2631QT has an internal pull-up resistor

I don't have a 2nd power supply, I'm planning on just using the Arduino power.

that defetes the whole pointed having an opto isolator making it a total waste of components, there will be no differance

Grumpy_Mike:

I don't have a 2nd power supply, I'm planning on just using the Arduino power.

that defetes the whole pointed having an opto isolator making it a total waste of components, there will be no differance

Hmmm. Then I'd probably be better off with a simple low pass filter. What do you think?

ScottG: Hmmm. Then I'd probably be better off with a simple low pass filter. What do you think?

Normally a stronger pullup would do the job, if you're saying it doesn't then it's impossible to say what to do without knowing: a) The source + type of the noise b) Why it would affect a switch on the end of a shielded cable. c) What type of switch it is

fungus:

ScottG:
Hmmm. Then I’d probably be better off with a simple low pass filter. What do you think?

Normally a stronger pullup would do the job, if you’re saying it doesn’t then it’s impossible to say what to do without knowing:
a) The source + type of the noise
b) Why it would affect a switch on the end of a shielded cable.
c) What type of switch it is

I’m already using a 330 ohm pull-up resistor.
The noise is coming from the pulses going to the stepper motors. The wires to the stepper motor are shielded, but the shield is floating. The wires to the limit switches are also shielded and the shield is connected to the ground on the Uno.
The limit switch is a McMaster Miniature snap action (see attached) (# 7779K22).

The problem is the Arduino thinks the limit switch was triggered when it wasn’t. Originally I had the stepper motor cable shields connected to the shields of the limit switches and all that was going to Arduino ground. In this config the problem was bad. The Arduino would immediately think the limit switch was tripped. Then I disconnected the motor cable limit switch so it was floating and it was a lot better. You can see some screenshots from my oscilloscope here:
http://www.shapeoko.com/forum/viewtopic.php?f=3&t=3423#p25805

Limit Switch.png

That's way beyond "noise" (4V of radio noise in a wire?)

Looks more like power supply and/or grounding problems to me.

fungus: That's way beyond "noise" (4V of radio noise in a wire?)

Looks more like power supply and/or grounding problems to me.

Do you have any suggestions for how to diagnose this further?

I find it hard to believe that those are real signals, they look like artifacts especially with such a small pull up resistor.

Anyway I would suggest you use the normally closed contact on the micro switch, then you should not get this interference under normal operation.

Grumpy_Mike: I find it hard to believe that those are real signals, they look like artifacts especially with such a small pull up resistor.

What do you mean by artifacts? I tried Googling "electrical noise artifact", but I got only medical stuff.

I'll see if using normally closed switch helps.

FYI, a floating shield is useless.

A few things I can think of. 1) You get 4V of noise, how are your scope probes setup? Are they set to 1x or 10x? (It looks like you have the same scope as one I use at work, and I know they can be either). If they are set to 10x, try setting them to 1x and see if the problem is still 4V. (Looking at the problem can make it worse since the probe is high impedance) 2) Try the low-pass filter. Since you aren't going for anything high speed, Use a big cap and small resistor. Make sure to put it next to the arduino. 3) Try adding some clip-on ferrite beads near your arduino on the cables. Just clip them around the whole cable. 4) How are your grounds configured? Do you have a loop in it, or is it in a proper star configuration? Can you put the electronics in a box, separate from your motors?

What do you mean by artifacts?

An artifact is something that shows in the data but is not real, it is a byproduct of the measuring or storage system. For example you might see ringing on a line, this ringing can be real, that is it is actually in the circuit or it can be caused by the scope lead being applied to the signal pin. If when you use a better scope lead there is no ringing then you conclude that the first observation was an artifact, it was not real. There are many other ways to get artifacts in your measurement like trouble with grounds. As I said I don't believe those measurements are real.

Grumpy_Mike:

What do you mean by artifacts?

An artifact is something that shows in the data but is not real, it is a byproduct of the measuring or storage system. For example you might see ringing on a line, this ringing can be real, that is it is actually in the circuit or it can be caused by the scope lead being applied to the signal pin. If when you use a better scope lead there is no ringing then you conclude that the first observation was an artifact, it was not real. There are many other ways to get artifacts in your measurement like trouble with grounds. As I said I don't believe those measurements are real.

I'm taking an oscilloscope class next week, this will be a good topic to ask about.

mirith: FYI, a floating shield is useless.

Things definitely got better with floating shields on the stepper motor cables (limit switch sheilds were still grounded). I noticed the difference on my scope. And more importantly, with the behavior of the CNC router. When I had the motor cable shields grounded, the CNC went into limit switch alarm mode right away. With floating shields, this didn't happen anymore. I'm not saying the way I have it now is the right way; it just works better then having all the shields tied together to ground. I do have all the motor shields connected to each other.

1) You get 4V of noise, how are your scope probes setup? Are they set to 1x or 10x? (It looks like you have the same scope as one I use at work, and I know they can be either). If they are set to 10x, try setting them to 1x and see if the problem is still 4V. (Looking at the problem can make it worse since the probe is high impedance)

They are set to 1X. I have Rogol DS1102E

2) Try the low-pass filter. Since you aren't going for anything high speed, Use a big cap and small resistor. Make sure to put it next to the Arduino.

I was going to use a 0.1uF cap with 1.5k resistor. Do you think I should use a different combination?

3) Try adding some clip-on ferrite beads near your Arduino on the cables. Just clip them around the whole cable.

Limit switch cables or stepper motor cables?

4) How are your grounds configured? Do you have a loop in it, or is it in a proper star configuration? Can you put the electronics in a box, separate from your motors?

There's a power supply that provides 24 volts to the motor controller (AKA gshield). The gshield plugs into the Arduino Uno, but the gshield does not power the Uno. Ground on the gshield and Uno are, of course, connected via the stacking headers, but the Uno is powered via USB from my laptop. I tested the CNC's 24 VDC power supply with my ohm meter to see if the ground terminal was connected to mains ground - it was not, which is what I would expect. But I figured I might as well check. I have a ground wire coming off the Uno that goes to a little proto board with some small screw terminal blocks attached. This is where the limit switches are wired into. So all the grounds are pretty close together on the proto board. Here's a picture of the setup. The three limit switch cables enter on the right, go into the terminal blocks, then down to the gshield, which is just bringing up pins D9,10,11 from the Uno underneath. I have the shield drain wire going into the same terminal block opening as the ground wire.

When I took my measurements with the scope I put the probe right on the limit switch wire as it entered the terminal block. The ground clip was connected to a wire I had coming out of another terminal block on the proto board.

330 ohm pull-up resistors are soldered to the bottom of the UNO. I've got a 0.1uF cap on one of the 3 limit switch cables, it's inserted into the screw terminal block along with the wires (cap was installed after I took the above picture).

Moving the electronics would take a lot of rewiring; something I'm not ready to do yet.

Thanks for your help. I'll give the low-pass filter a try tomorrow.

Is this the right way to add the RC Low-pass filter (R2 & C1)? See attached schematic.