cnc_lathe — count_cycles (door-cycle)
Physics
Section titled “Physics”On a manually-loaded CNC lathe cell, the operator opens the enclosure door once to unload the finished part and load the next blank, then closes it to start the next program cycle; the door therefore transitions open-then-closed exactly once per part. A magnetic (reed) or inductive proximity switch mounted at the door/frame interface senses the door’s closed state directly, and the detector counts one part per full open-close transition (a rising edge on “door closed” following a confirmed “door open” state), rather than counting the door’s existing interlock safety signal, which the recipe only reads and never writes to. Manual load/unload cycles on a lathe typically run 30 s to a few minutes per part even for small turned parts, so the fastest realistic door-cycle rate is well under 1 Hz; sampling the digital sensor output at 100 Hz gives >100x margin over Nyquist for that rate and comfortably resolves the door’s mechanical transition time (typically 200-500 ms to swing fully).
Sensor
Section titled “Sensor”- Spec: magnetic reed / inductive proximity door switch, digital, NO/NC
- Signal: counter ({count}), range n/a
Example parts
Section titled “Example parts”- Allen-Bradley/Rockwell 440N-Z21A2 magnetic safety door switch (non-contact, digital output)
- Pepperl+Fuchs NBB2-12GM50-E2 M12 inductive proximity sensor (2 mm range, PNP NO)
- Banner Engineering SLM50P6Q inductive block proximity sensor (M8-equivalent block body, 50 mm slot width, PNP NO) for door/guard position
Mounting
Section titled “Mounting”Mount the switch’s target half on the moving door leaf and the sensor half on the fixed machine frame, positioned so the target is within rated sensing range only when the door is fully closed; this reuses (reads only) the same physical interlock geometry most lathe doors already carry, via a separate sensor tapped alongside the existing safety switch, never spliced into the safety circuit itself.
Wiring
Section titled “Wiring”3-wire DC (24 V, 0 V, signal) to a digital input / counter channel on the edge box’s I/O module, run as an entirely separate cable from the machine’s safety-rated door interlock wiring; never tie the monitoring sensor’s output into the safety circuit’s signal path.
Validation
Section titled “Validation”run 20 manually-counted load/unload cycles at normal operator pace and compare the detector’s counter delta over the same window
Expected: counted cycles exactly equal to the manual count (a correctly mounted door switch gives an exact 1:1 count since the door motion is the load/unload event itself)
Safety notes
Section titled “Safety notes”- de-energize and lock out the lathe (LOTO) before working near the enclosure door and its existing safety interlock to install the monitoring sensor
- mount the monitoring sensor and its cable entirely clear of the door’s safety interlock switch and wiring; never splice into or share a terminal with the safety-rated interlock circuit
- route the monitoring sensor cable so it cannot be pinched or sheared by the door’s full range of travel
30–110 USD, difficulty 2/5, ~30 min install downtime.