08-23-2019 09:48 AM
Hi everyone. I'm trying to acquire data to an array and then do some other options. In order to make the data placed in a rising sequence I want to have the array start from "0". To be specific, I want it to be "0,1,2,3" instead of "1,2,3,0" or "2,3,0,1". Now I'm trying to achieve this goal by using case structure and when the first data of the 1D array is "0" then start save the data to the array. 2 days ago I made the code work but afterwards it cannot function as I wish. I think there must be errors which I didn't figure out. Any feedback would be helpful. Thank you!
Hereby is my code.
08-23-2019 10:08 AM
In my experience in the world of data acquisition
"zero is a fictitious number".
Comparing to "0" will only work if there is something wrong.
Ben
08-23-2019 10:45 AM
Agree with @SirBen.
You are looking at an analog input and trying to save on the condition when that input exactly equals 0. Unless you have a noise free environment, the chances of that happening are little to none.
Check to see if the value is in a specific range instead of zero. Best case scenario, ± 1 bit from 0, but you would probably have to increase this. However, that is not a good assumption, I would go with at least ± 5 bits on either side of zero. Note this assumes your digitizer has no DC bias. If it does then I would go with at least ± 5 bits on either side of the signal mean(DC Bias).
mcduff
PS Don't use a timed loop. Let the acquisition rate control the loop.
08-27-2019 09:14 AM
The range should be around ±0.02 on either side of zero. But I found that the computer can only work out at most 0.3 on either side of zero.
08-27-2019 09:39 AM
@chen3477 wrote:
The range should be around ±0.02 on either side of zero. But I found that the computer can only work out at most 0.3 on either side of zero.
Use In Range and Coerce
Not sure what you mean in your second sentence. If the Offset is 0.3V, then either look at the range 0.28 - 0.32V or subtract the mean from your signal such that it is centered at 0.
mcduff
08-27-2019 09:55 AM
Sorry for misleading. I mean the range should be from -0.02 to +0.02 but when I set like this, the code can't work out. So I enlarge the range and when it goes from -0.3 to +0.3 it works.
08-27-2019 10:31 AM
You're only looking at the first sample of the N=20 samples you are grabbing. If you have a lot of noise, maybe that first sample is only rarely falling in the tighter +/-0.02 range.