Automatically path correction with ultrasonic sensor

Dear all,
I would like to cut a square with an ABB ROBOT using a blade as tool.
I have a sensor (ultrasonic sensor) to check if the blade touch the material to cut.
I would like to know if it’s possible to do automatic offset while triming if the sensor don’t touch the material

PERS tooldata tPen := [ TRUE, [[200, 0, 30], [1, 0, 0 ,0]], [0.8,[62, 0, 17], [1, 0, 0, 0], 0, 0, 0]];
CONST robtarget p10 := [ [600, -100, 800], [0.707170, 0, 0.707170,0], [0, 0, 0, 0], [ 9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST robtarget p20 := [ [600, 100, 800], [0.707170, 0, 0.707170,0], [0, 0, 0, 0], [ 9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST robtarget p30 := [ [800, 100, 800], [0.707170, 0, 0.707170,0], [0, 0, 0, 0], [ 9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST robtarget p40 := [ [800, -100, 800], [0.707170, 0, 0.707170,0], [0, 0, 0, 0], [ 9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];

PROC main() MoveL p10, v200, fine, tPen;
MoveL p20, v200, fine, tPen;
MoveL p30, v200, fine, tPen;
MoveL p40, v200, fine, tPen;
MoveL p10, v200, fine, tPen;
ENDPROC

Is it possible to do interrupt each 5Hz to test if sensor is On or Off to adjust the trajectory ?
Thank you in advance for help.
Regards,
Naturlight

Look into using Corr. Or, a cheap and dirty version which mocks Corr could be dynamically creating a bunch of targets between two points and then correcting at each position in a simple move instruction.

Thank you for answer.

So if i write something like this (one sensor)
Could you help to manage the trap to automatically change the offset ?


num TARGET_DIST := 5;
CONST num SCALE_FACTOR := 0.5;

VAR intnum intno1;
VAR corrdescr hori_id;
VAR pos total_offset;
VAR pos write_offset;

VAR bool conFlag;

PROC PathRoutine()

! Connect to the correction generators for horizontal correction.
CorrCon hori_id;
conFlag := TRUE;

CONNECT intno1 WITH ReadSensors;

ITimer\Single, 0.2, intno1;

MoveJ p10, v100, z10, tool1;

! Run MoveL with both vertical and horizontal correction.

MoveL p20, v100, z10, tool1 \Corr;

! Read the total corrections added by all connected correction generators.

total_offset := CorrRead();

! Run MoveL with only horizontal interrupt correction.

MoveL p30, v100, fine, tool1 \Corr;

CorrClear;

! Remove the timer interrupt.

IDelete intno1;

ENDPROC

TRAP ReadSensors

VAR num horiSig;

! Compute the horizontal correction values and execute the correction.

## IF SENSOR DONT DETECT THE EDGE OF THE GLASS MOVE OFFSET IN THE Y DIRECTION ? how to manage it

horiSig := hori_sig;
write_offset.x := 0;
write_offset.y := (hori_sig - TARGET_DIST)*SCALE_FACTOR;
write_offset.z := 0;

CorrWrite hori_id, write_offset;

!Setup interrupt again

IDelete intnol;

CONNECT intno1 WITH ReadSensors;

ITimer\single, 0.2, intno1;

ENDTRAP

Not sure of your question… Your code looks good.