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

    How can I execute program on Mervis

    Scheduled Pinned Locked Moved Mervis
    7 Posts 3 Posters 2.7k Views 2 Watching
    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áčekM 1 Reply Last reply
      Reply Quote 0
      • Martin KudláčekM
        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áčekM 1 Reply Last reply
          Reply Quote 0
          • Martin KudláčekM
            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

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post