03-31-2015 05:16 PM
I have a program that runs DC and AC tests on some pieces of electronics. The values of the measurements are saved to arrays. Sometimes I need to run only one of the two tests, rather than both. When I run only one of the two tests, the array of the non-run test is empty in the saved file. However, I would like to have an array with, say, all zeros (or -1) for the test I don't run, just to keep a consistent format for the saved file. Right now the problem is easily solved because I have boolean switches on the front panel that allow me to choose what kind of test to run, and this in turn determines what is saved in the file. However, I am about to switch to a new version (my boss's decision, not mine) where I will not be using switches, but rather control how to run the tests from spreadsheets. Is there a way to initialize arrays so that if one of the two tests is not run, the program will save an array with fixed values? Sorry for the long thread. Here is the vi, if it helps.
03-31-2015 05:32 PM - edited 03-31-2015 05:48 PM
You are misunderstanding the concept of local variables. They just point to a specific control or indicator, so it makes absolutely no sense to write to an indicator and to a local variable of that same indicator in parallel. That's a duplication of effort. The data will be in the indicator no matter how you write to it. Also reading from a control is non-destructive, so it makes no sense to wire it back to a local variable of itself.
Instead of local variables, keep the various arrays in a shift regsiters where you can read or update them as needed from any of the program states.
You also should NOT save the VI with huge amounts of default data on controls and indicators. That just inflates the size on disk. Where do the "fixed values" come from? If all elements are the same, just use "initialize array". If the size is the same as an existing array, just multiply it with zero to get an array of the same size, but with all zeroes.
How is the VI controlled "from spreadsheets". Seems very vague.
04-13-2015 02:22 PM
Hi,
Thank you for your feedback and sorry for the late response. I will try to do it with shift registers. The subvi called port writer reads the values from a spreadsheet and runs the logic that controls what is written to the ports.