• M
    mishaivchenko

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

    posted in Modbus4J general discussion read more
  • M
    mishaivchenko

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

    posted in Modbus4J general discussion read more
  • M
    mishaivchenko

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

    posted in Modbus4J general discussion read more
  • M
    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.

    posted in Modbus4J general discussion read more