06-22-2016 10:11 AM - edited 06-22-2016 10:12 AM
As a first step I would probably get rid of matlab. (Why didn't you even mention it that you are using this?). What is the calculation you are doing?
I don't see where you are measuring the loop time. Are you talking about the inner FOR loop?
What is happening in all the subVIs?
Are you sure the slowdown is due to math and not due to communications with the instrument?
Can you give some real values to the measured execution time (does it slow down from nanoseconds to microseconds of from milliseconds to years, for example?
Again, can you show the entire code, not just some truncated portion?
When you say "running continuously" I assume there is an outer while loop and you are not using the "continuous run" debug button, right?
06-22-2016 10:22 AM
I would repeat what crossrulz has suggested. To test the behaviour you can create indicator out of the matlab node terminal and check the speed. Try to refactor your code with LabVIEW primitives
06-22-2016 11:26 AM
Thank you for the replies.
Calling Matlab can be slow, but is it normal that is getting more slowly in each call?
I can try to do the math in native LabVIEW, but I think that working with matrixes, array products, inverse matrixes... is very slow in LV (in addition to the difficulty to program it). I think that Matlab works more efficiently with these type of structures. The time is critical in my application, so the processing operations mustn't be slow. I'm very worried with this problem because I don't find a clear solution.
I have attached my LabVIEW project. As you can see, there are different subvis used to configure different devices, create directores and other functions. The name of the project is "Project_test_time" and the main Vi is "vi_state_machine_tiempo".
The core of the Vi is a state machine controlled by an event handler. The different states of the state machine are used to initialize the communications, create directories, open files to store results, close communications, close files and to perform the measurements. The state to perform the measurements is the state number 6. It is the state where I use the Matlab script and where are the 'for' loops that I have explained. As you can see, I'm measuring the time lapse in two different sections of this stage and it is stored in a text file. Is the first section where the lapse time is growing up.
There are much parameters that are set to constant. This is because I want only to test the lapse time.
I don't know if my explanation is very usefull. I hope that it may be.
About the altenbach questions:
- The Matlab code is used to obtain the amplitude, the phase and the frequency of the signals captured by the A/D converter (I'm using the LMSE algorithm in order to obtain it). When these parameters I can calculate the impedance and frequency of operation of a sensor.
- Some real values to the measured execution time are about seconds. When the application is running about 1 day it can waste about 10 minutes in order to perform a measurement.
- I say "running continuosly" because there is an outer while loop, as you say.
Thank you very much for your time.
06-27-2016 04:22 AM
Hello again,
I have finally translated the Matlab calculations into LabVIEW. As you say, the problem was in Matlab. Now, the Vi is not getting slowly over time.
Thank you very much.