# How to detect “fast” changes in signal processing

I'm working on a project where we measure the solderability of components. The measured signal is noisy. We need to process the signal in real time so that we are able to recognize the change that begins at the time of 5000 milliseconds.

My system takes sample of real value every 10 miliseconds - but it can be adjusted to slower sampling.

1. How can I detect this drop at 5000 milliseconds?
2. What do you think about signal/noise ratio? Should we focus and try to get better signal?
3. There is a problem that every measure has different results, and sometimes the drop is even smaller than this example.

Link to data files (they are not same with ones used for plots, but they show latest system status)

• You appear to have a relatively small signal-to-noise ratio. As with most detection problems, you'll want to consider the balance between the probability of correctly detecting the feature you indicated and the probability of falsely declaring that one is there. Which is more important for your application? Do you have any detection latency requirements? – Jason R Sep 19 '12 at 15:00
• The 'noise' looks more like an interference at a particular frequency. If this is the case (a spectrum plot will help), then appropriate filtering will do most of the job. – Juancho Sep 19 '12 at 15:51
• Actually the detection of this feature is very important. But I can live with some latency, but I need to adjust final stop position, becasue I don't know exactly where the part touches solder, and I need to control immersion depth. So for example if I know immersion should be 0,5 mm, I calculate theoretical position according to ideal size of solder globule, but then I need to do the correction for actual size of a globule which I detect by touch - it appears as a change in force. – Petr Sep 19 '12 at 15:57
• The whole measuremnt tool is located on springs, so it can move freely, but it also produces the noise and also we have fixed springs for the whole range of measurements, and of course these problems appears when using highest sensitivity, where measured forces are terribly small. – Petr Sep 19 '12 at 16:02
• Juancho - maybe this could help, but how can I solve it for different weghts of parts, resulting in different frequencies? Also this component changes when part is immersed into solder, because wetting process is reducing the noise level, but this happens only for bigger parts, here it is almost the same when in or out. – Petr Sep 19 '12 at 16:04

The classic reference for this problem is Detection of Abrupt Changes - Theory and Application by Basseville and Nikiforov. The whole book is available as a PDF download.

My recommendation is that you read Chapter 2.2 on the CUSUM (cumulative sum) algorithm.

I usually frame this problem as one of slope detection. If you compute a linear regression over a moving window, the illustrated drop will be visible as a significant change in slope sign and/or magnitude. This approach offers are a number of factors that will require "tuning": for example, the sampling frequency, the window size, etc, will affect the robustness (noise resistance) of the slope sign detector. This is where some of the above comments may be applied. Any filtering or noise suppression that can be applied prior to line fitting will improve your results.

I've done this sort of thing by computing a T-statistic of the mean of the left part of the data vs. the right part of the data. This assumes you know where the transition point is which of course you don't.

So, what you do is try several hundred partition points along the time axis and find the one with the most significant T-statistic.

u_left, u_right : mean of left and right portion
s_left, s_right : SD of left and right portion
n_left, n_right : number of samples on left and right (subtract one from each for the one degree of freedom)

se = sqrt(s_left^2 / n_left^2 + s_right^2 / n_right^2)
T = (u_left - u_right) / se


You can do this as something like a binary search. Try 10 data points, find the largest two, then try 10 points between those etc. This way you could get a pretty precise transition point. I'm not claiming accuracy. :-)

Let us know how it goes!

P.S. You can compute mean and sd as running sums which reduces the complexity of computing this partition function for every single possibilty this from N^2 to N. Doing this you can probably afford to just compute the T statistic at every possible partition point.