For experimental reasons i created a function that helps me to modulate a signal using BPSK, the input signal is {1,1,0,1,0} and it works fine
void BPSK_mod(unsigned short signal[], float fs, int spb, float output[])
{
float ts = 1.0 / fs;
float ti = 0.0;
float two_Pi_f= 2 * M_PI * FREQ;
int i,j;
int k = 0;
for( i = 0; i < 5; i++ )
{
int x = signal[i];
for( j = 0; j < spb; j++)
{
output[k] = sinf(two_Pi_f * ti + (M_PI * x));
ti += ts;
k++;
}
}
}
and this is the plotted signal
Now I am confused about how I should do the demodulation ... Can someone give the math and the theory behind it please