04-11-2017 03:16 AM - edited 04-11-2017 03:17 AM
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
04-11-2017 06:14 AM
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
04-11-2017 06:55 AM
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?
04-11-2017 07:20 AM - edited 04-11-2017 07:32 AM
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 ?
04-11-2017 04:27 PM - edited 04-11-2017 04:30 PM
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.
04-12-2017 01:01 AM
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?
04-12-2017 11:31 AM
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.