Read/Write Modbus
-
Hi All,
I'm more than likely misunderstanding the documentation. But I'm just after some clarification on how you read/write to the same Modbus register using REXYGEN. I have an RTU master that requires to read/write to several registers.
For those interested I am communicating to a device via a RS485/TTL adapter as part of a HIL project.
Cheers
Mike
-
Hi Mike,
in order to configure REXYGEN Modbus Slave register as read/write, just tick "Readable" and "Writable" options together in Item configuration dialog.
Note: be sure not to use write flag (GoTo flag) within REXYGEN Modbus Slave - it can lead to unexpected behaviour because of multiple sources for one register.
If you need any further assistance, let me know.
Cheers, Tomas
-
Thanks @cechurat, how does that work in terms of input and output blocks?
Guessing that you can't have two blocks with the same name and you have to use an input and output block to read/write. What would it schematically look like? I might be over thinking this!
Cheers
Mike
-
IMPORTANT - Speaking about Modbus Slave implemented in REXYGEN:
There should be no need for having input and output flags for the same item (same name).
If you want to observe it's state (i.e. changes made by writing from Master), you can add to your REXYGEN project input flags ("From" function block).
Output flags ("GoTo" function block) within Modbus Slave context are valid only for registers meant to be READ ONLY for Master.If you want to store some initial values within Modbus Slave, use "Init Values" box in Item configuration dialog.
If you can share a test Modbus mapping table suitable for you project I can prepare Modbus Slave implementation example for you.
Hope it helps.
Cheers, Tomas
-
@cechurat Thanks for your help with this. I'm pretty sure I have just misunderstood something. I have uploaded some of the project. Basically I need to write back to the same registers that Modbus blocks "sensors" and "parameters" are reading from. This is where I have got stuck, basically writing back to the same register.
Cheers
Mike
-
Hi Mike,
exec file is not enough - Modbus configuration is hidden in *.rio file. Can you share whole your project? You can send it via e-mail if there is some know-how you wouldn't share with others.
Can you describe your setup more to the details? What devices are "talking"? I was probably misunderstanding that you are trying to implement Modbus Slave in REXYGEN because you have some device acting like Modbus Master. That is wrong, right?Cheers, Tomas
-
Hi Tomas,
The project is a HIL simulator. I'm using the Monarco as a master, reading and writing values back to a refrigeration controller. The project will eventually have a task with a model performing the simulation back to the controller. For this to happen I need the master to write back to "sensors" and "parameters" blocks. Enclosed are the Modbus and Monarco .rio files . That's all the project has right now. I need to get the Modbus working before I can proceed.
Cheers
Mike
-
Hi Mike,
see the modified project attached. In such a case I recommend to use two different items - one for reading and one for writing. Therefore there won't be any naming collision. Keep us updated about your progress.
PS: I also modified Modbus Port settings to meet requirements for Modbus RTU usage via Monarco - there should be "/dev/ttyAMA0" - for more details see following topic at our Knowledge Base - https://support.rexygen.com/help/modbus-rtu-with-the-monarco-hat-on-raspberry-pi
Cheers, Tomas
-
Hi Tomas,
Thank you for your help. I understand how it works now, what you provided is where i wasn't sure what to do. It makes sense to me now.
Cheers
Mike