[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7054 - gnuradio/branches/developers/trondeau/ofdm2/gn
From: |
n4hy |
Subject: |
[Commit-gnuradio] r7054 - gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general |
Date: |
Wed, 28 Nov 2007 21:07:06 -0700 (MST) |
Author: n4hy
Date: 2007-11-28 21:07:04 -0700 (Wed, 28 Nov 2007)
New Revision: 7054
Modified:
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_math.h
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
Log:
gr_math has branchless clipping back in with comments. The ofdm_frame_sink has
a 2nd order PLL added for offset correction
Modified:
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_math.h
===================================================================
---
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_math.h
2007-11-29 01:07:00 UTC (rev 7053)
+++
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_math.h
2007-11-29 04:07:04 UTC (rev 7054)
@@ -64,4 +64,17 @@
return gr_fast_atan2f(z.imag(), z.real());
}
+
+/* This bounds x by +/- clip without a branch */
+
+static inline float gr_branchless_clip(float x, float clip)
+{
+ float x1 = fabsf(x+clip);
+ float x2 = fabsf(x-clip);
+ x1 -= x2;
+ return 0.5*x1;
+}
+
+
+
#endif /* _GR_MATH_H_ */
Modified:
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
===================================================================
---
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
2007-11-29 01:07:00 UTC (rev 7053)
+++
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
2007-11-29 04:07:04 UTC (rev 7054)
@@ -26,8 +26,12 @@
#include <gr_ofdm_frame_sink.h>
#include <gr_io_signature.h>
+#include <gr_expj.h>
+#include <gr_math.h>
+#include <math.h>
#include <cstdio>
#include <stdexcept>
+#include <iostream>
#define VERBOSE 0
@@ -96,7 +100,12 @@
unsigned char *out)
{
unsigned int i=0, bytes_produced=0;
+ gr_complex carrier;
+ carrier=gr_expj(d_phase);
+ std::cout << "carrier " << carrier << std::endl;
+
+ gr_complex accum_error = 0.0;
while(i < d_occupied_carriers) {
if(d_nresid > 0) {
d_partial_byte |= d_resid;
@@ -106,8 +115,16 @@
}
while((d_byte_offset < 8) && (i < d_occupied_carriers)) {
- //fprintf(stderr, "%f+j%f = %d\n", in[i].real(), in[i].imag(),
slicer(in[i]));
- unsigned char bits = slicer(in[i++]);
+ gr_complex sigrot = in[i]*carrier;
+
+ //fprintf(stderr, "%f+j%f = %d\n", sigrot.real(), sigrot.imag(),
slicer(in[i]));
+ //unsigned char bits = slicer(in[i++]);
+ unsigned char bits = slicer(sigrot);
+ i++;
+ gr_complex closest_sym = d_sym_position[bits];
+
+ accum_error += sigrot * conj(closest_sym);
+
if((8 - d_byte_offset) >= d_nbits) {
d_partial_byte |= bits << (d_byte_offset);
d_byte_offset += d_nbits;
@@ -130,7 +147,16 @@
d_partial_byte = 0;
}
}
+ //std::cerr << "accum_error " << accum_error << std::endl;
+ float angle = arg(accum_error);
+ d_freq = d_freq - d_freq_gain*angle;
+ d_phase = d_phase + d_freq - d_phase_gain*angle;
+ if (d_phase >= 2*M_PI) d_phase -= 2*M_PI;
+ if (d_phase <0) d_phase += 2*M_PI;
+
+
+ std::cerr << angle << "\t" << d_freq << "\t" << d_phase << std::endl;
return bytes_produced;
}
@@ -153,7 +179,7 @@
gr_make_io_signature (0, 0, 0)),
d_target_queue(target_queue), d_occupied_carriers(occupied_carriers),
d_byte_offset(0), d_partial_byte(0),
- d_resid(0), d_nresid(0)
+ d_resid(0),
d_nresid(0),d_phase(0),d_freq(0),d_phase_gain(0.25),d_freq_gain(0.25*.25*.25)
{
d_bytes_out = new unsigned char[d_occupied_carriers];
@@ -197,7 +223,12 @@
if (VERBOSE)
fprintf(stderr,">>> Entering state machine\n");
-
+
+ if(d_state != STATE_HAVE_HEADER) {
+ d_freq = 0.0;
+ d_phase = 0.0;
+ }
+
bytes = demapper(&in[0], d_bytes_out);
switch(d_state) {
Modified:
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
===================================================================
---
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
2007-11-29 01:07:00 UTC (rev 7053)
+++
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
2007-11-29 04:07:04 UTC (rev 7054)
@@ -77,6 +77,10 @@
unsigned char d_resid;
unsigned int d_nresid;
+ float d_phase;
+ float d_freq;
+ float d_freq_gain;
+ float d_phase_gain;
protected:
gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7054 - gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general,
n4hy <=