• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How can I execute program on Mervis

    Mervis
    3
    7
    1120
    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.
    • A
      ayone0518 last edited by

      I want to run my python program and receive results. How can I do this on Mervis?

      Martin Kudláček 1 Reply Last reply Reply Quote 0
      • Martin Kudláček
        Martin Kudláček @ayone0518 last edited by

        Hi @ayone0518,
        short answer is you can't.

        Slightly longer answer is you can, but I don't recommend it.

        The Mervis is sort of world of its own and it's not easy to make it communicate with anything over other than supported protocols. If we need to use external scripts in our projects, we use simple python script which acts as a ModbusTCP slave running inside the PLC on 127.0.0.1:503. You can add this device in the Mervis and communicate with it via registers and coils. It works, but it requires some deal of work.

        Best regards,
        Martin

        A 1 Reply Last reply Reply Quote 0
        • A
          ayone0518 @Martin Kudláček last edited by

          @martin-kudláček Thank you for the information. It sounds tough to implement. I finally figured out that if I keep running my application on PLC to collect data and passing result into variables that PLC can touch, it will work equivalent to my question above. Can I do this on Mervis ?

          Martin Kudláček 1 Reply Last reply Reply Quote 0
          • Martin Kudláček
            Martin Kudláček @ayone0518 last edited by

            Hi @ayone0518,
            then I suggest you to take a look at PyModbus, especially the client example: https://pymodbus.readthedocs.io/en/latest/readme.html#example-code

            On the side of the Mervis, you need to create Modbus Server, see: https://kb.unipi.technology/en:sw:01-mervis:setting-modbus-server-hidden

            In the Mervis Modbus Server, you will define registers and coils pointing to some Mervis variables. In the Python script, you will write value to these registers/coils.

            Best regards,
            Martin

            1 Reply Last reply Reply Quote 0
            • A
              ayone0518 last edited by

              Thanks Martin.
              PyModbus worked great to me and I understand how to map variables on Mervis to be placed as modbus tcp touchable.

              I Still have curious question. I configured 503 port as modbus server, because 502 is already used as another modbus. What is this modbus used for ?

              thank you.

              1 Reply Last reply Reply Quote 0
              • T
                tomkling last edited by

                The port 502 is used for passing all data from and to the UniPi I/Os to EVOK, for example. The program that runs it is called unipitcp-server or similar and allows connection only from the UniPi itself. As far as I understand what you're using Mervis for, you could have also gotten the values directly from ModbusTCP on port 502 and then processed them in Python. This would have been probably a bit more difficult, because you would need to decode some values from Modbus' encoding and because you would need to know which register to use, but you can get this information from here: https://kb.unipi.technology/files:products:00-start
                You need to choose your product line and download "Modbus Register map".

                A 1 Reply Last reply Reply Quote 0
                • A
                  ayone0518 @tomkling last edited by

                  @tomkling Thank you for your information. I also figured out 502 is used on debugging. So it is important.

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