Author Topic: Where are functions 2 and 4 of ModBUS ??  (Read 1351 times)

peer

  • Newbie
  • *
  • Posts: 22
    • View Profile
Where are functions 2 and 4 of ModBUS ??
« on: August 11, 2014, 05:38:32 pm »
It seems that the ModBUS implementation doesn't have function 2 (read input status) and function 4 (read input registers). Why not ?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #1 on: September 01, 2014, 09:12:30 am »
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

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #2 on: September 01, 2014, 12:45:14 pm »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #3 on: September 01, 2014, 02:43:57 pm »
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

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #4 on: September 01, 2014, 05:31:29 pm »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #5 on: September 01, 2014, 08:45:20 pm »
Hello

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

Code: [Select]
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

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #6 on: September 02, 2014, 05:06:23 pm »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #7 on: September 02, 2014, 05:58:22 pm »
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

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #8 on: September 03, 2014, 07:18:55 am »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #9 on: September 03, 2014, 07:45:06 am »
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

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #10 on: September 18, 2014, 06:23:03 pm »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #11 on: September 22, 2014, 08:08:27 am »
Hello

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


Quote
Reading 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

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #12 on: November 03, 2014, 10:01:14 am »
Quote
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.

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

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #13 on: November 03, 2014, 06:05:41 pm »
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.

peer

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Where are functions 2 and 4 of ModBUS ??
« Reply #14 on: November 05, 2014, 10:59:27 am »
Thanx !