LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Arrays

Solved!
Go to solution

I am trying to create an two data arrays and display them on my front panel as I aquire them over time. I do not know why, but neither array appears to be saving the values that I expect and neither are displaying correctly....

 

The first array is simply an index of stage positions and the second is the data aquired at each position. For the "Last Scan" display, it shows my data once and then does not update, and for my averaged array for the averaged data over time, it never shows anything.

 

Additionally, my array that is saved at the end is all zeros for my data, despite the fact that I know that the program is reading non-zero data points.

 

Any advice would be greatly appreciated.

 

0 Kudos
Message 1 of 9
(2,579 Views)

it wouldn't let me post with an attachment initially, so here it is.

0 Kudos
Message 2 of 9
(2,578 Views)

I cannot test without your gear, but there are a couple of simple beginners mistakes:

 

Realtime monitoring:

Dataflow problem. The loop conditions will never change once the loop runs. The control terminal needs to be in the innermost loop.

 

Saving problem:

You have an uninitialized shift register, meaning it starts out as an empty array. Adding an array to an empty array will always result in an empty array, because the shorter array "wins". LAter building the 2D array will pad with zeroes. You need to initialize the shift register with an aray of the proper size. You could multiply the array output from the preceeding loop by zero and wire from the outside of the shift regsiter.

 

There are probably other problems, I have not studied the code in detail. For example the larger sequence structure has no purpose. The innermost while loop should be a FOR loop, etc.

Message 3 of 9
(2,570 Views)

I took a quick glance while im waiting for a question of mine to be answered and from what I saw, you have some serious loop issues. 

 

1 issue to me is your DAQmx is not set up properly. You need to set it up so that is Starts, Reads in a loop, and stops outside a while loop. That loop should probably be seperate from the timed loop it is embedded in right now,too. If the "realtime Monitoring" button is True, your code is stuck in the loop inside the case structure. As long as it is in there, the outerloop will not iterate until the inner loop is stopped( Realtime Monitoring=F)

 

 

0 Kudos
Message 4 of 9
(2,565 Views)

Yes, well this is the first piece of labview I've ever written.

 

Is there a way to see what the values of an array are while stepping through the code without coding an output to the front panel?

 

I initialized the shift register, but when I get my output from the program the only 2 values in the array are at the 99th position ie.

 

0, . . . 99, 0

0, . . . 0.35, 0

0 Kudos
Message 5 of 9
(2,549 Views)

double post.

0 Kudos
Message 6 of 9
(2,542 Views)

Here is the updated code. To be honest, I don't really care about the realtime monitoring stuff at the moment, I am just trying to get my arrays to save properly, so if you could please focus any help in that area, I would appreciate it.

 

All of the loops have been replaced with For loops and I believe everything is initialized now.

0 Kudos
Message 7 of 9
(2,542 Views)

aethelwulf wrote:

Is there a way to see what the values of an array are while stepping through the code without coding an output to the front panel?


Use a conditional array probe in the desired location.

Message 8 of 9
(2,538 Views)
Solution
Accepted by topic author aethelwulf

I forgot to invclude a shift register, it's all working now.

0 Kudos
Message 9 of 9
(2,524 Views)