Hello, I'm working on an adhesive dispensing project where our application has a cartridge on it that has to be manually filled and does not contain enough to cover the entire part we are utilizing.

I was looking for help to come up with a solution where the program can track the distance traveled by the TCP and call an interrupt that pauses the program so the cartridge may be refilled and then continued until the part has been covered. I am needing to do this programmatically because due to the nature of the project, the distances/speeds between passes may vary as we further develop. Or maybe there is an alternative route that is less complicated.

I am utilizing a KRC4 controller running KSS 8.6.

I've attached a snippet of the code below for reference:

```
DECL REAL passDistance,zCalc1,passRemainder
DECL REAL arcAngle,arcBaseLength,arcHeightLength,maxArcLength,radiusCenterBase,radiusCenterHeight,arcLength
DECL REAL count1,count2,count3,radius1,radius2,pi,sinReturn,cosReturn,cosReturn2,sinReturn2,newX,newZ,rotationAngle
pi=3.14159
radius1=0.25 * 25.4
radius2=24 * 25.4
maxArcLength=0.298 * 25.4
count1=1
count2=1
count3=1
passDistance=3.5
passRemainder=0
arcLength=0
rotationAngle=68.382
;FOLD INI;%{PE}
;FOLD BASISTECH INI
GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS == TRUE DO IR_STOPM()
INTERRUPT ON 3
BAS(#INITMOV, 0)
;ENDFOLD (BASISTECH INI)
;FOLD USER INI
;Make your modifications here
;ENDFOLD (USER INI)
;ENDFOLD (INI)
SPTP XHOME
;OVER PART
SPTP XP8
;APPROACH
SLIN XP2
;PATH START
SLIN XP19
$OUT[1] = TRUE
;FOLD OUTER FLAT
;first pass around the base
SCIRC XP26, XP27
SCIRC XP28, XP29
WHILE XP30.Z < 33.8074 ;while the height is less than the start of the radius
zCalc1=XP30.Z + passDistance ;increase height by pass distance
XP30.Z=zCalc1
XP22.Z=zCalc1
XP23.Z=zCalc1
XP24.Z=zCalc1
XP25.Z=zCalc1
XP26=XP24
XP27=XP23
XP28=XP22
XP29=XP25
IF XP30.Z > 33.8074 THEN ;if height is greater than start of radius, exit while loop
passRemainder=XP30.Z - 33.8074
EXIT
ENDIF
SLIN XP30
IF ((count1 / 2) <> (count1 / 2.0)) THEN ;flip CW/CCW rotations
;odd
SCIRC XP22, XP23
SCIRC XP24, XP25
ELSE
;even
SCIRC XP26, XP27
SCIRC XP28, XP29
ENDIF
count1=count1 + 1
ENDWHILE
;ENDFOLD
;FOLD RADIUS
WHILE arcLength < maxArcLength
IF count2 ==1 THEN ;if first pass on the radius
arcLength=passRemainder ;create arc equal to pass remainder
IF passRemainder > maxArcLength THEN ;if the remaining pass will not land on the radius
count2 = count1
passRemainder = passRemainder - maxArcLength ;remaining distance for top surface
EXIT
ENDIF
arcAngle=(arcLength * 360) / (2 * pi * radius1)
count2 = count1
ELSE ;if not first pass on the radius
arcLength = arcLength + passDistance ;increment arc by pass distance
arcAngle=(arcLength * 360) / (2 * pi * radius1)
ENDIF
sinReturn=SIN(arcAngle)
cosReturn=COS(arcAngle)
arcBaseLength=radius1 * sinReturn
arcHeightLength=radius1 * cosReturn
radiusCenterBase=228.6 - radius1
radiusCenterHeight=33.8074
sinReturn2=SIN(90)
cosReturn2=COS(90)
newX=-1*((arcBaseLength * cosReturn2) - (arcHeightLength * sinReturn2)) ;2d rotation of point around 0,0
newZ=(arcBaseLength * sinReturn2) + (arcHeightLength * cosReturn2) ;2d rotation of point around 0,0
XP1.X=radiusCenterBase + newX ;shift new values to radius center
XP1.Z=radiusCenterHeight + newZ
XP31.Y=-1 * (radiusCenterBase + newX)
XP31.Z=radiusCenterHeight + newZ
XP32.X=-1 * (radiusCenterBase + newX)
XP32.Z=radiusCenterHeight + newZ
XP33.Y=radiusCenterBase + newX
XP33.Z=radiusCenterHeight + newZ
XP34.X=radiusCenterBase + newX
XP34.Z=radiusCenterHeight + newZ
XP36=XP32
XP35=XP33
XP38=XP34
XP37=XP31
IF arcLength > maxArcLength THEN
passRemainder=arcLength - maxArcLength ;remaining distance for top surface
EXIT
ENDIF
SLIN XP1
IF ((count2 / 2) <> (count2 / 2.0)) THEN ;flip CW/CCW rotations
;odd
SCIRC XP31, XP32
SCIRC XP33, XP34
ELSE
;even
SCIRC XP35, XP36
SCIRC XP37, XP38
ENDIF
count2=count2 + 1
ENDWHILE
;ENDFOLD
```

Display More