Hey guys,
I am having some issues with my PLC controlled queue system. In this cell I will have to control a 3 - station queue, I believe that all my logic is setup correctly however I am not able to generate a value for any of my Clocks after stopping them and reading them, The main program is executing past getTime and getPart calls and stopping at the WaitDI, however no clock values are being generated and pickupPart1 is not being executed. Here is the background and main modules :
MODULE MainBackground
VAR clock clockS1;
VAR clock clockS2;
VAR clock clockS3;
PERS bool clockS1_On := TRUE;
PERS bool clockS2_On := False;
PERS bool clockS3_On := False;
PROC main()
! main queue logic
LOOP:
IF Call_Get_P1 = 1 THEN
ClkReset clockS1;
ClkStart clockS1;
clockS1_On := True;
ELSEIF Call_Get_P2 = 1 THEN
ClkReset clockS2;
ClkStart clockS2;
clockS2_on := True;
ELSEIF Call_Get_P3 = 1 THEN
ClkReset clockS3;
ClkStart clockS3;
clockS3_On := True;
ENDIF
WaitDI Weld_Completed, 1;
GOTO LOOP;
ENDPROC
ENDMODULE
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MODULE MainModule
VAR clock clockS1;
VAR clock clockS2;
VAR clock clockS3;
VAR num timeS1;
VAR num timeS2;
VAR num timeS3;
PERS bool clockS1_On;
PERS bool clockS2_On;
PERS bool clockS3_On;
VAR num pickedPart := 0;
VAR wzstationary home;
CONST jointtarget jhome:=[[0.0,-31.1,34.7,0.1,77.9,0.9],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PROC power_on()
VAR shapedata joint_space;
CONST jointtarget home_pos := [ [ 0.0, -31.1, 34.7, 0.1, 77.9, 0.9], [ 9E9, 9E9,
9E9, 9E9, 9E9, 9E9] ];
CONST jointtarget delta_pos := [ [ 2, 2, 2, 2, 2, 2], [ 9E9, 9E9,
9E9, 9E9, 9E9, 9E9] ];
WZHomeJointDef \Inside, joint_space, home_pos, delta_pos;
WZDOSet \Stat, home \Inside, joint_space, DO_Home_7600, 1;
ENDPROC
PROC goHome()
MoveAbsJ jhome\NoEOffs, v200, fine, tool0;
ENDPROC
PROC getTime()
IF clockS1_On = True THEN
ClkStop clockS1;
timeS1 := ClkRead(clockS1);
ELSE
GOTO CLOCK2;
ENDIF
CLOCK2:
IF clockS2_On = True THEN
ClkStop clockS2;
timeS2 := ClkRead(clockS2);
ELSE
GOTO CLOCK3;
ENDIF
CLOCK3:
IF clockS3_on = True THEN
ClkStop clockS3;
timeS3 := ClkRead(clockS3);
ELSE
ENDIF
ENDPROC
PROC getPart()
IF timeS1 > timeS2 and timeS1 > timeS3 THEN
pickupPart1;
ELSEIF timeS2 > timeS1 and timeS2 > timeS3 THEN
pickupPart2;
ELSEIF timeS3 > timeS1 and timeS3 > timeS2 THEN
pickupPart3;
ENDIF
ENDPROC
PROC returnPart()
IF pickedPart = 1 and CheckP1_Present = 0 THEN
returnPart1;
ELSEIF pickedPart = 2 and CheckP2_Present = 0 THEN
returnPart2;
ELSEIF pickedPart = 3 and CheckP3_present = 0 THEN
ENDIF
ENDPROC
PROC pickupPart1()
pickedPart := 1;
IF CheckP1_Present = 1 THEN
MoveAbsJ [[39.8306,-33.2508,38.5093,-1.33887,71.6301,10.533],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]\NoEOffs, v200, z50, tool0;
goHome;
ENDIF
ENDPROC
PROC pickupPart2()
pickedPart := 2;
ENDPROC
PROC pickupPart3()
pickedPart := 3;
ENDPROC
PROC returnPart1()
MoveAbsJ [[39.8306,-33.2508,38.5093,-1.33879,71.6301,10.533],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]\NoEOffs, v200, z50, tool0;
goHome;
ENDPROC
PROC returnPart2()
<SMT>
ENDPROC
PROC returnPart3()
<SMT>
ENDPROC
PROC main()
IDLE: WaitUntil clockS1_on = True OR clockS2_on = True OR clockS3_on = True;
REPEAT:
WaitDI Weld_In_Process, 0;
WaitUntil clockS1_on = True OR clockS2_on = True OR clockS3_on = True;
getTime;
getPart;
WaitDI Weld_Completed, 1;
ReturnPart;
IF
clockS1_on = True OR clockS2_on = True OR clockS3_on = True THEN
GOTO REPEAT;
ELSE
GOTO IDLE;
ENDIF
ENDPROC
ENDMODULE