Send Command Get Lost Or Delay


raining010

Recommended Posts

Hi, everyone

 

I encountered a problem these days. I use DF to write command to a remote Modbus slave, sometimes after 3 or 5 seconds the remote execute my command, sometimes there is no response and needs more click. How to solve or improve this problem?

The address config should have no problem, and I used button to start sequence with command in, and also tried moving command into button's quick sequence, they all didn't work well

post-8996-0-78601400-1386898989_thumb.jp

Link to comment
Share on other sites

Do you have lots of other channels that you are reading?  What is the timeout for the port?  Its possible that DAQFactory is busy doing many other queries and thus the query to send the output is getting delayed, or if the delay is more than the timeout, it just never goes out and you get a port locked error.

Link to comment
Share on other sites

Hi, I used 247 variables reading remote modbus slave, and 10 variables writing into remote modbus slave.

About 247 variables, they are all read holding S16, and same modbus station address,  I have tried to make them to be continuous addresses.

About 10 variables, they are all force coil

Link to comment
Share on other sites

It will all depend on what the total bandwidth required to read the inputs is vs how quickly you are trying to read them.  If they all have the same timing/offset, try setting the timing to something large like 10, then go to the comm monitor and turn on the time stamp for tx/rx.  Then look at the time at the start of a block of reads (the first Tx), and then the time of the last Rx in the block.  That's how long its taking to read all your inputs.  If that's greater than your normal Timing value, or even your Timeout, then you don't really have room for outputs.

Link to comment
Share on other sites

thanks, I revised time from 1 to 5, will check this. By the way, this RS485 link only has one modbus slave station, can I divide these 247 reading variables as two groups? They all have same station address.

I used this way while there were two modbus slave stations on same RS485 link.

Link to comment
Share on other sites

Hi, I want to improve its communication quality, as DF is our standard scada software in future, and I will write more programs, I want to solve it in this project.

 

Totally, one RS485 link has one modbus slave, the module is our own product, and we always read about 300 variables, write about 20 variables(actually due to manually click, only several variables are written to slave). How can I make it communicate fast? Extend timing, divide variables by different offset, or define several groups? Or is there good topic in forum about this?

 

Thanks very much

Link to comment
Share on other sites

Probably the easiest thing to do is to figure out how many registers you can read in about 200 milliseconds.  Use the monitor with "Time of Tx/Rx" checked.  Slim down your app so you are reading, perhaps 20 registers, by setting all the other's Timing to 0, then see how long it takes to read all 20 registers.  Increase or decrease the number of registers until the time is about 200 milliseconds.  Then group your channels in blocks that size by putting them in different groups.  Set the timing to 0 for all of them.  Make sure not to include any output channels in these groups.

 

Finally, create a little polling sequence to do the polling, introducing small gaps for outputs.  Let's say you simply named your groups group1, group2, etc.  The sequence would simply be:

 

private groupDelay = 0.05

while(1)

   try

      channel.readGroup("group1")

      delay(groupDelay)

      channel.readGroup("group2")

      delay(groupDelay)

      channel.readGroup("group3")

      delay(groupDelay)

      channel.readGroup("group4")

      delay(groupDelay)

   catch() 
      ? strLastError)
   endcatch
   delay(1)
endwhile
 
This will create a little break between each block to allow for outputs.  Now, if you want the reads to be evenly spaced, say every 10 seconds, you'll need to modify the code a little as the above code will take however long it takes to read all the groups + # of groups * groupDelay + 1 second each iteration.  The change is pretty simple:

 

private groupDelay = 0.05

private interval = 10

private nexttime = systime() + interval

while(1)

   waituntil(nexttime)

   nexttime += interval

   try

      channel.readGroup("group1")

      delay(groupDelay)

      channel.readGroup("group2")

      delay(groupDelay)

      channel.readGroup("group3")

      delay(groupDelay)

      channel.readGroup("group4")

      delay(groupDelay)

   catch() 
      ? strLastError)
   endcatch
endwhile
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.