Edit:
While not ideal, I was able to get the desired behavior by having the outer-most construct of my sub-Program to be an IF-ELIF statement, both clauses being “continuously checked”.
It would be nice to have the ability to perform an early return from a sub-Program.
Hey all,
I’m looking for some help on a UR10e project that interfaces with a PLC. The PLC is controlling the state of the robot’s environment; e.g. cylinder positions, object positions, etc. Therefore, I wanted the PLC to be the source that initiates/terminates robot motion commands.
I often use a control structure with an ENUM/INT that signifies the type of “Operation” I want a piece of equipment to execute. For example, in both my PLC and UR I have a DINT “Operation” where the PLC commands the UR to execute an “Operation” (“Move to Home” Sub-Program). In my main “Robot Program”, I use an IF-ELIF-THEN or SWITCH statement to call the appropriate sub-program exactly once based on the commanded “Operation”.
The UR-PLC communication is handled via PROFINET and a Thread that cyclically calls a URScript. The URScript maps the PROFINET Inputs/Outputs to/from “Installation” variables and does other process control logic.
Everything works great, until I want to satisfy my “OP_CANCEL_OP” operation, which is to stop motion if and only if an “Operation” (e.g. sub-Program) is already running, but should maintain the UR main “Robot Program” in a running state.
Initially, I just used my central URScript to call stopj(a=2), but I received the error that “Robot motion is being controlled from another Thread” and my program left the running state.
I then tried to use a continuous IF check in main “Robot Program”, but that didn’t seem to truly be continuously checked once a sub-Program had been called.
Finally, I tried to put a continuous IF check in the last operation of a sub-Program, in the hopes that when it evaluated to True, it would preempt the above logic of the sub-Program. This also didn’t seem to help.
Any assistance or perspective on this would be appreciated.
V/R,
Adam H.