EMI - Science, Voodoo or DooDoo?
A way forward to deal with EMI.
I've been building CNC machines for more than 20 years and while the technology has changed a lot, one thing that has remained constant is the bane of electromagnetic interference (EMI). I'm involved with a number of online CNC groups and EMI problems come up time and time again. What is also true is the number of people that claim to understand it and provide specific remedies. Just do this or that and your problems will be gone. Unfortunately a lot of these remedies are a bit like baying at the moon. Hopefully this will help you understand EMI better.
Of course, it all goes back to Maxwell, Faraday, Volta, et al. Basically EMI is unwanted electromagnetically induced current in a wire. This current can do things like trigger inputs, crash microcontrollers or, in the extreme, damage electronics. So, yes, it is science. And science does point the way to solutions. Or, at least, mitigations. I say this because you will never fully get rid of EMI. It is a messy science.
For the beginning CNCer, EMI sounds like a lot of gobbledygook and there is a tendency to ignore it. Until they can't. In the extreme, I've heard people say it's just a hoax to sell unsuspecting system builders expensive components. And the remedies (and claims of effectiveness) are all over the map. The thing is, you can just move a wire and some times cause the problem to "go away". But that hasn't changed the fact that the wire is pumping out EMI. I make a couple of CNC breakout boards and have applied what I believe are best practices yet I would never claim they prevent EMI. There are just too many ways for it to sneak into your system.
To the poor beginner that just had their shiny new CNC machine stop mid-job because of EMI, doodoo is probably way too mild a term. What I find reprehensible are manufacturers that simply ignore EMI and leave their customers on their own.
So, what should we do to prevent EMI? Going back to the science, there is the concept of a Faraday cage which prevents radio waves from getting in or out. There is also the concept of a filter that will reduce (attenuate, in electronics jargon) EMI. And the concept of isolation - basically a barrier to EMI. These lead to a number of concrete things to do. You can apply some or all of these to your machine to harden it up. Just remember, more is better.
All wires act as antennas and will pick up EMI. These wind up as voltage transients - little spikes of energy. They can cause false triggers or disrupt communications. In order to prevent (or mitigate) these transients, there are a number of things you can do:
Switch trigger sense. By changing switches from Normally Open (NO) to Normally Closed (NC), you can increase the amount of energy it takes to force a false input. Basically, in a NC circuit, the voltage is normally high. In order to trigger the input, the voltage has to go to zero. This is much harder for EMI to do. Converting may force you to rewire your inputs if you have multiple switches on a single input (Series for NC, Parallel for NO).
Increase signal voltage.
Hard to do for an existing build but by using a higher voltage, it is harder for EMI to falsely trigger. My newer boards run the inputs at 12V vs the typical 5V for a lot of breakout boards.
False signals are typically transients - short, fast pulses. These can be filtered out via an electronic filter. The most common is called an RC low pass filter which attenuates signals above a certain frequency called the cut-off frequency. The practice of putting capacitors between the input signal and ground is a form of that but a bit of a stab in the dark. Use proper RC construction techniques to make an RC filter with the desired cut-off frequency. While an RC filter can work, it is hit or miss as EMI can have a very wide range of frequencies.
This is a device which uses light to ensure there is no electrical connection yet passes the desired signal. The device has an LED that the signal lights up and a phototransistor that receives the light and turns it back into an electrical signal. It is both isolation and a form of filter. It takes a lot more energy to transmit a false signal through an opto-isolator. And because the coupled LED and phototransistor take some time to pass the signal, the opto isolator inherently rejects short, fast transients. I use opto-isolators on my breakout boards and consider them a top tool in fighting EMI.
These are those little "donuts" that you fit over the signal wires. They can be helpful in reducing transients. I would not rely solely on them.
I hear this a lot and while it is true that twisted pairs do help some, there are better solutions. I would not solely rely on twisted pairs.
An electrical circuit needs to be "complete" for electrons to flow. The electrons come from a positive anode and flow to a negative cathode. (Purists are cringing over this description but describing holes as moving is confusing to most people.) The ultimate cathode is an earth ground. EMI electrons will happily flow to earth ground and out of your machine.(Yes, I know I am vastly simplifying this.) Many of us are lucky to have a power system that provides an earth ground in every outlet. But if you live in an older house or a place that doesn't have ground wiring, you can make your own earth ground simply by driving a metal rod into the ground. The US Nation Electric Code (NEC) says the rod must be driven at least 8 ft (2.5 meters) into the ground. Though I believe it is common to do only 1/2 that. Your plumbing, if metal, can serve as a good earth ground.
Make sure you earth ground all the metal structural parts of your machine and do so in a "star". Don't create daisy chains.
Reducing EMI Emissions and Pickup.
Typically, a wire acts as a receiving antenna for EMI. The longer the wire, the more EMI is received. By encasing the wires in a Faraday cage, you can significantly reduce the EMI pickup. This is the theory behind shielded wires and it does work. While you can't create a perfect Faraday cage, if you cover 95% of the wire, you will significantly reduce the amount of EMI pickup. Ensure that the shield is connected to earth ground. There are two schools of thought on whether to ground both ends of the shield or just one. I won't get into the details but think it's a silly argument - either way seems to work fine for most cases..
In addition, a wire can also be a "transmitter" of EMI. If you use a VFD to control a spindle, the power wires to the spindle can be strong emitters of EMI. Encasing them in a shield can significantly reduce EMI emissions. The bottom line is shielded wires significantly help to avoid the effects of EMI. While shielded wire does cost more and takes more work to correctly install, it is worth it. I consider this another top tool for fighting EMI.
A good thing to do is to encase your electronics in a faraday shield - a metal case. It can also serve as the center of a star ground. Bring all the shielded wires back the metal case and ground them there. Then connect the case to earth ground.
Another reduction technique is separation. This isn't always practical but can be effective. Radiative power decreases with square of distance so it doesn't take a lot of distance to have an impact. One system I worked on to reduce EMI problems, we moved the dust collector farther away form the CNC machine and that decreased, though did not completely eliminate, the number of EMI events. Thanks to Brian Slee for reminding me of that one.
Using inherently EMI Resistant Communications.
A huge number of hobby machines use USB for communication between a computer and the CNC controller. I see a large number of cries for help that boil down to USB communications getting garbled by EMI. You can get USB cables with ferrite "blobs" on the ends. These can help though often not enough. Better yet is to move to a communication mechanism that is inherently EMI resistant. Ethernet is a common one. Since it uses transformers to isolate the signal there is no way for EMI to be directly conducted into the controller. And because it uses an error detecting protocol (TCP/IP), bad communication packets are rejected and resent. WiFi is similar in that it uses TCP/IP. It is telling that a lot of industrial CNC equipment uses Ethernet. I consider this another top tool for fighting EMI.
Power Line EMI
If you work in a shop with welding, plasma cutting, large brushed motors or similar things, you may be seeing a lot of EMI coming in via the power line. Your best hope there is to use a power line filter. They aren't cheap though. Costs range from around $100 USD to thousands for larger industrial machines. Selection is dependent on your machine specifics. A note on plasma cutters. A lot of the cheaper (or older) plasma cutters use something called HF start. This uses a burst of high frequency radio waves to start the plasma running. Unfortunately this is a huge burst of EMI and even the best protection techniques have trouble with it. Your best bet is physical separation.
The most important thing to understand here is that EMI has many ways to get into your machine and cause mischief. If you are building a CNC machine, I recommend that you take more than one step to protect your controller. Tracking down and fixing an EMI problem can be maddening. Better to prevent the problems when you are building the machine. There are few things more disheartening than when you have a project that isn't going forward because of EMI.