10-13-2017 11:20 AM
Is there a method for defining and updating a variable inside a MathScript RT node without using a shift register? Something like this except that it would actually run:
I had a couple ideas but they didn't work:
The reason I don't want to use a shift register (like with variable 'i') is that the actual script will have a lot of arrays and variables. I'd like to avoid "mapping" the variables to the arrays in order to pass their values to the next iteration.
Any suggestions?
10-13-2017 11:39 AM
Is there a specific reason for using the Mathscript node to do array math? Switch everything over to Labview primitives and throw it all into a subVI. Make use of the auto-indexing functionality of for loops, along with shift registers for storing values between loop iterations.
10-13-2017 11:41 AM
j_lewis,
I don't quite understand your reasoning for why you don't want to use shift registers. Do you mind elaborating a little more?
If you want to store values locally in a RT system and then access them, this link covers the different methods.
Keep in mind that if you want to maintain determinism, you should use a Single Process Shared Variable with RT FIFO enabled (either single element or multi-element), or an RT FIFO. Generally, the Shared Variable will be easier to implement but the RT FIFO allows dynamic configuration and faster execution speeds.
Best,
BrandonN
Applications Engineer
10-13-2017 12:40 PM - edited 10-13-2017 12:43 PM
A quick description of this system is that it will read 4k values, perform a few hundred different calculations, then transmit/log about 500 values. It will run on a PXIe RT controller at 10ms.
MathScript RT was chosen as the method for performing the calculations (over primitives, formula nodes, etc.) because a .m script will be easier to read and maintain outside LabView.
Ideally, I would like to input my 4k values as an array into a MathScript Node and output the array of 500 values. What I've run into is that most of the calculations require variables to retain their values from one iterate to the next. The only method I know of is to output the variable and use a shift register. Due to the number of different variables, this would be a sizable effort. I can clean it up by mapping all the variables to an array, but again a very sizable effort.
The method I'm trying to develop is to populate the "workspace" on the first iteration with all the variables, then use that workspace to retain the values for subsequent iterations. It seems like this is what is happening in the MathScript Window but I can't figure out how to do it in the Node.
10-13-2017 04:45 PM
@j_lewis wrote:
MathScript RT was chosen as the method for performing the calculations (over primitives, formula nodes, etc.) because a .m script will be easier to read and maintain outside LabView.
OTOH, a pure g version will be much more efficient and fast. How complicated are these "calculations"? Purely graphical code has many advantages, such as the ability to do certain calculations in parallel.
@j_lewis wrote:
The method I'm trying to develop is to populate the "workspace" on the first iteration with all the variables, then use that workspace to retain the values for subsequent iterations.
Why can't you use the looping within the mathscript node directly? Obviously, we don't quite have all the details of what you are trying to do.