hi,
One of my freind is asking for bpsk modulator and demodulator. It's out of my domain knowledge and i'm not sure what is it about.
Can you refer to some C language example codes of the above.
will appreciate your quick reply
thx
hi,
One of my freind is asking for bpsk modulator and demodulator. It's out of my domain knowledge and i'm not sure what is it about.
Can you refer to some C language example codes of the above.
will appreciate your quick reply
thx
Short, practical note that builds on the thread: is right that a production-grade BPSK modem (carrier recovery, timing recovery, channel equalization, framing, error control) gets complex. For learning or a lab demo there is a very small, workable C example that shows the core idea: map bits to +1/−1, multiply a carrier (phase 0 or π), and at the receiver multiply by the same carrier and integrate over the symbol interval (coherent demodulation). The snippet below is intentionally minimal — it assumes a perfectly synchronized local carrier and ideal channel so it’s suitable for experimentation and teaching, not RF hardware use.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
const double PI=3.141592653589793;
const int Fs=8000, fc=1000, Ns=80, Nbits=32;
double phase_inc=2.0*PI*fc/Fs, phase=0.0;
double *sig = malloc(sizeof(double)*Ns*Nbits);
int bits[Nbits], dec[Nbits];
for(int i=0;i<Nbits;i++) bits[i]=rand()&1;
for(int i=0;i<Nbits;i++){
double sym = bits[i]?1.0:-1.0;
for(int n=0;n<Ns;n++){
sig[i*Ns+n]=sym*cos(phase);
phase+=phase_inc; if(phase>2*PI) phase-=2*PI;
}
}
double local=0.0;
for(int i=0;i<Nbits;i++){
double acc=0;
for(int n=0;n<Ns;n++){ acc += sig[i*Ns+n]*cos(local); local+=phase_inc; if(local>2*PI)local-=2*PI; }
dec[i] = acc>=0;
}
for(int i=0;i<8;i++) printf("%d -> %d\n", bits[i], dec[i]);
free(sig);
return 0;
} Notes and quick troubleshooting:
This provides a compact starting point for while acknowledging ’s point about real-system complexity.
Jump to Post— jephthah 1,888did you try this?
hmm... you're serious aren't you?
okay, no: there is no "simple c code" for developing a binary phase shift key modem.
if there were, then people wouldn't get paid salary to develop solutions to relatively complex engineering projects.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.