• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Try to reading data on the Modbus network from the Altivar frequency converter or MODICON PLC

    Modbus4J general discussion
    3
    9
    2.9k
    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
      mishaivchenko
      last edited by mishaivchenko

      Hello dear masters, tell me whether it is possible to directly read the values ​​of the registers from the equipment using the Modbus protocol. I want to implement in java language reading registers and outputting them to the jsp page. The program is needed for the diploma project and gaining knowledge in java. Did anyone try to do this?
      I try to use "Modbus4j" with Mango jars but when i try reading Registers i get only "null" despite the fact that the documentation for the device on the addresses that I enter should be found values ​​of not null.

      I have to add some information. I connected the Schneider electric ATV 71 frequency converter to Modbus TCP to the computer (The connection is established because the software sees this device).

      Below is an example of the code used. The host is different because the device is in the university and I do not remember the address that indicated.

      public class Test {
      
         public static void main(String[] args) throws ErrorResponseException, ModbusTransportException {
         ModbusFactory factory = new ModbusFactory();
             IpParameters parameters = new IpParameters();
             parameters.setHost("127.0.0.1");
             parameters.setPort(502);
             parameters.setEncapsulated(false);
             ModbusMaster master = factory.createTcpMaster(parameters,true);
             master.setTimeout(1000);
             master.setRetries(0);
             try {
                 master.init();
                 master.setConnected(true);
                 NumericLocator locator = new NumericLocator(1,RegisterRange.HOLDING_REGISTER,0,DataType.FOUR_BYTE_INT_SIGNED);
                 System.out.println("value: "+master.getValue(locator));
                 System.out.println(master.isInitialized());
                 System.out.println(master.isConnected());
             } catch (ModbusInitException e) {
                 System.out.println("Something wrong");
                 e.printStackTrace();
             }
      
         }
      }
      

      methods "master.isInitialized()" and "master.isConnected()" return value "true".
      The address set in the device is "1". It also confirms the connection because an exception is thrown when installing another id.

          NumericLocator locator = new NumericLocator(1,RegisterRange.HOLDING_REGISTER,0,DataType.FOUR_BYTE_INT_SIGNED);
                 System.out.println("value: "+master.getValue(locator));
      

      The code above always returns "null" whatever shift I set.

      So i believe with this information you can help me. Thank you in advance for your answers.

      1 Reply Last reply Reply Quote 0
      • CraigWebC
        CraigWeb
        last edited by

        With the little information you provided all I can suggest is making sure your data type corresponds to your modicon plc documentation. I have in the past got zero values when you trying to read a float as an integer for example.

        1 Reply Last reply Reply Quote 0
        • CraigWebC
          CraigWeb
          last edited by

          @mishaivchenko said in Try to reading data on the Modbus network from the Altivar frequency converter or MODICON PLC:

          Schneider electric ATV 71 frequency

          Please post a link to the modbus documentation for the VSD

          M 1 Reply Last reply Reply Quote 0
          • M
            mishaivchenko @CraigWeb
            last edited by

            @craigweb if I understand what you mean
            link text
            If you can’t open - I will give you .xls when come home. Thank you.

            1 Reply Last reply Reply Quote 0
            • CraigWebC
              CraigWeb
              last edited by

              What are you expecting to see in register 0. I do not see it on the . xlsx. Have you tried other registers ?

              M 1 Reply Last reply Reply Quote 0
              • M
                mishaivchenko @CraigWeb
                last edited by

                @craigweb I show you this code only for example. I try write different address but I always get “null”.
                I can provide output to the console only on Tuesday. Because the country celebrates the holiday.

                1 Reply Last reply Reply Quote 0
                • CraigWebC
                  CraigWeb
                  last edited by

                  please make sure you set your modbus4j data type to the exactly the same as the xlsx sheet. word = 2 byte unsigned, int = 2byte signed, Uint = 2byte unsigned, Dint = 4byte singed etc

                  M 1 Reply Last reply Reply Quote 0
                  • M
                    mishaivchenko @CraigWeb
                    last edited by

                    @craigweb on Tuesday I will recheck everything and give you output. but it seems to me that the values ​​should not be null, even if I do not correctly specify the type.

                    1 Reply Last reply Reply Quote 0
                    • phildunlapP
                      phildunlap
                      last edited by

                      Hi mischaivchenko,

                      Three things I would consider trying are,

                      1. What happens if you use Mango's tools on the Modbus Data Source page to read these registers? Do you get better feedback, or output to the log file? The point locator test tool uses the same method you are using.
                      2. Can you attach a debugger? Modbus4J is open source and as far as gaining knowledge in Java goes, you should be able to attach a debugger in your IDE and step into the code.
                      3. Get a log4j configuration that will output the various log statements from TcpMaster and pass that into your program as a command line argument.
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post