# How can I shift this signal to it's midpoint in order to decode it

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!

• Look up "integrate and dump filter". – MBaz Mar 25 '16 at 19:25
• I used the matlab function intdump(r(16 samples), 16) and plotted the output of this, which looks like it filters the noise a good amount, but the signal is still in the same position (not centered around zero). As @vaz mentioned, I really just need to define a threshold, i was just trying to define that threshold as 0. Is there a good algorithm for determining this threshold if the amplitude of the pulse and noise vary? – gerrgheiser Mar 25 '16 at 21:48
• If the amplitudes vary you can high-pass the signal to remove DC and use 0 as the threshold (you still use I&D to maximize the SNR), or you can use an automatic gain control algorithm to keep the gain roughly constant. – MBaz Mar 25 '16 at 23:30

You don't need to remove the DC part of your signal (i.e. "to center" it). In terms of decoding performance, there is no gain. Your signal looks like a typical ASK. Applying a simple integrator and sampling at $t=T$, where $T$ is the pulse duration, would do the job.
You only need to define a threshold, which usually corresponds to $AT/2$, where $A$ is the expected pulse amplitude.