Detection sparks during machining