Пример #1
0
        /// <summary>
        /// Creates a new Phase-Locked Loop
        /// </summary>
        /// <param name="sampleRate">The sampling rate of the signal stream</param>
        /// <param name="carrierFrequency">The center frequency of the PLL</param>
        /// <param name="spanHz">VCO bandwidth</param>
        /// <param name="useIntegrator">If true, an the phase error is integrated (type 2 PLL), otherwise is a type 1 PLL</param>
        public PLL(int sampleRate, float carrierFrequency, float spanHz, bool useIntegrator)
        {
            _sampleRate = sampleRate;
            _vco        = new Vco(sampleRate, carrierFrequency, spanHz);
            _lockFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.LOWPASS, 50, sampleRate, 0.707);

            _armFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.LOWPASS, 63, sampleRate, 0.707);

            // Notch filter at 2x carrier frequency
            _notchFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.NOTCH, Math.Min(carrierFrequency * 2, (sampleRate / 2) - 10), sampleRate, 0.707);

            _piPhase = new Integrator(0.707f, (1f / sampleRate) * 10f);

            _isTrackingEnabled = true;
            _errScale          = 1f;
            _useIntegrator     = useIntegrator;
        }
Пример #2
0
        public Costas(int sampleRate, float carrierFrequency, LoopType loopType)
        {
            _sampleRate = sampleRate;
            _vco        = new Vco(sampleRate, carrierFrequency, 50);
            _lockFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.LOWPASS, 50, sampleRate, 0.707);


            _iArmFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.LOWPASS, 63, sampleRate, 0.707);
            _qArmFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.LOWPASS, 63, sampleRate, 0.707);

            // Notch filters at 2x carrier frequency
            _iNotchFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.NOTCH, Math.Min(carrierFrequency * 2, (sampleRate / 2) - 10), sampleRate, 1.0);
            _qNotchFilter = new BiQuadraticFilter(BiQuadraticFilter.Type.NOTCH, Math.Min(carrierFrequency * 2, (sampleRate / 2) - 10), sampleRate, 1.0);

            _piPhase = new Integrator(0.707f, (1f / sampleRate) * 10f);

            _doFilterOutput    = true;
            _isTrackingEnabled = true;
            _errScale          = 1f;

            PhaseErrorAlgorithm = loopType;
        }