Author Topic: Isolate noise from CNC limit switches  (Read 25345 times)

0 Members and 1 Guest are viewing this topic.

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Isolate noise from CNC limit switches
« on: May 07, 2015, 11:58:24 pm »
I'm making a PCB for my Shapeoko desktop CNC machine in order to isolate the Arduino Uno from noise on the limit switch wires and pushbutton wires.  The main reason for doing this is electrical noise from the stepper motors and from the router motor can cause the limit switch inputs to trigger.  I've got ferrite beads on the limit switch wires and the power cord going to the router.  The firmware that's running on the Arduino is GRBL.  For the limit switches GRBL can be configured for N.O. or N.C switches.  But for the push-buttons the input is configured with internal pull-up resistor on and assumes your switch is N.O. and tied between ground and the input. 
For my circuit I'm using a Murata NKE0503DC DC-DC converter (See data sheet) so I can get an isolated power (3.3v) for the limit switches and pushbuttons.  I'm using Vishay optocoupler SFH6732 (see data sheet) between the limit switches and Arduino Uno. 

I know on way to reduce noise would be to add caps between ground and the inputs, but I wasn't sure if that made sense in this setup. 

I'd appreciate any feedback.  Attached is my schematic.
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Isolate noise from CNC limit switches
« Reply #1 on: May 08, 2015, 12:09:40 am »
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.)

It seems to me that it would be an order of magnitude simpler to just put those 47 ohm resistors between +3V3 and the Arduino input pin and let the switches pull down the 47 ohms directly.  Or am I missing something here?
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 1738
  • Country: au
Re: Isolate noise from CNC limit switches
« Reply #2 on: May 08, 2015, 12:19:25 am »
Have a similar setup. To reduce noise you can do one or both of the following:
1. Twist the signal wire coming from the sensor with a ground wire terminated at the Arduino ground.
2. The best and simplest is to just put a capacitor between gnd and the pullup resistor near the Arduino. I have a small breadboard shield attached just for such things.

2. Is the simplest and really the best. a 0.01uF capacitor should be plenty. Try this first before more complex solutions. Best of luck. :)
 

Offline lincoln

  • Regular Contributor
  • *
  • Posts: 155
  • Country: us
Re: Isolate noise from CNC limit switches
« Reply #3 on: May 08, 2015, 12:56:00 am »
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. 

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.

3. be sure you have galvanic isolated you motor drives form the micro controller.

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

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.

7. run an extra ground wire from you chassy ground all the way to the motor mount and attache under one of the mounting bolt.

8. if you are using connecter in between the motors and drives, keep the wire shield and the motor shield as two separate contacts even though they both terminate in the drive box. the point is to make a low impedance path to ground.

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)

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.


best of luck,
 

Offline rob77

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: sk
Re: Isolate noise from CNC limit switches
« Reply #4 on: May 08, 2015, 07:53:17 am »
stronger pull-up (smaller pullup resistor value) + capacitor across the switch . if that will not help, then your problem is elsewhere ;)
 

Offline mc

  • Regular Contributor
  • *
  • Posts: 155
  • Country: scotland
Re: Isolate noise from CNC limit switches
« Reply #5 on: May 08, 2015, 06:17:45 pm »
Capacitors on a CNC machine switch are generally considered a bodge for an underlying issue. It's certainly not something you'd really want to implement for critical timing switches like homing switches/probes where delays could cause accuracy issues.

Provided all your wiring is good, with motor wiring shielded and properly grounded, most noise should be reasonably well controlled. 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.


Going marginally away from the OP, and one for those with more knowledge, but would it be better to have the limit switches pulled high directly from the power source (i.e. at 3.3/5V in this example) when inactive, than it would to be pulling them to ground when inactive?
My thinking is it'll take more noise on the wires to lower the 3.3V/5V below the guaranteed high voltage (2.5V for a AVR?), than it would for noise to nudge the voltage above the guaranteed low voltage (0.7V stick in my mind?).
I know the 5V would give you a 2.5V noise margin if my memory is correct, however something says I could be a bit off the mark with that assumption.
 

Offline rob77

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: sk
Re: Isolate noise from CNC limit switches
« Reply #6 on: May 08, 2015, 06:46:57 pm »
Capacitors on a CNC machine switch are generally considered a bodge for an underlying issue. It's certainly not something you'd really want to implement for critical timing switches like homing switches/probes where delays could cause accuracy issues.

it's the end-stop switch => hitting the end-stop switch means GAME OVER - a CNC machine is NOT supposed to hit the end-stop witch during normal operation.
the purpose of the end-stop is to detect faults and avoid jamming the precious linear drives by shutting down the drive.
 

Offline mc

  • Regular Contributor
  • *
  • Posts: 155
  • Country: scotland
Re: Isolate noise from CNC limit switches
« Reply #7 on: May 08, 2015, 06:51:54 pm »
Capacitors on a CNC machine switch are generally considered a bodge for an underlying issue. It's certainly not something you'd really want to implement for critical timing switches like homing switches/probes where delays could cause accuracy issues.

it's the end-stop switch => hitting the end-stop switch means GAME OVER - a CNC machine is NOT supposed to hit the end-stop witch during normal operation.
the purpose of the end-stop is to detect faults and avoid jamming the precious linear drives by shutting down the drive.

Perhaps you overlooked the bit where I said critical timing switches.
I never said limit switches weren't critical, it's just a few milliseconds delay isn't going to make much difference if you hit the a limit.
 

Offline rob77

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: sk
Re: Isolate noise from CNC limit switches
« Reply #8 on: May 08, 2015, 06:55:39 pm »
Capacitors on a CNC machine switch are generally considered a bodge for an underlying issue. It's certainly not something you'd really want to implement for critical timing switches like homing switches/probes where delays could cause accuracy issues.

it's the end-stop switch => hitting the end-stop switch means GAME OVER - a CNC machine is NOT supposed to hit the end-stop witch during normal operation.
the purpose of the end-stop is to detect faults and avoid jamming the precious linear drives by shutting down the drive.

Perhaps you overlooked the bit where I said critical timing switches.
I never said limit switches weren't critical, it's just a few milliseconds delay isn't going to make much difference if you hit the a limit.

sorry, you're right. my apologies.

but when reading about switches in a context of a CNC - i'm always thinking about the end-stop switches... because i never seen a mechanical switch which would be critical to timing ;)
 

Offline mc

  • Regular Contributor
  • *
  • Posts: 155
  • Country: scotland
Re: Isolate noise from CNC limit switches
« Reply #9 on: May 08, 2015, 07:09:36 pm »
sorry, you're right. my apologies.

but when reading about switches in a context of a CNC - i'm always thinking about the end-stop switches... because i never seen a mechanical switch which would be critical to timing ;)

Apology accepted.  :)

But who said anything about mechanical switches ;)

Mechanical switches can be used for homing with pretty good repeatability, usually within a thou or two if you use good quality switches and mount them sensibly, which is good enough for the majority of machines. For most home machines, I wouldn't think you'd gain much by using opto sensors, especially given they're far more prone to dust/dirt/shavings/swarf, unless you manage to enclose them well.

Personally, I've now got the luxury of a mix of mechanical and opto switches, combined with encoder indexing for homing purposes on machines that require accurate homing, but my old lathe used an opto slot sensor on the X-axis and a mechanical microswitch on the Z-axis and homing accuracy was always well within a thou on both axis. Just had to remember and clear any stringy bits of swarf out the slot sensor first  :D

Anyway, all this discussion of switches isn't answering my thoughts about high/low switching!
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 1738
  • Country: au
Re: Isolate noise from CNC limit switches
« Reply #10 on: May 08, 2015, 11:41:25 pm »
Capacitors on a CNC machine switch are generally considered a bodge for an underlying issue. It's certainly not something you'd really want to implement for critical timing switches like homing switches/probes where delays could cause accuracy issues.

it's the end-stop switch => hitting the end-stop switch means GAME OVER - a CNC machine is NOT supposed to hit the end-stop witch during normal operation.
the purpose of the end-stop is to detect faults and avoid jamming the precious linear drives by shutting down the drive.

If the switch is Normally Open mechanical limit switch and the wire resistance is reasonably low, below 100 ohms, and the cap 0.01uF, you will get less than a 1 to 2us delay in closing, which is the critical action to respond to. That is plenty fast enough. The opening delay will be slower, granted, but you are not normally too concerned about that.
« Last Edit: May 09, 2015, 12:12:18 am by moffy »
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Isolate noise from CNC limit switches
« Reply #11 on: May 09, 2015, 12:29:46 am »
Wow, there's a lot of discussion here.  I'll try to answer some of the questions about my setup.

Quote
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.

Quote
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.

Quote
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. 

Quote
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?

Quote
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.

Quote
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

Quote
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?

Quote
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.

Quote
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.

 

Online moffy

  • Super Contributor
  • ***
  • Posts: 1738
  • Country: au
Re: Isolate noise from CNC limit switches
« Reply #12 on: May 09, 2015, 01:10:47 am »

Quote
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.

That sounds like some sort of a grounding issue, where stepper motor return currents are flowing where they shouldn't. If you are using twin shielded cable for your switches then only connect the shield at one end, near the Arduino, not at both ends.
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Isolate noise from CNC limit switches
« Reply #13 on: May 09, 2015, 01:30:35 am »

Quote
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.

That sounds like some sort of a grounding issue, where stepper motor return currents are flowing where they shouldn't. If you are using twin shielded cable for your switches then only connect the shield at one end, near the Arduino, not at both ends.

That's how I have the shields connected - only at the Arduino side.
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 1738
  • Country: au
Re: Isolate noise from CNC limit switches
« Reply #14 on: May 09, 2015, 01:34:13 am »
That's good practice. Where were you grounding the shields of the stepper motors to?
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Isolate noise from CNC limit switches
« Reply #15 on: May 09, 2015, 01:39:39 am »
That's good practice. Where were you grounding the shields of the stepper motors to?

When I grounded the shields on the steppers the ringing was worse, so I left them floating.

There's really no chassis ground on the Shapeoko.  The power supply is similar to what you see for laptops. 
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Isolate noise from CNC limit switches
« Reply #16 on: May 09, 2015, 04:19:35 am »
FLOATING grounds are worse than no grounds at all! 
When you say "grounded the shields on the steppers" does that mean you connected the shields at the MOTOR END?
That is actually the wrong end.  Perhaps you need to ESTABLISH a central "star ground" point where everything meets.
Grounding and shielding is a "gray art" at best.  A great deal of it is trial-and-error.
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Isolate noise from CNC limit switches
« Reply #17 on: May 09, 2015, 03:16:36 pm »
FLOATING grounds are worse than no grounds at all! 
When you say "grounded the shields on the steppers" does that mean you connected the shields at the MOTOR END?
That is actually the wrong end.  Perhaps you need to ESTABLISH a central "star ground" point where everything meets.
Grounding and shielding is a "gray art" at best.  A great deal of it is trial-and-error.

No, I grounded the shields to the microcontroller ground, not the motor end.

I think part of the problem is I don't really have a good chassis ground anywhere.  The Shapeoko just uses this power supply; which is the kind of p/s you'd get with a laptop and it just has 24 volts coming out of it.  I'd probably be better off with something like this power supply.  Which has a nice metal case which I assume is connected to earth ground on my mains.  Then I could connect all my shields to this chassis ground.  What do you think?


 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Isolate noise from CNC limit switches
« Reply #18 on: May 09, 2015, 05:47:07 pm »
But where does that "line-lump" power supply plug in?  I would establish that power input connector as the "star-ground" point where everything else references.  Just having a power supply with a metal enclosure is not likely to solve the problem by itself.

I would also run two conductor shielded wire out to each switch. The two inner conductors would connect to the switch contacts, and the shield would connect back to ground at the controller board. And if one side of the switch connects to ground, it would be back at the controller board, never out at the far end where the switch is.
« Last Edit: May 09, 2015, 05:49:04 pm by Richard Crowley »
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Isolate noise from CNC limit switches
« Reply #19 on: May 09, 2015, 06:32:34 pm »
How about using current-driven control signal: Place a capacitor between the MCU input and the ground. Create a 2mA constant current source and feed it through the limit switch to the input capacitor / input pin. When the switch is closed, the capacitor will be charged by the constant current. Create 1mA constant current sink and place it in parallel with the capacitor in order to discharge the capacitor when the limit switch opens again. Should be quite insensitive to the voltage coupled noise. Of course, you can use an opto-coupler in current driven mode, but that would be way too easy.  :)
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Isolate noise from CNC limit switches
« Reply #20 on: May 09, 2015, 06:41:18 pm »
A simple circuit using a 47 ohm pull-up resistor to 5V should present such a low impedance that should make it immune to any kind of induced noise possible from such a relatively low-power system. 47 ohms will firmly pull-up the input pin to VCC and prevent induced noise from dragging the pin below the threshold voltage.  And a simple micro-switch can easily pull 5V through 47 ohms down to near-zero, well below the threshold voltage.  Dunno why it has to be any more complicated than that?
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Isolate noise from CNC limit switches
« Reply #21 on: May 09, 2015, 07:30:16 pm »
I would also run two conductor shielded wire out to each switch. The two inner conductors would connect to the switch contacts, and the shield would connect back to ground at the controller board.

This is how the limit switches are currently setup.
 

Offline scott216Topic starter

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Isolate noise from CNC limit switches
« Reply #22 on: May 09, 2015, 07:33:02 pm »
A simple circuit using a 47 ohm pull-up resistor to 5V should present such a low impedance that should make it immune to any kind of induced noise possible from such a relatively low-power system. 47 ohms will firmly pull-up the input pin to VCC and prevent induced noise from dragging the pin below the threshold voltage.  And a simple micro-switch can easily pull 5V through 47 ohms down to near-zero, well below the threshold voltage.  Dunno why it has to be any more complicated than that?
I'll give that a try.  I might have to find another project to use my opto-couplers on ;D
 

Offline chefkoch84

  • Contributor
  • Posts: 41
Re: Isolate noise from CNC limit switches
« Reply #23 on: May 18, 2015, 05:15:00 pm »
I had similar issues on a 3D printer (reprap). Back then I figured (at least thought) that the stepper motor wires croostalk to the signal levels. 

My solution was to 3-wire all the limit switches:
Code: [Select]
5V  -- 
       \-- switch   --> digital input
GND--

By this solution you need 3 wires for each switch but in every state you have a very defined level.
Depending on your situation (type of switches ... wires ... ect. ) this could also be a good alternative.


 

Offline cncjerry

  • Supporter
  • ****
  • Posts: 1283
Re: Isolate noise from CNC limit switches
« Reply #24 on: May 18, 2015, 07:20:08 pm »
Before you spend a lot of time on the switches, make sure your head/tail stock motors are plugged into separate outlets and grounds.  Also, try lifting the ground on either the headstock motors or the electronics if it is safe.  I had the same problem and the more controls, sensors and switches I added the worse it became.  I tried ferrites (e.g. clamps, toroids, etc) as well as shielded cable with conductive HVAC tape.  Each that I added reduced the noise BUT lifting the ground on my electronics and running the power from a separate breaker fixed it all.  I then sequentially removed each of the ferrites and other shielding and the problem was gone.  I ultimately used shielded cables for all with one end only grounded;  a separate ground to a cold water pipe for the machine itself; separate breakers and outlets for the headstocks and electronics; and sprinkled clamp on ferrites where they fit.

All this was on two stepper systems, a lathe and a small engraving mill, both had the same problem using different drivers.  My larger servo system which is CL never had problems but that was 220V motors with 110V electronics so that had more isolation from day one.

You should also have an opto isolated BOB on the computer if using parallel port drive.  I avoid USB though it is silly in this day but the lag for E-stop was too long for me.

Jerry
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf