5 Replies Latest reply on Dec 29, 2017 10:22 AM by pdwyer RSS
    pdwyer Newbie

    Connecting Modbus Device through serial to TCP server

    Hi there I have a MODBUS Level meter that is connected to a serial to Ethernet adaptor that I want to connect to the Thingworx Industrial connector and then obviously bring that data into thingworx. Despite reading the forum I am unable to see any clear steps as to how you would go about this for MODBUS configuration where you can set which registers to read etc.  I have seen some information with older thingworx releases with simulation but not actual real word connection. Can any one guide me through this to assist in testing? Here are the devices I have.

     

    1) Ultrasonic Level meter with RS485 with MODBUS RTU

    2) A serial to ethernet server connected to the level meter via RS485

     

     

    ConnectionExample1.jpg

      • Re: Connecting Modbus Device through serial to TCP server
        supandey Ninja

        Hi Patrick,  I haven't tried this yet, but do I get it right that you are looking to achieve this connectivity using Kepware server? Not sure if this helps Connecting to a Modbus Ethernet Device

         

        May be someone here has better idea on this.

          • Re: Connecting Modbus Device through serial to TCP server
            stmarchessault Creator

            Hi Patrick and Sushant,

             

            It should be possible to use the KEPServerEX Modbus RTU Serial driver with Ethernet Encapsulation to interface with this level meter device. Ethernet encapsulation adds a TCP header to the serial-based Modbus RTU protocol. This header is removed/added as it passes to/from the Serial/Ethernet gateway. Modbus RTU is the original Modbus protocol, and even with the TCP header, it is slightly different from the Modbus TCP (Modbus Ethernet) protocol.

             

            Follow these steps to connect with this device:

            1. In KEPServerEX (Industrial Connectivity), create a new Channel, and select the Modbus RTU Serial driver.

            2. Keep most of the default settings for the Channel until you see the Physical Medium. Change this from 'COM Port' to 'Ethernet Encapsulation'.

            3. Create a new Device. Here you will also keep most of the default settings. Device ID will be the Modbus Slave Node ID assigned to the meter (keep this at 1 if you are unsure what this should be). The IP address/port will be the IP/port of your USR Wifi232 device.

            4. Once the Device is created, create a new Tag. For the address, enter a Modbus address you know exists in the dervice (for example, holding register 40001).

            5. Launch the Quick Client (the QC icon in the KEPServerEX Configuration), and locate the tag group that is named <Channel>.<Device> for the Channel and Device you created in the previous steps.

             

            Can you see the value you expect for this tag/register?

             

             

            Best regards,

            Steven M

              • Re: Connecting Modbus Device through serial to TCP server
                pdwyer Newbie

                Dear Steven & Sushant, thank you for your replies. I was able to follow your clear instructions thank you. So I am now stuck when creating the tag. I am trying to read the holding register only.       

                     

                My target registry is "0000" (2 bytes high type first) But when I edit the tag  I keep getting out of range errors or syntax errors as I must be using the wrong syntax with the data type setting. Would you mind taking a quick look at the below doc and suggest what I should enter to read registry "0000". Also is there an area where i set the multiplier, unit of measure etc? with other data acquisition software I have used with this set up I just put in the registry offset to read the registry I want, add a multiplier (.01) to convert into metres then select the unit of measure, is there a section for this?

                GXUM+Ultrasonic+Level+Meter+MODBUS+Communication+Protocol 1.jpg

                GXUM+Ultrasonic+Level+Meter+MODBUS+Communication+Protocol 2.jpg

                 

                GXUM+Ultrasonic+Level+Meter+MODBUS+Communication+Protocol 3.jpgGXUM+Ultrasonic+Level+Meter+MODBUS+Communication+Protocol 4.jpg

                  • Re: Connecting Modbus Device through serial to TCP server
                    stmarchessault Creator

                    Hi Patrick,

                     

                    Thanks for sharing the device documentation, that gives us some key insight.

                     

                    [A] To read the "0000" register, here are the steps you will want to follow:

                     

                    1. Create a new tag. Name it "0000", to align with the documentation you have for the device.

                    2. For the address, enter "40001". Since the address is an "Analog Output", being read by Function Code 3, this tells us it is an Analog Output Holding Register in KEPServerEX, which is addressed as "4xxxx". Per the Modbus Spec, the default setting for "Zero-based addressing" is Enabled. You can shift all of your address by 1 (i.e. 0000 is 40001, 0001 is 40002, etc); or you can disable this setting in the Device Properties, within the Settings property group (i.e. 0000 is 40000, 0001 is 40001, etc).

                    3. For the Data Type, keep this as Default, or manually set it to Word. This is the default 16-bit (2 byte) Modbus Holding Register data type.

                    4. Launch the Quick Client and locate your tag. Are you seeing the value you expect? You may need to Disable the "Modbus Byte Order" in the Device Properties > Settings property group.

                     

                    For more information on Modbus addressing, here is a link to the "Modbus Addressing" section of the KEPServerEX Modbus RTU driver help manual:

                    https://www.kepware.com/en-us/products/kepserverex/drivers/modbus-serial/documents/modbus-serial-manual.pdf#page=28

                     

                    Simply Modbus is also an excellent resource for understanding this protocol:

                    Simply Modbus - About Modbus

                     

                    [B] For the second part of your question, is it important to note KEPServerEX is bringing the raw values from the Device and converting them into whichever Data Type you have specified. To multiply the value, you will need use a Client application, or ThingWorx. There is an internal Client Plug-in available called Advanced Tags. By creating a Derived Tag within Advanced Tags, you could apply arithmetic operations to a value to produce a new value that will be read by a Client or ThingWorx (for example, to multiple the value by 1000).

                     

                    While you will not be able to embed the units with the raw value in the same tag, It may be possible to create a separate tag that contains a String value representing the units. I can't tell, how do you extrapolate the units from what the Device has sent? It appears the units might be a setting put in place on this Device that will be universal for all values.

                     

                     

                    Best regards,

                    Steven M