Showing
1 changed file
with
45 additions
and
0 deletions
... | @@ -11,4 +11,49 @@ public: | ... | @@ -11,4 +11,49 @@ public: |
11 | char DecodedData[Nbits]; | 11 | char DecodedData[Nbits]; |
12 | void demodulate(); | 12 | void demodulate(); |
13 | }; | 13 | }; |
14 | + | ||
15 | +void Creceiver::demodulate() | ||
16 | +{ | ||
17 | + for (int i = 0; i < Nbits; i++) | ||
18 | + { | ||
19 | + constellation[i]=r[i]/Eb; | ||
20 | + } | ||
21 | + for (int i = 0; i < Nbits; i+=2) | ||
22 | + { | ||
23 | + if (constellation[i]>0&&constellation[i + 1]>0) | ||
24 | + { | ||
25 | + DecodedData[i] = 1; | ||
26 | + DecodedData[i + 1] = 1; | ||
27 | + } | ||
28 | + else if (constellation[i]<0&&constellation[i + 1]>0) | ||
29 | + { | ||
30 | + DecodedData[i] = 0; | ||
31 | + DecodedData[i + 1] = 1; | ||
32 | + } | ||
33 | + else if (constellation[i]<0 &&constellation[i + 1]<0) | ||
34 | + { | ||
35 | + DecodedData[i] = 0; | ||
36 | + DecodedData[i + 1] = 0; | ||
37 | + } | ||
38 | + else if (constellation[i] >0 && constellation[i + 1]<0) | ||
39 | + { | ||
40 | + DecodedData[i] = 1; | ||
41 | + DecodedData[i + 1] = 0; | ||
42 | + } | ||
43 | + } | ||
44 | +} | ||
45 | +#endif | ||
46 | +#ifndef __RECEIVER | ||
47 | + | ||
48 | +#define __RECEIVER | ||
49 | +#include <cmath> | ||
50 | +#include "variables.h" | ||
51 | +class Creceiver { | ||
52 | +public: | ||
53 | + Creceiver() {}; | ||
54 | + float *r; // corrupted signal = received signal | ||
55 | + float constellation[Nbits]; | ||
56 | + char DecodedData[Nbits]; | ||
57 | + void demodulate(); | ||
58 | +}; | ||
14 | #endif | 59 | #endif | ... | ... |
-
Please register or login to post a comment