LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spurious commands delaying read time

I thought this particular problem had been cured, but it seems to have come back. I’ve been using a Modbus development tool to read ADC output values without a problem. I've written a small vi which should do the same thing. It runs on the same PC and uses the same COM port. Obviously I have to close the Modbus programme to release the COM port for LabView. The vi runs fine, but data only appears on the front panel every 8 seconds.

 

Putting in a 500ms delay in MB Serial Receive.vi improves the response time to around 500ms, but I need 100ms.  A shorter delay just results in 8 second refresh times again. The 500ms delay workaround has been implemented in the vi Reverse Power by putting the delay in a FOR Loop.

 

I’ve created log files looking at the data flows and they are very different between the dvelopment tool and the vi. I’ve attached these. For the Modbus development tool it can be seen that at line 130 that the data is written as a single word, and immediately received as a single word.

 

For the vi, there’s a lot of communication activity at the start that as a novice I don’t begin to understand, but at line 35 the data gets written. However, the read operation doesn’t take place until line 68.

 

I've attached the vi, Reverse Power, and the sub-vi's, and the log files. I would appreciate any ideas on how to solve this problem. Thank you.

0 Kudos
Message 1 of 6
(2,821 Views)

Hello Placebo,

 

Thank you for your post on this forum.

 

I have had a look at your code and I need to ask you for some clarifications to better understand the issue. From your post I could gather that you were experiencing similar issues before. Is this the case? Did you manage to solve it at that time?

 

Moreover, it would be hard for me to test your code since I don't have the hardware you are currently using. It might be useful to give me some more information on what you are trying to do.

 

The link below might help you if you have not seen it before:

http://zone.ni.com/devzone/cda/tut/p/id/7675

Have a look to make sure you have implemented your VIs properly.

 

Many thanks,

 

Shalini B
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 2 of 6
(2,766 Views)

Hello Placebo,

 

While looking at your codes I could see that a lot of parameters (for example; baud rate, etc) are being read or written to inside the loop. This means that each time the loop is executed, these parameters are set which add to the execution time and hence the delay you are experiencing. I would suggest you set all these paramaters outside the loop and keep things like VISA read inside the loop. This might reduce the delay.

 

Hope this helps.

 

 

Shalini B
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 3 of 6
(2,755 Views)
Thank you for your time analysing this. I've taken a beginners approach and used the Modbus library vi un-modified to control a stepper motor. This works fine, although of course no data is being read back. I've used the same un-modified Modbus library to read data, but data only appears on the indicators I've added to the library vi every 8 seconds. Adding a delay makes the data appear on the indicators much faster.
0 Kudos
Message 4 of 6
(2,728 Views)

Hello Placebo,

 

I am glad that you managed to solve the issues you were ecountering. I also have to mention that it is always good practice to put a delay in a loop so that you do not use all the processor time.

 

Well done and if you have any other issue I would be happy to help.

 

Regards,

Shalini B
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 5 of 6
(2,722 Views)

Thank you. I am having trouble integrating the solution. The reason is I really need a response time of 100ms, but of course putting in a delay value of 500ms means I don’t achieve a response time of 100ms. A delay value below 300ms causes the data to go back to refreshing every 8 seconds.

 

Also, even with a delay of 500ms, when I link the vi in COM 2 Share_2.vi, it doesn’t run at all although Stepper Move runs fine.

 

Any tests you can think of would be very much appreciated.

0 Kudos
Message 6 of 6
(2,697 Views)