Wow, there's a lot of discussion here. I'll try to answer some of the questions about my setup.
Its all about shielding. What kind of limit switches are you using?
1. use ether opto interrupter or hall effect interrupter, Both have drawbacks, both do not have mechanical bounce.
The limit switches are also the homing switches. My Shapeoko doesn't support having separate switches. I'm using good mechanical switches from McMaster (P/N 7779K22). I'm not worried about mechanical bounce. The firmware has some debouncing in it. Plus, I don't see how bounce would cause a problem. The mechanical switches seem to be working very well.
2. Use shielded twisted pairs, we used Belden 8451, basically shield is ground, red is voltage to drive the sensor and black is the sensor output.
6. Shield all the cable leading form the drives to the motor. You can by raw shielding tube and run the wires inside. It looks like giant solder wick. All motor wires need to be shielded from the drives to the motor housing.
Wires to stepper motors are shielded 18 gauge. Wires to limit switches are shielded but not twisted.
4. have your MCU in a shielded box.
Motor drives of any complexity are almost all chopper/ current mode drivers.
5. drives and drive power should be mount in a metal box. This is your chassy ground
Stepper driver and Uno are not in a shielded box. This would require a lot of rewiring.
3. be sure you have galvanic isolated you motor drives form the micro controller.
I think it's isolated How would I check, just use a multimeter and check the resistance between the motor and ground on the microcontroller?
10. now if you have done all that to minimize the amount your radiating and still having problems, as a last resort snap on ferrite over the sensor cables to snub and rf coming into you mcu box.
I've already got ferrite beads on limit switch wires and router power cable.
9. don't skimp on the wire gauge between motor and drive. You want your drives moving motor not heating wire. If your using nema 23 motor and running more that a foot of cable there is no shame in using 18 AWG, (not related to noise, just a pet peeve)
I'm using NEMA 17 motors with 18 gauge wire
Is the noise coming from ground loops on the low side? Is that why you think you need opto-isolation? (I would think not)
Or is the noise coming from such a very high input impedance as the internal pull-ups in the Arduino? (That would be my STRONG suspicion.)
I don't know. Is there a way to figure it out?
However if you're still getting noise issues, and you still want to opto-isolate things, then I would use a higher voltage for the switch side. Industrial machines use 24V, however 12V is usually more than enough to solve noise problems and if you're making your own board, then it'll be a pretty easy alteration.
That's a good idea. I am making my own board. I'm actually making it on the desktop CNC in question.
Is the simplest and really the best. a 0.01uF capacitor should be plenty. Try this first before more complex solutions.
I could probably get away with something simpler like this. But I kind of like going overkill and I feel I learn more.
A big part of this is trying to get a better understanding of noise issues on my CNC. I'd like to know more than one way to deal with it and understand where it comes from and the different techniques that can be used. All these posts have been very helpful.
Also, I while ago I did put a scope on the limit switch wires and there was a lot of ringing. It actually got worse when I grounded the shield on the stepper motor wires. So I've left the stepper motor shield floating. The limit switch shields are all tied together near the microcontroller and grounded.