10-05-2010 06:23 AM
Hello,
This is a complex task.
I attached a vi (LV 8.5) to demonstrate my dilemma.
I am plotting the data to XY Graph. My task is to find the point where the curve "jumps" and the point where the "jump" ends. It is easy to approximate where those points are: jump start x coordinate is about 4650 and jump end x coordinate is about 6000. But how could LV code does it? One thing I have tried is in the example.vi. While loop compares consecutive data samples and if current sample > previous sample +0.2 it increases the counter by 1. And if it is not, the counter is reinitialized back to 0. While loop ends when counter is >= 100 or time out happens. Now it finds the jump start to be at 4875. While loop for jump end searching is also incomplete.
Maybe this is not the most reliable way to do it. Any ideas?
I also tried to use linear fit.vi but you have to split the data into the 3 pieces (data before jump start, jump itself and data after jump end) and in that case you still have to know where jump start and jump end are.
BR,
Jick
10-05-2010 07:08 AM - edited 10-05-2010 07:17 AM
Let's try again...
10-05-2010 09:40 AM
Jick,
I think you may have some trouble defining the boundaries of the jump because of the noise on the signal. The 4650 point you call the starting point is definitely affected by the 2 cycle per 1000 motor pulse interference. Similarly, does the jump end at ~5100 or 6000? The dip at 5500 is very similar to the one at 9000.
I put together a simple split and threshold method which produces 4750 = start and 5074 = end. I am looking at refining this with linear fits and intersections of lines. If that works, I will post back later.
Lynn
10-05-2010 10:17 AM - edited 10-05-2010 10:27 AM
What about
1. Filter the data (from both sides to cancel any delays caused by the filtering)
2. Take the differential of the data
3. Find location of peak (max value) of differential data
4. Look on both sides for the adjacent zero crossings which determine the points where the slope changes direction
Cutoff for filter = 0.01, I get 4602 as start and 5135 as end.
Cutoff for filter = 0.005, I get 4508 as start and 5241 as end.
Hard to tell what is data and what is noise.
10-05-2010 10:19 AM
Here is a version with linear fits to the before, jump, and after array subsets. The start and end locations are calculated from the slope and intercept outputs from the fit VIs using the mx+b equation for a straight line.
This finds the start at 4675 and the end at 5147.
Sorry the code gets a little messy at the lower right corner. I did not take any time to clean it up.
Lynn
10-05-2010 10:45 AM
Here is what I tried to do.
10-05-2010 01:29 PM - edited 10-05-2010 01:29 PM
Thanks guys,
I take a closer look tomorrow about what you have done.
The jump really ends at ~6000 and it should be found. The one at ~5100 is a periodical disturbance, possibly from the mechanics or from the product. Not sure yet. That should be somehow ignored by the code.
I added averaging method which filters the code pretty nicely. If it helps...
BR,
Jick
10-05-2010 02:31 PM
What generates the jump? What is the source of the variations in the horizontal portions of the data?
The reason for asking is that often a knowledge of the underlying mechanisms or a good model of the behavior can be helpful in defining the transitions between segments. For example if the end of the jump is really at 6000, then a straight line model of the jump is not going to work very well because the data tilts toward the horizontal significantly between 5000 and 6000 compared to the data between 4600 and 5000.
Lynn
10-06-2010 02:23 AM
The code calculates difference between ideal screw and screw with the small chance in spiral. When the spiral of a screw changes, you see the jump.
Tester mechanics creates most of the noise in the signal. Software should take care of the rest. In other words, jump's start and end have to be found.
I have no more data available at this point to do more tests with your code. I try to find out where really is the actual end of the jump. If the jump is at 6000 (in this case, with this data) codes should be changed somehow to ignore the "fake" end and continue to search next possible end.
BR,
Jick
10-06-2010 05:02 AM
johnsold, y start doesn't fit to corresponding x start value in your example2.3. X start is 4675,12, y start should be about 14. Your code calculates 5,20465. Same to the ends.
Jick