06-07-2012 10:20 AM - edited 06-07-2012 10:32 AM
Your code is just crawling with with weird, overly complicated code and a lot of type mismatches. I don't think there is any good reason to make that array EXT. DBL will be just fine. Also your queue is of the wrong type.
Here's a quick draft.
(It does not have all the features you need and probably has some problems. You need to adapt it further.)
06-07-2012 01:27 PM
So the problem I see with initializing the array to a certain size is that I have no way of knowing how many data points that the program will take ahead of time. There may be 100, there may be 800, it all depends on what the tech running it wants, and he doesn't specify how many data points, just a place to stop.
06-07-2012 02:42 PM
@LarsUlrich wrote:
So the problem I see with initializing the array to a certain size is that I have no way of knowing how many data points that the program will take ahead of time. There may be 100, there may be 800, it all depends on what the tech running it wants, and he doesn't specify how many data points, just a place to stop.
If you have a resonable upper limit (e.g. 1000 or 10000), you can initialize with that. That's peanuts for a typical computer. It is still not clear how you want to build the array and how it should depend on the ring setting. Can you explain.
06-07-2012 04:00 PM
@LarsUlrich wrote:
So the problem I see with initializing the array to a certain size is that I have no way of knowing how many data points that the program will take ahead of time. There may be 100, there may be 800, it all depends on what the tech running it wants, and he doesn't specify how many data points, just a place to stop.
Altenbach is right. I have one application that uses a 2D array with varying sizes. I initialize it with 10,000 elements so I am sure not to exceed the limit. But you need to know your limits and that will depend on the data you are collecting, how often, and for how long.
06-08-2012 08:45 AM
Ok, so I remembered how to do a change of base of log functions and am able to do some math to work out how many data points there are going to be (horray math!), but here is the problem:
If my start/stop frequency controls are outside of the consumer loop, they won't work. The tech will have to abort the program, then type everything in, and then start it again so the values are there when the program starts initially.
However, the initialize arrays need to be outside/before the consumer loop in order to use the shift registers.
The formula box takes the start/stop frequencies and tells me how big my array needs to be, and somehow needs to be wired to the array index.
I attached an image and the actual program itself (not the random number generated copy).
The point of the menu ring in the front is that in order to do this calibration, you need to run the LISN Sweep sub.vi 3 times and measure 3 seperate things. The menu ring in the front indentifies which set of data the user is taking. Now, each time the LISN Sweep sub.vi is run, you get 2 arrays: 1 array of frequencies and 1 array of data points. Since I only need the frequencies 1 time (I don't need 3 sets of the same data) there is the case structure in there that only executes when the 1st option in the menu ring is selected. In the end, my array columns will look like frequencies, data 1, data 2, data 3.
With the insert into array it works as it is (minus the unnesseccary formula) so long as I run the menu ring in order.
If I switch the insert into array with replace array subset will I have to initialize the array size first?
06-08-2012 08:48 AM
... there is an extra array in there I forgot about, it is not supposed to be there, just a remnant of something I was fooling around with. It is the one that is all the way at the bottom of the consumer loop... totally unnessesary and I meant to take it out.
06-08-2012 10:23 AM
You have not defined how many elements you are using in the arrays. You have two 2D arrays "initialized.", but with 0 elements.
You probably do not need a P/C archetecture for what you are doing. You are only passing the ring control value to the consumer loop. You could do this with a basic archetecture, but I would stick with it. It's overkill for what you are doing, but will give you room to grow in the future. This was just an observation.
Your order of operation may be confusing to the operators. They must have the right side controls selected before the Measurement control is used. The Insert into Array function will grow your array, the Replace Array Subset will not, but the array should be intialized first.
How are you handling your errors? I would steer away for Automatic Error handling and use your own.
06-08-2012 10:33 AM
MoReese, that is the problem (and my question):
The size of the initialized array is determined by that formula that is inside the consumer loop. I am not sure how to get that to work properly, as I cannot wire the result to go outside of the consumer loop to initialize the arrays.
06-08-2012 10:35 AM
Sorry, I misunderstood. I will take another look.
06-08-2012 10:44 AM
You can use something like this.