Costas loop looks working again

This commit is contained in:
ha7ilm 2017-05-14 23:39:11 +02:00
parent 7718eda15b
commit fe46aba98d
4 changed files with 15 additions and 4 deletions

1
csdr.c
View file

@ -2807,6 +2807,7 @@ int main(int argc, char *argv[])
bpsk_costas_loop_state_t state;
init_bpsk_costas_loop_cc(&state, decision_directed, damping_factor, loop_bandwidth);
errhead(); fprintf(stderr, "alpha = %f, beta = %f\n", state.alpha, state.beta);
if(!initialize_buffers()) return -2;
sendbufsize(the_bufsize);

View file

@ -693,7 +693,7 @@
</param>
<param>
<key>commandline</key>
<value>tee /s/costas_input | csdr bpsk_costas_loop_cc 0.01 0.707 --dd --output_combined /s/costas_error /s/costas_dphase /s/costas_nco | tee /s/costas_output</value>
<value>tee /s/costas_input | csdr bpsk_costas_loop_cc 0.1 0.707 --output_combined /s/costas_error /s/costas_dphase /s/costas_nco | tee /s/costas_output</value>
</param>
<param>
<key>comment</key>

View file

@ -0,0 +1,9 @@
#!/bin/bash
sox -r 48k -t f32 -c 2 /s/costas_nco -t wav -e floating-point /s/costas_nco.wav
sox -r 48k -t f32 -c 1 /s/costas_error -t wav -e floating-point /s/costas_error.wav
sox -r 48k -t f32 -c 1 /s/costas_dphase -t wav -e floating-point /s/costas_dphase.wav
sox -r 48k -t f32 -c 2 /s/costas_input -t wav -e floating-point /s/costas_input.wav
sox -r 48k -t f32 -c 2 /s/costas_output -t wav -e floating-point /s/costas_output.wav

View file

@ -2078,8 +2078,9 @@ char* timing_recovery_get_string_from_algorithm(timing_recovery_algorithm_t algo
void init_bpsk_costas_loop_cc(bpsk_costas_loop_state_t* s, int decision_directed, float damping_factor, float bandwidth)
{
//fprintf(stderr, "init_bpsk_costas_loop_cc: bandwidth = %f, damping_factor = %f\n", bandwidth, damping_factor);
//based on: http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html
float bandwidth_omega = 2*M_PI*bandwidth; //so that the bandwidth should be around 0.01 by default (2pi/100), and the damping_factor should be default 0.707
float bandwidth_omega = 2*PI*bandwidth; //so that the bandwidth should be around 0.01 by default (2pi/100), and the damping_factor should be default 0.707
float denomiator = 1+2*damping_factor*bandwidth_omega+bandwidth_omega*bandwidth_omega;
s->alpha = (4*damping_factor*bandwidth_omega)/denomiator;
s->beta = (4*bandwidth_omega*bandwidth_omega)/denomiator;
@ -2091,9 +2092,9 @@ void bpsk_costas_loop_cc(complexf* input, complexf* output, int input_size, floa
for(int i=0;i<input_size;i++)
{
complexf nco_sample;
e_powj(&nco_sample, -s->nco_phase);
if(output_nco) output_nco[i]=nco_sample;
e_powj(&nco_sample, s->nco_phase);
cmult(&output[i], &input[i], &nco_sample);
if(output_nco) output_nco[i]=nco_sample;
float error = 0;
if(s->decision_directed)
{