12-13-2012 09:36 AM
Hi everyone!
I built an application that read data from sensors using a DAQ and send it via UDP to a Java application.
The problem is that Labview sends only 1 or 2 datagrams/s (I saw this fact using "String2 indicator") and the DAQ sample rate is 1k/s. Why do I lose so much data?
I attach a sketch of my program.
(The Java program works well... I test it with another application).
Thanks,
Veronica
12-13-2012 11:40 AM
For one thing you have a race condition with your local variable for string and the indicator itself. I assume this is what is triggering your data acquistion to stop. Given that you have a race condition it is very likely you are stopping earlier than you want. You should place your data in a shift register to ensure you are comparing the correct data.
12-15-2012 05:33 AM
Yes, it's for stopping the subVI.
I didn't understand how a shift register could be help to speed up the program...
12-15-2012 08:39 AM
1st make it work.
2nd make it work faster. 😉
/Y
12-17-2012 03:42 AM
Is it the right way to transmit data?
Is faster than befor but is slower than 1000samples/s.
Thanks for your help!
12-17-2012 09:41 AM
You still have the race condition which can lead to problems. If you want to look at speeding things up don't use the express VI. Use teh DAQ primitives to do the work. Express VIs tend to have lots of stuff in them you don't need to do every iteration such as starting/stopping the task every iteration.
12-17-2012 10:42 AM
I agree with Mark that Express vi's should not be used, however I don't see any race condition in the code.
Best performance is achieved this way:
1) create and initialize the DAQ task
2) start the task
3) read data in a loop
4) after the loop, stop the task
5) clear the task
Depending on your specific measurement, the code to do thid may non be trivial.
Try searching an example that meet your needs in the help.
12-17-2012 11:07 AM
@pincpanter wrote:
I agree with Mark that Express vi's should not be used, however I don't see any race condition in the code.
You are correct, there isn't a race condition. I didn't look at teh names closely enough to notice it was String and String 2. However, I would avoid the use of local variable and use wires instead. Take some time to learn how dataflow works and use it in your programs. Leverage the poswer of LabVIEW, don't use bad practices.