opto-coupler: transistor vs logic

NO

connect D9 between C1 and R2 R2 can have much higher resistans, 100 kohms. 0.1 uF and 100 kohms make an timeconstant (RC) of 10 ms

Pelle

Pelleplutt: connect D9 between C1 and R2 R2 can have much higher resistans, 100 kohms. 0.1 uF and 100 kohms make an timeconstant (RC) of 10 ms Pelle

Thanks. I'll give it a try.

I tried the RC low-pass filter on one of the limit switch wires, it didn’t seem to do much looking at my scope. Attached is the circuit I used. I used a 1.5k resistor. Tomorrow I’ll try 100k.

What ever made you think that would work? I would imagin that is worse than ever.

Grumpy_Mike: What ever made you think that would work? I would imagine that is worse than ever.

Not worse, but not better either. I wanted a low-pass filter to get rid of the noise on the limit switch line. Can you explain why this would make it worse?

Can you explain why this would make it worse?

Because when the switch has been triggered it is only being pulled down with 1K5 which is not as hard as a direct pull to ground therefore making it more prone to interference.

What happened when you tried the fail safe option of having the switch normally connect to ground?

The way I see it you have a grounding problem.

Grumpy_Mike:

Can you explain why this would make it worse?

Because when the switch has been triggered it is only being pulled down with 1K5 which is not as hard as a direct pull to ground therefore making it more prone to interference.

What happened when you tried the fail safe option of having the switch normally connect to ground?

The way I see it you have a grounding problem.

Good point. Do you have any suggestions for how I should filter out the noise?

ScottG,

Please see the attached drawing.
I’m showing the circuit using the normally-closed terminal.
In normal operation there will be a Low on the input (or there’s something very, very wrong).
If something runs into the “lever”, in an actuation event, the switch will open and the input pin will go High.

NC_pup.JPG

I'm showing the circuit using the normally-closed terminal.

@Runaway Pancake Been telling him that for ages but he keeps on ignoring it.

Grumpy_Mike:

I'm showing the circuit using the normally-closed terminal.

@Runaway Pancake Been telling him that for ages but he keeps on ignoring it.

I wasn't ignoring it, I appreciate all the feedback. I did do some testing with normally closed switch - actually I just closed the limit switch to see if that made any difference with the noise I saw on the scope. Unfortunately, I didn't see any difference. I thought I posted that on the forum, but apparently I didn't.

If you did see no change when you did this you have got something seriously wrong with your wiring or your scope grounding. Sort this out you are just wasting everyone's time until you do. Your wiring is not what you think it is . As you have not bothered to post your schematic then only you know what your wiring is.

Did you actually try this or just look at the scope? You should try it.

I tend toward your assessment, G_M.

[I was wondering about a 4.7k-10K for the pull-up and adding a 0.1uF from the input pin (at/near the Arduino) to Gnd.]

Here are some pictures of my setup. Inside the yellow electrical enclosure I have an Uno. Plugged into the Uno is a gshield motor controller. In the upper left is a proto board with some screw terminal blocks. Into the top set of screw terminal blocks plug two push-button switches which then go to A0 and A1 on the Uno. The 3 limit switch cables go into the screw terminal blocks on the right side of the proto board. For the limit switches, I have the ground wire and shield connected together in the same opening in the terminal block. On the X-axis limit switch you can see I have a 0.1uF cap, nothing on the other two. On the bottom of the Uno (which you can’t see) I have three 330 ohm pull-up resistors for the limit switch lines, which are inputs D9,10,11 and the 5V pin. The limit switches wires actually connect to the gshield, but it’s a direct connection down to the Uno via the stacking header. The ground on the proto board (and thus all the limit switches and push-buttons) comes from the ground pin next to D13.
The gsheild is powered by a 24 VDC power supply. The Uno does not get power from the ghsield, instead it’s powered by the USB cable from my laptop.
The three stepper motors are connected on the right side of the gshield. The shields are not connected to ground, but they are connected to each other. I initially had the stepper motor shields connected to ground, but this caused the Uno to think the limit switch was activated.

I’m working on a schematic I’ll upload shortly.

Edit: The limit switch wires have ferrite chokes right outside the yellow enclosure.

Here’s a picture of where my scope probes are connected and a few screenshots of what I’m seeing on the scope. The ground wire for the scope is coming out of one of the unused terminal block pins.

Noise1.bmp (146 KB)

Noise2.bmp (146 KB)

Noise3.bmp (146 KB)

Here’s a schematic of my wiring (not including wires going to the stepper motors).
The gshield schematics can be found here:

So you're saying that if you write a simple sketch that starts a stepper to spinning and monitors those input pins that then those inputs (D9,10,11) will report back Highs when there should be Lows and/or Lows when there should be Highs?

Here's a schematic of my wiring (not including wires going to the stepper motors).

That is not much of a schematic is it. Could you make it from that schematic? Dose it show the power supply? Does it show you where the wires are going, especially the ground? Is the screening on your cable still floating? You have been told about that.

I initially had the stepper motor shields connected to ground, but this caused the Uno to think the limit switch was activated.

So how does that work with the shield and Arduino floating with respect to each other?

Those scope readings are AC coupled. Any logic input will be able to cope with that much ripple on the inputs, it should not be an issue if you have your grounds right.

[quote author=Runaway Pancake link=topic=240435.msg1728975#msg1728975 date=1400461338] So you're saying that if you write a simple sketch that starts a stepper to spinning and monitors those input pins that then those inputs (D9,10,11) will report back Highs when there should be Lows and/or Lows when there should be Highs? [/quote] I'm not familiar enough with steppers and the gshield to write a sketch to that. Maybe it's easy, I'm not sure.

When I first installed the limit switches, I had the shields from the limit switch wires and the shields from the stepper motor wires all connected to the Arduino ground. When I turned everything on, it immediately went into alarm mode because it thought a limit switch had been tripped. If I reset the alarm, it would just go right back into alarm mode for a limit switch. The next thing I did was disconnect the motor shield from ground and just let it float. This helped a lot, the machine didn't go into alarm mode as before. I put my scope on the input as shown in a previous photo and I looked at the signal under both scenarios above. With the motor shield connected to ground I had big oscillations, ringing or something. It was a couple volts p-p. When I had the shield floating, it was much better. A number of people who have the same CNC router (a ShapeOko) report that they have problems with noise and the limit switches. What I'm trying to do now is just decrease the noise as much as possible to minimize the chance of false limit switch triggers.