LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus test without connected device results in high processor usage

Solved!
Go to solution

I use NI cRIO 9076 with Modbus display connected through serial port on cRIO chassis. I use NI Modbus Library 1.2.1.42, block Create Serial Master to check display presence - if I get error 56, the display is not connected. In that case, reference is closed with Shutdown block. VI works fine but results in huge processor usage around 60 % for around 10 seconds, even though both Modbus VIs are finished and program waits at Wait block. On the picture from Distributed System Manager, you can see CPU usage with period of 15 seconds, which is timing of the loop. (Each peak is about 5 seconds long.) If the loop period is short, say 1 second, CPU usage has still the same peaks, but close to each other - that is pretty weird.

 

I have no display at the moment to test the behavior of Modbus when display IS connected, but I need to get rid of this problem. Any ideas how to test display connection without starting Modbus Serial Master, which obviously needs a lot of overhead?

 

Minimum working example is included.

 

image.png

0 Kudos
Message 1 of 5
(2,655 Views)

Dear Thomas444,

 

In order to resolve the issue, I need to ask you if the VI running on it's own does consume this high percentage of CPU, or this behavior happens only while there are more VIs running in paralel ? Another thing, that should be taken in consideration is the display you are using. What type of the screen is it ? To find a solution, I think we need to know more details.

 

Regards

FH

0 Kudos
Message 2 of 5
(2,613 Views)
Solution
Accepted by Thomas444

Hi Thomas444,

 

Fedor here. After closer examination, I might just have found core issue that is causing issues in your code. Your VI basically establishes a new serial connection every iteration of the loop, specifically, in this case, 15 seconds. This might be probably the reason, why it consumes such amount of CPU. It should be placed before while loop.Inside of the loop should have only code executing actual read/write.

 

My suggestion in this case would be to just simply send a signal every second from display device to host and simply check every two seconds if the signal is received. Also, you can adjust "check time" accordingly to your needs, it's only up to you.

 

I was able to find example project, which comes automatically with Modbus library. In LabVIEW, click Help > Find Examples > Modus Library > Slave on Desktop and Master on Desktop. I hope this  might shed some light on the issue. 

 

Regards

FH

0 Kudos
Message 3 of 5
(2,601 Views)

Hi Fedor,

 

your point is quite clear, I don't get why I didn't think of it earlier. I will try running it ASAP and hopefully let you know in this thread.

 

Thank you!

0 Kudos
Message 4 of 5
(2,584 Views)

Opening ref only once works like charm! Thank you.

0 Kudos
Message 5 of 5
(2,547 Views)