1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2013
Posts
5
Rep Power
0

#### Modulation Process For Direct Sequence Spread Spectrum In C++

Hi, everyone, I need to write a C++ program to simulate a modulation process for Direct Sequence Spread Spectrum but I don't even have any idea how to start. I need some advices here.... Here are the requirement of the program:

1. A thousand digit represented in binary PN (pseudonoise) sequence or c(t)
2. The input data d(t) will also consist of one thousand digit binary
3. Assume amplitude A is alternating the values of 1 and -1.
4. c(t) and d(t) should be modulated to produce the propagated signal s(t).
5. The frequency carrier, cos(2fct) is also represented in binary

The final expected output would be a bit stream of a propagated signal which satisfies the equation:

I am seriously have no idea on how to start the coding because I can't understand how to do it...Thank you!! :(
2. I will need your class notes to work on this project.
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2013
Posts
5
Rep Power
0
Originally Posted by b49P23TIvg
I will need your class notes to work on this project.
I just realize that all I need to do is just XOR all the value provided in the text filles.

example of XOR: 0 to 0 = 0, 1 to 0 = 1, 0 to 1 = 1, 1 to 1 = 0

it compare the bits and the result is based on XOR rules.

and I believe I missed out something on the original details. The original details are as following:

1. A thousand digit represented in binary PN (pseudonoise) sequence or c(t), which is provided in the text file named PN.txt.
2. The input data d(t) will also consist of one thousand digit binary stored in a text file named data.txt.
3. Assume amplitude A is alternating the values of 1 and -1.
4. c(t) and d(t) should be modulated to produce the propagated signal s(t).
5. The frequency carrier, cos(2fct) is also represented in binary which is provided in the file named fc.txt.

The final expected output would be a bit stream of a propagated signal which satisfies the equation:
Feel free to test your program using your own data sets d(t), c(t) and cos(2fct) in a lesser bits probably 5 or 10 later to make sure your program works for the actual thousand bit data sets.

there are 1000 bits in each txt file so I'll just provide the first 5 bits for each file,

data.txt : 11001
fc.txt: 01111
PN.txt: 01010
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2013
Posts
5
Rep Power
0
and here's the code I have worked out so far, but it is not running.

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inputfile_1, inputfile_2;
char temp;
int i;
int data[1000], pn[1000], fc[1000], a[i], final[i];
inputfile_1.open("data.txt");
inputfile_2.open("PN.txt");

i=0;
while (inputfile_1.get(temp))
{
data[i] = temp - '0';
i++;

}

i=0;
while (inputfile_2.get(temp))
{
pn[i] = temp - '0';
i++;

}

for (i=0; i<1000; i++)
{
int a[1000];
if (data[i] == pn[i])
temp = 0;
else
temp = 1;

a[i] = temp;

ifstream inputfile_3;
inputfile_3.open("fc.txt");
i=0;
while (inputfile_3.get(temp))
{
fc[i] = temp - '0';
i++;
}

for (i=0; i<1000; i++)
{
int final[i];
if (fc[i] == a[i])
temp = 0;
else
temp = 1;

final[i] = temp;

}

cout<<"Output : \n";
for (i=0; i<1000 ; i++)
{
cout << final[i];
}
}
cout << endl;
system("pause");
return 0;

}
5. Instead of xoring, sum all the bits and test if the result is odd or even. Wouldn't that be easier?
6. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2013
Posts
5
Rep Power
0
Originally Posted by b49P23TIvg
Instead of xoring, sum all the bits and test if the result is odd or even. Wouldn't that be easier?
hm, how can I do that? Could you show me how to do it?
7. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2013
Posts
5
Rep Power
0
Originally Posted by lonewolf92
hm, how can I do that? Could you show me how to do it?
by the way, I have managed to modify my code a little bit, the program is running, but doesn't manage to XOR bits....here's the modified code:

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inputfile_1, inputfile_2, inputfile_3;
char temp;
int i;
int data[1000], pn[1000], fc[1000], a[1000], final[1000];
inputfile_1.open("data.txt");
inputfile_2.open("PN.txt");
inputfile_3.open("fc.txt");

i=0;
while (inputfile_1.get(temp))
{
data[i] = temp - '0';
i++;

}

i=0;
while (inputfile_2.get(temp))
{
pn[i] = temp - '0';
i++;

}

i=0;
while (inputfile_3.get(temp))
{
fc[i] = temp - '0';
i++;
}

for (i=0; i<1000; i++)
{
int a[i];
if (data[i] == pn[i])
temp = 0;
else
temp = 1;

a[i] = temp;
}

for ( i = 0; i<1000; i++)
{
int final[i];
if (a[i] == fc[i])
temp = 0;
else
temp = 1;

final[i]= temp;
}

cout<<"Final Output : \n";
for (i=0; i<1000 ; i++)
{
cout << final[i];
}

cout << endl;
system("pause");
return 0;

}