Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: electrotwelve on March 09, 2019, 02:03:57 AM

Title: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on March 09, 2019, 02:03:57 AM
So I have a 12V relay board that I used to use with my Arduino. It actually has two relays on it and I'm using only one channel. The board schematic is like the one shown in the image:

(https://i.imgur.com/2suWxgjl.png)

Since I wanted the relay to operate on an active high input, I tied IN1 and GND together. The GND here is also the LPTs GND. On the Vcc terminal where it says Arduino's 5V, I have pin 14 of the LPT connected. Across JDVcc and GND is an independent 12V supply.

Now every time I try to switch on the spindle, the relay clicks ON for a fraction of a second and then turns OFF and I see a 'Limit switch triggered' on the screen. Can anyone help me understand what is happening here?
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: Tweakie.CNC on March 09, 2019, 03:14:01 AM
Sounds very much like electrical 'noise'.

Try increasing the Debounce Interval (Config. / General Config.) to around 1000 and see if that makes any difference.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: hof on March 09, 2019, 03:20:05 AM
Sounds like you're suffering from EMI from when the spindle is turning on.
A motor that is turning on at full speed (as when controlled using a relay) is causing huge inductive spikes that can interfere with nearby electronic circuits. Even the ones that aren't physically connected to the motor.

Try disconnecting the spindle from the relay to verify this. If the limit switch stops triggering when the spindle is disconnected you know it's noise from the spindle that's causing it.
Try moving the relay and the wiring to the spindle further away from other cabling such as limit switch cables and circuits.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: MN300 on March 09, 2019, 06:16:25 AM
There is no need to connect the LPT GND to the relay board GND, just to IN1 as you did is fine. The LPT powers the OPTO input and the 12V supply powers the relay side. The extra ground tie just provides a path for noise.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on March 09, 2019, 09:37:29 AM
Thank you all.

Sounds very much like electrical 'noise'.

Try increasing the Debounce Interval (Config. / General Config.) to around 1000 and see if that makes any difference.

I put in a value of 1000 and with that the relay would trigger properly and the job would start as well. However, I have started getting random failures with a 'Limit switch triggered' message. I then increased it to a value of 6250 (the equivalent of 250ms). With this, it still randomly stops but there is a significant delay now before the job fails - still randomly. The stepper wires are shielded but not the limit switches and the estop.

Before Mach3, I was using Grbl with the same wiring and it never failed randomly like this. Which is why I'm stumped here.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: Tweakie.CNC on March 09, 2019, 10:01:21 AM
Quote
I put in a value of 1000 and with that the relay would trigger properly and the job would start as well. However, I have started getting random failures with a 'Limit switch triggered' message. I then increased it to a value of 6250 (the equivalent of 250ms). With this, it still randomly stops but there is a significant delay now before the job fails - still randomly. The stepper wires are shielded but not the limit switches and the estop.

This confirms that it is indeed electrical noise and you now need to check your wiring layout to see where improvements can be made.

I think you have already identified the problem...
All inputs (limit switches, EStop, etc) should be connected with twin shielded cable (with the shield connected to a single point Earth at the controller end only). If you do this then you should be able to reduce the debounce value to a sensible value of about 500.

Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on March 09, 2019, 11:08:25 AM
Is it okay to use Ethernet cables for the limit and estop switches? They are twisted pair and shielded(?).
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: joeaverage on March 09, 2019, 01:23:16 PM
Hi,
yes you could use Ethernet cable.

You should try to indentify the source of the interference and eliminate it if you can.

What you are trying to do is protect sensitive circuits from EMI. If you eliminate the EMI than you have protected
ALL the sensitive circuits in one go.

The most likely source of EMI is the spindle. Disconnect the spindle as Hof has suggested to prove it.
It may be something as simple of a line filter or even as simple as connecting your spindle to a different
230V outlet to your PC/controller will do the job.

Craig
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on March 09, 2019, 01:39:59 PM
You should try to indentify the source of the interference and eliminate it if you can.

Hi, Thank you. I will try running a job without the spindle turned on. This should tell me if that is the source of EMI.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: hof on March 09, 2019, 01:44:06 PM
Just unplug the spindle and run the same code as before. You want to drive the relay to make sure there's no other problems with your circuit.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: reuelt on March 10, 2019, 08:51:33 PM
So I have a 12V relay board that I used to use with my Arduino. It actually has two relays on it and I'm using only one channel. The board schematic is like the one shown in the image:

(https://i.imgur.com/2suWxgjl.png)
some comments:
1. YOU need to use a (high current) "SOLID STATE RELAY" - not an electromagnetic type relay.
2. (std) Ethernet cable is UTP "(unshieded) twisted-pair" and cannot be used for this application. Proper cable with grounded coaxial shielding must be used for limit switches.
3. You limit switches are better to be made normally closed (with preferable higher voltage and always on) rather than normally open.
4. A 0.1uf capacitor should be parallel to the each terminals of the limit switch input and ground at the BOB (break out board) of each axis.


Since I wanted the relay to operate on an active high input, I tied IN1 and GND together. The GND here is also the LPTs GND. On the Vcc terminal where it says Arduino's 5V, I have pin 14 of the LPT connected. Across JDVcc and GND is an independent 12V supply.

Now every time I try to switch on the spindle, the relay clicks ON for a fraction of a second and then turns OFF and I see a 'Limit switch triggered' on the screen. Can anyone help me understand what is happening here?
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on March 13, 2019, 10:56:50 PM
So I ran the job without the spindle powered up and it ran smoothly without any issues. I guess that confirms that the spindle is the source of the trip, even though the limit switches have RC noise filters. Thank you all for your actionable suggestions! They really helped.

some comments:
1. YOU need to use a (high current) "SOLID STATE RELAY" - not an electromagnetic type relay.
2. (std) Ethernet cable is UTP "(unshieded) twisted-pair" and cannot be used for this application. Proper cable with grounded coaxial shielding must be used for limit switches.
3. You limit switches are better to be made normally closed (with preferable higher voltage and always on) rather than normally open.
4. A 0.1uf capacitor should be parallel to the each terminals of the limit switch input and ground at the BOB (break out board) of each axis.

I did think about using a solid state relay, however, my spindle is weird in a way that it has two terminals that act as a switch. When shorted, the spindle turns ON. I could however, short those terminals and use the SSR to switch the main power to the spindle. The ethernet cable I have is S/FTP. Each pair has a foil shield and then there is shielding foil over all of them together. Yes my limit switches are configured to be NC and they have an RC filter between them and the board.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: joeaverage on March 13, 2019, 11:07:07 PM
Hi,
there are two ways to approach EMI (electromagnetic interference).

Things like shielding cables, RC filters  on signal lines are all variations on the theme of 'decreasing the sensitivity
of signal circuits to EMI'. This is not the best, or perhaps the first approach.

The other way is to apply line reactors and/or filters to the VFD/spindle so that no EMI is generated. Then all signal
circuits operate is a low noise environment.

What sort of spindle are you using?

Craig
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: MN300 on March 13, 2019, 11:16:04 PM
Connecting the ground of the computer to the ground of the machinery can provide a path for noise to enter and affect the computer, regardless of the limit switch filtering. If none of the previous suggestions solve the problem an opto-isolator type BOB may be needed.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on March 14, 2019, 01:53:50 AM
Hi,
there are two ways to approach EMI (electromagnetic interference).

Things like shielding cables, RC filters  on signal lines are all variations on the theme of 'decreasing the sensitivity
of signal circuits to EMI'. This is not the best, or perhaps the first approach.

The other way is to apply line reactors and/or filters to the VFD/spindle so that no EMI is generated. Then all signal
circuits operate is a low noise environment.

What sort of spindle are you using?

Craig

This is a Chinese 300W DC spindle (https://www.aliexpress.com/item/CNC-Spindle-300W-Air-Cooled-0-3kw-Milling-Motor-Spindle-Speed-Power-Converter-52mm-Clamp-13pcs/32702815007.html?spm=a2g0s.9042311.0.0.27424c4dkEe5CC). I'm curious about the filters for the spindle that you are referring to.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on March 14, 2019, 01:55:35 AM
Connecting the ground of the computer to the ground of the machinery can provide a path for noise to enter and affect the computer, regardless of the limit switch filtering. If none of the previous suggestions solve the problem an opto-isolator type BOB may be needed.
This was going to be my next port of call. I'm curious as to how opto-isolation would be able to isolate noise...
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: joeaverage on March 14, 2019, 02:18:46 AM
Hi,
I was thinking that maybe you had a VFD and a asynchronous motor. For such motors line reactors
are appropriate.

For a DC spindle I would suggest a line filter like this in the AC input circuit:

https://nz.element14.com/corcom-te-connectivity/5vb1/power-line-filter-emi-rfi-5a-700ua/dp/2505259 (https://nz.element14.com/corcom-te-connectivity/5vb1/power-line-filter-emi-rfi-5a-700ua/dp/2505259)

In fact even between the DC controller and the motor would go a long way to suppress brush arcing.

Craig
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on April 07, 2019, 01:44:37 AM
So I've been doing testing on this further and I'm ready to give up. I switched off the limit sensing that seemed to be triggering the stops. I replaced all the cables on the machine to shielded ones and grounded the cable shields. I still get random stops in the middle of a job. Its not an estop because the spindle is still spinning. Not sure what is happening.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: joeaverage on April 07, 2019, 02:13:07 AM
Hi,
have you tried a line filter on the AC input to your DC power supply/spindle combination?

Shielded cable is all very well but its trying to 'keep the noise out' rather than stopping the noise at its source.

Craig
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: electrotwelve on April 07, 2019, 05:32:32 AM
I don't really want to keep spending more money on this considering that it works perfectly fine with grbl-based hardware and software. The only problem with those is the inability to handle really large files. Anything program with more than 100K lines and grbl starts to get bogged down.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: Overloaded on April 07, 2019, 08:51:53 AM
  I'm curious as to how opto-isolation would be able to isolate noise...

I've seen mention that it interrupts the mechanical connection therefore helping to prevent ground loops in the circuit.
Title: Re: Turning on the relay causes a 'limit switch triggered' error
Post by: reuelt on April 08, 2019, 02:32:39 AM
I don't really want to keep spending more money on this

Hi
Sorry, may I suggest you scrap your circuit and you buy this proven MACH3 Break Out Board
https://www.ebay.com/itm/MACH3-CNC-5-Axis-Interface-Breakout-Board-For-Stepper-Motor-Driver-CNC-Mill/172256512913?epid=22019898979&hash=item281b49cb91:g:734AAOSwLs9aWaON
for $5.38 + delivery.
It has a built in relay for your spindle, opto isolated inputs for limit switches and buffered IO for the motor drivers.
You will need a 12V-24V PSU for the opto isolated inputs to work.
I have the manual for this card. It works well with MACH3.