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

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


  • 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.


  • 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.


  • @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


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


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


  • @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.


  • 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


  • @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.


  • 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.