@Sebastien since turning an output on or off does not require any move time the system executes the command and blows right past it pretty dang fast, we actually have to add small amounts of sleep when using pneumatic grippers to give them the 50-70 ms they need to close before motion starts. I would think that you would be perfectly fine with a TO[0]=ON right before the move starts and a TO[0]=OFF right after the move stops, especially the off, what I have found in using the is_steady() is it takes a moment after a move for the robot to return true, depending on how fast you are moving and decelerate.
If you think about it you set a flag after the moves, that same time slice which is setting the flag condition could just be used to set the valve on and off and with fewer calls to the API.
Have you tried just putting the actions in-line with the moves?
Program
BeforeStart
isMoving≔ False
isRobotRdy≔ False
Robot Program
MoveL
Home_pos
paint_start
Set TO[0]=On
MoveP
paint_stop
Set TO[0]=Off
Program
BeforeStart
isMoving≔ False
isRobotRdy≔ False
Robot Program
MoveL
Home_pos
paint_start
Set TO[0]=On
MoveP
paint_stop
Set TO[0]=Off
Hi Pros,
we have been working on a paint application where you need precise start and stop positions of a painting application. The paint gun is triggered using a pneumatic 24VDC valve. On Fanuc robot you are allowed to add a motion line that can trigger a digital IO within the motion line. So as the robot starts moving the gun would start. This option is not available on UR Robots. There are probably a couple ways of doing this. First I thought of triggering the IO for the gun just before the motion line but I was afraid it would create a little spill of paint at the beginning. So I tried to find a way to trigger the paint gun as the robot starts moving. So what I did, is that I used a thread that would monitor the value returned by the script function is_steady(). Then based on whether I am in the paint motion or not I would trigger the valve. Because of the infinite loop error that I had when I tried to run the program, I had to add a wait command in the thread but I kept it very slow. Since the thread is looping at 0.008s I believe that there will be some inconsistencies in the paint start and stop positions that will depend on the actual robot speed. This is the way I thought of doing it. Do you guys have any suggestions?
Here is the code and video. In the video you see a green light on the valve when it is being actuated. More tests on this to come!
Program
BeforeStart
isMoving≔ False
isRobotRdy≔ False
Robot Program
MoveL
Home_pos
paint_start
isRobotRdy≔ True
MoveP
paint_stop
isRobotRdy≔ False
Thread_1
isMoving≔ not is_steady()
If isRobotRdy and isMoving
Set TO[0]=On
Else
Set TO[0]=Off
Wait: 0.001