It’s supposed to check some sensors to see if the part is staying in the right spot, but even with “check expression continually”
the thread won’t keep running while the main program is doing it’s thing.
How should I program something with this functionality properly. Its purpose is to pause the entire program as soon as someone moves the part away before its supposed to be moved.
The “check expression continuously” is meant for something else and not applicable in this case.
Your thread should work fine. It will check the thread 500 times a second (or more). You should add a sync() or a wait 0.01 outside the If command to prevent the computer from getting overburdened.
Anyhow. Why do you think the thread isn’t looping? I think you might be getting tricked by the “else”: The moment one of the conditions become false (one input becomes false), both linkscheck and rechtscheck are set to false again.
So if your digital input is only active for a short amount of time, your variable will also only be true a short amount of time.
EDIT: I just read the last part of your post. It’s not that simple to pause a program from within itself, since it won’t be able to restart.
Could wiring your sensors as safeguard inputs work? The program will only run when the part is in place, though.
Alternatively, you might need a PLC to pause and start the robot.
I didnt think it was properly looping because it didnt correctly update as it was supposed to, but I’ve fixed that.
The operator will have access to the teacherpad so it shouldnt be a problem to pause the program just using the simple “pause” command in a script node. Restarting can be done with the play button, or i could put it in remote and add some external buttons.
This pause just has to function as a safety feature incase the product which the cobot works on gets. But the sensor checking also have to be used to identify the orientation of the product, so i dont think using safeguard inputs is gonna be a good idea.
I think i have it mostly figured out in an external program. It’s just got some small mistakes left. But if you think of any efficient way to program this I’d love to hear it.
You won’t be able to pause the program and resume it from a thread.
If I were you, I would connect the sensor to the Safeguard inputs and make it Normally Closed. Sounds like you want the entire program to be paused/started.