REXYGEN Community Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Login

    Read/Write Modbus

    Modbus RTU
    2
    9
    2.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MikeyH
      last edited by jaroslav_sobota

      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

      1 Reply Last reply Reply Quote 0
      • cechuratC
        cechurat
        last edited by

        Hi Mike,

        in order to configure REXYGEN Modbus Slave register as read/write, just tick "Readable" and "Writable" options together in Item configuration dialog.

        0_1554726474848_2777d94a-0e03-4eb5-a6c6-e951c5459b47-image.png

        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

        M 1 Reply Last reply Reply Quote 0
        • M
          MikeyH @cechurat
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • cechuratC
            cechurat
            last edited by cechurat

            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

            M 1 Reply Last reply Reply Quote 0
            • M
              MikeyH @cechurat
              last edited by MikeyH

              @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

              1_1554961565988_main_task.mdl 0_1554961565988_HIL_exec.mdl

              1 Reply Last reply Reply Quote 0
              • cechuratC
                cechurat
                last edited by

                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

                M 1 Reply Last reply Reply Quote 0
                • M
                  MikeyH @cechurat
                  last edited by MikeyH

                  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

                  1_1555013054598_monarco.rio 0_1555013054597_master_cfg.rio

                  1 Reply Last reply Reply Quote 0
                  • cechuratC
                    cechurat
                    last edited by

                    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

                    0_1555070706951_modbus_RW.zip

                    M 1 Reply Last reply Reply Quote 0
                    • M
                      MikeyH @cechurat
                      last edited by

                      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

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      This is a community forum for REXYGEN users and fans. Detailed information can be found at REXYGEN homepage.

                      There is also an outdated REXYGEN community forum.

                      Powered by NodeBB.