Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus TCP with Vision Builder is Slow

Hello,

 

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!

Josh

0 Kudos
Message 1 of 33
(4,900 Views)

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?

 

Thanks,

 

Christophe

 

0 Kudos
Message 2 of 33
(4,892 Views)

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

 

 

VisionTimer2.jpg

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

 

Josh

0 Kudos
Message 3 of 33
(4,883 Views)

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.

Sami Fathallah
ALLIANCE VISION
HW and SW Components for Scientific Imaging and Machine Vision
http://www.alliancevision.com
0 Kudos
Message 4 of 33
(4,864 Views)

Sami,

 

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

 

Josh

0 Kudos
Message 5 of 33
(4,861 Views)

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?

 

Josh

0 Kudos
Message 6 of 33
(4,858 Views)

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.

 

Christophe

0 Kudos
Message 7 of 33
(4,855 Views)

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.

 

Best regards,

 

Christophe

Message 8 of 33
(4,854 Views)

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.

 

Josh

0 Kudos
Message 9 of 33
(4,833 Views)

 

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

 

Thanks!

0 Kudos
Message 10 of 33
(4,361 Views)