question

Candan avatar image
0 Likes"
Candan asked Jeanette F commented

Emulation to control object

How to use the value returned by Emulation to control the object sent by the Source

How to set Modbus Control Register?

provide examples.

FlexSim 20.2.3
emulation
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Candan, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

To control what type of object the source creates, you can set its 'itemclass' variable.

object.setVariable('itemclass', rank)

The second parameter 'rank' is the flow items rank/index in the Flow Item Bin.

1656497016506.png

The attached model was a test. We set the modbus connection up so we could remote control the conveyor speed from a Raspberry Pi.

emulation_modbus_test.fsm


· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Candan avatar image Candan commented ·

1.png


1.Does it means I send data by my computer IP? Can I send data by other port of mobus?

2.png

2.How do I set in variables if I want to use photoeye?

0 Likes 0 ·
1.png (8.1 KiB)
2.png (24.0 KiB)
Felix Möhlmann avatar image Felix Möhlmann Candan commented ·

1. Data is exchanged through a network connection. FlexSim can either function as the server (slave), which is what we did in our test. So the IP address is that of the computer running FlexSim in the local network. If FlexSim is running as client, it would be the address of the server.

Yes, you can change which port is used. 502 is used as standard in any source we found, so we used that one.

2. You'd add a new Sensor Register (Sensor - FlexSim writes values on event, Control - FlexSim reacts to change in value) and choose the photo eye as the Associated Object. Under 'Write Events' you can then specific which event will trigger a write operation and what value should written to the register.

1656568996156.png

0 Likes 0 ·
1656568996156.png (44.0 KiB)
Candan avatar image Candan commented ·

How to verify your model??

Can't see anything special?

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Candan commented ·

It's in the nature of the task: You can't verify if the connection works without setting one up. The model should serve as an example of how to set up a connection in FlexSim and connect registers to values in the model.

We used pymodbus (modbus implementation for python) to write to and read from the registers FlexSim provides when running as server. This article helped with the basics (mainly section: pymodbus as Modbus client)

https://blog.jonasneubert.com/2019/11/02/using-pymodbus-to-communicate-with-a-plc/

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.