# Improving SNR using DSP techniques

I am building an optical OOK (On off Key Ring) system without a carrier frequency. [However I have a guard time in between symbols, so a consecutive "1" messages will result in a pulse train as opposed to DC, see image]. Essentially, the presence of signal indicates one and lack of it indicates zero. I have a precise clock that is syncs the receiver with transmitter. The system operates with a low SNR and I like to improve SNR using DSP techniques.

I have a few questions:

I do selective sampling in my hardware, in other words, I do not continuously sample the channel but only sample when the probability of seeing the signal is maximum (i.e. this is a light pulse, I time the ADC such that ADC samples at the end of the pulse where I know the whole analog chain is stabilized). See image.

Naturally, this drawing doesn't show the noise but it is there. This is particularly a low signal system and primary noise sources are shot noise, johnson noise and amplifiers internal noise. (optical system so there are no other interferer except Sun). My observation of noise indicates, it is similar in all frequencies. (At least what I see in Scope)

I now use a simple threshold comparison in software to determine if the data is one or zero. Is there a better way? I have thought of some options but I like to hear from the experts.

So far I have considered the following options:

• Do continuous ADC and try to integrate during rise time:Not entirely sure on the benefit (There may be other benefits, I don't know).

• Matched filter in software: Don't really understand the math but based on what I read, a possibility

• Sample during the guard time and subtract this from the signal ADC value (This may provide some further details but also not so sure, guard time would be the noise measurement)

• Change hardware to a synchronous decoder, costly, time consuming and may not work well since my data rate is fast and getting a synchronous demodulator would mean expensive board since I have to built a multi-MHz carrier frequency system.

• How does your sampler know when the pulses are going to occur? Is there some other form of time synchronization between transmitter and receiver? – Jason R Jan 28 '12 at 13:59
• @JasonR yes. It is mentioned in the text. – Frank Jan 28 '12 at 16:16
• Sorry, I missed it during my initial read. How is the noise characterized? Is it white? Gaussian? Is it even noise at all, or is it interference from some other source? As a note, I would consider the first two options that you listed to be equivalent, and they may be relevant to your problem, but I wanted more information on the conditions of your system first. – Jason R Jan 28 '12 at 19:08
• @JasonR thanks for the feedback, I updated the question regarding noise. – Frank Jan 29 '12 at 0:57
• I would place some serious bets on a matched filter. – Phonon Jan 30 '12 at 14:24

## 2 Answers

Since you indicated that the power spectrum of your background noise is flat, I'll assume it is white. A major drawback with your current approach is that you are discarding a large amount of the signal power; even with the effect of front-end bandlimiting shown by in your diagram by the exponential-rise step response, a single ADC sample near the end of the rounded pulse provides a snapshot of the receiver input that is rather localized in time. You can take advantage of more of the signal power by sampling at a higher rate and applying a matched filter at the higher sample rate.

## Theory:

You can look at this as a relatively simple problem in detection theory. In each symbol interval, your receiver needs to decide between two hypotheses:

$$\begin{eqnarray*} H_0 &:& signal \ is \ not \ present \\ H_1 &:& signal \ is \ present \end{eqnarray*}$$

This sort of problem is often solved using Bayesian decision rules, which attempt to make the optimum decision according to some specified measure of risk. This provides a framework where one can optimally make detection decisions based on a flexible set of criteria. For example, if there is a large penalty to your system for failing to detect the signal if it is in fact present (i.e. you pick $H_0$ when $H_1$ is true), then you can build that into your decision rule if needed.

For a detection problem such as yours, where you're trying to decide between zeros and ones at the receiver output, the penalty is typically assumed to be equal (outputting a zero when a one was transmitted, and vice versa, "hurt equally"). The Bayesian approach in that case reduces to a maximum-likelihood estimator (also described here): you pick the hypothesis that is most likely, given the observation that your receiver makes. That is, if the quantity that your receiver observes is $x$, then it would generate a decision based on the hypothesis that has the largest likelihood function value. For the binary decision case, the likelihood ratio can be used instead:

$$\Lambda(x) = \frac{P(x\ |\ H_0 \ is \ true)}{P(x\ |\ H_1 \ is \ true)} = \frac{P(x\ |\ signal \ is \ not \ present)}{P(x\ |\ signal \ is \ present)}$$

Using the above model, for each observation of the channel $x$, the optimal receiver would decide that the signal was not present (therefore outputting a zero) if the likelihood ratio $\Lambda(x)$ is greater than one (and therefore the signal was most likely to be not present based on the observation), and vice versa.

What remains is a model for the signal of interest and any other components in the receiver detection statistic $x$ that could affect its decisions. For a digital communications like this, it might be modeled as follows:

$$\begin{eqnarray*} H_0 &:& x = N \\ H_1 &:& x = s + N \end{eqnarray*}$$

where $n$ is a random variable taken from some distribution (often assumed to be zero-mean Gaussian) and $s$ is a deterministic component of the observation that is due to the signal that you're looking for. The distribution of the receiver observable $x$, therefore, varies depending upon whether hypothesis $H_0$ or $H_1$ is true. In order to evaluate the likelihood ratio, you need a model for what those distributions are. For the Gaussian case referenced above, the mathematics look like this:

$$\Lambda(x) = \frac{P(x\ |\ H_0 \ is \ true)}{P(x\ |\ H_1 \ is \ true)} = \frac{P(x\ |\ x = N)}{P(x\ |\ x = s + N)}$$

$$\Lambda(x) = \frac{P(x\ |\ H_0 \ is \ true)}{P(x\ |\ H_1 \ is \ true)} = \frac{e^{\frac{-x^2}{2 \sigma^2}}}{e^{\frac{-(x - s)^2}{2 \sigma^2}}}$$

where $\sigma^2$ is the variance of the Gaussian noise term. Note that the additive signal component only has the function of shifting the mean of the resulting Gaussian distribution of $x$. The log-likelihood ratio can be used to get rid of the exponentials:

$$\ln(\Lambda(x)) = \ln\left(\frac{e^{\frac{-x^2}{2 \sigma^2}}}{e^{\frac{-(x - s)^2}{2 \sigma^2}}}\right) = \left(\frac{-x^2}{2 \sigma^2}\right) - \left(\frac{-(x - s)^2}{2 \sigma^2}\right)$$

Recall that our decision rule picked $H_0$ if the likelihood ratio was greater than one. The equivalent log-likelihood decision rule is to pick $H_0$ if the log-likelihood is greater than zero. Some algebra shows that the decision rule reduces to:

$$\begin{eqnarray*} x < \frac{s}{2} \rightarrow choose\ H_0 \\ x > \frac{s}{2} \rightarrow choose\ H_1 \end{eqnarray*}$$

Note that if $x = \frac{s}{2}$, then both hypotheses are equally likely, and you would need to just pick one; this isn't a practical concern for continuously-valued signals, however. So, given a known signal amplitude $s$, we can detect its presence against a background of Gaussian noise optimally by setting a threshold $T = \frac{s}{2}$; if the observed value $x$ is greater than $T$, we declare the signal present and emit a one, and vice versa.

## Practice:

There are a few practical issues that creep into this simple, toy theoretical example. One: just mapping the scenario that you described into a deceptively simple-looking model might not seem straightforward. Secondly, it's very rare that you would know the amplitude $s$ of the signal that you're looking for, so threshold selection requires some thought.

As I referenced before, noise is often assumed to be Gaussian because the normal distribution is so easy to work with: the sum of a bunch of independent Gaussians is still Gaussian, and their mean and variances just add also. Also, the first- and second-order statistics of the distribution are enough to completely characterize them (given the mean and variance of a Gaussian distribution, you can write its pdf). So, hopefully that's a decent approximation at least for your application.

There are two ways to improve the performance of the detector given the model described above: you can increase $s$ (i.e. increase the signal power), making it stand out more against the noise. You could decrease $N$ (i.e. reduce the amount of noise), reducing the amount of interference that makes the presence of $s$ unclear. Or, equivalently, you can think of the signal to noise ratio instead. To see its importance, let's go back to the theory for a second. What is the probability of a bit error given our decision rule?

$$\begin{eqnarray*} P_e &=& P(choose \ H_0 \ |\ H_1\ true) P(H_1\ true) + P(choose \ H_1 \ |\ H_0\ true) P(H_0\ true) \\ &=& \frac{1}{2} P(x < \frac{s}{2} \ |\ x = s + N) + \frac{1}{2} P(x > \frac{s}{2} \ |\ x = N) \\ &=& \frac{1}{2} F_{x\ |\ x = s + N}\left(\frac{s}{2}\right) + \frac{1}{2} \left(1 - F_{x\ |\ x = N}\left(\frac{s}{2}\right)\right) \end{eqnarray*}$$

where $F_{x\ |\ x = s + N}(z)$ is the cumulative distribution function of the distribution of the observation $x$, given that $x = s + N$ (and likewise for the other function). Substituting in the cdf for the Gaussian distribution, we get:

$$\begin{eqnarray*} P_e &=& \frac{1}{2} \left(1 - Q\left(\frac{\frac{s}{2} - s}{\sigma}\right)\right) + \frac{1}{2} Q\left(\frac{\frac{s}{2}}{\sigma}\right) \\ &=& \frac{1}{2} + \frac{1}{2} \left(-Q\left(\frac{\frac{s}{2} - s}{\sigma}\right) + Q\left(\frac{\frac{s}{2}}{\sigma}\right)\right) \\ &=& \frac{1}{2} + \frac{1}{2} \left(-Q\left(\frac{-s}{2\sigma}\right) + Q\left(\frac{s}{2\sigma}\right)\right) \\ &=& \frac{1}{2} + \frac{1}{2} \left(-Q\left(\frac{-SNR}{2}\right) + Q\left(\frac{SNR}{2}\right)\right) \\ &=& Q\left(\frac{SNR}{2}\right) \end{eqnarray*}$$

where $Q(x)$ is the Q function:

$$Q(x) = \frac{1}{\sqrt{2 \pi}} \int_{x}^{\infty} e^{\frac{-z^2}{2}} dz$$

(i.e. the tail integral of the standard normal distribution's pdf, or $1$ minus the distribution's cdf) and $SNR$ is the signal-to-noise ratio $\frac{s}{\sigma}$. The above function is a strictly decreasing function of $SNR$; as you increase the ratio of the signal amplitude $s$ to the noise standard deviation $\sigma$, the probability of making a bit decision error decreases. So, it behooves you to do whatever you can to increase this ratio.

Remember our assumption that the noise was white and Gaussian? That can help us now. If the noise is white and Gaussian, then the noise components contained in each observation are jointly independent of one another. An important property of independent random variables is that when you sum them together, their means and variances sum. So, let's consider another simple case, where instead of taking one sample per symbol interval, you take two, then sum them together. I'll assume for simplicity that the pulse shape is rectangular (not an exponential rise), so the signal component $s$ in each observation $x_1$ and $x_2$ is the same. What is the difference in signal to noise ratio between just a single observation $x_1$ and the sum of two independent ones?

$$SNR_1 = \frac{s}{\sigma}$$

$$SNR_2 = \frac{2s}{\sqrt{2 \sigma}} = \sqrt{2}SNR_1$$

So, the signal to noise ratio in the combined observation is larger than using only a single sample (under the assumption of equal signal component and equal-variance white Gaussian noise in both samples that we took). This is a basic observation that points out the potential benefits of taking more than one sample per symbol interval and integrating them together (which, for a rectangular pulse, is a matched filter). In general, you want to cover the entire symbol interval with samples so that your receiver "ingests" as much of the transmitted energy for each symbol, thus maximizing the SNR in the combined output. The ratio of symbol energy to the background noise variance $\frac{E_s}{N_0}$ is often used as a figure of merit when evaluating digital communications system performance.

More rigorously, it can be shown that a matched filter has an impulse response that is identical in shape (that is, "matched", with the only subtle exception being that the impulse response is reversed in time) to the pulse shape that the receiver sees (so it weights more strongly samples that have larger signal components). That shape is a function of the transmitted pulse shape as well as any effects induced by the channel or receiver front end, such as bandlimiting or multipath.

To implement this sort of arrangement in practice, you would convolve the stream of samples taken by your ADC with the time-reversed expected pulse shape. This has the effect of calculating the cross-correlation between the pulse shape and the received signal for all possible time offsets. Your implementation is aided by the precise time synchronization that you have available, so you'll know exactly which matched filter output samples correspond to correct sampling instants. The filter outputs at those times are used as the detection statistic $x$ in the theoretical model above.

I referred to threshold selection before, which can be a complicated topic, and there are many different ways that you can choose one, depending upon your system's structure. Selecting a threshold for an on-off-keyed system is complicated by the likely-unknown signal amplitude $s$; other signal constellations, like antipodal signaling (e.g. binary phase shift keying, or BPSK) have a more obvious threshold choice (for BPSK, the best threshold is zero for equally-likely data).

One simple implementation of a threshold selector for OOK might calculate the mean of many observations. Assuming that zeros and ones are equally likely, the expected value of the resulting random variable is half of the signal amplitude, which is the threshold that you seek. Performing this operation over a sliding window can allow you to be somewhat adaptive to varying background conditions.

Note that this is only intended to be a high-level introduction to the issues inherent in digital communications with respect to detection theory. It can be a very complicated topic, with a lot of statistics involved; I tried to make it somewhat easy to understand while keeping true to the underlying theory. For a better explanation, go get a good textbook, like Sklar's.

• thanks for the detailed answer, I learned a lot from it. I like to ask a few clarifications. I get the point of more than 1 sample at the duration. In this case how a matched filter look like? Say, I have three samples x1,x2,x3 (x3 at the tail end and x1 at the beginning). Based on what I read, I must convolve this with a same but symmetrical shape signal. Can you perhaps explain this part? [I think I know the answer but just to make sure] Second part, I know what is the dynamic range of incoming signal would be as I have taken measurements. Can I use that range for threshold setting? – Frank Feb 1 '12 at 1:35
• A matched filter is a way of implementing a sliding cross-correlation between the signal seen by your receiver and the expected pulse shape. The diagram shown in your question illustrates the pulse seen by the ADC as an exponential rise; if that is indeed your model for what the receiver sees, then the appropriate matched filter would have the same shape, only reversed in time (the time reversal turns the convolution operation into correlation). If the receiver front end doesn't appreciably distort the pulse, you could use an "ideal" rectangular matched filter, which is simpler to implement. – Jason R Feb 1 '12 at 4:54
• As to your second question: yes, if you know a priori the expected amplitude of the signal component, then you can use that to select a threshold. Using the statistical model for the system (based on the type of noise that is present), you can calculate the bit error rate as a function of the signal to noise ratio (which is proportional to the signal amplitude). If the thermal noise of your receiver is the dominant source, then white Gaussian noise is usually a good assumption. – Jason R Feb 1 '12 at 4:57
• My receiver has a BPF that cuts the high frequency signals. The BPF rounds off the initial spike of the pulse and it becomes a more exponential in nature. I can disable the BPF but this will introduce HF noise currently not in the chain. It sounds like I have a tradeoff, how can I quantify which way is better. (i.e remove BPF and use matched filter for a pulse, don't remove BPF and use a matched filter for a exponential rise) – Frank Feb 1 '12 at 6:21
• I awarded the bounty to you, thanks very much for a great answer. – Frank Feb 6 '12 at 9:13

One possible technique might be to try using periodic training sequences to gather statistics, not only to differentiate between the 1's and 0's, or to calculate a reliability metric for any given threshold, but to analyze how various bit sequences might affect an adaptive bit decision threshold.

• interesting thinking but not suitable. I need to make a decision fast and even if I work with previous data, variation in the field would be large. – Frank Jan 31 '12 at 23:49