Showing
6 changed files
with
37 additions
and
29 deletions
No preview for this file type
No preview for this file type
This file is too large to display.
... | @@ -112,7 +112,6 @@ | ... | @@ -112,7 +112,6 @@ |
112 | <ItemGroup> | 112 | <ItemGroup> |
113 | <ClCompile Include="constellation_main.cpp" /> | 113 | <ClCompile Include="constellation_main.cpp" /> |
114 | <ClCompile Include="myMatrix.cpp" /> | 114 | <ClCompile Include="myMatrix.cpp" /> |
115 | - <ClCompile Include="receiver.cpp" /> | ||
116 | <ClCompile Include="sender.cpp"> | 115 | <ClCompile Include="sender.cpp"> |
117 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader> | 116 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader> |
118 | </ClCompile> | 117 | </ClCompile> | ... | ... |
... | @@ -24,9 +24,6 @@ | ... | @@ -24,9 +24,6 @@ |
24 | <ClCompile Include="sender.cpp"> | 24 | <ClCompile Include="sender.cpp"> |
25 | <Filter>소스 파일</Filter> | 25 | <Filter>소스 파일</Filter> |
26 | </ClCompile> | 26 | </ClCompile> |
27 | - <ClCompile Include="receiver.cpp"> | ||
28 | - <Filter>소스 파일</Filter> | ||
29 | - </ClCompile> | ||
30 | </ItemGroup> | 27 | </ItemGroup> |
31 | <ItemGroup> | 28 | <ItemGroup> |
32 | <ClInclude Include="sender.h"> | 29 | <ClInclude Include="sender.h"> | ... | ... |
... | @@ -6,67 +6,79 @@ | ... | @@ -6,67 +6,79 @@ |
6 | using namespace std; | 6 | using namespace std; |
7 | 7 | ||
8 | Csender::Csender() { | 8 | Csender::Csender() { |
9 | - srand((unsigned int)time(NULL)); | ||
10 | - for (int i = 0; i < 1000; i++) | ||
11 | - { | ||
12 | - data[i] = rand() % 2; | ||
13 | - } | ||
14 | 9 | ||
15 | 10 | ||
16 | } | 11 | } |
17 | 12 | ||
18 | -float s[Nbits / Nbitspersymbol * Nsamplespersymbol]; // trasmitted signal | ||
19 | void Csender::transmitData() | 13 | void Csender::transmitData() |
20 | { | 14 | { |
15 | + float A = 1; | ||
21 | float c0[20]; | 16 | float c0[20]; |
22 | float c1[20]; | 17 | float c1[20]; |
23 | - for (int i = 0; i < 20; i++) | 18 | + float c; |
24 | - { | 19 | + srand((unsigned int)time(NULL)); |
25 | - for (float t = 0; t < 1 / Nsamplespersymbol; t+0.05) | 20 | + |
21 | + for (int i = 0; i < 1000; i++) | ||
26 | { | 22 | { |
27 | - c0[(int)t] = sqrt(2 * Nsamplespersymbol)*cos(2 * PI*Nsamplespersymbol*t); | 23 | + data[i] = rand() % 2; |
28 | - } | ||
29 | } | 24 | } |
30 | 25 | ||
31 | - for (int i = 0; i < 20; i++) | 26 | + cout << "data: " << endl; |
27 | + | ||
28 | + for (int i = 0; i < 40; i++) | ||
32 | { | 29 | { |
33 | - for (float t = 0; t < 1 / Nsamplespersymbol; t + 0.05) | 30 | + for (int j = 0; j < 25; j++) |
34 | { | 31 | { |
35 | - c1[(int)t] = sqrt(2 * Nsamplespersymbol)*sin(2 * PI*Nsamplespersymbol*t); | 32 | + cout << data[i * 25 + j] << " "; |
36 | } | 33 | } |
34 | + cout << endl; | ||
37 | } | 35 | } |
38 | 36 | ||
39 | - float A = 10; | 37 | + for (float t = 0; t < (1. / Nsamplespersymbol); t = t + 1 / 400.) |
40 | - for (int i = 0; i < 1000; i + 2) | ||
41 | { | 38 | { |
42 | - if (data[i] == '0' && data[i + 1] == '0') | 39 | + |
40 | + c = 400. * t; | ||
41 | + c0[(int)c] = sqrt(2 * Nsamplespersymbol)*cos(2 * PI*Nsamplespersymbol*t); | ||
42 | + c1[(int)c] = sqrt(2 * Nsamplespersymbol)*sin(2 * PI*Nsamplespersymbol*t); | ||
43 | + | ||
44 | + } | ||
45 | + c0[12] = -4.41708; | ||
46 | + c1[12] = -4.41708; | ||
47 | + | ||
48 | + | ||
49 | + for (int i = 0; i < 1000; i = i + 2) | ||
50 | + { | ||
51 | + | ||
52 | + if (data[i] == 0 && data[i + 1] == 0) | ||
43 | { | 53 | { |
44 | for (int k = 0; k < 20; k++) | 54 | for (int k = 0; k < 20; k++) |
45 | { | 55 | { |
46 | - s[20*i+k] = A * c0[k] + A * c1[k]; | 56 | + s[(i * 10) + k] = A * c0[k] + A * c1[k]; |
47 | } | 57 | } |
48 | } | 58 | } |
49 | - else if (data[i] == '0' && data[i + 1] == '1') | 59 | + else if (data[i] == 0 && data[i + 1] == 1) |
50 | { | 60 | { |
51 | for (int k = 0; k < 20; k++) | 61 | for (int k = 0; k < 20; k++) |
52 | { | 62 | { |
53 | - s[20 * i +k] = A * c0[k] - A * c1[k]; | 63 | + s[(i * 10) + k] = A * c0[k] + (-A) * c1[k]; |
54 | } | 64 | } |
55 | } | 65 | } |
56 | - else if (data[i] == '1' && data[i + 1] == '0') | 66 | + else if (data[i] == 1 && data[i + 1] == 0) |
57 | { | 67 | { |
58 | for (int k = 0; k < 20; k++) | 68 | for (int k = 0; k < 20; k++) |
59 | { | 69 | { |
60 | - s[20 * i +k] = -1*A * c0[k] + A * c1[k]; | 70 | + s[(i * 10) + k] = (-A) * c0[k] + A * c1[k]; |
61 | } | 71 | } |
62 | } | 72 | } |
63 | - else if (data[i] == '1' && data[i + 1] == '1') | 73 | + else if (data[i] == 1 && data[i + 1] == 1) |
64 | { | 74 | { |
65 | for (int k = 0; k < 20; k++) | 75 | for (int k = 0; k < 20; k++) |
66 | { | 76 | { |
67 | - s[20 * i +k] = -1*A * c0[k] + -1*A * c1[k]; | 77 | + s[(i * 10) + k] = (-A) * c0[k] + (-A) * c1[k]; |
68 | } | 78 | } |
69 | } | 79 | } |
70 | - | ||
71 | } | 80 | } |
81 | + | ||
82 | + | ||
83 | + | ||
72 | }; | 84 | }; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment