jonfarrugia
Member
I’m trying to write a program that calculates OEE. However, When I run the code I get stack errors. I’m pretty sure it’s because some calculation could be dividing by zero. How do you deal with math functions that could be dividing by zero?
I've attached the exported code
VAR
Availability: REAL; (*Total Time the Line/Cell is available to run production in minutes*)
Downtime: REAL; (*Total Time the Line/Cell is down not making parts in minutes*)
Total_Parts: DINT; (*Total parts processed. Including passed and failed parts*)
Good_Parts: DINT; (*Total parts passed*)
Ideal_Run_Rate_per_min: REAL; (*Ideal Parts per minute rate. This is an expected value i.e. 5 parts required per minute.*)
(*output values are all in percentage*)
Oee_Availability: REAL;
Oee_Performance: REAL;
Oee_Quality: REAL;
Oee_Overall: REAL;
END_VAR
Oee_Availability:=((Availability-Downtime)/Availability)*100;
Oee_Performance:=((Total_Parts/(Availability-Downtime))/Ideal_Run_Rate_per_min)*100;
IF Oee_Performance>100 THEN
Oee_Performance:=100;
END_IF
Oee_Quality:=(Good_Parts/Total_Parts)*100;
Oee_Overall:=(Oee_Availability*Oee_Performance*Oee_Quality)/10000;
I've attached the exported code
VAR
Availability: REAL; (*Total Time the Line/Cell is available to run production in minutes*)
Downtime: REAL; (*Total Time the Line/Cell is down not making parts in minutes*)
Total_Parts: DINT; (*Total parts processed. Including passed and failed parts*)
Good_Parts: DINT; (*Total parts passed*)
Ideal_Run_Rate_per_min: REAL; (*Ideal Parts per minute rate. This is an expected value i.e. 5 parts required per minute.*)
(*output values are all in percentage*)
Oee_Availability: REAL;
Oee_Performance: REAL;
Oee_Quality: REAL;
Oee_Overall: REAL;
END_VAR
Oee_Availability:=((Availability-Downtime)/Availability)*100;
Oee_Performance:=((Total_Parts/(Availability-Downtime))/Ideal_Run_Rate_per_min)*100;
IF Oee_Performance>100 THEN
Oee_Performance:=100;
END_IF
Oee_Quality:=(Good_Parts/Total_Parts)*100;
Oee_Overall:=(Oee_Availability*Oee_Performance*Oee_Quality)/10000;