I'm wondering if there's a simple way to decode this pulse signal as I'm reading it in. I'm thinking the simplest way to decode this is if i can shift the whole signal down so that it's centered around 0. Then if my pulse goes above 0, I know it's a 1 and it'f it's below zero, i know it's a zero. Figures below to see what i'm trying to do. Please note that my sampling frequnecy $Fs = 8Hz$, my pulse width is between 1-2 seconds, and come in pairs of 2. these pairs are spaced about 20 seconds apart. There is also a 3 pulse header which denotes the start of the message, with the first pulse being wider than the other pulses.
if I know the peak value of the pulses, then this is obviously just taking my signal and subtracting half of the peak, $d(t) = r(t) - peak/2$. The problem is this peak amplitude is going to vary, as is the noise level. If i try to just subtract a running average, then the noise part of my signal will be centered around 0 as well, which then my decision won't be a simple above/below zero decision. I've plotted subtracting the mean in figure 3 below. My signal is $d(t) = r(t) - runAvg(past 4 samples)$
It seems like there should be an easy way to filter this, either in the time or frequency domain, I'm just not thinking of it. Thanks for your time!