# How much to decimate?

What I don't understand is the connection between the sample rate, the baud rate, decimation and using convolution or correlation.

I'm sampling at 2048000 Hz but I don't know my baud rate, I estimated it (by looking at the time length of one of the short pulses) to be about 2000 pulses per second.

So these are my steps (roughly):

1. get samples
2. demodulate
4. correlate with ones

Here is an example of what my signal looks like after demodulation:

You can see that there are 4 symbols but many many samples. How can I turn those many many sample into just 4 symbols? I think it is related to convolution/correlation, but I'm not sure how.

• Normally, you first filter and then downsample/decimate the filtered signal. If you show us more of your signal and what kind of pulse shaping you use, we might be able to help more. – Maximilian Matthé Nov 16 '16 at 18:23
• right, i added a screenshot – Nick Lang Nov 16 '16 at 18:31
• So, I suppose you are facing a PWM modulation? I.e. the width of the pulse contains the information transmitted? Which sequence do you expect to be demodulated from the signal in the screenshot? – Maximilian Matthé Nov 16 '16 at 19:02
• I thought it was ASK. But regardless, yes I expect something like: 0100 or perhaps 00110000 or maybe even 000110100100. anything sensible would be ok. i just don't know what is the standard approach to get from the samples to symbols. – Nick Lang Nov 16 '16 at 19:15
• Might also be ASK, with 2ary symbols (i.e. A=1.2 or A=0). How to get the data out really depends on how the data is modulated. If it's ASK, then you'd convolve/correlate with a rectangular filter that has the length of one symbol. Then, afterwards, you decimate at the symbol rate (i.e. samplerate/symbollength). If it's PWM, you could correlate with two filters: one longer rect, one shorter rect. After decimation of each signal (by same rate as in ASK), you would compare which filter has the higher output and assign the correspnoding bit. – Maximilian Matthé Nov 16 '16 at 19:24

Here's a general example on how to perform the convolution + decimation for an ASK signal.

amplitudes = [1, 0 0 1 0 1 1 0 1 0];
N = 100; % the symbol length.
pulse = 1.2*ones(N, 1); % the Rx pulse (used for correlation)

% the tx pulse (used to recreate your RX signal);
tx_pulse = pulse + 0.2*sin(2*pi*10/N*(1:N)');

% artificially create a signal
signal = zeros(N*length(amplitudes),1);
for i=1:length(amplitudes)
signal((i-1)*N+(1:N)) = amplitudes(i) * tx_pulse;
end
signal = signal + 0.01*randn(size(signal));

subplot(3,1,1);
plot(signal);
title('RX signal');

subplot(3,1,2);
after_conv = conv(signal, pulse);
plot(after_conv);
title('After convolution');

subplot(3,1,3);
stem(after_conv(1:N:end));
title('After decimation');


• wow thanks, can you explain the line: pulse = 1.2*ones(N, 1); where does the number 1.2 come from? and does ones(N, 1) just make a 1d array of ones that is N long? – Nick Lang Nov 16 '16 at 20:11
• and how are you decimating the signal here? – Nick Lang Nov 16 '16 at 20:13
• Ok i see how you're decimating, you're using matlab notation: 1:N:end. BUT - what if this isn't lined up so nice, how do you cherry pick the right samples in the decimation stage? – Nick Lang Nov 16 '16 at 20:28
• ones(N,1) in Matlab equals ones((N,1)) in python/numpy. Regaring the decimation point, you need to get somehow a synchronization, i.e. get to know where the symbol starts. Can either be done manually, or by exploiting the signal structure. For your case, e.g. look for strong signal rises to find the start of a symbol. – Maximilian Matthé Nov 16 '16 at 21:03