View Full Version : Proximity switch "contact bounce"

08-01-2017, 11:50 PM
I'm just commissioning my new router and have been testing limit/home switches. I am using NPN NC proximity switches, running off 24V. I started by doing basic limit switch testing - jog gently towards the limit switch and check that it worked. I have combined home/limit switches at one end of each axis (XYZ), limit at the other (XY), and just at one end for Z. Pretty standard configuration; for me it was easier to mount two switches than have one travelling switch and I had bought a box of 10 off eBay anyway. I am using three separate inputs on a CSMIO-IP/M so each axis has its own input with cascaded pairs of switches on X and Y.

Limit switch functions worked fine - good reliable stop. Then I moved to checking homing function with Mach3 and that's where I started seeing problems. Using "Ref All Home", Z homes to the top of travel, overshoots slightly, and then moves off the switch to find home. Usually. However, I get frequent "limit switch" trips and when I look closely, I see that the LED indicating on/off on the Z prox switch is flickering slightly. I had noticed something like this when I first fitted the switches and was just testing them by winding the relevant axis by hand, using the LED as an indicator as the IP/M was not connected at the time. Some of them seemed to have a pretty sharp cutoff, and some seemed to have a slight area of uncertainty. I put this down to them not being fully wired in and that the input circuitry of the motion controller would sharpen up the switching point.

What I think is happening is that Z moves to home, overshoots as expected, and then backs slowly off. However, the IP/M detects "home" the first time the switch trips, but because the switch then changes state a few more times (and goes on doing this) this is detected as a limit switch event. Even if the Z homing works OK (maybe 50% of the time) as the other axes home, the vibration (???) shakes the Z axis slightly, and the limit function trips again. On X, I have made the target block as square-edged as possible for the most accurate triggering; on Y I use the edge of the ballnut but that is also fairly square; on Z I am using the end of the Hiwin rail which has something of a bevel on it. Don't know if this is a contributory factor.

It might be noise related as I can have the machine sitting with the Z switch LED flickering and then hit e-stop (which turns off power to the motors, amongst other things). The flickering stops, but restarts when I reset Mach3. I shall try taking the switch cable out of the drag chain it shares with the Z motor cable (CY screened) to see if that helps, but I ran out of time this evening.

It might be a cheap and nasty set of switches, of course - one of them was completely faulty from new. Has anyone seen anything like this before? I know that JazzCNC has demonstrated excellent repeatability of these switches but maybe that was with a better quality switch!

Clive S
09-01-2017, 12:15 AM
Neale I don't know anything about CSMIO-IP/M but could it be something simple like a floating input that might have to be pulled high etc.:cower: Or the grounds of the ps not connected

09-01-2017, 09:04 AM
I was of the understanding (seem to remember Dean saying it) that you couldn't use the same proxy as limit and home with the IPM?

Sent from my HUAWEI VNS-L31 using Tapatalk

Robin Hewitt
09-01-2017, 10:30 AM
Wild guess, the switch output is an open collector and your pull up resistor isn't connecting.

09-01-2017, 10:49 AM
Thanks for the comments, guys.

Don't think that it's pull-up problem as the IP/M has a bit more sophisticated input arrangement that does not need these. In any case, the indicator led on the switch itself flickers which suggests a problem upstream of the IP/M.

Grounding - I'll come back to that.

Don't remember anything in the docs that says that IP/M does not support combined home/limit switching; that bit seems to work and it's just the unreliable home switch trip (again, you can see this at the led without considering the motion controller) that does not work. In other words, the IP/M seems to work as per standard Mach3 functionality.

Now - grounding. For testing the control box is sat on the floor in front of the machine. So the wire from the star point in the box is not connected to the mounting bolt as intended. I shall sort this out, but I seem to remember noticing that there was not a clear switching point when testing using a bench power supply, so I'm starting to suspect that this is not noise-related.

Around 4 am I woke up thinking about hysteresis. When I was reading up on these switches, I remembered seeing something about this so I have just gone back to check. Typically, these things should have a hysteresis range of 10-20% of the switching distance, so about 0.4-0.8mm in my case. Switch-on and switch-off points are separate, specifically to avoid this kind of switching uncertainty and the possibility of false switching when things vibrate. Just what I'm seeing. I think that some of my switches are better than others so I shall go back and test more carefully. Anyone know a source of good examples of these switches? My ebay source doesn't seem to be there any more. I wonder why?

Please keep comments coming. The silliest problems are always the ones you can't see yourself :smile:

Clive S
09-01-2017, 11:04 AM
Neile How about setting the home position to say about 2 -3 mm away from the switch so that the limit won't see it any more. Just a thought!

Robin Hewitt
09-01-2017, 11:27 AM
I might be completely misunderstanding what you are doing, but...
An NPN output usually requires a separate pull up resistor
If you want to gang them up on one line you get NO not NC

09-01-2017, 12:09 PM
Home position - problem here is that the same switch is home and limit. During homing, Mach3 disables limit function to allow homing to take place (l believe). It homes, and then immediately re-enables limit function and the next "flicker" (random switch operation) trips the limit. I think! Sometimes the z homing does work, and Mach3 starts the XY homing (I home both together). I suspect that gantry vibration then trips the hair-trigger Z limit switch again and it all stops. I could, I suppose, move z away from the home position once it has homed (if it does without tripping a limit) so that subsequent vibration does not cause false triggers, but that's not really fixing the underlying problem.

Pull-ups - IP/M doesn't work that way. A lot of BOBs use some kind of buffer input so you use a pull-up/pull-down resistor to one rail and switch to the other rail. The IP/M input looks rather like an opto-isolator input (with some clever current limiting, etc, to handle a range of input voltages and with both ends brought out to a terminal block) so you take one end to one of the rails and switch to the other. In my case, with open-collector NPN switches, I take one side of each input to the 24V rail and switch the other side to ground. My X and Y axes both have two switches wired in cascade (effectively in series as they are NC); this seemed to work fine testing on the bench and seems to work OK on the machine for limit switch purposes. In any case, the problematic axis at present is Z where there is only one switch anyway!

Sorry if I might come over as teaching anyone to suck eggs but I wanted to explain some of my reasoning to people with less knowledge; sometimes those with less knowledge make fewer assumptions and can see wood for trees :smile:

Personally, I still suspect those switches...

Boyan Silyavski
09-01-2017, 01:04 PM
Hi Neale,
how exactly you have connected that limit switches? If you connected them separately to 24VDC power source / the 2 wires only/ do they flicker or not?

09-01-2017, 01:19 PM
I bought a box of ten a couple of years ago (this machine has taken longer to finish than I expected!) I have fitted 6, so I have gone through the rest of the box testing each of the other four. I bolted each one in turn to the machine so I could trigger it by turning the ballscrew by hand and connected it to a bench power supply. So, completely independent of the control box, motion controller, etc.

One does not work at all. One turned out to be an "EX" version which only had two wires instead of a three-wire AX. The other two both have this sharp switch-on/switch-off point with a microscopic movement of the ballscrew needed to go from on to off with a flickering stage between. As I understand it, this is not what a proximity switch should do - there should be a difference between on and off trigger points to avoid exactly this situation. I think I have a bad batch of switches.

Boyan Silyavski
09-01-2017, 03:10 PM
You must have been unlucky with that batch/ seller. Yes, there is not a flickering stage normally. Its either on or off. Hysteresis means once you are ON and the back to OFF, like you noted there is a ~0.4mm distance / at least on my switches.

09-01-2017, 04:25 PM
The more I look, the more certain I am that that is the problem. Fortunately I only need to replace three of them - the switches are fine as limits where the lack of hysteresis doesn't matter. But how do you find a seller that has good ones in stock! Maybe not looking for the cheapest would be a good start...

09-01-2017, 04:58 PM
I bought mine from Farnell, think they were 8 each....but as I wasn't paying for them 😁 decided cost didn't matter therefore to buy from uk...

Sent from my HUAWEI VNS-L31 using Tapatalk

Clive S
09-01-2017, 05:05 PM
The more I look, the more certain I am that that is the problem. Fortunately I only need to replace three of them - the switches are fine as limits where the lack of hysteresis doesn't matter. But how do you find a seller that has good ones in stock! Maybe not looking for the cheapest would be a good start...

Neale if you pm me your address I will send you one

09-01-2017, 05:11 PM
Clive - that's a very kind offer but I have just ordered 4 more which should be here by the end of the week. For the moment, I can get by with homing each axis in turn (using the buttons on the Diagnostics page). I home one axis, then jog it a tiny bit away from the home position. Doing each axis in turn like this is a bit of a chore but it does mean that I can continue with testing. Next job is to sort out squaring the gantry and then test my ideas for dual-motor homing using an IP/M which does not support this.

16-01-2017, 11:24 PM
I ordered some new switches, and I also put the controller box in the machine frame where it was supposed to go. That meant that I could connect the star point earth terminal in the control cabinet to the frame. This completely cured all the homing problems I was seeing. Reliable homing, and not a single limit switch trip since. Was this a shielding/noise/ground loop problem? No idea, but I seem to have fixed it. I was testing the proximity switches by connecting them to a bench power supply and just watching the built-in LEDs; in retrospect I'm not sure that this is a valid test and I should probably have connected the switch output to some kind of load (like motion controller input). When the new switches arrived, I tested those and still did not see any hysteresis but again this was "off load" and might not be a valid test. I do see the axis overshoot very slightly and then return slowly to the home position (which is what you would expect) on two of the three axes; it might be happening on the third but the movement is too small to see easily.

I did have a problem with one limit switch apparently triggering as the cable chain containing motor cables moved near its cable but I rerouted the cable and that seems OK now.

I haven't measured resetting accuracy when homing yet. Be interesting to see what these cheap switches can achieve.

17-01-2017, 01:40 AM
I had the bouncing problem when the distance between the sensor and the triggering metal was too high and the triggering metal was aluminium. I have the sensor passing by the metal not towards it.
In regard to repeatability, I have one sensor mounted too close to the stepper and the triggering position differs with the position of the stepper rotor, but only by a few hundredths of a millimeter.

Boyan Silyavski
17-01-2017, 08:02 AM
When i home with Mach3 i am not in a hurry and use low speeds for not to overshoot much. With the Chinese controller this is not a problem as i can program it to home 5 times, so it checks 5 times where it is, each of them slower. I use 2 times though. First time overshoots, then slowly homes on place.

17-01-2017, 10:10 AM
An NPN output usually requires a separate pull up resistor I think that is incorporated in the switch, but the exact switch has not been mentioned, so I cannot be sure.