libsdr  0.1.0
A simple SDR library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sdr::BPSK31< Scalar > Class Template Reference

A simple BPSK31 "demodulator". More...

#include <psk31.hh>

Inheritance diagram for sdr::BPSK31< Scalar >:
sdr::Sink< std::complex< Scalar > > sdr::Source sdr::SinkBase

Public Member Functions

 BPSK31 (double dF=0.1)
 Constructs a new BPSK31 demodulator. More...
 
virtual ~BPSK31 ()
 Destructor. More...
 
virtual void config (const Config &src_cfg)
 Needs to be implemented by any sub-type to check and perform the configuration of the node. More...
 
virtual void process (const Buffer< std::complex< Scalar > > &buffer, bool allow_overwrite)
 Needs to be implemented by any sub-type to process the received data. More...
 
- Public Member Functions inherited from sdr::Sink< std::complex< Scalar > >
 Sink ()
 Constructor. More...
 
virtual ~Sink ()
 Drestructor. More...
 
virtual void handleBuffer (const RawBuffer &buffer, bool allow_overwrite)
 Re-implemented from SinkBase. More...
 
- Public Member Functions inherited from sdr::SinkBase
 SinkBase ()
 Constructor. More...
 
virtual ~SinkBase ()
 Destructor. More...
 
- Public Member Functions inherited from sdr::Source
 Source ()
 Constructor. More...
 
virtual ~Source ()
 Destructor. More...
 
virtual void send (const RawBuffer &buffer, bool allow_overwrite=false)
 Sends the given buffer to all connected sinks. More...
 
void connect (SinkBase *sink, bool direct=false)
 Connect this source to a sink. More...
 
void disconnect (SinkBase *sink)
 Disconnect a sink again. More...
 
virtual void setConfig (const Config &config)
 Stores the configuration and propergates it if the configuration has been changed. More...
 
virtual double sampleRate () const
 Returns the configured sample rate or 0 otherwise. More...
 
virtual Config::Type type () const
 Returns the configured source type or Config::Type_UNDEFINED otherwise. More...
 
template<class T >
void addEOS (T *instance, void(T::*function)())
 Adds a callback to the end-of-stream signal of the source. More...
 

Protected Member Functions

bool _hasTransition () const
 Returns true if there is a phase transition at the current sample. More...
 
int _currentContellation () const
 Returns the current constellation. More...
 
float _phaseError (const std::complex< float > &value) const
 Computes the phase error. More...
 
void _updatePLL (const std::complex< float > &sample)
 Updates the PLL (_F and _P). More...
 
void _updateSampler (const std::complex< Scalar > &value)
 Updates the sub-sampler. More...
 
void _errorTracking (const std::complex< float > &sample)
 Updates the PPL state (_mu and _omega). More...
 
- Protected Member Functions inherited from sdr::Source
void signalEOS ()
 Signals the EOS. More...
 
void propagateConfig (const Config &config)
 Propagates the given configuration to all connected sinks. More...
 

Protected Attributes

size_t _superSample
 Holds the number of phase constellations per bit. More...
 
float _P
 Phase of the carrier PLL. More...
 
float _F
 Frequency of the carrier PLL. More...
 
float _Fmin
 Lower frequency limit of the carrier PLL. More...
 
float _Fmax
 Upper frequency limit of the carrier PLL. More...
 
float _alpha
 Gain factor of the carrier PLL. More...
 
float _beta
 Gain factor of the carrier PLL. More...
 
Buffer< std::complex< float > > _dl
 The delay line for the interpolating sub-sampler. More...
 
size_t _dl_idx
 The current index of the delay line. More...
 
float _mu
 Holds the fractional sub-sampling counter. More...
 
float _gain_mu
 Gain factor of the sub-sampler. More...
 
float _theta
 Constant phase shift between real axis and first constellation. More...
 
float _omega
 Current sub-sample rate. More...
 
float _omega_rel
 Relative error of the subsample rate. More...
 
float _min_omega
 Minimum of the sub-sample rate. More...
 
float _max_omega
 Maximum of the sub-sample rate. More...
 
float _gain_omega
 Gain of the sub-sample rate correction. More...
 
std::complex< float > _p_0T
 Phase at T = 0 (samples). More...
 
std::complex< float > _p_1T
 Phase at T=-1 (samples). More...
 
std::complex< float > _p_2T
 Phase at T=-2 (samples). More...
 
std::complex< float > _c_0T
 Constellation at T=0 (samples). More...
 
std::complex< float > _c_1T
 Constellation at T=-1 (samples). More...
 
std::complex< float > _c_2T
 Constellation at T=-2 (samples). More...
 
Buffer< float > _hist
 The last _superSample phases. More...
 
size_t _hist_idx
 Current phase history index. More...
 
int _last_constellation
 The last output constellation. More...
 
Buffer< uint8_t > _buffer
 Output buffer. More...
 
- Protected Attributes inherited from sdr::Source
Config _config
 Holds the source configuration, this can be updated by calling setConfig. More...
 
std::map< SinkBase *, bool > _sinks
 The connected sinks. More...
 
std::list< DelegateInterface * > _eos
 The connected EOS singal handlers. More...
 

Detailed Description

template<class Scalar>
class sdr::BPSK31< Scalar >

A simple BPSK31 "demodulator".

This node consumes a complex input stream with a sample rate of at least 2000Hz and produces a bitstream with 31.25 Hz "sample rate". Use the Varicode node to decode this bitstream to ASCII chars. The BPSK31 signal should be centered around 0Hz. This node uses a simple PLL to adjust for small detunings.

Constructor & Destructor Documentation

template<class Scalar >
sdr::BPSK31< Scalar >::BPSK31 ( double  dF = 0.1)
inline

Constructs a new BPSK31 demodulator.

This node first subsamples the input signal to a multiple of 31.25 Hz (by default to 2000Hz = 64*31.25) using an interpolating sub-sampler. Therefore, the input signal must be filtered sufficiently well to avoid artifacts of the interpolating sub-sampler. Then, the phase-constellation of the signal is determined as either -pi or pi while the frequency of the carrier is tracked using a simple PLL. Finally, the BPSK31 bit stream is decoded by detecting a phase-change (0) or not (1).

Note
This node uses floating point arithmetic, hence it should not be used on streams with a high sample rate! Which is not neccessary as it only decodes a BPSK signal with approx. 31 baud.
Parameters
dFSpecfies the (relative anglular) frequency range of the PLL to adjust for small deviations of the BPSK31 signal from 0Hz.
template<class Scalar >
virtual sdr::BPSK31< Scalar >::~BPSK31 ( )
inlinevirtual

Destructor.

Member Function Documentation

template<class Scalar >
int sdr::BPSK31< Scalar >::_currentContellation ( ) const
inlineprotected

Returns the current constellation.

template<class Scalar >
void sdr::BPSK31< Scalar >::_errorTracking ( const std::complex< float > &  sample)
inlineprotected

Updates the PPL state (_mu and _omega).

template<class Scalar >
bool sdr::BPSK31< Scalar >::_hasTransition ( ) const
inlineprotected

Returns true if there is a phase transition at the current sample.

template<class Scalar >
float sdr::BPSK31< Scalar >::_phaseError ( const std::complex< float > &  value) const
inlineprotected

Computes the phase error.

template<class Scalar >
void sdr::BPSK31< Scalar >::_updatePLL ( const std::complex< float > &  sample)
inlineprotected

Updates the PLL (_F and _P).

template<class Scalar >
void sdr::BPSK31< Scalar >::_updateSampler ( const std::complex< Scalar > &  value)
inlineprotected

Updates the sub-sampler.

template<class Scalar >
virtual void sdr::BPSK31< Scalar >::config ( const Config src_cfg)
inlinevirtual

Needs to be implemented by any sub-type to check and perform the configuration of the node.

Implements sdr::SinkBase.

template<class Scalar >
virtual void sdr::BPSK31< Scalar >::process ( const Buffer< std::complex< Scalar > > &  buffer,
bool  allow_overwrite 
)
inlinevirtual

Needs to be implemented by any sub-type to process the received data.

Implements sdr::Sink< std::complex< Scalar > >.

Member Data Documentation

template<class Scalar >
float sdr::BPSK31< Scalar >::_alpha
protected

Gain factor of the carrier PLL.

template<class Scalar >
float sdr::BPSK31< Scalar >::_beta
protected

Gain factor of the carrier PLL.

template<class Scalar >
Buffer<uint8_t> sdr::BPSK31< Scalar >::_buffer
protected

Output buffer.

template<class Scalar >
std::complex<float> sdr::BPSK31< Scalar >::_c_0T
protected

Constellation at T=0 (samples).

template<class Scalar >
std::complex<float> sdr::BPSK31< Scalar >::_c_1T
protected

Constellation at T=-1 (samples).

template<class Scalar >
std::complex<float> sdr::BPSK31< Scalar >::_c_2T
protected

Constellation at T=-2 (samples).

template<class Scalar >
Buffer< std::complex<float> > sdr::BPSK31< Scalar >::_dl
protected

The delay line for the interpolating sub-sampler.

template<class Scalar >
size_t sdr::BPSK31< Scalar >::_dl_idx
protected

The current index of the delay line.

template<class Scalar >
float sdr::BPSK31< Scalar >::_F
protected

Frequency of the carrier PLL.

template<class Scalar >
float sdr::BPSK31< Scalar >::_Fmax
protected

Upper frequency limit of the carrier PLL.

template<class Scalar >
float sdr::BPSK31< Scalar >::_Fmin
protected

Lower frequency limit of the carrier PLL.

template<class Scalar >
float sdr::BPSK31< Scalar >::_gain_mu
protected

Gain factor of the sub-sampler.

template<class Scalar >
float sdr::BPSK31< Scalar >::_gain_omega
protected

Gain of the sub-sample rate correction.

template<class Scalar >
Buffer<float> sdr::BPSK31< Scalar >::_hist
protected

The last _superSample phases.

template<class Scalar >
size_t sdr::BPSK31< Scalar >::_hist_idx
protected

Current phase history index.

template<class Scalar >
int sdr::BPSK31< Scalar >::_last_constellation
protected

The last output constellation.

template<class Scalar >
float sdr::BPSK31< Scalar >::_max_omega
protected

Maximum of the sub-sample rate.

template<class Scalar >
float sdr::BPSK31< Scalar >::_min_omega
protected

Minimum of the sub-sample rate.

template<class Scalar >
float sdr::BPSK31< Scalar >::_mu
protected

Holds the fractional sub-sampling counter.

template<class Scalar >
float sdr::BPSK31< Scalar >::_omega
protected

Current sub-sample rate.

template<class Scalar >
float sdr::BPSK31< Scalar >::_omega_rel
protected

Relative error of the subsample rate.

template<class Scalar >
float sdr::BPSK31< Scalar >::_P
protected

Phase of the carrier PLL.

template<class Scalar >
std::complex<float> sdr::BPSK31< Scalar >::_p_0T
protected

Phase at T = 0 (samples).

template<class Scalar >
std::complex<float> sdr::BPSK31< Scalar >::_p_1T
protected

Phase at T=-1 (samples).

template<class Scalar >
std::complex<float> sdr::BPSK31< Scalar >::_p_2T
protected

Phase at T=-2 (samples).

template<class Scalar >
size_t sdr::BPSK31< Scalar >::_superSample
protected

Holds the number of phase constellations per bit.

template<class Scalar >
float sdr::BPSK31< Scalar >::_theta
protected

Constant phase shift between real axis and first constellation.

(Currently unused).


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