The most important thing is to HAVE a ground, and only one. The body of the machine should be securely bonded, through a dedicated wire, to the power ground of your building. In the US, this is the GROUND terminal present on any self-respecting outlet. You want to have a single ground for the electronics, and connect everything to this point. This can be a buss-bar, heavy terminal strip, a metal chassis, or something on that order - something with essentially zero resistance between the many connections. NEVER ever daisy-chain grounds. For shielded cables, ground the shield at only one end, usually the power source end. So, for example, encoder cables should have the shield grounded at the end opposite the encoder, where the power supply is. NEVER use a shield as a power or signal return. Always provide a dedicated power or signal return wire, or you render the shield largely useless. You never want to setup a situation where you can have current flowing through a shield. You never want to have a situation where a signal wire can serve as a power return.
Regards,
Ray L.