Announcement

Collapse
No announcement yet.

Read / Write information in Do More PLC from a c# application running in windows PC?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


  • Read / Write information in Do More PLC from a c# application running in windows PC?

    Hello,

    I want to know if it is possible to read and write information to a Do More PLC from a visual studio C# application running in a PC. For example, my Do More PLC has a thermocouple input module measuring the temperature of a machine at four different regions. Is it possible to read this temperature information (usually stored in RX registers) by an external application? What communication method would one use for this?

    One workaround would be to publish temperatures through MQTT and have the c# application subscribe to it. However, can data in a register (for Example D0) in PLC be modified by the application?


  • #2
    I believe there are C# libraries for Modbus, which would allow for communications.
    The DoMore could read/write to the C# application using all native memory locations.
    The C# application could read/write to MC, MI, MHR, MIR memory locations in the DoMore.

    Comment



    • #3
      You may want to look at Advanced HMI it's free and works good.

      Comment



      • #4
        You could easily write a custom protocol between C# and Do-more, using UDP packets in C# and PACKETIN and PACKETOUT in Do-more. But if you haven't done stuff like that before, it might be easiest to use something off-the-shelf like Modbus. Just remember that Modbus servers in Do-more controllers only expose MI, MC, MIR, and MHR memories, so you'll have to copy to/from those memories. Look at the PUBLISH and SUBSCRIBE instructions to move data in and out of the Modbus memories.

        Comment



        • #5
          +1 AdvancedHMI
          Here is a post on communication to the Do-More using Modbus TCP.
          https://accautomation.ca/brx-plc-adv...on-modbus-tcp/
          Here is a link to the entire series.
          https://accautomation.ca/series/brx-do-more-plc/

          Regards,
          Garry

          Comment



          • #6
            For those suggesting Advanced HMI, if the C# app is an important part of the system, how does the OP get from it to the C# app?

            Comment



            • #7
              https://stackoverflow.com/questions/...e-same-project
              Mixing the two can be done but not with the compiler in Visual Studio. (Unless this is a web page application.)
              https://www.carlosag.net/tools/codetranslator/
              I would suggest a code translator such as above keep it all one language.

              Regards,
              Garry

              Comment



              • #8
                Originally posted by BobO View Post
                You could easily write a custom protocol between C# and Do-more, using UDP packets in C# and PACKETIN and PACKETOUT in Do-more. But if you haven't done stuff like that before, it might be easiest to use something off-the-shelf like Modbus. Just remember that Modbus servers in Do-more controllers only expose MI, MC, MIR, and MHR memories, so you'll have to copy to/from those memories. Look at the PUBLISH and SUBSCRIBE instructions to move data in and out of the Modbus memories.
                Bob O The MHR and MIR registers are of type Signed Word. The thermocouple temperatures are stored in RX registers which are of type Real. When I do a simple MOVE command (say RX1 to MHR1), the decimal portion is lost and only integer portion is displayed on the application. Is there a workaround for reading real values from Modbus/TCP.

                I was looking at the publish/subscribe instructions you mentioned. I didn't quite understand if it is possible to convert and store real values in MHR or MIR registers. Is there a way to send the real value stored in RX1 register through Modbus/TCP?

                Comment



                • #9
                  Originally posted by Garry View Post
                  https://stackoverflow.com/questions/...e-same-project
                  Mixing the two can be done but not with the compiler in Visual Studio. (Unless this is a web page application.)
                  https://www.carlosag.net/tools/codetranslator/
                  I would suggest a code translator such as above keep it all one language.

                  Regards,
                  Garry
                  Garry thanks for your video link! I was able to successfully use advanced HMI VB project. The bundled solution also had AdvancedHMIcs (C#) version project. It was missing few references to run correctly. I was able to add the missing references. However, it seems that the "AdvancedHMIControls" and "AdvancedHMIDrivers" are still coded in VB instead of C#. It looks like these projects are essential to generate all the driver components and the controls (gages, meters, buttons) in the toolbox.

                  This is going to create a conflict since driver and controls are part of a VB project. I am unsure which files to convert to C# using the code translator converter you mentioned. Do you have any suggestions?
                  Attached Files

                  Comment



                  • #10
                    https://www.advancedhmi.com/forum/index.php?topic=774.0
                    The above link may help you out with running C# with AdvancedHMI.

                    Regards,
                    Garry

                    Comment



                    • #11
                      Originally posted by RockB View Post

                      Bob O The MHR and MIR registers are of type Signed Word. The thermocouple temperatures are stored in RX registers which are of type Real. When I do a simple MOVE command (say RX1 to MHR1), the decimal portion is lost and only integer portion is displayed on the application. Is there a workaround for reading real values from Modbus/TCP.

                      I was looking at the publish/subscribe instructions you mentioned. I didn't quite understand if it is possible to convert and store real values in MHR or MIR registers. Is there a way to send the real value stored in RX1 register through Modbus/TCP?
                      You just need to reinterpret the MHR memory through a cast. Move RX1 to MHR2:R (which treats MHR2 and 3 as a real), then read MHR2 and 3 from your C# app.

                      Comment



                      • #12
                        Originally posted by BobO View Post

                        You just need to reinterpret the MHR memory through a cast. Move RX1 to MHR2:R (which treats MHR2 and 3 as a real), then read MHR2 and 3 from your C# app.
                        Bob O I am little confused. I use the MOVE command with Source = RX1 and destination = MHR2:R (Do-more automatically converts this to MHR2:RD). When I look up the values of MHR2 and MHR 3 in data view, the numbers don't make sense. I haven't worked with casting before. (See attached pics). Am I missing something here? I have also noticed that the value of MHR2 register going to zero and negative values after some time.
                        Attached Files
                        Last edited by RockB; 05-02-2019, 11:16 AM.

                        Comment



                        • #13
                          Originally posted by Garry View Post
                          https://www.advancedhmi.com/forum/index.php?topic=774.0
                          The above link may help you out with running C# with AdvancedHMI.

                          Regards,
                          Garry
                          Thanks Garry My workaround was exactly same as this solution. But the solution still has vb and cs projects and works for now. Will have to see if anything breaks when I publish the application.

                          Comment



                          • #14
                            Originally posted by RockB View Post

                            Bob O I am little confused. I use the MOVE command with Source = RX1 and destination = MHR2:R (Do-more automatically converts this to MHR2:RD). When I look up the values of MHR2 and MHR 3 in data view, the numbers don't make sense. I haven't worked with casting before. (See attached pics). Am I missing something here? I have also noticed that the value of MHR2 register going to zero and negative values after some time.
                            The way the numbers are stored in the PLC memory are as a 32 bit number. What you are seeing is the binary representation of the Real number. A sign bit, an exponent and a mantissa. This is all done according to the IEEE-754 32 bit floating point specification.

                            Take a look at Pages I-5 and I-6 in this resource: https://cdn.automationdirect.com/sta...serm/appxi.pdf

                            If you want to view it to see that it was stored correctly, use casting in your data view.
                            Last edited by Do-more PE; 05-02-2019, 11:27 AM.
                            If you have an urgent issue, please contact AutomationDirect's Technical Support team.

                            AutomationDirect.com Technical Support: 1(800) 633-0405 or (770) 844-4200 Email Tech Support

                            Comment



                            • #15
                              Originally posted by Do-more PE View Post

                              The way the numbers are stored in the PLC memory are as a 32 bit number. What you are seeing is the binary representation of the Real number. A sign bit, an exponent and a mantissa. This is all done according to the IEEE-754 32 bit floating point specification.

                              Take a look at Pages I-5 and I-6 in this resource: https://cdn.automationdirect.com/sta...serm/appxi.pdf

                              If you want to view it to see that it was stored correctly, use casting in your data view.
                              Thank you for the documentation. I understand how the real value in RX register is represented as a 32 bit binary number: one sign bit, 8 bits for exponent and 23 bits for mantissa. My data view seems to correlate with the 32-bit binary representation

                              The MHR2 register value = decimal representation of bits 15 to 0
                              The MHR3 register value = decimal representation of bits 32 to 16

                              However, converting this back to real can be a tedious task. I found a simple workaround: Say if I want to send 22.8005 through ModbusTCP, If I want a 2 decimal point resolution, multiply the value of RX1 register and store it in a register (like N0). Move N0 to MHR1

                              On the other end (C# application), just divide the number by 100. Seems to be an easy workaround

                              Comment

                              Working...
                              X