LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire values & store in an array

Hi guys,

 

Once my program execute, it constantly get values from an output.

 

1) How do I store this values in an array? For example, I may need to acquire 10 values every few ms & store them in an array.

 

2) Once array is full, I need to find the max out of all the values for display.

 

3) After which, clear the array & repeat the steps.

 

Any example I can refer to?

Many Thanks.Cat Happy

 

0 Kudos
Message 1 of 2
(4,068 Views)

This doesn't seem a difficult task: where do you find problems and which one?

 

A pseudo-code framework for your task could be:

#define MAX_SAMPLES   10

int  index = 0;
double  result, *array = NULL;

// Dimension result array
array = calloc (... MAX_SAMPLES, ...)

// Loop through the acquisition
do {
  // Acquire measures in 'result' variable
// ... your code here // Acumulate in the array array[index] = result; // Acquisition complete? if (++index > MAX_SAMPLES) { // Find the maximum MaxMin1D (...);
// Display // ... your code here // Clear memory and restart acquisition Set1D (array, 0, MAX_SAMPLES); index = 0; } } while (endCondition)

Keep in mind that this simple skeleton is simply a proof of concept: no error checking inside, no evaluation of loop end, no interaction with the user and system blocked in the loop. Nevertheless, it can help you plan your solution.

 

MaxMin1D and Set1D are functions from the Analisys library that you need to add to your project.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(4,059 Views)