03-13-2017 07:17 AM
Hi,
I acquire Pitch Roll Yaw angles continuously from a gyro. I would like to check if the value (RPY angles) changes greater than 60 degrees in a time frame of 500ms. I run the loop every 10ms. According to the data below, the value changes 10 to 80 degrees in 5 or more steps when a change actually occurs.
Can someone guide me as to how this could be implemented
01/03/2017 12:19:01,860 10,790822
01/03/2017 12:19:01,984 15,046648
01/03/2017 12:19:02,083 26,481090
01/03/2017 12:19:02,201 40,054445
01/03/2017 12:19:02,300 61,342823
01/03/2017 12:19:02,387 82,453988
03-13-2017 08:27 AM
I think that your question is slightly ambiguous. You state that you are sampling every 10 msec and have a question about values in a 500 msec sample = 50 samples. So let me rephrase the question slightly -- given 50 samples, do you want to know:
Bob Schor
03-13-2017 08:33 AM
Here's one way:
If you sample every 10 mSec, then your interval (500 mSec) is 50 samples.
Create a buffer (array) of size 50.
Use it as a circular buffer, i.e. every sample, you store at BUFFER[i} and then increment i.
If I >= 50, set i = 0.
That means that i always points to the NEXT sample to replace, and the buffer always (after you get 50 samples) contains the most recent 50 samples.
Every sample, take the MAX-MIN of the buffer and subtract MAX - MIN. That's your max change over the last 500 mSec.
You might have to do some special things:
1... If you have zeroes in the buffer at the start, then 0 might show up as your minimum, until you get 50 samples. Disregard the result for the first 500 mSec, or start with empty (0 element) buffer and expand it each sample up to 50, or take the first sample and fill the buffer with 50 copies of it.
2... If your data ranges from 0..359, or from -180..+179, then you have some wrong results when crossing that boundary. (359 - 0 = 359, but it's only a 1-degree change). There are ways to deal with that, but get the first part basically working first.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-13-2017 11:13 PM
Hi Steve,
Thanks for the idea and I tried the circular buffer concept. I am now running the loop at 50ms and so I am checking the every 11 samples (every 550ms) and a threshold of 60 degrees. But there are instances, like in the front panel screenshot attached, where Peak angle value is not added to the buffer because by then, the buffer is full and hence the threshold check condition is not met. I want to check for value greater than 60. How can this be overcome?
P.S. I running the VI with sample data from file and not with the actual acquisition VI
03-14-2017 08:22 AM
I can't see anything terribly wrong there, but then I can't see everything that's there.
Is "Buffer" on the front panel the same as "SubArray" on the diagram?
Do the FALSE cases pass thru the indicated wires unchanged?
If so, then you need to use single stepping and probes to find out what's happening.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-14-2017 09:29 AM
I think the VI is working fine but its the logic now ehich is the problem. I am checking every 11 elements in 550ms. The change in angle in the file starts at index 107 with lowest value of 10 and peak value of 82 at index 111. So this range of 5 values does not come under the multiple of 11 altogether. I hope you understand
03-14-2017 10:00 AM
So... what does a probe tell you the peak is when you extract the array MAX/MIN ?
Looks like it should be 82 if you do a comparison on the data you show.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-14-2017 10:18 AM
The max value is 61. The buffer gets full, moves to index 0 and peak value 82 which comes after 61 is stored at index 0. The next 10 elements are between 80 and 90. the subtraction will give 10 which less than threshold 60 and output is zero. I have attached the data file. Use the VI and you will understand my earler point
03-14-2017 10:21 AM
I set your buffer size back to 11, put some phony data in column 5 of a 2-D string array, and your code does exactly what you tell it to (they usually do).
You are aware that your light will only come on for 50 mSec, right?
The next time you go thru the loop, the index will be different and you turn OFF the light.
If you want to see it longer, put a 500 mSec wait IF TRUE on the output of your CASE structure.
Here's another problem with your code - you will miss some changes unless you test (MAX - MIN > 50) on EVERY SAMPLE.
Note how my original scheme said test on EVERY SAMPLE. You are testing every 10 SAMPLES.
That means that I could have data like 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, and your scheme will not see the change, because it happens to line up with your block size.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-14-2017 10:31 AM
The code you actually sent has some logic errors, too.
You fill up a buffer with 50 copies of "-1". After replacing 10 of those samples with real data, you test the whole buffer for MAX/MIN. your min is.... -1.
As I said originally, you have to ignore the results until the buffer is full, or pre-load the buffer with the first real sample.
Blog for (mostly LabVIEW) programmers: Tips And Tricks