MODBUS stops the Robot Program

Hello,

I am communicating the cb5 UR Robot with a PLC.

There is no issue in the communication.

But when I send modbus_set_output_signal() or modbus_set_output_register(), the robot program stops.

I am using ScriptSender and ScriptCommand from Jacob’s repository. I checked the Sequential Mode in the installation.

I tried the same thing with ursim and the server in my PC, the same thing happened.

What could be the issue?

Thank you,

MB

The scriptsender does say in the code:

/**
* Method used to send a ScriptCommand as a primary program to the Secondary Client Interface.
* If called while a program is already running, the existing program will halt.
* @param command the ScriptCommand object to send.
*/

So this is expected. If you explain a little more about how you’re trying to sequence your modbus communications with the main program, perhaps we can suggest a different approach.

1 Like

I have a PLC as a Modbus Server that is constantly updating 2 registers with servo position data.

I am trying to plan a trajectory according to the servo position data that is coming from the PLC.

Therefore I need to read the values of the modbus registers while the program is running and send them to Java.

Ok, is there no way that you can plan the trajectory in the program running in Polyscope/URScript? The Java side of things is generally intended for handling GUI related tasks, not robot motions.

I think I can plan the trajectory in URScript.

But I have already written the trajectory program in Java and it is working fine.

So is there any way to send variables from URScript to Java while the program is running?

I tried to implement the trajectory planning in URScript/Polyscope as you have instructed.

But I am having hard time doing that because the arrays in URScript are not resizable.

In my application, I get 2 points from the user and plan the trajectory accordingly.

Then, I move the robot in generateScript using writer.appendline().

But I need to read the values of get_actual_tcp_pose() and modbus_get_signal_status() without halting the robot program.

Maybe it would be good idea to use URCap with daemon written in C++ or Python. You can get values of actual TCP pose and modbus signal status in URScript and send it to daemon. Daemon can do calculations and send it back to URScipt (for example to feed servoj() function with trajectory).

Here is URCap with daemon example: GitHub - UniversalRobots/MyDaemonSwing: URCap sample that mainly demonstrates the principle of DaemonContribution and DaemonService

For communication between URCap and daemon you can use RTDE. Maybe this will be useful for you: Universal Robots RTDE C++ Interface

Please correct me if I am wrong but we can’t get modbus_get_signal_status() from RTDE, right?

I’m not sure, but I suppose the answer is: yes.

Using RTDE you can exchange data between URScript and daemon (C++/Python), so you can get value using modbus_get_signal_status() in URScript, put this value in some INT register and read it from this register in daemon.

1 Like

Do I have to assign a register inside a Thread in InstallationContributionNode like:

a = modbus_get_signal_status(“servo1”, False)
write_output_integer_register(24, a)

Then call the register from Python/ C++ via RTDE?

Yes, something like this :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.