Hi guys!
I came accross an application I have to develop, where the customer wants me to securely count parts incoming from a pair of conveyors, if the part has to be counted ...
I currently have 2 counters, one per conveyor. The way I implemented them as of today is done in the sps.sub, with a tweak to monitor only a rising edge, like this :
// $CONFIG.DAT
...
DECL BOOL bInBufferCnv3 = FALSE
DECL BOOL bInBufferCnv4 = FALSE
DECL BOOL bCountBuffer3Active = ((NOT DryRun) AND ($AUT OR $EXT) AND (NOT InCnv3Trash))
DECL BOOL bCountBuffer4Active = ((NOT DryRun) AND ($AUT OR $EXT) AND (NOT InCnv4Trash))
SIGNAL InBufferCnv3 $IN[34]
SIGNAL InBufferCnv4 $IN[35]
...
//SPS.SUB
...
IF (InBufferCnv3 AND bCountBuffer3Active AND NOT bInBufferCnv3) THEN
CntPatrsBuffer3 = CntPatrsBuffer3 + 1
ENDIF
bInBufferCnv3 = InBufferCnv3
IF (InBufferCnv4 AND bCountBuffer4Active AND NOT bInBufferCnv4) THEN
CntPatrsBuffer4 = CntPatrsBuffer4 + 1
ENDIF
bInBufferCnv4 = InBufferCnv4
...
Display More
My issue is: will this work as inteded and is this the best, optimal way of counting rising edges ?
I am not really used to throw a whole lot of stuff in the SPS.SUB (these counters are a tiny bit of the stuff I have to implement in there, mostly using IF and SWITCH statements, and I do not know the effects of overcrowding it.
I remember reading somewhere here that interrupts are triggered rising (==TRUE) or falling (==FALSE) edges, so I imagined this:
DEF PGM.SRC ()
...
$CYCFLAG[1] = ((NOT DryRun) AND ($AUT OR $EXT) AND (NOT InCnv3Trash))
$CYCFLAG[2] = ((NOT DryRun) AND ($AUT OR $EXT) AND (NOT InCnv4Trash))
INTERRUPT DECL 19 WHEN $CYCFLAG[1] DO IR_CntBuffer3() PRIO=-1
INTERRUPT ON 19
INTERRUPT DECL 20 WHEN $CYCFLAG[2] DO IR_CntBuffer4() PRIO=-1
INTERRUPT ON 20
...
END
DEF IR_CountBuffer3()
INTERRUPT OFF 19
CntPatrsBuffer3 = CntPatrsBuffer3 + 1
INTERRUPT ON 19
END
DEF IR_CountBuffer4()
INTERRUPT OFF 20
CntPatrsBuffer4 = CntPatrsBuffer4 + 1
INTERRUPT ON 20
END
Display More
I do not have nor a robot nor a working KUKA.Sim + OL handy to test for the next few days, but I'm starting the base layout of my application and wanted to address this issue.
Thanks a lot for your time and help guys!
Robot information : KUKA KR 210L180-2 // KR C2ed05 // KSS 5.6.14