LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create executable that uses mathscript? (LabVIEW 8.2)

Hello all, I have a rather lengthy algorithm developed in MATLAB that needs to be ported to LabVIEW 8.20, with the restraint of having to execute my code in under half a second. If I use the MathScript node/window, I can get the code to run in ~100ms by compiling it in the window and then running the VI. If I don't compile the code before running it, it takes approximately 16 seconds each time I run it, plus some hang up time after it finishes, as if it is closing something. However, it seems that I have to recompile every time I load the project or close/reopen the MathScript Window. My first question is if there is anyway around this, like saving the compiled code to be used if the program is closed and reopened. But in the end, the whole thing must go in an executable. I saw that in 8.20 MathScript code can be built into executables, but the executable that results still takes 48 seconds to run each time. Is this unavoidable? In the build specifications, I've checked the Enable MathScript Support box, and included the code file in the Dynamic VIs/Support Files category and have tried all the options under Additional Exclusions in the build spec window. By compiling the code in the MathScript Window and clicking Save All in the Project Window, there is an option to save a VI that the script seems to have created, which I have also tried to include in the build but received the same results. Any help at all would be greatly appreciated. Thanks in advance,

Chris
0 Kudos
Message 1 of 7
(3,649 Views)

Hello Chris,

After running the exe once (taking 48 seconds), does it begin to run faster?

Could you include an example of both your code and the exe?  If you create a Mathscript exe with just a simple algorithm (say, add two numbers), do you see similar performance?

Let us know so we can help out,

Janell R | applications engineer

0 Kudos
Message 2 of 7
(3,643 Views)
Hi Janell, thanks for responding.

The exe does not run any faster if I run it multiple times. I've only ever run it three times in a row, however, before giving up on that build.

I've attached a zip of the project folder that includes the m file and the project/VI files. The exe is also in there in the folder 'Cueing'. I did make a simple MathScript program that added two numbers and it ran fine, both using a function call and the MathScript window and just putting the code in the MathScript node. Both implementations had no problems, neither did the exe's using either method.

Thanks,
Chris

Message Edited by ChrisReeves on 07-26-2007 01:41 PM - Well, I don't know if I will be able to attach the exe since the site is timing out on me when I try to upload it. It might just be too big.

Message Edited by ChrisReeves on 07-26-2007 01:44 PM

0 Kudos
Message 3 of 7
(3,634 Views)

Hello Chris,

Since a simple program did not show similar errors in performance, I'm thinking it might be either due to a large amount of data that you are trying to handle or a bug in a function you are using.  What are your thoughts on that?

Have a great weekend,

Janell

0 Kudos
Message 4 of 7
(3,617 Views)
Hi again,

I don't think the issue is a bug in the coding since it will run quickly under the right setup. The code is certainly long and math-intensive, and takes a while to compile through the MathScript window, but I'm never handling large amounts of data all at once unless you count all the stored variables used in the script. As I said before, the program will run quickly when I have the code compiled in the MathScript window and then run the VI, but is there a way to compile the script and then include it in the build so the exe can run as quickly? Thanks again, and have a good weekend,

Chris
0 Kudos
Message 5 of 7
(3,612 Views)
Hi Chris,

Unfortunately, I am not aware of a way to precompile a file and then use that precompiled file in your executable to speed up execution.  This would, however, be a great product suggestion that I highly recommend you suggest at our product suggestion center linked.


Regards,

Nadim
Applications Engineering
National Instruments
 

 


0 Kudos
Message 6 of 7
(3,582 Views)
Hi Nadim, thanks for the response. That seems to be answer I got from the email support as well. They say the MathScript is compiled in the background like any other VI, but that doesn't explain to me why it takes so long to execute. I tried using the Formula Node and it worked perfectly after changing the syntax, so if anyone else has similar problems and has simple math, try that.

Chris
0 Kudos
Message 7 of 7
(3,568 Views)