LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Average AI data then save average value to 2D array to get an image

Hello, I am trying to collect AI data from PCIe6363 and planning to average every 10 sample to get one value, then put this value in a certain position of 2D array to get an image when all the average values are filled in the 2D array.

 

In the attached VI, I simulated the sawtooth data and could get the average value. I am puzzled how to give this value into the right position I set in the 2D array. 

I set an zero array and replace one element with the corresponding averaged value in each For loop. 

But I found the new loop array covers the previous array. I need to add them to get an image. How to keep the array values in the previous loop iterations? 

Please help me have a modify to the VI as I attached.

Thank you very much 

0 Kudos
Message 1 of 6
(1,576 Views)

Your 2D array needs to be anchored on the while loop. none of your inner FOR loops are needed.

 

The rest of your code makes very little sense. Why do you generate 100 points per iteration if you only ever keep 10? Is the final image really just 15x15? You say "certain position" but you don't specify what that means (element by element in memory order, for example?).  What should happen once the 2D array is filled? You also have to code that gets constant folded. What's the purpose? Please start with the tutorials listed on the top of the forum.

0 Kudos
Message 2 of 6
(1,544 Views)

Thank you, King of NI, 

The code is for the simulation of AI data storage into an 2D array and then the 2D array need to be transferred to an real time image in the laser scanning imaging system.

In the real measurement, I need to generated an real time image with 100x100 pixels. The AI data is acquired by APD and PCIe-6363 as a time series signal. According to the sampling duration for each pixel, I need to average at least 10 data to fill one pixel of the image.   

In my code attached, firstly I set the sawtooth signal and then get the first 10 data and average them. Then I put this value in the 2D array pixel in sequence till I get enough average value to fill the 2D array. But I found that the new array will cover the previous one not added together. 

If I connect the iteration to the while loop, How can I define the index of the averaged value into 2D array?

Thank you very much

0 Kudos
Message 4 of 6
(1,513 Views)

@Rhapsody16 wrote:

If I connect the iteration to the while loop, How can I define the index of the averaged value into 2D array?


Did you look at my example at all?

0 Kudos
Message 5 of 6
(1,496 Views)

Yes, I run it and it worked well. Thank you.

0 Kudos
Message 6 of 6
(1,490 Views)