If I am not wrong, your program extracts only one value from a single channel (Index 0) at each read performed.
At triggering of the 5000ms timer, you may shift the read value and compare it to the next value read and keeps whichever is higher to the shift register. Repeat such shifting and comparing until the timer is up. Then, save the last higher value to the file.
I would like to read about 100 or so values if possible and then compare them to a high limit value. If any of those values are higher they are taken out. Then I would take an average of those values and that value would be written out.
Purpose for this is to make sure that the values that I write is real and not a spike value that just got read.
What I'm looking to do is to take my current program and modify it so that the outliers or erroneous data is taken out.
By saying this I would need to take a certain amount of data points from my channels lets say 100 reads and then stripping out 10 of the highest values (I dont care if the highest values are good values) and then averaging the other 90 values.
A problem that I have is that the array that I have is one dimensional and I have different values for each channel (voltages, temperatures etc.).
Attached is my code (please incorporate the code that I attached if possible).
I am getting more and more confuse about what you really wish to accomplish in your code. Perhaps, you wanna indicate clearly in your code of which is the array of interest and of which element in the array you wish to collect for saving? etc.
In fact, it should not be difficult if you know exactly the data that you want to collect. We are always here to help, guide and even learn, but we really cannot affort to do the coding without letting you try it out on your own.
Let us know your array thus element of interest, and see how we could help you from here 🙂
I have changed my mind from the previous post, that is why I reposted again sorry for running you into a loop.
Let me reiterate what I'm trying to accomplish. Based on the attached code I need to simply take 100 readings (which I'm not doing) from my channels and then strip out 10 of the highest values in the array and then average the remainding values.
After that I need to write the average number in an excel file.
I am getting more and more confuse about what you really wish to accomplish in your code. Perhaps, you wanna indicate clearly in your code of which is the array of interest and of which element in the array you wish to collect for saving? etc.
In fact, it should not be difficult if you know exactly the data that you want to collect. We are always here to help, guide and even learn, but we really cannot affort to do the coding without letting you try it out on your own.
Let us know your array thus element of interest, and see how we could help you from here
1. Extract 100 readings from each iteration, Remove 10 most highest readings, compute average of the rest and save to file. Or
2. Extract 100 readings over 100 iterations (which means each iteration might takes more than 5000ms). At completion of getting 100 readings, remove the 10 most highest readings, compute average of the rest and save to file.
Nevertheless, please find attached an example on how the 10 most highest readings could be removed. If this is what you wished to perform, you may add this code into your main code.
Ian, Option #2 will do it and I understand your code that you sent but I have a trigger wont I see 0's when its triggering. Also how will I average the numbers with 1D array coming out with different values and such?
-------------------------------------------------------------------------------------------------------- Hi Pier,
I am not sure if you want to
1. Extract 100 readings from each iteration, Remove 10 most highest readings, compute average of the rest and save to file. Or
2. Extract 100 readings over 100 iterations (which means each iteration might takes more than 5000ms). At completion of getting 100 readings, remove the 10 most highest readings, compute average of the rest and save to file.
Nevertheless, please find attached an example on how the 10 most highest readings could be removed. If this is what you wished to perform, you may add this code into your main code.
Not sure if this is what you have been trying to do.
I have, basically, added two subVIs into your demo.vi
These subVI perform #of loops for AI 1-SCAN. And, for each loop, top 10 readings of the AI output array is removed and the remainers are computed for its mean value. After #of loops are executed, the array[average] is output for file saving.
I cannot find out why the write portion does not output correctly. I have looked deeply into the files and I beleive that when the max and min files are determined that its not outputing correctly.