Hi,
Need to know the best way to accomplish the following function:
*CRX-robot (with Mini Plus controller)
*Robot performs a slow linear motion over a relative large distance
*Robot is in Local mode (as opposed to Remote -controlled through UOP)
I would like to, at the push of a button (connected to a DI in the controller), abort the current motion and call a homing routine.
This cannot be done with a Macro (Motion Group is already locked by another task), nor with a Monitor/Condition solution.
I don't want to split the motion up into smaller increments, and check for this button to be pushed after each motion instruction (too much coding and not a general solution).
Is my only choice to switch over to Remote and start using additional push buttons for Start and Stop functions?
I'm thinking that this "abort and go to home"-button will be used in a BG-logic program something like this:
[PSEUDO CODE]
! Check Sequence Step
IF (R[1: Step #] < 10) OR (R[1: Step #] > 80), R[1: Step #] = 10
! Check if Sequece is running
IF R[1: Step #] > 10, F[100: Sequence is running] = ON
! Jump to current step in the sequence
JMP LBL[R[1: Step #]]
! Step 10: Stop prg?
LBL[10]
IF DI[1: Abort and go Home] AND F[23: UO 3 PRG RUNNING] THEN
F[4: UI 4 STOP] = ON
R[1: Step #] = R[1: Step #] + 10
R[2: Counter/Timer] = 0
ENDIF
JMP LBL[999]
! Step 20: Wait a few cycles
LBL[20]
R[2: Counter/Timer] = R[2: Counter/Timer] + 1
! Use a counter that increments for n cycles to measure that a time has passed
IF R[2: Counter/Timer] > n THEN
R[1: Step #] = R[1: Step #] + 10
R[2: Counter/Timer] = 0
ENDIF
JMP LBL[999]
! Step 30: Wait for prg to be stopped
LBL[30]
IF !F[23: UO 3 PRG RUNNING) THEN
F[6: UI 6 START] = ON
R[1: Step #] = R[1: Step #] + 10
ENDIF
JMP LBL[999]
! Step 40: Wait a few cycles
R[2: Counter/Timer] = R[2: Counter/Timer] + 1
! Use a counter that increments for n cycles to measure that a time has passed
IF R[2: Counter/Timer] > n THEN
R[1: Step #] = R[1: Step #] + 10
R[2: Counter/Timer] = 0
ENDIF
JMP LBL[999]
! Step 50: Try to restart from Main
F[6: UI 6 START] = OFF
R[1: Step #] = R[1: Step #] + 10
JMP LBL[999]
! Step 60: Check if running again
LBL[60]
R[2: Counter/Timer] = R[2: Counter/Timer] + 1
! Use a counter that increments for n cycles to measure that a time has passed
IF F[23: UO 3 PRG RUNNING) THEN
! Program is running (from Main) again, SUCCESS!
R[2: Counter/Timer] = 0
R[1: Step #] = 10
F[100: Sequence is running] = OFF
ENDIF
IF R[2: Counter/Timer] > n THEN
R[1: Step #] = R[1: Step #] + 10
R[2: Counter/Timer] = 0
ENDIF
! Step 70: Prg not running, try to reset
LBL[70]
F[5: UI 5 RESET] = ON
R[1: Step #] = R[1: Step #] + 10
JMP LBL[999]
! Step 80: Wait a few cycles
R[2: Counter/Timer] = R[2: Counter/Timer] + 1
! Use a counter that increments for n cycles to measure that a time has passed
IF R[2: Counter/Timer] > n THEN
! Try the start procedure again
R[1: Step #] = 30
R[2: Counter/Timer] = 0
ENDIF
JMP LBL[999]
LBL[999]
END
Display More
Basically a simple sequence for getting the timing for the UOP signals correct in order to first abort the running program and then initiate the main program with the start signal. If needed, perform a reset before trying to start.
I will set the CSTOPI for ABORT = TRUE
and START for CONTINUE only = FALSE
in the SYSTEM CONFIG MENU.
Also I will make the required mapping of Flags to the correct UO/UI signals
I will also make another BG Logic program where I monitor the pushbuttons mapped to the UI-signals and disregard these if the sequence is running:
IF !F[100: Sequence is running] THEN
F[4: UI 4 STOP] = DI[4: UI 4 STOP]
F[5: UI 5 RESET] = DI[5: UI 5 RESET]
F[6: UI 6 START] = DI[6: UI 6 START]
ENDIF
END
What do you think?
Is there a better/easier way to accomplish my desired functionality?