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

Where are functions 2 and 4 of ModBUS ??

Started by peer, August 11, 2014, 02:38:32 pm

Previous topic - Next topic

peer

It seems that the ModBUS implementation doesn't have function 2 (read input status) and function 4 (read input registers). Why not ?

Roman Novgorodov

Hello

Thank you for your interest in our product.

We use several Modbus controllers for tests. These devices implement partial Modbus functions only. We implemented functions that exist in our devices.

I've review functions 02 and 04 in Modbus specification. I think there is no problem to implement these functions in the next release of nrComm Lib.
We planning release new nrComm Lib in the next two weeks.

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.

peer

Thank you. Another question: Can you add a extra delay setting between polling ? Most libraries have that option, the devices are polled then you wait for xx seconds and start polling again. That reduces the load on the system.

Also I have problems with Timeouts, when I do a ReadRegister (no polling) then I get a Timeout event (after xx seconds). Is that as designed ?

Roman Novgorodov

Hello

You can use TnrModbus.DelayRead property for increase Poll interval. It is milliseconds.

I need to look your code that reads registers without polling.
Please upload simple sample proect here.

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.

peer

TnrModbus.Delay is used to delay between each individual ReadRegister. That's okay. What I meant was: read as quick as possible for example 20 registers, then wait 15 seconds and then read again those 20 registers, wait 15 sec., read again etc.. That reduces the load on the system but also on the devices.

Timeout example is easy, just assign the TnrModbus.OnTimeOut event in your ModbusDemo, set the timout to 5000 and read one register (not polling). After the reading and after >5000ms the OnTimeOut event is called.

Roman Novgorodov

Hello

The following code wil poll 20 registers from first $A400 every 15 seconds:

nrModbus1.DelayRead := 15000;
nrModbus1.ReadRegisters($A400, 20, True);

Please try.

We will check OnTimeout issue.

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.

peer

Can't check at this moment because I get "Illegal data value (03h)" error with a ToshibaVF-SW11 motordrive when polling with your ModbusDemo.

Roman Novgorodov

Hello

Hmmm ... Often controllers do not implement full Modbus function set.

Also you can try use the single read operation in ModbusDemo for test device (not poll).

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.

peer

I tried to poll register $FA00..$FA01, also $FE00..$FE01 with the same error as result. If I read those registers as a single readregister then it works. Also with an  DelayRead of 15 sec. ModbusDemo doesn't react anymore during the delay. Is it blocking the main thread ?

Roman Novgorodov

Hello

Please check that Count has 1 (for poll single register as you try when click Read register button).
Also you can set nrComm1.UseMainThread := false; rebuild and try long Poll (read) delay again.

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.

peer

UseMainThread:=False doesn't help, it still blocking the main thread. In the source I can see that the "OnModbusReply" event is called and then the delay is executed (ie. Sleep(DelayReed) )...

Reading multiple registers also doesn't work on different Modbus devices.

Roman Novgorodov

Hello

You can try latest version of Modbus demo project http://deepsoftware.com/nrcomm/modbusdemo.zip.
It provides new option PollDelay.


QuoteReading multiple registers also doesn't work on different Modbus devices.


All works fine in our tests. Possible you forget to analyze Reply.Address value in OnModbusReply event. This event triggers on every modbus reply. One device sends one reply. Two devices send two replies and Modbus demo does not separate them and new result test overwrites previous.

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.

peer

QuoteI've review functions 02 and 04 in Modbus specification. I think there is no problem to implement these functions in the next release of nrComm Lib.
We planning release new nrComm Lib in the next two weeks.


I don't see the new functions in v9.39 :(, when can we expect them ?

Roman Novgorodov

Hello

Oppsss...  Sorry our mistake ...
Latest version implements new methods for Coils reading/writing functionality.

We will release a new nrComm Lib with function 2 (read input status) and function 4 (read input registers) at 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.