Welcome to Open Discussion

2008-04-12
2013-05-13
  • Welcome to Open Discussion

     
    • Nik
      Nik
      2009-06-03

      Hi,

      I am looking for someone who can freelance to write code for a modbus meter reader.

      If you are interested shoot me an email to nik@accuratesolarpower.com

       
  • Raveesh
    Raveesh
    2011-12-05

    Hi,

    For Modbus protocol implementation, I am using "modbus4j.jar" java library. But I am not able to retrieve the device properties like device name, device MAC Address, VendorId etc. But for Bacnet protocol "bacnet4j.jar" provides the suitable classes and functions for that. Can any one provide the helpful pointer about it .

    -Raveesh

     
  • Raveesh
    Raveesh
    2011-12-05

    2011-12-04 22:41:40 PST
    Hi, For Modbus protocol implementation, I am using "modbus4j.jar" java library. But I am not able to retrieve the device properties like device name, device MAC Address, VendorId etc. But for Bacnet protocol "bacnet4j.jar" provides the suitable classes and functions for that. Can any one provide the helpful pointer about it .

    -Raveesh

     
  • The Modbus protocol doesn't support that. Solutions for getting that kind of information are proprietary to the equipment makers.

     
  • Raveesh
    Raveesh
    2011-12-07

    Hi mlohbihler,
             Thank you so much for your help.  :)
    - Raveesh.

     
  • Raveesh
    Raveesh
    2012-04-18

    Hi,

    We are trying to read/write values using modbus4j library to MODBUS PLC simulator as:

    1.ModbusRequest req = new WriteRegistersRequest( int slaveId, int startReferenceAddress,short registerValue)
    2. WriteRegistersResponse res =  master.send(  req)

    We are getting the response using ModbusMaster 's send (ModbusRequest req).
    We are able to read and write the integer value to the MODBUSPLC but unable to read/write the float/character values since the API offers to write only the short values.

    Is there any way to read/write float or character values from a PLC simulator using modbus4j since the simulator allows to set float/character values in its register?

     
  • Raveesh
    Raveesh
    2012-04-18

    Hi,

    MODBUS PLC simulator supports the following datatypes as:
    float32,decimal,hex,word16,dword 32,long 32,char string

    When we set character values such as 'a' (say) we get its ASCII value when we read using modbus4j API but ,if we set a string
    "ab"(say) we get 24930 on reading using modbus4j API
    "bc"(say) we get 25187 on reading  using modbus4j API

    Similary, on Reading float values we got
    2.5(say) gives 16416
    3.24(say)gives 16463 and its next register will automatically have this value 19027

    Can someone suggest about the pattern/code ?how is it generated?

    Is there any way to read/write other dataTypes except decimal values from a PLC simulator using modbus4j ?

     
  • Please look at the ModbusMaster API, in particular the setValue methods. Locator types include Binary, Numeric, and String.

     
  • Raveesh
    Raveesh
    2012-04-23

    Thanx mlohbihler for the response.

    Can u tell us how can we read other than decimal values from the PLC simulator  using ModbusLocator API more specifically?
    I am unable to get the read API with respect to ModbusLocator in modbus4j.

     
  • Raveesh
    Raveesh
    2012-04-26

    we are trying to write the Analog holding registers using MdbusLocator API as:
    ModbusLocator modLocator=new ModbusLocator(new SlaveAndRange(slaveId, range),startReferenceAddress, DataType.FOUR_BYTE_FLOAT);
    short  registerValueWritten=modLocator.valueToShorts(registerValue);
    ModbusRequest  req = new WriteRegistersRequest(slaveId,startReferenceAddress,registerValueWritten );
    WriteRegistersResponse res = (WriteRegistersResponse) master.send(req);

    we are able to write float values successfully to the simulator but we are unable to read it .
    Can you suggest us the How can we read the float values from the simulator using modbus4j API.

    Is it possible to read float/Character values from PLC simulator using modbus4j API?

     
  • Raveesh
    Raveesh
    2012-04-26

    also we are unable to write the last register of each device…?
    if each devices are set to have 20 registers in Modbus PLC and if we are trying to write a FOUR BYTE FLOAT value using the same API(above Query) ,we are unable to write the 17th,18th,and 19th register .Why is it so?
    same way  if we are trying to write a TWO BYTE INTEGER value using the same API(above Query) ,we are unable to write the 18th,and 19th register .Why is it so?

     
  • Raveesh
    Raveesh
    2012-05-11

    hi,
    I am implementing MODBUS RTU support using MODBUS PLC simulator using RS232 cable .
    IS there any way make it work with MODBUS PAL simulator?
    Does MODBUS PAL simulator supports MODBUS RTU?

     
  • Raveesh
    Raveesh
    2012-05-11

    On implementing MODBUS ASCII we are getting error "port in use" while testing it with MODBUS PLC simulator in RS232 mode .
    what should I do?Please suggest….

     
  • Raveesh
    Raveesh
    2012-05-12

    I am trying to discover devices using modbus RTU (modbus4j).I have used modbus PLC simulator with a mode RS232.even connected the two systems with RS232 cable.But we are getting the following exception after the initialization of the master. Infact the request is reaching to the simulator n we are getting the following exception 240 times for each device.
    com.serotonin.modbus4j.exception.IllegalFunctionException: Function code: 0x20
    14:38:02,925 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:68)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:37)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:02,925 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:02,925 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:02,925 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:02,925 ERROR  com.serotonin.modbus4j.exception.IllegalFunctionException: Function code: 0x8
    14:38:02,925 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:68)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:37)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:02,925 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:02,925 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:02,925 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:02,925 ERROR  com.serotonin.modbus4j.exception.IllegalFunctionException: Function code: 0x23
    14:38:02,925 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:68)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:37)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:02,925 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:02,925 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:02,925 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:02,925 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:03,425 ERROR  com.serotonin.modbus4j.exception.ModbusTransportException: Invalid slave id
    14:38:03,425 ERROR  at com.serotonin.modbus4j.msg.ModbusMessage.<init>(ModbusMessage.java:33)
    14:38:03,425 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.<init>(ModbusResponse.java:78)
    14:38:03,425 ERROR  at com.serotonin.modbus4j.msg.ReadResponse.<init>(ReadResponse.java:31)
    14:38:03,425 ERROR  at com.serotonin.modbus4j.msg.ReadCoilsResponse.<init>(ReadCoilsResponse.java:32)
    14:38:03,425 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:46)
    14:38:03,425 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:37)
    14:38:03,425 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:03,425 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:03,425 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:03,425 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:03,425 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:03,925 ERROR  com.serotonin.modbus4j.exception.ModbusTransportException: CRC mismatch: given=288, calc=56705
    14:38:03,925 ERROR  at com.serotonin.modbus4j.base.ModbusUtils.checkCRC(ModbusUtils.java:104)
    14:38:03,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:41)
    14:38:03,925 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:03,925 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:03,925 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:03,940 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:03,940 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:03,940 ERROR  com.serotonin.modbus4j.exception.IllegalFunctionException: Function code: 0x8
    14:38:03,940 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:68)
    14:38:03,940 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:37)
    14:38:03,940 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:03,940 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:03,940 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:03,940 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:03,940 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:03,940 ERROR  com.serotonin.modbus4j.exception.IllegalFunctionException: Function code: 0x23
    14:38:03,940 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:68)
    14:38:03,956 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:37)
    14:38:03,956 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:03,956 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:03,956 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:03,956 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:03,956 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:04,456 ERROR  com.serotonin.modbus4j.exception.ModbusTransportException: Invalid slave id
    14:38:04,456 ERROR  at com.serotonin.modbus4j.msg.ModbusMessage.<init>(ModbusMessage.java:33)
    14:38:04,456 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.<init>(ModbusResponse.java:78)
    14:38:04,456 ERROR  at com.serotonin.modbus4j.msg.ReadResponse.<init>(ReadResponse.java:31)
    14:38:04,456 ERROR  at com.serotonin.modbus4j.msg.ReadDiscreteInputsResponse.<init>(ReadDiscreteInputsResponse.java:32)
    14:38:04,456 ERROR  at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:48)
    14:38:04,456 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:37)
    14:38:04,456 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:04,456 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)
    14:38:04,456 ERROR  at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
    14:38:04,456 ERROR  at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
    14:38:04,456 ERROR  at java.lang.Thread.run(Unknown Source)
    14:38:04,956 ERROR  com.serotonin.modbus4j.exception.ModbusTransportException: CRC mismatch: given=8208, calc=14308
    14:38:04,956 ERROR  at com.serotonin.modbus4j.base.ModbusUtils.checkCRC(ModbusUtils.java:104)
    14:38:04,956 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:41)
    14:38:04,956 ERROR  at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:41)
    14:38:04,956 ERROR  at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:37)

    Please suggest as soon as possible.

     
  • nikhil
    nikhil
    2012-05-17

    Hi,

    I am trying to implement MODBUS ASCII and MODBUS UDP/IP using modbus4j.but unable to get an appropriate Simulator.
    Does MODBUS PAL and MODBUS PLC support MODBUS ASCII and MODBUS UDP/IP?
    Can anyone suggest any non-commercial simulator(freeware )?

     
  • nikhil
    nikhil
    2012-05-17

    Hi,

    I am trying to discover device in MODBUS POLLER simulator using modbus4j(MODBUS TCP/IP) but couldn't able to discover them .During establishing connection in modbus poll simulator we have to specify the IP of the sys on which another PLC sim (say) is running.
    while performing discovery, if we are using IP of the system on which modbus poll sim is running are not able to discover the device?why is it so?
    how do we discover devices on modbus poll?

     
  • nikhil
    nikhil
    2012-06-20

    We have implemented Modbus protocol using Modbus simulators like Modbus PLC, PAL and  Slave simulators., with which we are able to get virtual devices to be discovered. We are also able to perform read and write operation on discovered virtual devices.

    We would like to know ,Is there any simulator available for Zigbee protocols that offers Zigbee virtual devices ,so that we can implement  the same.

     
  • Raveesh
    Raveesh
    2012-08-27

    Hi,

    Modbus PAL offers 247 instances of device but it allows us to add only 108 instances at a time.

    Can any one,please suggest us how to add all the 247 instances at a time?

     
  • Raveesh
    Raveesh
    2012-10-05

    Hi,

    We are trying to read/write data from a bacnet simulator (Bacnet Server,VTS simulator) .Both are at different instance number
    . remoteDevice = new RemoteDevice(
    instanceNumber,
    Address address,Network network);
    Have created remote device using the above statement and specified the parameters properly.
    but when we are sending the read request at the system on which the simulator is running irrespective of the instance number of the device(which is currently on ) it sends the read response instead of rejecting the request.

    that means every time other parameters are same only the instance number  varies but why the simulator is unable to recognise the request based on instance number?
    Is it the limitation of Simulators or The BAcnet 4j API ?
     

     
  • Please note that you are in the modbug4J forum.

    If your request is sent properly, i.e. with the correct instance id, then i'd suggest it is the simulator that is responding incorrectly. What you can try is to set up a BACnet4J listener and send the same request to that, and see how it responds.

     
  • madwhoo
    madwhoo
    2012-10-20

    hi i am new in this type of programming. and also to this website. i am trying to read holding registers but its not working can you help me?
    i am using these line-
    System.out.println(getValue(modbReadLocator));
    ModbusResponse response = (ReadResponse)send(request);
    new ReadInputRegistersRequest(slaveId, readoffset,1 )

     
  • madwhoo
    madwhoo
    2012-10-20

    hi i am new in this type of programming. and also to this website. i am trying to read holding registers but its not working can you help me?
    i am using these line-
    System.out.println(getValue(modbReadLocator));
    ModbusResponse response = (ReadResponse)send(request);
    new ReadInputRegistersRequest(slaveId, readoffset,1 )