02-12-2015 02:05 AM - edited 02-12-2015 02:06 AM
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.
02-12-2015 03:53 AM - edited 02-12-2015 03:55 AM
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.