diff --git a/csdr.c b/csdr.c index 98ce304..c1e4b59 100755 --- a/csdr.c +++ b/csdr.c @@ -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); diff --git a/grc_tests/test_bpsk_costas_loop.grc b/grc_tests/test_bpsk_costas_loop.grc index 2aacc7f..6a6ec5d 100644 --- a/grc_tests/test_bpsk_costas_loop.grc +++ b/grc_tests/test_bpsk_costas_loop.grc @@ -693,7 +693,7 @@ commandline - 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 + 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 comment diff --git a/grc_tests/test_bpsk_costas_loop_convertwavs.sh b/grc_tests/test_bpsk_costas_loop_convertwavs.sh new file mode 100755 index 0000000..d7c08f0 --- /dev/null +++ b/grc_tests/test_bpsk_costas_loop_convertwavs.sh @@ -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 + + + diff --git a/libcsdr.c b/libcsdr.c index 5a0a600..bc3eef5 100755 --- a/libcsdr.c +++ b/libcsdr.c @@ -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;inco_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) {