LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus rate problem

Hello,

 

I have a system where I acquire data from an analogue sensor (via a NI USB-6001) and from a device that transmits data via tcp/ip (code attached). I noticed that when the analogue sensor AND the modbus acquires data there is a gap in the measurement as shown in the attached picture. If I delete the modbus code then the acquired analogue signal is perfect. Why is this happening? Is it a modbus rate problem? and how can I correct it?

 

Thank you in advance

Download All
0 Kudos
Message 1 of 7
(2,651 Views)

what do you call modbus code ? The PL.FB VI ? It is missing in your attachments, can you join it ?

Try set a timeout on your tcp connection

0 Kudos
Message 2 of 7
(2,609 Views)

Thank you for your prompt reply!

Please find attached to this post the PL.FB vi

 

How do you suggest to add the timeout and how can I quantify it? ie what number to put and how to calculate it?

0 Kudos
Message 3 of 7
(2,602 Views)

Well in your MB ethernet master query there is a 5 sec timeout (versus 10 sec for your DAQmx VI).

You don't close the TCP connection at the end also ... 

In your picture the software seems to be working at the begining then there is a gap ? It is the analog value or the TCP value which cause problem ? I think at one moment information is missing from one of your 2 module hence the gap. Is the problem random ?

0 Kudos
Message 4 of 7
(2,594 Views)

There is nothing guaranteeing that the data points are going to be equally separated each time. The time of your graph is determined by the current time minus the start time, but the current time is "sometime" between iterations. When you were using just the 6001 that time was pretty solid because you are probably just grabbing buffered data from the 6001, but there was still no guarantee that it was going to be the same every time. The reality is that the modbus read is going to take as long as it need, and your code in the loop is going to take as long as it needs, and that time is going to affect the x axis of the graph.

Message 5 of 7
(2,561 Views)

The problem seems to be random.

Can you please point out where the MB master query has the 5sec timeout? I was under the impression that its at 10sec too.

I added a TCP close but the problem persists.

 

Any other ideas?

0 Kudos
Message 6 of 7
(2,537 Views)

I don't have the 'MB Ethernet Master Query.vi', but I don't think the timeout has anything to do with the problem you are seeing. It looks to my like you are trying to get a rate of 10 ms between points, I don't see how a time out of 5 seconds vs 10 seconds would have any impact on that. I think the problem is that sometimes the code in your while loop is done within 10 ms, but sometimes it's not. That is going to affect how your graph looks.

0 Kudos
Message 7 of 7
(2,522 Views)