Author Topic: Modbus can't do twice  (Read 576 times)

crestxa

  • Newbie
  • *
  • Posts: 15
    • View Profile
Modbus can't do twice
« on: June 02, 2015, 09:04:37 am »

begin
  HQ_RegBase:=$00A8;      //
  HQ_RegVal:=StrToInt(e420mAMax1.Text)*10;
  HQ_RegAddr:=StrToInt(eAddress.Text);
  nrModbus1.ASCII := grpMode.ItemIndex > 0;
  // write register value by using modbus function 6       //
  nrModbus1.WriteRegister(HQ_RegBase, HQ_RegVal, HQ_RegAddr);
  HQ_RegBase:=$00C8;      // 4-20mA
  HQ_RegVal:=StrToInt(e420mAMin1.Text)*10;
  sleep(100);
  nrModbus1.WriteRegister(HQ_RegBase, HQ_RegVal, HQ_RegAddr);
end;
this procedure can't run twice,
if there is one  nrModbus1.WriteRegister(HQ_RegBase, HQ_RegVal, HQ_RegAddr);  modify nrModbus1 timeout to 100,can be do any time.but when there are two writeregister ,whatever nrModbus1 timeout is ,can't do twice,
if i reopen nrComm1,it can writeregister again ,but not twice.It's seem nrModbus1 want some date back,
if I want some writeregister in one  procedure ,How can i do?BTW:I use  trial version of nrcomm to test
thanks!

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Modbus can't do twice
« Reply #1 on: September 07, 2015, 06:08:35 pm »
Hello

TnrMobus places requests into internal queue.
It sends one request and waits reply (confirmation) or timeout.
After that sends next request from queue.

We inserted your code into Modbus demo and all works fine.

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.