What is the easiest way to monitor the state of a limit switch? Basically I would want the switch to break the WP circuit on a laser PSU, but at the same time trigger an arduino pin so that I can display a message saying the switch has been triggered. Since a limit switch has a NC and a NO pin, I was thinking that it should be possible somehow, I just can’t seem to wrap my head around it today.
Use 2 switches bolted together one is in interlock circuit and one is connected to Arduino. It keeps the interlock loop totally isolated.
With this approach you can tell which switch is closed/open otherwise you can tell the loop is open but not from where.
I have a light on mine that is on when loop is open. Forgot how I did it and not at home.
There are two ways to monitor an input, polling and interrupts. Polling works by continuously checking the state of the input with a loop. When the input state changes, do something. Polling is the easiest to implement but it is inefficient.
The second method is to use an interrupt. An interrupt will signal the CPU that something has happened. The CPU will then stop what it is doing and perform what ever action you want via a software routine known as an Interrupt Service Routine (ISR).
Multiple times I have considered building a safety and maintenance processor for the K40 but concluded that since for the most part K40 users are unwilling to install simple interlocks they probably would not value, build or buy a monitoring solution.
Safety Interlock Design
I contend that its not a good practice for software to be used in line as part of a safety interlock circuit irrespective of the use of interrupts or polling techniques.
We can spend a lot of energy debating if software can be as reliable as a switch but the bottom line is that software running on an embedded controller is too complex to be considered fail proof. In fact in these K40 machines we should be running redundant circuitry and beam interrupters to be compliant with most any safety standards for a laser of this power.
The current approach which uses serially connected switches in a serial loop provides a level of safety protection but also caries with it some disadvantages.
You can monitor this loop to see if it is open but you cannot tell what interlock is open. This can be annoying. i.e. you may not notice that the laser is not operating when a K40 job starts with interlocks open and you have to restart that job after checking every interlock for its state.
A Better Approach?
My notion is that ganged (dual) interlock switches would keep our level of interlocks reasonably fail proof while providing better information. One of the switches functions as the interlock switch and the other functions as an interlock monitor switch.
The interlock switch’s are serially in the interlock circuit and the interlock monitor switch monitors the physical state of the interlock with an interlock processor.
Each of the interlock monitor switches in a gang is wired back to an “interlock processor” that can individually monitor the state of the corresponding interlock. The interlock processor itself can disable the laser. This way when a interlock is broken both the serial loop and the interlock processor disables the laser. Correspondingly the interlock processor informs the operator with specifics of what interlock is open.
This schema also makes the wiring of the interlocks easier. Each gang has 4 leads going to the interlock processor, rather than wiring them physically to each other. On the interlock processor one pair of wires from the interlock switch is used to implement a serial loop in the copper and the other two wires connect as inputs to the processor. My single switch interlocks are wired this way.
In this schema whether the interlock processor polls or uses interrupts we provide better reliability, redundancy and operator information.
The coolant flow switch is one exceptional element of interlock consideration. In its case, making the switch redundant is impractical. Yet the flow switch is the least reliable interlock switch and the hardest to determine its state.
With this schema the interlock processor can conclude that the coolant switch is open by exception. When the loop is broken the interlock processor knows that all other switches are closed and therefore can deduce that the coolant switch must be open. In the case of multiple open switches the state of the coolant switch is hidden until the other interlocks are closed after which the coolant interlocks state is visible.
The interlock processor could also monitor and report on various temperature sensors, keep a tube time meter etc…
In fact while we are dreaming … we could build a K40 replacement operator panel that does all this:
- Laser power control
- Interlock implementation and monitoring
- Temperature monitoring with power control (tube, coolant, cabinet)
- Laser current monitoring
- Laser tube usage meter
- Laser enable
- Laser test
- Scheduled maintenance reminder
- Fire detection
- Main power switch
- LPS Diagnostics
- DC voltage monitoring
In general, the voltages around an interlock circuit won’t be compatible with arduino inputs. So the best solution, as others have said, is to use pairs of switches.
There are a few ways around it, if you don’t want to do that.
If you can ground the wiper of the interlock switch such that it grounds the interlock input with one of the contacts and an arduino with the other, it will be relatively safe. Unfortunately, interlocks don’t usually work this way : they’re in series and only one switch at the end of the chain will be ground (and might, in some circuits, be 12V or similar).
If the result of the interlock chain is an input to the power supply that ends up providing some voltage to the power supply - perhaps 12V or 24V - you can sense that voltage with a divider or a relay to give a status to the arduino. You need to analyse the interlock circuit to work it out : there isn’t a default (I think the common K40 PSU actually has both a positive and a negative interlock input and I wouldn’t want to rely on one or the other being used on a particular sample).
Sorry, out of subject to direct question, but I was wondering to improve security in a K40, to simply have a mechanical obstruction of the ray when someone open the door.
I found a way to light an LED if the circuit is open but that is the best I could do without safety disruption.