Hi guys.
I have 3 proximity sensors on my cnc gantry that are used as homing switches. They are normal closed sensors and I believe they are NPN. When they get power the led on them is on. When they sense a metal object the led goes of and the state of the input changes to give the signal. I have been using it for a year now but I have started to think that there is an issue with the way they are wired and I would like some advice.

Here is a photo of my control box.

The ribon cable from the break out board connects to an adapter like this one.

One day after working on my control box I found out that the home switches stopped working. After a lot of trial and error I found out that the reason they stopped working was a strange issue with the adapter. This adapter is glued on the side of the control box where there is also an aluminum sheet. When the metal surrounding portion of the adapter is in contact with the aluminum sheet, the switches work fine. If I push a little bit the adapter and the surrounding metal portion is not in contact with the aluminum sheet the home switches power down and seem tripped on mach3.
I measured continuity between that aluminum sheet and my -12v connection on the 12v supply.

Here is how my break out board, 5v supply, 12v supply, and proximity sensor wiring is done at the moment.

And an illustration of it on my control box too.


So from what I get the return path to -12v is done through the aluminum sheet which has continuity with the -12v and when the metal portion of the adapter loses contact with the that aluminum sheet the switches power down.

What I have temporarily done to get it more reliable at the moment is to run a cable screwed on the -12v and the little bolt on the parallel adapter.
Here is a wiring diagram of this and a photo of the actual cable. It is the grey cable.


The home switches work fine this way. But I feel that this wiring is wrong and could cause some other issues. I had some issues with a touch plate that I am using to set zero which was triggering randomly before touching the touchplate some times. I installed a 0.1uF capacitor on the input of the touch plate to fix this.
From what I understand there is already a connection between -12v and ground. When the metal portion of the adapter touches the aluminum sheet another connection with the ground occurs which could create a ground loop??
After some research I think I found that the correct way to wire my proximity sensors is to not run the ground wire from the sensor to the break out board, but to the -12v terminal? And have -5v and -12v connected together? Like this diagram?


Any help would be great guys!