fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
fun::frame_detector Class Reference

The frame_detector block. More...

#include <frame_detector.h>

Inheritance diagram for fun::frame_detector:
fun::block< std::complex< double >, tagged_sample > fun::block_base

Public Member Functions

 frame_detector ()
 Constructor for frame_detector block. More...
 
virtual void work ()
 Signal processing happens here. More...
 
- Public Member Functions inherited from fun::block< std::complex< double >, tagged_sample >
 block (std::string block_name)
 constructor More...
 
- Public Member Functions inherited from fun::block_base
 block_base (std::string block_name)
 block_base constructor More...
 

Private Attributes

circular_accumulator
< std::complex< double > > 
m_corr_acc
 Circular accumulator for calculating correlation. More...
 
circular_accumulator< double > m_power_acc
 Circular accumulator for calculating correlation. More...
 
int m_plateau_length
 Counter for keeping track of STS plateau length. More...
 
bool m_plateau_flag
 Flag for signaling whether we are currently in a plateau or not. More...
 
std::vector< std::complex
< double > > 
m_carryover
 Vector for storing the last 16 samples from the input_buffer and carrying them over to the next call to work() More...
 

Additional Inherited Members

- Public Attributes inherited from fun::block< std::complex< double >, tagged_sample >
std::vector< std::complex
< double > > 
input_buffer
 input_buffer contains new input items to be consumed More...
 
std::vector< tagged_sampleoutput_buffer
 output_buffer is where the output items of the block should be placed More...
 

Detailed Description

The frame_detector block.

Inputs complex doubles from USRP block. Outputs tagged samples to timing sync block.

This block is in charge of detecting the beginning of a frame using the short training sequence in the preamble.

Definition at line 34 of file frame_detector.h.

Constructor & Destructor Documentation

fun::frame_detector::frame_detector ( )

Constructor for frame_detector block.

Definition at line 23 of file frame_detector.cpp.

23  :
24  block("frame_detector"),
29  m_plateau_flag(false)
30  {
31  }

Member Function Documentation

void fun::frame_detector::work ( )
virtual

Signal processing happens here.

This block uses auto-correlation to detect the short training sequence. This autocorrelation is achieved through a moving window average using the circular accumulators to keep track of the current auto-correlation and input power of the input samples. The normalized auto-correlation is then compared to a threshold to determine if the current samples are part of the STS or not.

Implements fun::block< std::complex< double >, tagged_sample >.

Definition at line 41 of file frame_detector.cpp.

References fun::circular_accumulator< T >::add(), fun::block< std::complex< double >, tagged_sample >::input_buffer, m_carryover, m_corr_acc, m_plateau_flag, m_plateau_length, m_power_acc, fun::NONE, fun::block< std::complex< double >, tagged_sample >::output_buffer, PLATEAU_THRESHOLD, fun::STS_END, STS_LENGTH, STS_PLATEAU_LENGTH, fun::STS_START, and fun::circular_accumulator< T >::sum.

42  {
43  if(input_buffer.size() == 0) return;
44  output_buffer.resize(input_buffer.size());
45 
46  // Step through the samples
47  for(int x = 0; x < input_buffer.size(); x++)
48  {
49  output_buffer[x].tag = NONE;
50 
51  // Get the delayed samples
52  std::complex<double> delayed;
53  if(x < STS_LENGTH) delayed = m_carryover[x];
54  else delayed = input_buffer[x-STS_LENGTH];
55 
56  // Update the correlation accumulators
57  m_corr_acc.add(input_buffer[x] * std::conj(delayed));
58 
59  // Update the power accumulator
60  m_power_acc.add(std::norm(input_buffer[x]));
61 
62  // Calculate the normalized correlations
63  double corr = std::abs(m_corr_acc.sum) / m_power_acc.sum;
64 
65  if(corr > PLATEAU_THRESHOLD)
66  {
69  {
70  output_buffer[x].tag = STS_START;
71  m_plateau_flag = true;
72  }
73  }
74  else
75  {
76  if(m_plateau_flag)
77  {
78  output_buffer[x].tag = STS_END;
79  m_plateau_flag = false;
80  }
81  m_plateau_length = 0;
82  }
83 
84  // Pass through the sample
85  output_buffer[x].sample = input_buffer[x];
86  }
87 
88  // Carryover the last 16 output samples
89  memcpy(&m_carryover[0],
91  STS_LENGTH * sizeof(std::complex<double>));
92  }

Member Data Documentation

std::vector<std::complex<double> > fun::frame_detector::m_carryover
private

Vector for storing the last 16 samples from the input_buffer and carrying them over to the next call to work()

Definition at line 69 of file frame_detector.h.

Referenced by work().

circular_accumulator<std::complex<double> > fun::frame_detector::m_corr_acc
private

Circular accumulator for calculating correlation.

Definition at line 47 of file frame_detector.h.

Referenced by work().

bool fun::frame_detector::m_plateau_flag
private

Flag for signaling whether we are currently in a plateau or not.

Definition at line 63 of file frame_detector.h.

Referenced by work().

int fun::frame_detector::m_plateau_length
private

Counter for keeping track of STS plateau length.

Definition at line 57 of file frame_detector.h.

Referenced by work().

circular_accumulator<double> fun::frame_detector::m_power_acc
private

Circular accumulator for calculating correlation.

Definition at line 52 of file frame_detector.h.

Referenced by work().


The documentation for this class was generated from the following files: