summaryrefslogtreecommitdiff
path: root/gnuradio-core
diff options
context:
space:
mode:
authorTom Rondeau2011-03-26 12:16:37 -0400
committerTom Rondeau2011-03-26 12:16:37 -0400
commitd24a3fa25cd213b7a0aeab07da232bdce904af80 (patch)
treea8eb0c57f1343f965e7cc7d4c06c1a334d41b4d0 /gnuradio-core
parent068fbaa83fbc931abb4ea22c5ab738e1cb6fb3bb (diff)
downloadgnuradio-d24a3fa25cd213b7a0aeab07da232bdce904af80.tar.gz
gnuradio-d24a3fa25cd213b7a0aeab07da232bdce904af80.tar.bz2
gnuradio-d24a3fa25cd213b7a0aeab07da232bdce904af80.zip
Adding phase detector in Costas loop for 8PSK.
Diffstat (limited to 'gnuradio-core')
-rw-r--r--gnuradio-core/src/lib/general/gr_costas_loop_cc.cc22
-rw-r--r--gnuradio-core/src/lib/general/gr_costas_loop_cc.h6
2 files changed, 26 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
index f3bfd0951..b77b19745 100644
--- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2010 Free Software Foundation, Inc.
+ * Copyright 2006,2010,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -64,12 +64,30 @@ gr_costas_loop_cc::gr_costas_loop_cc (float alpha, float beta,
d_phase_detector = &gr_costas_loop_cc::phase_detector_4;
break;
+ case 8:
+ d_phase_detector = &gr_costas_loop_cc::phase_detector_8;
+ break;
+
default:
- throw std::invalid_argument("order must be 2 or 4");
+ throw std::invalid_argument("order must be 2, 4, or 8");
break;
}
}
+float
+gr_costas_loop_cc::phase_detector_8(gr_complex sample) const
+{
+ float K = sqrt(2.0) - 1;
+
+ if(abs(sample.real()) >= abs(sample.imag())) {
+ return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() -
+ (sample.imag()>0 ? 1.0 : -1.0) * sample.real() * K);
+ }
+ else {
+ return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() * K -
+ (sample.imag()>0 ? 1.0 : -1.0) * sample.real());
+ }
+}
float
gr_costas_loop_cc::phase_detector_4(gr_complex sample) const
diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.h b/gnuradio-core/src/lib/general/gr_costas_loop_cc.h
index 3b4aab86c..181880f1c 100644
--- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.h
+++ b/gnuradio-core/src/lib/general/gr_costas_loop_cc.h
@@ -89,6 +89,12 @@ class gr_costas_loop_cc : public gr_sync_block
int order
) throw (std::invalid_argument);
+ /*! \brief the phase detector circuit for 8th-order PSK loops
+ * \param sample complex sample
+ * \return the phase error
+ */
+ float phase_detector_8(gr_complex sample) const; // for 8PSK
+
/*! \brief the phase detector circuit for fourth-order loops
* \param sample complex sample
* \return the phase error