Showing
2 changed files
with
32 additions
and
2 deletions
constellation/constellation/receiver.cpp
0 → 100644
1 | +#include "receiver.h" | ||
2 | + | ||
3 | +Creceiver::Creceiver() {} | ||
4 | + | ||
5 | +void Creceiver::demodulate() { | ||
6 | + | ||
7 | + T = Nsamplespersymbol; | ||
8 | + float c0[Nsamplespersymbol], c1[Nsamplespersymbol]; | ||
9 | + for (int i = 1; i <= Nsamplespersymbol; i++) { | ||
10 | + c0[i - 1] = sqrt(2 / T) * cos(2 * PI / T * i); | ||
11 | + c1[i - 1] = sqrt(2 / T) * sin(2 * PI / T * i); | ||
12 | + } | ||
13 | + float temp0[1], temp1[1]; | ||
14 | + for (int i = 0; i < Nbits / 2; i++) { | ||
15 | + matrixmult(1, Nsamplespersymbol, 1, r + (Nbitspersymbol * i), c0, temp0); | ||
16 | + matrixmult(1, Nsamplespersymbol, 1, r + (Nbitspersymbol * i), c1, temp1); | ||
17 | + constellation[2 * i] = temp0[0]; | ||
18 | + constellation[2 * i + 1] = temp1[0]; | ||
19 | + } | ||
20 | + for (int j = 0; j < Nbits; j++) { | ||
21 | + if (constellation[j] >= 0) DecodedData[j] = '0'; | ||
22 | + else DecodedData[j] = '1'; | ||
23 | + } | ||
24 | + | ||
25 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | #ifndef __RECEIVER | 1 | #ifndef __RECEIVER |
2 | 2 | ||
3 | #define __RECEIVER | 3 | #define __RECEIVER |
4 | +#define PI 3.141592 | ||
4 | #include <cmath> | 5 | #include <cmath> |
6 | +#include <fstream> | ||
5 | #include "variables.h" | 7 | #include "variables.h" |
8 | +#include "myMatrix.h" | ||
6 | class Creceiver { | 9 | class Creceiver { |
7 | public: | 10 | public: |
8 | - Creceiver() {}; | 11 | + float T; |
12 | + Creceiver(); | ||
9 | float *r; // corrupted signal = received signal | 13 | float *r; // corrupted signal = received signal |
10 | float constellation[Nbits]; | 14 | float constellation[Nbits]; |
11 | char DecodedData[Nbits]; | 15 | char DecodedData[Nbits]; |
12 | void demodulate(); | 16 | void demodulate(); |
13 | }; | 17 | }; |
14 | -#endif | 18 | + |
19 | +#endif | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment