Wait command not allowed in Threads?

Is there a trick to using Wait commands within a thread, or do they just not work?

I’m activating an air cylinder in a gaging application. – see my previous thread on this: Machine Tending strategy - #13 by dpeva

Since I’ll be activating the gage cycle while the robot is placing the previously measured part on a rack, I need this gage cycle to be within a thread.

I need to advance the cylinder in a few stages, increasing the pressure at each stage, then read the gage value. This requires pauses at each stage of this process.

I’ve created a simple test program to prove out this part of the process:

image

The wait on line 9 is apparently necessary, otherwise the thread never recognizes that Gage_trigger has become true.

The wait on line 20 seems to kill the thread - if I turn it off, the rest of the commands work fine. Doesn’t seem to matter how long the wait is - I’ll actually need several 1 ~ 2 second pauses.

edit: I’ve moved the sync() command outside of the If statement, which seems to have gotten rid of the C271A1 error, but doesn’t keep the wait command from killing the thread - if I move the wait command, it runs everything up until that point but nothing after.

Any thoughts?

. . .

And to make this even more interesting, I forgot that Thread_1, which is turned off in the above config, is almost identical (controls a different cylinder), and it works fine!

Here’s the current setup -

image

Thread_1 works fine with 2 Wait commands, but Thread_3 will stop at the Wait command (line 21). If I move it up or down it still stops at that point. If I suppress that Wait, it works, but of course without the desired wait.

Hi @dpeva,

I think you have enabled “Check expression continuously” that will create a new thread that will be killed if “Gage_trigger” changes to something different from “True”. The popup seems to affect it in the moment that the popup call is made.
As long as you only have a sync() the evaluation will me made extremely fast and will let your if scope run to the end every time it is started.

Ebbe

@Ebbe

The “Check expression continuously” box doesn’t seem to have any effect in this case.

However, it then occurred to me to doublecheck my “Program Loops Forever” setting - I had that unchecked, as this is just a test program.
So, my main program was running the query on line 8, then when the Gage_trigger variable was enabled, it only had 0.1 second to finish the program and run the thread - enough time to activate any of the outputs, but once it hit a Wait command, the program just ended.
By enabling “Program Loops Forever”, it seems to work (though I get repetitive queries from the Assign node).
A longer wait time on line 9 also solves the problem.

In the final configuration, the robot will busy be doing other things, so I shouldn’t have to worry about this issue.

It’s always the silly little things that get ya!

1 Like