title: Patternmatching to detect signal edge?
body: <p>I have a analog signal and I want to detect edges/'waveforms'. The waveforms to detect are sometimes as simple as in the first example below (simple rising edge), but also more complex (like a rising edge with a preceding smaller 'blob'). The Signal has noise and unwanted smaller signals, so a output like 'matching grade' 0.0 to 1.0 would be nice to set a threshold.
  Another requirement is the detection time: The algorithm has to 'trigger' within 1 'rise time', like the red blob circle in the image. As early as possible, but not before maximum is reached.</p>
  
  <p>Everything will be executed on a STM32 ARM controller, the signal has 100 points per second. A flank rising edge takes 0.5 - 2 seconds, so the data range to 'look at' would be around 250 - 500 datapoints.</p>
  
  <p>I have read about correlation and FFTs, but if I understand the subject right, this will only apply to periodic waveforms (as the FFT will dismantle the signal into sin/cos parts).</p>
  
  <p>Is FFT and correlation the correct path to take or are there better methods for our requirement? If our path is correct, is there recommended literature/search terms for a easy entry into the subject?</p>
  
  <p>Edit:
  I added examples of real data.
  In <a href="https://i.stack.imgur.com/0UMqE.png" rel="nofollow noreferrer">Picture 2</a> you can see a easy to detect edge. We have no problems with this edges using a basic edge detection.</p>
  
  <p>In <a href="https://i.stack.imgur.com/uAmRy.png" rel="nofollow noreferrer">Picture 3</a> lies our problem:
  Our current algorithm detects a edge at 2565s, but we want a detection at 2574s.
  The first 'blob' always appears in with around 40% - 85% of signal level compared to the edge to detect.</p>
  
  <p><a href="https://i.stack.imgur.com/cOMth.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cOMth.png" alt="Sample waveforms to detect"></a></p>
  
  <p><a href="https://i.stack.imgur.com/0UMqE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0UMqE.png" alt="example of good data"></a></p>
  
  <p><a href="https://i.stack.imgur.com/uAmRy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uAmRy.png" alt="example of bad data"></a></p>