# How to modulate PSK63 with liquiddsp?

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'm missing?

• sorry, I don't know PSK-63, and chances are slim anyone else here immediately does. You'll have to refer us to some definition / standard. Oct 17 '20 at 9:30

## 1 Answer

Posting a standard is actually a good point.

After reading several definitions i've figured out that i have to keep the symbol (and thus the phase) if I want to transmit 1 and reverse it if i want to transmit zero.

(see: http://www.arrl.org/psk31-spec, PSK-63 has just higher speed, about 63 baud.)

if(ctr==(11025/63)){
ctr=0;
c=message[subsym]-'0';
subsym++;
if(subsym>=strlen(message)){
subsym=0;
}
if(!c) // here instead of just assigning bit=symbol
sym_in = !sym_in;
}