Modbus

Modbus

manikantaravi
Not applicable
158 Views
21 Replies
Message 1 of 22

Modbus

manikantaravi
Not applicable

[ FlexSim 23.1.3 ]

I am trying to get a data from a universal robot in URsim environment. I found the address of the robot to be connected. and connected according to the steps https://www.universal-robots.com/articles/ur/interface-communication/connecting-to-client-interfaces....

1690188157064.png

I am trying to get the joints data of the robot while it is running into flexsim using Modbus connection

1690188269873.png

According to universal robot website https://www.universal-robots.com/articles/ur/interface-communication/modbus-server/

1690188359095.png

address (registers 270 to 275 gives a joint data of the robot)

In flexsim I emulated the connection as

1690188580424.png

detailed model Emulation example flexsim question.fsm here i am basically testing whenever a data comes from the register create a object on queue / change the colour of the queue using control registers. But when i run the model no change in the property of queue.

I doubted whether the connection is good and checked with qModMaster https://sourceforge.net/projects/qmodmaster/

It seems i am getting data from the URsim robot for the Base joint which is in 270 register. But it is not reflecting in the flexsim model.

How do i check whether flexsim is receiving data from the address by using MODBUS TCP connection. Is there anything I could do alternatively in the model like populating the data in global table. Help me in this regard so that I could get data from the robot.

0 Likes
Accepted solutions (1)
159 Views
21 Replies
Replies (21)
Message 2 of 22

moehlmann_fe
Observer
Observer
Accepted solution

The software you are using to check the connection is emulating a modbus master/client, so I would assume that the robot is acting as the slave/server. As such FlexSim should also be set up to serve as a client instead of a server.

0 Likes
Message 3 of 22

manikantaravi
Not applicable

Hi Felix

I changed into client,

1690222598120.png

1690222643631.png

But the changes are not reflecting in the model, is there a way for me to check whether flexsim is getting the data from the robot using actions in control register or like writing the values in global table.

0 Likes
Message 4 of 22

moehlmann_fe
Observer
Observer

Try checking the box to poll for changes. To show whether any values are received I'd suggest to print the values to the output console.

capture.png

0 Likes
Message 5 of 22

manikantaravi
Not applicable

Hi felix thank you

1690228508203.png

I could now confirm that flexsim is getting data from the robot through modbus connection. I have few doubts regarding how to convert these data first i need to get a signed integer as these are unsigned. I don't know whether clicking 16bit int gives the same functionality in the register type.

1690228658217.png

Next thing is i am trying to get the robot joint values in degrees

1690228826488.png

What kind of code should I use.

Also, i could see that output console is showing the data only there is a change in the value. What should i do if I just want to view the value when the value is not changing (i.e robot is not moving).

0 Likes
Message 6 of 22

moehlmann_fe
Observer
Observer

You can choose between signed and unsigned integer for the Holding Register. So I would assume that FlexSim will interpret the bit number based on that choice.

1690268949159.png


I'd assume that the 16bit value map linearly to the valid range of the joints (looks to be -360° to 360° in your screenshot (?)). So you'd just multiply the value by the respective conversion factor.


You can store the latest value somewhere else in the model (table, global variable, labels, ...). So even if the update code does not fire because the value didn't change, you can still read it from there.

0 Likes
Message 7 of 22

joerg_vogel_HsH
Mentor
Mentor
@Felix Möhlmann, I don’t think that is 16bit is enough for an accurate resolution of a robot joint. Typically it is a resolution of a drive without a gear. Then a gear is added to this drive and an 16bit integer represents a fraction of whole turn of a joint.
0 Likes
Message 8 of 22

moehlmann_fe
Observer
Observer
Good point. If it's not documented anywhere, then you'd have to run tests to find the relationship between the degree and integer values.
0 Likes
Message 9 of 22

manikantaravi
Not applicable

I agree 16bit integer is not enough for the accurate representation of the robot joint.

0 Likes
Message 10 of 22

manikantaravi
Not applicable

Thank you for you help felix so far I have few doubts should I check the 'poll for external changes' to receive the data. I think it is to receive data only when there is change right

1690367069604.png

Also, You can see that I have made an action to store the data (applying conversion factors) received from the registers (Robot degrees) in Global table. But global table is not updating with the current data (Present data of robot degree) it is showing zero after resetting and running the model. Only when I change the physical robot rotation global table is showing the data regarding that degree.

What changes should i make in actions so that I get the current data from the register. Instead receiving data only when there is a change in data in the registers thank you

0 Likes
Message 11 of 22

moehlmann_fe
Observer
Observer

FlexSim must save previous somewhere, so it can compare the current value against it when deciding whether to run the action code or not.

I can't test this since I currently don't have an emulation setup. You can try to set the 'oldValue' you see marked in the screenshot to some value outside of the possible range after updating the table and upon resetting the model. (Use setsdtvalue() to change the value inside the node)

Maybe that will cause FlexSim to run the action since the new value will be different.

1690369444313.png

0 Likes
Message 12 of 22

manikantaravi
Not applicable

1690531480862.png

Dear Felix, I found out which value through model it is Curvalue how do I take the Curvalue into actions, I basically want to feed Curvalue of the register to the global table through actions, and also whenever the Curvalue changes global table needs to be updated with the most recent value.

1690531769567.png

I tried using Current in action but it is of no use

1690531888306.png

I tried whether can i get oldvalue atleast it seems unless there is a change in the register it is not showing in the global table.

But it is confirmed that flexsim is getting the current value and it is stored in the Curvalue. Problem is I need to feed

0 Likes
Message 13 of 22

moehlmann_fe
Observer
Observer
You can add logic that copies the curValue from the tree to the global table in a fixed interval, independently of the emulation connection.

This could be a small process flow or a user event.

0 Likes
Message 14 of 22

manikantaravi
Not applicable
can you say how to do it / guide me with any example so that I can learn to do that?
0 Likes
Message 15 of 22

jason_lightfootVL7B4
Autodesk
Autodesk

Isn't the value you want passed into the action as newValue?

0 Likes
Message 16 of 22

moehlmann_fe
Observer
Observer

You find user events under Modeling Logic in the toolbox. The code below should copy the current value of the "Base" variable to the global table. For other variables you just have to change the path in the .find method to get the correct node (you can see how the path is constructed when you look at the screenshot of the tree from your previous post) and the table cell to copy it to.

capture.png

// Get emulation variable node
treenode baseVariable = Model.find("Tools/Emulation>variables/emulationVariables/Base"); // Get current value from node int curValue = getsdtvalue(baseVariable, "curValue"); // Copy value to global table Table("GlobalTable1")[1]["Base"] = curValue;
0 Likes
Message 17 of 22

manikantaravi
Not applicable
Hi Jason it is passing as a newvalue, but only when the robot position changes, when the robot position is not changing it is not passing the newvalue, so in the table it says 0 only.
0 Likes
Message 18 of 22

manikantaravi
Not applicable

Thank you so much felix now i am able to get the current values in the tables. Now I have a different problem.


1690885848039.png

How do i link the global table values to the robot in the flexsim so that the robot in flexsim moves real time with actual robot.

I know there is a option called motion path in flexsim robot but i couldn't link that it to global table.

0 Likes
Message 19 of 22

jason_lightfootVL7B4
Autodesk
Autodesk
Okay, thanks. Do you need further assistance?
0 Likes
Message 20 of 22

moehlmann_fe
Observer
Observer
Please ask this as a new question, since its a new topic (having the robot travel to specific joint angles).
0 Likes