04-20-2011 02:40 PM
I am using Modbus TCP to send and recieve data between NI Vision Builder AI and my machine control program. Communication is fine, but the time it takes to complete one inspection varys from 500 - 1500 ms. Ideally this should be much faster. I have pinpointed the problem to the data transfer using Modbus TCP. My setup is as follows:
1. I write a value to an coil register
2. VB is looping in a state waiting for that value
3. Once VB sees the value, it continues to the next state and performs it's inspection.
4. VB writes data to input registers for my machine program to read
The problem is that 500-1500 ms passes between steps 1 and 2. I am running both programs on the same computer and have no physical ethernet network. Why does it take so long to write and read a single register value?
Thanks in advance!
04-20-2011 04:29 PM
Which version of Vision Builder AI are you using? In 2010, I tried the attached inspection, and it takes much less than 500 ms from the time I write the coil to the time the image is acquired in the second state.
Would that be possible to make a copy of your inspection, depopulate it to show just that problem and attach it so we can take a look at it?
04-21-2011 08:37 AM
I am using Vision Builder 2010. I am using localhost IP address 127.0.0.1.
Please see attached file. It is basically the same as yours except I am writting an additional value to an Input Register for my macine program to read.
Notice on this screenshot that the total elapsed time from when I write a value of '1' to the trigger (coil resiger 0xA) to the time I receive a value of 1' from the inspection complete flag (input register 0x0) is 783 ms
I suspect it is the modbus read/write that is taking so long because if I turn the trigger on before running the inspection and run a benchmark test, the entire inspection only takes a hair over 7 ms.
I have also tried this on a newer computer with similar results.
Thank you for your help
04-22-2011 04:34 AM
Can't we imagine that the application VBAI communicates with, is consuming too much CPU compared to VBAI ?
The modbus service running in VBAI must have quite a low priority so if there is a CPU overhead caused by another application, it may explain why Modbus R/W takes so long to occur.
04-22-2011 07:55 AM
Thank you for the suggestion, but I have tried changed the prioriy setting of the applications and received the same results.
We use Modbus TCP with several other applications, so I don't understand why it is so slow with VBAI.
Any other thoughts or suggestions would be appreciated, Thanks
04-22-2011 08:20 AM
Upon further investigation, I noticed that while VBAI is looping in the "wait for trigger" state, my CPU usage is near 100%, but as soon as it moves on and continues with inspection, the CPU usage drops down to normal levels. Any ideas why my CPU usage is so high when it is simply waiting in a state?
04-22-2011 08:51 AM
Try adding a Wait step in the state that loops. Say 5ms. This should free some CPU time for other apps.
Also, do you experience the problem in both configuration and inspection mode, or inspection mode only. The timing in both mode is different.
04-22-2011 08:59 AM
Also, the period at which the Modbus server is checking for incoming messages is configurable in the Vision Builder ini file located here: <Program Files>\<National Instruments>\Vision Builder AI 2010\Vision Builder.ini
This is the LoopRate key in the [Modbus] section. The default value is 200ms, which is fine for most applications, since most applications don't require really fast Modbus communication.
You can try to lower it to increase the responsiveness of the server.
That, in conjunction with adding a small delay in the state that reads the register should help.
04-25-2011 03:39 PM
Excellent! Changing the LoopRate key did the trick. Adding the wait and running in inspection mode also helped reduce CPU usage. I appreciate your help.
08-29-2014 06:33 PM
Can anyone suggest where to find the loop rate setting in VBAI 2013, installed on Windows 7? I don't see any Modbus entries in this file:
C:\Program Files (x86)\National Instruments\Vision Builder AI 2013\Vision Builder.ini