Simulating Pulse Amplitude Modulation(PAM) on a Mac

One can use the IT++ library: http://itpp.sourceforge.net

This code is actually cross-platform because IT++ is cross-platform.

//Chinmoy Gavini.

//Code licensed under the GPLv2

//Update: I have tested the following code. It works. Note that the binary string below must not have spaces or endlines(of course, your text editor will word-wrap the content–that is fine).

//However, the usual disclaimers in GPLv2 apply to this code.

#include <itpp/itbase.h>
#include <itpp/comm/modulator.h>

int main()
{
PAM p(4); //We want 4-PAM
vec output; //modulated thing
bvec demodded_out;
bvec input = “0100100001100101011011000

110110001101111001000000101011

10110111101110010011011000110010000100001“;

//Binary representation of Hello World!

//The following line of code simulates the transmitter end.
p.modulate_bits(input,output);

//In a realistic simulation, we would have code to add pulse shaping and noise where this comment is

//The following simulates the receiver end.
p.demodulate_bits(output,demodded_out);

if(input == demodded_out)

{

cout<<“Hello World”<<endl;

{

else

{

cout<<“Big Bad World”<<endl;

}

return 0;
}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s