Many of the "grounding" issues are the creation of ground loops. The issue many times is a misrepresentation of the term ground for return and 0V. On the AC side (assuming 120V, and a 3 wire system) you have safety ground, neutral and a hot wire. Many mistakes are made in the handling of the neutral and safety ground because they tie together in the AC distribution panel, so people think they need (or it's ok) to tie together again. That is an absolute no-no. When building a controller:
- Use an AC filter on the incoming line, depending on load such as a Qualtek 857-06/027.
- The incoming neutral should only be on one net. i.e. transformer, or powersupply input.
- The incoming safety ground should tie to metal framework only.
- Power supply output return/0V often referred as gnd (but it isn't safety ground) should be considered the tie point and left floating in respect to the incoming neutral and safety ground. That floating 0V will wind up being tied to safety ground via the AC distribution system through pins 18-25 in an non-isolated system, thus not providing a ground loop possibility.
- Physical routing or wires is EXTREMELY important. Many people use nylon ties to make a nice clean routing layout which looks nice and isn't a problem until you start mixing low level control signals with heavy current carrying wire. Heavy switched current wires running parallel with signal wire will couple noise into signal wires. #5 Use normally closed switches for the running state. Follow these points and you will eliminate many problems and "mysterious" infrequent "what happened" and why.
Opto isolated drives or electronics should follow the same as above, but you will need to split the 0V based on the isolation requirements. Plant or industrial settings where power distribution can be "iffy" should utilize a isolation transformer, or isolation system and a local ground rod and re-reference the system.
Below is a wiring diagram. The drivers/electronics are wired via a "STAR" ground. A "STAR" ground is where one tie point is established for all returns, usually the negative of the power supply is considered that tie point. This minimizes ground loops, provides a non cumulative voltage offset due to summing or currents.