Remark 4: Reaction on floating point exceptions

As of firmware version V1.2.0 of the AC500 CPUs and Control Builder version V1.2, the behavior of the CPUs PM59x regarding floating point exceptions can be set. In standard case, any floating point exception triggers an E2 error: class=E2, err=38, d1=9, d2=31, d3=31.

The CPU goes to STOP.

CPUs without floating point processor PM57x and PM59x do not trigger a floating point exception.

If the parameter “Reaction on floating point exceptions” is set to “No failure”, no error is triggered in case of a floating point exception. The CPU remains in RUN mode.

By means of the function block FPU_EXCEPTION_INFO FPU_EXCEPTION_INFO (contained in SysInt_AC500_V10.lib) it can be determined whether a floating point exception occurred during calculation. Depending on the result, either the calculation can be continued with default values or the machine can be shut down.

Program example:

PROGRAM PLC_PRG
VAR
  FPUEXINFO1 : FPU_EXINFO;
  rV1 : REAL := -1.0;
  rV2 : REAL;
  bError : BOOL;
  bWarning : BOOL;
END_VAR
bWarning := bError := FALSE;
rV2 := SQRT(rV1); (* floating point calculation *)
FPUEXINFO1(); (* check for exception occurred *)
IF FPUEXINFO1.ERR THEN  
  (* evaluation of exception *)
  (* for example, shut down system, continue calculation with default values or corrected values *)
  rV1 := 1.0;
  bWarning := TRUE;
  (* same calculation with corrected values *)
  rV2 := SQRT(rV1);
  FPUEXINFO1(); (* recheck.. *)
  IF FPUEXINFO1.ERR = TRUE THEN
  bError := TRUE;
  END_IF
END_IF
(* here, for example, evaluation of bWarning, bError.. *)