If you post the FB code maybe someone can figure out why it is stalling.
// Code is here
StepNum := real_to_int (((int_to_real (Z2) / 100.0 * dint_to_real (ZPPI)) - dint_to_real (ZPosPulses)) / (int_to_real (StepDistanceIn) / 100.0 * dint_to_real (ZPPI)));
If StepNum = 0 Then
StepDistancePulses := 0;
StepDistanceOut := 0;
Else
StepDistancePulses := real_to_dint (((int_to_real (Z2) / 100.0 * dint_to_real (ZPPI)) - dint_to_real (ZPosPulses)) / int_to_real (StepNum));
(
StepDistanceOut := real_to_int (dint_to_real (StepDistancePulses) / dint_to_real (ZPPI) * 1000.0);
End_If;
Rminor := int_to_real (Dminor) / 2.0 / 100.0;
AngleR := int_to_Real(Angle);
If DMajor = 0 Then
Rmajor := Rminor;
Else
Rmajor := int_to_real (DMajor) / 2.0 / 100.0;
End_If;
If StraightDist = 0 Then
ZOffset := Sqrt (Expt(Rmajor,2) - Expt(Rminor,2));
Repeat
X1 := (Cos(AngleR * 3.141592654 / 180.0) * ZOffset - Sqrt(Expt(Rminor,2) + Expt(ZOffset,2) - Expt(Rmajor,2))) / Sin(AngleR * 3.141592654 / 180.0);
If X1 > Rminor Then
ZOffset := ZOffset + 0.01;
End_if;
Until Abs(X1) < Rminor
End_Repeat;
ZOffset := ZOffset + (int_to_real(ZPosIn) / 100.0);
Repeat
X1 := (Cos(AngleR * 3.141592654 / 180.0) * ZOffset - Sqrt(Expt(Rminor,2) + Expt(ZOffset,2) - Expt(Rmajor,2))) / Sin(AngleR * 3.141592654 / 180.0);
If X1 < -Rminor Then
ZOffset := ZOffset - 0.01;
End_if;
Until Abs(X1) < Rminor
End_Repeat;
Inrsec1 := 1800 - Real_to_Int(ACos(X1/Rminor) * 180.0 / 3.14159265 * 10.0) + Offset;
Inrsec2 := 1800 + Real_to_Int(ACos(X1/Rminor) * 180.0 / 3.14159265 * 10.0) + Offset;
X2 := (Cos(AngleR * 3.141592654 / 180.0) * (ZOffset + ZValue) + Sqrt(Expt(Rminor,2) + Expt(ZOffset + ZValue,2) - Expt(Rmajor,2))) / Sin(AngleR * 3.141592654 / 180.0);
If X2 > Rminor Then
SingleMode := true;
Inrsec3 := 0;
Inrsec4 := 0;
Else
SingleMode := false;
Inrsec3 := 1800 - Real_to_Int(ACos(X2/Rminor) * 180.0 / 3.14159265 * 10.0) + Offset;
Inrsec4 := 1800 + Real_to_Int(ACos(X2/Rminor) * 180.0 / 3.14159265 * 10.0) + Offset;
End_If;
If Inrsec1 = Inrsec3 Then
Inrsec1 := Inrsec1 - 10;
Inrsec2 := Inrsec2 + 10;
Inrsec3 := Inrsec3 + 10;
Inrsec4 := Inrsec4 - 10;
End_If;
Else
Distance := SQRT(EXPT(Rmajor,2) - EXPT(Rmajor - (int_to_real(Z2 - ZPosIn) / 100.0),2));
SingleMode := false;
Num := (int_to_real (StraightDist) / 100.0 / 2.0) + Distance;
If Num > Rminor Then
Num := Rminor;
End_if;
InrsecAngle := Real_to_Int (ACOS(Num / Rminor) * 180.0 / 3.1415 * 10.0);
If InrsecAngle = 0 or Distance = 0.0 Then
InrsecAngle := 1;
End_If;
Inrsec1 := (900 - InrsecAngle) + Offset;
Inrsec2 := (2700 + InrsecAngle) + Offset;
Inrsec3 := (900 + InrsecAngle) + Offset;
Inrsec4 := (2700 - InrsecAngle) + Offset;
End_If;
If Direction = 0 or Direction = 3 then
(*Calculate the rotational target positions in pulses*)
Angle1DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec1 - (Offset * 2)) / 3600.0 * dint_to_lreal (APPR)));
Angle2DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec2 - (Offset * 2)) / 3600.0 * dint_to_lreal (APPR)));
Angle3DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec3 - (Offset * 2)) / 3600.0 * dint_to_lreal (APPR)));
Angle4DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec4 - (Offset * 2)) / 3600.0 * dint_to_lreal (APPR)));
Else
Angle1DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec1) / 3600.0 * dint_to_lreal (APPR)));
Angle2DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec2) / 3600.0 * dint_to_lreal (APPR)));
Angle3DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec3) / 3600.0 * dint_to_lreal (APPR)));
Angle4DistPulses := lreal_to_dint ((int_to_lreal (StepCompleted) * dint_to_lreal (APPR)) + (Int_to_lreal (Inrsec4) / 3600.0 * dint_to_lreal (APPR)));
End_If;
ZeroDistPulses := lreal_to_dint (int_to_lreal (StepCompleted + 1) * dint_to_lreal (APPR));
AVC1LockMin := Inrsec1 + 20;
AVC1LockMax := Inrsec2 - 20;
AVC2LockMin := Inrsec3 - 20;
AVC2LockMax := Inrsec4 + 20;
the PLC goes into Err HH, Error code 809F everytime this block is activated, picture attached.
I will try to move this function to a task of itself. However I will look if all the calculations are permitted, it seems weird to me that this calculations would overcycle the PLC, it being a CJ2M-CPU35. Plus we've designed many machines with this function block and as far as I know only two are showing this behavior.