Forums

How to modulate PSK63 with liquiddsp?

Started by jbaudot 1 week ago64 views

I am trying to implement the BPSK-63 modulator using liuid dsp library.

Here is my code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <math.h>
#include <complex.h>
#include <liquid/liquid.h>

#define SAMPLERATE 11025

int main(){
    modem mod   = modem_create(LIQUID_MODEM_BPSK);
    
    nco_crcf q = nco_crcf_create(LIQUID_NCO);
    nco_crcf_set_phase(q,0);
    nco_crcf_set_frequency(q, 2*M_PI*(2000.0/(float)SAMPLERATE));
    
    const char *message = "1010111100101111011001010100101110100"; //RYry

    std::complex<float> x=_Complex_I*0;
    unsigned int symbol=0;
    unsigned int outs=0;
    int ctr=0;
    float ous[1];
    int offset=0;

    
    while(1){
        if(ctr++ == (SAMPLERATE/63)) {
            ctr=0;
            char sym = message[offset]-'0';
            offset++;
            if(offset >= strlen(message))
                offset = 0;
            symbol = sym & 0x01;
            
        }
        
        modem_modulate(mod, symbol, &x);
        nco_crcf_mix_up(q, x, &x);
        nco_crcf_step(q);
        
        ous[0] = x.real();
        fwrite((void *)ous,1,sizeof(float),stdout); // | aplay -f FLOAT_LE -r 11025 -c 1
    }
}

It looks like it works, however it sounds a bit different (has some clicks) to working modulator from FLDIGI program. However when I feed the audio into the fldigi, I can see a carrier in the right spot, however it demodulates a series of "ot e" like:

ot e
ot e
ot e

instead of RYryRYryRYryRYry. So, it sees five characters instead of four and detects a space and a newline when there is none.

Also, i see some harmonics, but i don't think this is a problem, since fldigi provides an adjustable filter on it's waterfall.

What I have missed?