This signal is from an instrumentation amplifier, read from Arduino MEGA2560 ADC, loop delay 10ms (rate 100Hz)

I need to count high spikes only, (in below figure, 6 high spikes can be observed)

Edited - its and ECG signal and signal was sampled at a rate of 100Hz

enter image description here

  • \$\begingroup\$ What does the frequency spectrum (FFT) look like? Can probably use a digital filter to get rid of the lower frequency shift. \$\endgroup\$ Aug 7, 2020 at 8:52
  • \$\begingroup\$ What have you tried so far? Is this purely a software algorithm question? Oh and is that a heart rate waveform? If it is, then the algorithm can be made to expect something about the signal. \$\endgroup\$
    – Justme
    Aug 7, 2020 at 8:56
  • \$\begingroup\$ Looks similar to an EKG. Maybe you can use methods that are applied to those? \$\endgroup\$
    – Drew
    Aug 7, 2020 at 8:56
  • 1
    \$\begingroup\$ yes, look at the first derivative. \$\endgroup\$
    – Jasen
    Aug 7, 2020 at 11:43
  • 1
    \$\begingroup\$ That agrees with your chart showing heartbeats at just over one per second, and the vertical grid lines spaced every 100 samples. \$\endgroup\$
    – JRE
    Aug 7, 2020 at 13:31

1 Answer 1


It can be done by using some high pass filter to remove DC bias, then you differentiate the signal to detect high dv/dt. At each high dv/dt you set a flip-flop. If the FF is set you compare the amplitude threshold and you clear the FF when dv/dt becomes negative.

  • \$\begingroup\$ How to differential the signal? \$\endgroup\$
    – kobi89
    Aug 9, 2020 at 8:01
  • 2
    \$\begingroup\$ The differential is : y(k) =( u(k)-u(k-1) ) / T_sample; Where u(k) is the actual sample and u(k-1) is the previous sample. Find some book about digital control, look for differentiation. Also you can scrape the D-part of some yet available PID algorithm for Arduino. \$\endgroup\$ Aug 9, 2020 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.