CELL.src:
LOOP
P00 (#EXT_PGNO,#PGNO_GET,DMY[],0 )
Then, P00:
CASE 3
;*******************
IF PGNO>0 THEN
WAIT FOR $IN[PGNO_FBIT+PGNO-1]==FALSE
ENDIF
K=0
REPEAT
FOR I=0 TO PGNO_LENGTH-1
IF $IN[PGNO_FBIT+I] THEN
IF K==0 THEN
K=I+1
ELSE
PGNO_ERROR=0
K=0
ENDIF
ENDIF
ENDFOR
UNTIL ((K<>0) OR (PGNO_ERROR==0))
PGNO=K
ENDSWITCH
Display More
Here, P00 waits until $IN[33] is cleared. But then it immediately runs through the rest of the code, and ends up with K=0 and PGNO_ERROR=0. It returns these values back to CELL.src
Then back in CELL.src:
LOOP
P00 (#EXT_PGNO,#PGNO_GET,DMY[],0 )
SWITCH PGNO ; Select with Programnumber
CASE 1
P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
BasicLoop() ; Call User-Program
CASE 2
P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
;EXAMPLE2 ( ) ; Call User-Program
CASE 3
P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
;EXAMPLE3 ( ) ; Call User-Program
DEFAULT
P00 (#EXT_PGNO,#PGNO_FAULT,DMY[],0 )
ENDSWITCH
ENDLOOP
Display More
The DEFAULT case is selected, which is the #PGNO_FAULT in P00:
CASE #PGNO_FAULT
.
.
.
.
IF PGNO_ERROR==0 THEN
IF (PGNO_TYPE==3) THEN
MsgQuit("ProgNumberWrong", "P00")
ELSE
MsgQuit("ProgramNotAvailable", "P00", PGNO)
ENDIF
...
Display More
This generates the "Incorrect program number" (i.e. "ProgramNumberWrong").
I can clear the message and it keeps popping up until after I resend PGNO bits, and PGNO>=1. Then it disappears. The motion program runs. Then, "Wait for not Input 33" shows up. Then, the bits are cleared, then "Incorrect program number" pops up. Then, I resend PGNO bits, and so on.
It's not a showstopper, but I would like to get rid of the "Incorrect program number" popup because it's a bit silly why it pops up, now that I understand the code.
I was wondering if I can fix this by assigning an input which I turn on from PLC after resending PGNO bits. Then, in P00 I can add a WAIT FOR this input to turn on:
CASE 3
;*******************
IF PGNO>0 THEN
WAIT FOR $IN[PGNO_FBIT+PGNO-1]==FALSE
ENDIF
WAIT FOR $IN[PGNObitsON from PLC]==TRUE
K=0
REPEAT
FOR I=0 TO PGNO_LENGTH-1
IF $IN[PGNO_FBIT+I] THEN
IF K==0 THEN
K=I+1
ELSE
PGNO_ERROR=0
K=0
ENDIF
ENDIF
ENDFOR
UNTIL ((K<>0) OR (PGNO_ERROR==0))
PGNO=K
ENDSWITCH
Display More
This way, the code doesn't process K until new bits are available. Would this work?