CNC Services Northwest

Centroid CNC control sales, service, training and support


MPU11 PLC Program Applications

Faults, Errors and Warnings

A Fault is a condition which cancels any program cycles; turns off the spindle, coolant, and other devices; releases servo power; and opens the emergency stop contactor.

Faults should be used for conditions where it could be dangerous or harmful to allow any device to continue to receive power, and where there is little or no need to run any machine components until the problem is resolved.

For example, on a horizontal boring mill with a hydraulic brake release and counter balance cylinder on the Y axis, a tripped overload relay on the hydraulic pump should be a fault, because without hydraulic pressure, it will be impossible to move the axis.

An Error is a condition which cancels any program cycles and turns off the spindle, coolant, and other devices, but which leaves servo power on and does not open the emergency stop contactor. An Error condition does not prevent subsequent use of components not affected by the error. For example, it may be an Error to attempt to start the spindle with the chuck open or tool unclamped, but that would not prevent the operator from jogging the servo axes.

Errors should be used for most abnormal conditions, when there is no immediate hazard presented by leaving power on to the drives and keeping a hydraulic pump running.

A Warning is a condition which requires a message on the screen advising the operator of something abnormal, but which otherwise does not require interrupting operations.

Faults

To implement a fault:

For example, to trigger a fault in case a hydraulic pump trips its overload relay:

In plcmsg.txt:

  42  9042 Hydraulic Motor Overload

In the PLC source:

  ; in Message Definitions:
  HYD_MOTOR_OL         IS 10753;(1+256*42)
  
  ; in Input Definitions:
  HydraulicOk          IS INP36  ; 1 = okay               0 = overload

  ; in MainStage logic:
  IF !HydraulicOk THEN FaultMsg_W = HYD_MOTOR_OL, SET OtherFault_M
  

Existing logic in the standard PLC programs will set SV_STOP in response to OtherFault_M, and will handle resetting the fault with Emergency Stop and clearing the fault message.

Errors

To implement an error:

For example, to trigger an error if there is an attempt to start or run the spindle with the drawbar unclamped:

In plcmsg.txt:

  56  8056 Drawbar is Unclamped

In the PLC source:

  ; in Message Definitions:
  SPIN_DRAWBAR_ERR      IS 14338;(2+256*56)

  ; in Input Definitions:
  ToolClamped           IS INP55  ; 1 = drawbar clamped

  ; in MainStage logic:
  IF SpindleEnableOut && !ToolClamped THEN ErrorMsg_W = SPIN_DRAWBAR_ERR, SET ErrorFlag_M
  

Existing logic in the standard PLC programs will perform a Cycle Cancel in response to ErrorFlag_M, and will turn off the spindle and coolant.

In the example above, the error will be detected one scan of the PLC program after SpindleEnableOut is turned on, and ErrorFlag_M will cause the spindle to be turned off in the next scan after that. Therefore the spindle relay will stay on for approximately 40ms.

If it is not acceptable to turn the spindle on at all with the problem present, the logic can be inserted in the spindle start/stop sequence in JogPanelStage, earlier in the program:

  IF ((SpinStartKey || KbSpinStart_M) && !SpinAutoModeLED) ||
     (SpinAutoModeLED && (M3 || M4) && !SpindlePause_M) ||
     ((SpinStartKey || KbSpinStart_M) && ((M3 || M4) && SpinAutoModeLED))
    THEN (SpinStart_M)

  ; Apply inhibits
  IF SpinStart_M && !ToolClamped
    THEN ErrorMsg_W = SPIN_DRAWBAR_ERR, SET ErrorFlag_M

  IF (SpinStopKey || KbSpinStop_M) ||
     (SpinAutoModeLED && !(M3 || M4)) ||
     (SV_PC_RIGID_TAP_SPINDLE_OFF && SpinAutoModeLED) ||
     ProbeDetect || SV_STOP || ErrorFlag_M || LimitTripped_M
    THEN (SpinStop_M)
  

With this logic, ErrorFlag_M gets set upon any attempt to start the spindle, prior to the checks for spindle-stop conditions (which include ErrorFlag_M).

As a result, the subsequent standard code which reads:

  IF (SpindleEnableOut || SpinStart_M ) && !SpinStop_M
    THEN (SpindleEnableOut)
will see both a start condition and a stop condition. The stop condition overrides the start condition, and the spindle is never turned on.

The only remaining loophole in this example is that it would not detect if the ToolClamped switch were to open while the spindle is already running in Manual spindle mode.

That could be addressed by testing both SpinStart_M and SpindleEnableOut in JogPanelStage:

  ; Apply inhibits
  IF (SpinStart_M || SpindleEnableOut) && !ToolClamped
    THEN ErrorMsg_W = SPIN_DRAWBAR_ERR, SET ErrorFlag_M

It is important that the Error condition you are testing be something that goes away as a result of setting ErrorFlag_M, or be something transient such as a keypress. In the above examples, the error conditions include SpindleEnableOut, which is guaranteed to be turned off in response to the error; and SpinStart_M, which depends on either M3/M4 in Auto mode, which go away when the program cycle is cancelled, or a press of the Spindle Start key in Manual mode, which goes away as soon as the operator releases the key.

If you set an error on a condition which persists even after ErrorFlag_M has been set, then the error message will continuously reappear in the message box every couple seconds.

In this situation, a Warning message with a PD trigger will probably be a more appropriate solution.

Warnings

To implement a warning:

For an example, consider the standard code to display a warning if the way lube level goes low while a program cycle is running (but to refrain from triggering a fault until the program cycle has finished):

In plcmsg.txt:

  52  5052 Warning: Lube Low

In the PLC source:

  ; in Message Definitions:
  LUBE_WARNING_MSG     IS 13314;(2+256*52)

  ; in Input Definitions:
  LubeOk               IS INP9  ;Lube is "ok" when input is closed

  ; in PD (One-Shot) Definitions:
  LowLubePD            IS PD18

  ; in MainStage logic:
  IF !LubeOk THEN (LowLubePD)
  IF LowLubePD && SV_PROGRAM_RUNNING THEN InfoMsg_W = LUBE_WARNING_MSG
  

Spindle Interlock

Generally, spindle interlocks (logic to prevent the spindle from starting or running when there is potential interference or hazard) should be implemented as Error conditions, as shown above.

There are a couple common errors that novice PLC programmers make when attempting to apply a spindle interlock:

  1. Failing to pause or cancel the automatic program cycle. If you prevent the spindle from starting in response to M3 or M4, but do not prevent the program cycle from proceeding, then the machine may run a stopped cutter into the part.
  2. Failing to display an explanatory message. If you block M3/M4 or block manual spindle start, then you must display a message telling the operator why the spindle is failing to start or run.

Cycle Inhibit

Many cycle inhibits should be handled as Error conditions as well.

In some cases, however, it may be desirable to block the action of Cycle Start without otherwise cancelling the program cycle. This can be done by preventing the Cycle Start key (or keyboard equivalent) from asserting the DoCycleStart action. Again, it is critical that you display an explanatory message so the operator knows why Cycle Start is not working.

For example, consider a machine with a protective cover, and a requirement that no automatic program cycle begin with the cover open, and that a cycle in progress pause (but not cancel) if the cover is opened while the cycle is running.

First, we want to prevent the operation of Cycle Start when the cover is open. This will prevent both starting a new cycle, and also resuming out of Feed Hold, with the cover open.

Second, we want to assert Feed Hold if the cover opens while a cycle is running.

In plcmsg.txt:

  57  5057 Cover is Open

In the PLC source:

  ; in Message Definitions:
  COVER_WARNING_MSG    IS 14594;(2+256*57)

  ; in Input Definitions:
  CoverClosed          IS INP14 ;  1 = closed                 0 = not closed

  ; in Memory Definitions:
  StartRequest_M       IS MEM88 ;  1 = Cycle Start pressed    0 = idle

  ; in PD (One-Shot) Definitions:
  CoverOpenPD          IS PD56  ;  1 = Cover just opened

  ; in JogPanelStage logic:
  IF (CycleStartKey  || KbCycleStart_M) THEN (DoCycleStart)
  IF (CycleStartKey  || KbCycleStart_M) THEN (StartRequest_M)
  IF StartRequest_M && CoverClosed THEN (DoCycleStart)

  IF !CoverClosed THEN (CoverOpenPD)
  IF SV_PROGRAM_RUNNING && CoverOpenPD || StartRequest_M && !CoverClosed
    THEN InfoMsg_W = COVER_WARNING_MSG
  

Note that the warning message condition is based on two transient conditions, and not on a persistent condition. The message will be displayed (or re-displayed) if the cover goes from closed to open while a cycle is active, or when the Cycle Start button is pressed while the cover is open.

If we had omitted the PD and instead written something like this:

  IF SV_PROGRAM_RUNNING && !CoverClosed || StartRequest_M && !CoverClosed
    THEN InfoMsg_W = COVER_WARNING_MSG
  
then the message would continuously redisplay every few seconds as long as the cover remained open during a program cycle.

Remote Cycle Start and Feed Hold

Remote buttons which are equivalent to standard jog panel buttons are very easy to program in MPU11 systems. Each such function has a line or two in JogPanelStage, combining the jog panel key and keyboard equivalent and asserting a request to the MPU11 controller. You need only add your button input to that combination.

For example, consider a lathe with Start and Pause (Feed Hold) buttons on the apron panel, which are to be accepted as equivalents to the jog panel buttons in all circumstances:

  ; in Input Definitions:
  ApronCycleStartButton IS INP44  ;
  ApronFeedHoldButton   IS INP45  ;

  ; in JogPanelStage logic:
  IF (FeedHoldKey || KbFeedHold_M) THEN (FeedHoldPD)
  IF (FeedHoldKey || ApronFeedHoldButton || KbFeedHold_M) THEN (FeedHoldPD)
  ; ... additional standard code to manage FeedHoldLED and DoFeedHold ...

  IF (CycleStartKey  || KbCycleStart_M) THEN (DoCycleStart)
  IF (CycleStartKey || ApronCycleStartButton || KbCycleStart_M) THEN (DoCycleStart)
  

Complex Device Sequencing

Devices such as tool changers, gear shifters, and pallet changers usually require step-by-step sequencing to perform their functions. This can be programmed in a variety of ways.

I find that breaking down the sequence into discrete steps, and defining a PLC program Stage for each step, provides a clear structure. Clear structure, with clearly defined entry and exit conditions and with clearly delineated responsibilities, improves readability, reliability and maintainability.

For an example of this approach, see Twin Turret Lathe PLC Programming.

Using Integer Arithmetic and Modulo for Wraparound

When monitoring the position of a tool turret or spindle encoder, it is usually necessary to ignore whole turns and calculate the position of the device within the turn that it is in.

This can be done using modulo arithmetic. For an example of this type of calculation, and a discussion of positive/negative value issues, see Integer Divide and Modulo.

PLC Program for Mills and Machining Centers with Oak-based controls

This is a full-featured PLC program, supporting mills with typical umbrella or swing-arm type tool changers, and optionally including many common optional systems.

Oak Unified PLC Program


CNC Services Northwest Home

Copyright © 2017 Marc Leonard
Last updated 31-Oct-2017 MBL