Skip to content

F33RNI/QPSK-mod-demod-libs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QPSK-mod-demod-libs

C-libraries for QPSK modulation and demodulation

  include
 butterworth_filter.hButterworth Filter implementation for filtering continues signal Original code from: https://github.com/filoe/cscore
 bytes_symbols_converter.hMethods to convert array of bytes to symbols and back
 pll.hNumerically-controlled Phase locked loop
 qpsk_demodulator.hQPSK demodulator (decoder)
 qpsk_modulator.hQPSK modulator (encoder)
 rrc_filter.hRoot raised cosine (RRC) filter implementation by Fern Lane for filtering continues signal
  src
 butterworth_filter.cButterworth Filter implementation for filtering continues signal Original code from: https://github.com/filoe/cscore
 bytes_symbols_converter.cMethods to convert array of bytes to symbols and back
 pll.cNumerically-controlled Phase locked loop
 qpsk_demodulator.cQPSK demodulator (decoder)
 qpsk_modulator.cQPSK modulator (encoder)
 rrc_filter.cRoot raised cosine (RRC) filter implementation by Fern Lane for filtering continues signal

Generated by doxygen 1.9.8

qpsk_modulator.c File Reference

Functions

qpsk_modulator_sqpsk_modulator_init (float sample_rate, float carrier_frequency, float bandwidth, uint16_t halfcycles_per_symbol, float amplitude_peak)
 Initializes QPSK demodulator.
 
uint32_t qpsk_modulator_calculate_samples_chunk_length (qpsk_modulator_s *qpsk_modulator, uint32_t symbols_chunk_length)
 Calculates the size of the array of sample after modulation.
 
void qpsk_modulator_modulate_chunk (qpsk_modulator_s *qpsk_modulator, uint8_t *symbols_chunk, uint32_t symbols_chunk_length, float *samples_chunk, uint8_t debug_messages)
 Modulates chunk of symbols.
 
void qpsk_modulator_reset (qpsk_modulator_s *qpsk_modulator)
 Resets QPSK modulator to the initial state.
 
void qpsk_modulator_destroy (qpsk_modulator_s *qpsk_modulator)
 Frees all memory allocated by QPSK modulator.
 

Detailed Description

QPSK modulator (encoder)

Author
Fern Lane
Version
1.0.0
Date
2023-09-26
Copyright
Copyright (c) 2023

Copyright (C) 2023 Fern Lane, QPSK modulator / demodulator libraries Licensed under the GNU Affero General Public License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.en.html Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file qpsk_modulator.c.

Function Documentation

◆ qpsk_modulator_calculate_samples_chunk_length()

uint32_t qpsk_modulator_calculate_samples_chunk_length ( qpsk_modulator_s qpsk_modulator,
uint32_t  symbols_chunk_length 
)

Calculates the size of the array of sample after modulation.

Parameters
qpsk_modulatorQPSK modulator's struct
symbols_chunk_lengthnumber of symbols
Returns
uint32_t number of samples

Definition at line 104 of file qpsk_modulator.c.

◆ qpsk_modulator_destroy()

void qpsk_modulator_destroy ( qpsk_modulator_s qpsk_modulator)

Frees all memory allocated by QPSK modulator.

Parameters
qpsk_modulatorQPSK modulator's struct

Definition at line 252 of file qpsk_modulator.c.

◆ qpsk_modulator_init()

qpsk_modulator_s * qpsk_modulator_init ( float  sample_rate,
float  carrier_frequency,
float  bandwidth,
uint16_t  halfcycles_per_symbol,
float  amplitude_peak 
)

Initializes QPSK demodulator.

Parameters
sample_rateSampling rate (in Hz)
carrier_frequencyCarrier frequency (in Hz)
bandwidthOutput signal required bandwidth (in Hz)
halfcycles_per_symbolRate of symbols in carrier halfcycles (2 halfcycles = 1 full carrier wave cycle)
amplitude_peakAmplitude of modulated signal (peak value)
Returns
qpsk_modulator_s* QPSK modulator's struct

Definition at line 44 of file qpsk_modulator.c.

◆ qpsk_modulator_modulate_chunk()

void qpsk_modulator_modulate_chunk ( qpsk_modulator_s qpsk_modulator,
uint8_t *  symbols_chunk,
uint32_t  symbols_chunk_length,
float *  samples_chunk,
uint8_t  debug_messages 
)

Modulates chunk of symbols.

Parameters
qpsk_modulatorQPSK modulator's struct
symbols_chunkArray of symbols
symbols_chunk_lengthLength of array of symbols
samples_chunkAllocated array of samples (size must be qpsk_modulator_calculate_samples_chunk_length * sizeof(float))
debug_messagesEnable printf() debug messages (greatly affects performance)

Definition at line 120 of file qpsk_modulator.c.

◆ qpsk_modulator_reset()

void qpsk_modulator_reset ( qpsk_modulator_s qpsk_modulator)

Resets QPSK modulator to the initial state.

Parameters
qpsk_modulator

Definition at line 232 of file qpsk_modulator.c.


Generated by doxygen 1.9.8

qpsk_demodulator.c File Reference

Functions

float clampf (float value, float min, float max)
 Clamps float value to a range.
 
qpsk_demodulator_sqpsk_demodulator_init (float sample_rate, float lo_frequency, float bandwidth, uint16_t halfcycles_per_symbol, float carrier_start_threshold, float carrier_lost_threshold, float pll_lock_threshold, float pll_lock_time)
 Initializes QPSK demodulator.
 
void qpsk_demodulator_demodulate_chunk (qpsk_demodulator_s *qpsk_demodulator, float *samples_chunk, uint32_t samples_chunk_size, uint8_t *symbols_chunk, uint8_t debug_messages)
 Demodulates one chunk of samples into symbols.
 
void qpsk_demodulator_reset (qpsk_demodulator_s *qpsk_demodulator)
 Resets QPSK demodulator to the initial state.
 
void qpsk_demodulator_destroy (qpsk_demodulator_s *qpsk_demodulator)
 Frees all memory allocated by QPSK demodulator.
 

Detailed Description

QPSK demodulator (decoder)

Author
Fern Lane
Version
1.0.0
Date
2023-09-26
Copyright
Copyright (c) 2023

Copyright (C) 2023 Fern Lane, QPSK modulator / demodulator libraries Licensed under the GNU Affero General Public License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.en.html Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file qpsk_demodulator.c.

Function Documentation

◆ clampf()

float clampf ( float  value,
float  min,
float  max 
)

Clamps float value to a range.

Parameters
valueValue to clamp
minRange minimum value
maxRange maximum value
Returns
float Clamped value

Definition at line 42 of file qpsk_demodulator.c.

◆ qpsk_demodulator_demodulate_chunk()

void qpsk_demodulator_demodulate_chunk ( qpsk_demodulator_s qpsk_demodulator,
float *  samples_chunk,
uint32_t  samples_chunk_size,
uint8_t *  symbols_chunk,
uint8_t  debug_messages 
)

Demodulates one chunk of samples into symbols.

Parameters
qpsk_demodulatorQPSK demodulator's struct
samples_chunkAarray of samples
samples_chunk_sizeLength of array of symbols
symbols_chunkAllocated array of symbols (size equal to samples_chunk_size) 0xFF - no symbol decoded at current sample, 0b00, 0b01, 0b10, 0b11 - decoded symbols at specific samples
debug_messagesEnable printf() debug messages (greatly affects performance)

Definition at line 153 of file qpsk_demodulator.c.

◆ qpsk_demodulator_destroy()

void qpsk_demodulator_destroy ( qpsk_demodulator_s qpsk_demodulator)

Frees all memory allocated by QPSK demodulator.

Parameters
qpsk_demodulatorQPSK demodulator's struct

Definition at line 481 of file qpsk_demodulator.c.

◆ qpsk_demodulator_init()

qpsk_demodulator_s * qpsk_demodulator_init ( float  sample_rate,
float  lo_frequency,
float  bandwidth,
uint16_t  halfcycles_per_symbol,
float  carrier_start_threshold,
float  carrier_lost_threshold,
float  pll_lock_threshold,
float  pll_lock_time 
)

Initializes QPSK demodulator.

Parameters
sample_rateSampling rate (in Hz)
lo_frequencyCarrier frequency (local oscillator) (in Hz)
bandwidthInput signal bandwidth (in Hz)
halfcycles_per_symbolRate of symbols in carrier halfcycles (2 halfcycles = 1 full carrier wave cycle)
carrier_start_thresholdSignal must be above this threshold to start PLL locking and demodulating (in dBFS RMS)
carrier_lost_thresholdSignal must be below this threshold to stop PLL locking and demodulating (in dBFS RMS)
pll_lock_thresholdPLL's input (IQ error) should't change during pll_lock_time more than this value
pll_lock_timePLL's input (IQ error) should't change during this time (in seconds) more than pll_lock_threshold
Returns
qpsk_demodulator_s* QPSK demodulator's struct

Definition at line 61 of file qpsk_demodulator.c.

◆ qpsk_demodulator_reset()

void qpsk_demodulator_reset ( qpsk_demodulator_s qpsk_demodulator)

Resets QPSK demodulator to the initial state.

Parameters
qpsk_demodulatorQPSK demodulator's struct

Definition at line 449 of file qpsk_demodulator.c.


Generated by doxygen 1.9.8