• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

Can not use ModBus by Socket,Why?

Started by sxbug, October 07, 2018, 06:16:23 am

Previous topic - Next topic

sxbug

Hi

     I had added a nrSocket componet to DEMO - ModBus program and changed nrSocket's DataProcessor  to nrModBus1.  At the beginning of the program set nrSocket1.Active:=true;  nrModBus1.Active:=true;
    nrSocket.host=127.0.0.1     port=502

    I also made a Modbus server(just like a PLC device), with other clients(ModBus Client) to read and write are normal, but I can NOT use this program to read and write the ModBus Server, any operate show errors'Timeout!!! No reply from device'.

    How do I deal with it?

    Thanks.


      sxbug

sxbug

i found modbus component send string was error by my tcp toolsã€,send string:3A 30 37 30 33 30 30 30 31 30 30 30 31 46 34 0D 0Aã€,the correct string maybe 01 00 00 00 00 06 FF 03 00 00 00 01
What can I do?thanks

sxbug

I have changed nrmodbus mode to Rtu,but send string is error too,it is shorter then other,why?

sxbug

nrsocket must set servermode=true?else nrmodbusreply is not trigger?
thanks

Roman Novgorodov

Hello

Modbus TCP transfer request RTU packet without CRC and with some additional header bytes.
Job with TCP support for nrModbus component is in progress now.

I hope we can release new version this week.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sxbug


Roman Novgorodov

Hello

You can check new ModbusDemo with your device.
http://deepsoftware.com/nrcomm/modbusdemo.zip

If it works well we will release the new version of nrComm Lib soon.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sxbug

Hi
  I haven't tested it on my device yet. I'm just comparing the string that I've sent(my program) and your program has sent.  It is diffrent a little.When I have time in the afternoon, I'll use the equipment again.

my  :01 00 00 00 00 06 FF 03 00 00 00 01

your:00 01 00 00 00 06 01 03 4A 00 00 01

Great works! Thanks

     sxbug

sxbug

I have used nrcomm 9.51 ,but I could not read any coils and register data from bcnet-fx(FX PLC connect device). for example:
M8000  =   5001,     D0 = 402001,     D1  = 402002, M0  =     10001   ,   M1   =   10002  etc

I can read them by my old prog.

why?

Thanks

sxbug

I had made a Modbus client. I read it by ModbusDemo program. I have read back data. Why did the demo prog display the timeout? just like:
.......
Device: 255 Coil:000A=False
Timeout!!! No reply from device!
Device: 255 Reg:0001 = 0DD7
Timeout!!! No reply from device!
.......

Roman Novgorodov

Hello

Do you real use device id 255 ? Are you sure?

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sxbug


sxbug

Hi:
I read my hardware by the rule (Below list it), and I couldn't read any data at all.
But I can read my computer's virtual Modbus salve data through the demo program. Because only one register client was done, the others(coils ,DI ....)  could not be tested, but after the data read back,the DEMO prog displayed timed out msg  .

Why?

Thanks

Roman Novgorodov

Hello

Please read following quotes from wiki Modbus description:

Quote
...
A Modbus command contains the Modbus address of the device it is intended for (1 to 247).
...


Therefore your device id 255 is strange.

And about numeration:

Quote
Coil, discrete input, input register, holding register numbers and addresses

Some conventions govern how access to Modbus entities (coils, discrete inputs, input registers, holding registers) are referenced.

It is important to make a distinction between entity number and entity address:

    Entity numbers combine entity type and entity location within their description table.
    Entity address is the starting address, a 16-bit value in the data part of the Modbus frame. As such its range goes from 0 to 65,535

In the traditional standard, numbers for those entities start with a digit, followed by a number of 4 digits in the range 1â€"9,999:

    coils numbers start with 0 and span from 00001 to 09999,
    discrete input numbers start with 1 and span from 10001 to 19999,
    input register numbers start with 3 and span from 30001 to 39999,
    holding register numbers start with 4 and span from 40001 to 49999.

This translates into addresses between 0 and 9,998 in data frames. For example, in order to read holding registers starting at number 40001, corresponding address in the data frame will be 0 with a function code of 3 (as seen above). For holding registers starting at number 40100, address will be 99. Etc.

This limits the number of addresses to 9,999 for each entity. A de facto referencing extends this to the maximum of 65,536.[13] It simply consists of adding one digit to the previous list:

    coil numbers span from 000001 to 065536,
    discrete input numbers span from 100001 to 165536,
    input register numbers span from 300001 to 365536,
    holding register numbers span from 400001 to 465536.

When using the extended referencing, all number references must have exactly 6 digits. This avoids confusion between coils and other entities. For example, to know the difference between holding register #40001 and coil #40001, if coil #40001 is the target, it must appear as #040001.
...


Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sxbug

I will try again tomorrow by modifying the Slave ID and device address.            Now another question is, why do I read back the data on a software ModBus salve, but still display the error message-‘Timeout!!! No reply from device! ’     ?

Thanks