Hello everyone, I have a problem with programming a robot. I have implemented a PM to grab different products to the conveyor belt. Now I want to connect this program to a PLC to control the gripping of specific products through different variables sent by the PLC. I recorded each path and added the wait signal. I think this is enough to grab specific products at will, but in reality the program must always execute in the order of T1,T2,T3, which means the PLC must send signals in the order of Boolean signal 1, Boolean signal 2, Boolean signal 3. Does anyone know how to modify this? Thanks!
Waiting for PLC signal to grab any product.vcmx
Hello Miao Wentao,
This problem just sounds like a logic problem, in fact, because the “wait” in the robot program is similar to the “triggerCondition” kind of pause, when it is not met, the program will not continue to follow up with your expected judgment, solve it is a logical question. I think the most convenient way is to use the “while” function externally, and use “if” in the middle to judge the source of the signal. This way, when any signal is triggered, the corresponding action can be taken. Of course, this is not without cost. “while” queries may cause the program to freeze. At this point, you can use some means to reduce the number of “while”, so as to achieve your goal while ensuring the smooth running of the simulation.
Hope this helps and have a nice day.
Thank you, brother. But in the robot program, it seems that if, while cannot be followed by a signal like wait.
As I said before, when you use “wait”, you are actually notifying the system to some extent that you need to do things in order, that is, it must be the order of Boolean signal 1 and Boolean signal 2. The effect of using while + if is that it will judge the state of the Boolean signal 1 and Boolean signal 2 during scanning, and use this as the trigger condition to operate without “Sir, I need you to wait for someone, in the Until then, you have nothing to do.” When using the combination of “while + if”, you are sacrificing part of the fluency to ensure that any signal can trigger its own event. By the way, using Python scripts can solve this side effect. Unlike robot programs, Python scripts are a multi-threaded operation. When we use Condition in Python scripts, it just temporarily stops the code running on this thread. It will not affect the operation of another Python script.
Just like this, there is no need for wait, but more judgment.
Do you mean that I can use while and if in a python script, and then in it I can also call my recorded robot program directly, just as I can execute recorded paths in PM?
ummm. . . Python can indeed be called to achieve this effect, but what I mean is that in a robot program, only using a combination of while and if can also achieve out-of-order fetching, but it has a greater burden on the computer, while python with the same effect The script will be smaller. Both methods can do the same thing, but the burden on the computer is different.
I prefer to implement this effect in a robot program as I’m still new to python and not too familiar with it. But I’ve tried to use the method you described, and the difficulty I’m having is that the if judgment condition in the robot program doesn’t seem to be able to incorporate signals, as in the picture I posted before. (if PLCSIGNAL1==True then Call Path1, Else if PLCSIGNAL2==True then Call Path2)
I don’t understand very well, when your PLC signal is connected, you can assign it to any robot signal port “IN~IN[X]” It is not difficult to use these signals, as long as your robot program is in Use one in main():
Of course not just IF, SWITCH can also do it.
If you want to use wait in the robot program, as I said before, it will make the program just run step by step.
Hello Bad! You understand very correctly, that’s what I wanted to know. Now I know how to use the port after if,while. I did a simple test as shown in the picture, I assigned True to port 20, but I don’t know why it doesn’t execute it. In addition I have a question, I have always made my projects in PM, if I want to execute the robot program in Main now, do I have to remove the robot controller?
I’m glad you found a solution. The reason why the IN event is not executed is because in the robot program, the loop is not executed by default, that is to say, when the system finds that there is no trigger condition for the first time, it will automatically stop, instead of looping like a PLC. To solve this problem, you can actually find the robot controller in the modeling module, which has a corresponding loop attribute (or you can also nest a while True).
And about PM and bot, they are conflicting, in fact, python script and bot are also conflicting. The robot program hopes that the robot itself is free, whether it is a PM or a Python script (the early PM is actually a script), they will control the robot. At this point, the robot actuator will actively shut itself down to prevent conflicts. If robots are to be used, Robot Manager must be removed. To be precise, the control function of the robot manager must be removed. It is located in the interface of the modeling module. When managers lose control, they must be removed. Turn on the robot actuator, and the robot can run the robot program.
Hope this helps, good luck.
Hello Bad. thank you so much, you have helped me several times. I wish you happy every day!