-
Notifications
You must be signed in to change notification settings - Fork 4
/
MyTransmitter.m
37 lines (28 loc) · 1.12 KB
/
MyTransmitter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [ OutPutSamples ] = MyTransmitter( input )
% MyTransmitter takes in a vector bits b of real valued bits (zeros and
% ones) of unknown length and outputs a vector of complex samples labeled
% as OutPutSamples of length N with unit average power. The data in input
% will be given in terms of real numbers.
%% Load the config file to adjust parameters %%
configuration;
% Place bits into packets of specified size %%
tic;
if PACKETIZE
packets = packetizeBits(input, HEADER_SIZE_BITS, PACKET_SIZE_BITS);
input = packets(:)';
end
toc;
%% Convolutional Encoding %%
if CODING
encoded_bits = conv_encode(input, 1, GENERATING_POLYS, CONSTRAINT_LENGTH);
encoded_bits = interleave(encoded_bits, 64); %Assumes coded packet size of 4096 bits
else
encoded_bits = input;
end
%% Add pilot/sync bits
bits_with_sync = add_sync_bits(encoded_bits, SYNC_PATTERN, PACKET_SIZE_BITS/CODE_RATE);
%% Convert the encoded bits to symbols (at complex baseband) %%
modulated_samples = modulate(bits_with_sync, MODULATION, SAMPLES_PER_SYMBOL);
%% Apply the pulse shaping %%
OutPutSamples = apply_filt(modulated_samples, PULSE_SHAPE);
end