rtl433  UNKNOWN
RTL-433 utility
pulse_demod.h File Reference

Pulse demodulation functions. More...

Go to the source code of this file.

Functions

int pulse_demod_pcm (const pulse_data_t *pulses, r_device *device)
 Demodulate a Pulse Code Modulation signal. More...
 
int pulse_demod_ppm (const pulse_data_t *pulses, r_device *device)
 Demodulate a Pulse Position Modulation signal. More...
 
int pulse_demod_pwm (const pulse_data_t *pulses, r_device *device)
 Demodulate a Pulse Width Modulation signal. More...
 
int pulse_demod_manchester_zerobit (const pulse_data_t *pulses, r_device *device)
 Demodulate a Manchester encoded signal with a hardcoded zerobit in front. More...
 
int pulse_demod_dmc (const pulse_data_t *pulses, r_device *device)
 Demodulate a Differential Manchester Coded signal. More...
 
int pulse_demod_piwm_raw (const pulse_data_t *pulses, r_device *device)
 Demodulate a raw Pulse Interval and Width Modulation signal. More...
 
int pulse_demod_piwm_dc (const pulse_data_t *pulses, r_device *device)
 Demodulate a differential Pulse Interval and Width Modulation signal. More...
 
int pulse_demod_osv1 (const pulse_data_t *pulses, r_device *device)
 
int pulse_demod_string (const char *code, r_device *device)
 Simulate demodulation using a given signal code string. More...
 

Detailed Description

Pulse demodulation functions.

Binary demodulators (PWM/PPM/Manchester/...) using a pulse data structure as input

Copyright (C) 2015 Tommy Vestermark

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Function Documentation

◆ pulse_demod_dmc()

int pulse_demod_dmc ( const pulse_data_t pulses,
r_device device 
)

Demodulate a Differential Manchester Coded signal.

No level shift within the clock cycle translates to a logic 0 One level shift within the clock cycle translates to a logic 1 Each clock cycle begins with a level shift

+—+ +—+ +----—+ + high | | | | | | | | | | | | | |

  • +—+ +—+ +----—+ low

^ ^ ^ ^ ^ clock cycle | 1 | 1 | 0 | 0 | translates as

Parameters
device->short_widthWidth in samples of '1' [us]
device->long_widthWidth in samples of '0' [us]
device->reset_limitMaximum gap size before End Of Message [us].
device->toleranceMaximum deviation from nominal widths [us]
Returns
number of events processed

References account_event(), bitbuffer_add_bit(), bitbuffer_add_row(), bitbuffer_clear(), bitbuffer_print(), bitbuffer::bits_per_row, r_device::decode_fn, pulse_data::gap, r_device::name, pulse_data::num_pulses, bitbuffer::num_rows, pulse_data::pulse, r_device::s_long_width, r_device::s_reset_limit, r_device::s_short_width, r_device::s_tolerance, and r_device::verbose.

Referenced by run_ook_demods().

◆ pulse_demod_manchester_zerobit()

int pulse_demod_manchester_zerobit ( const pulse_data_t pulses,
r_device device 
)

Demodulate a Manchester encoded signal with a hardcoded zerobit in front.

Demodulate a Manchester encoded signal where first rising edge is counted as a databit and therefore always will be zero (Most likely a hardcoded Oregon Scientific peculiarity)

Clock is recovered from the data based on pulse width. When time since last bit is more than 1.5 times the clock half period (short_width) it is declared a data edge where:

  • Rising edge means bit = 0
  • Falling edge means bit = 1
    Parameters
    device->short_widthNominal width of clock half period [us]
    device->long_widthNot used
    device->reset_limitMaximum gap size before End Of Message [us].
    Returns
    number of events processed

References account_event(), bitbuffer_add_bit(), bitbuffer_add_row(), bitbuffer_clear(), bitbuffer_print(), r_device::decode_fn, pulse_data::gap, r_device::name, pulse_data::num_pulses, bitbuffer::num_rows, pulse_data::pulse, r_device::s_reset_limit, r_device::s_short_width, r_device::s_tolerance, and r_device::verbose.

Referenced by pulse_analyzer(), run_fsk_demods(), and run_ook_demods().

◆ pulse_demod_osv1()

◆ pulse_demod_pcm()

int pulse_demod_pcm ( const pulse_data_t pulses,
r_device device 
)

Demodulate a Pulse Code Modulation signal.

Demodulate a Pulse Code Modulation (PCM) signal where bit width is fixed and each bit starts with a pulse or not. It may be either Return-to-Zero (RZ) encoding, where pulses are shorter than bit width or Non-Return-to-Zero (NRZ) encoding, where pulses are equal to bit width The presence of a pulse is:

  • Presence of a pulse equals 1
  • Absence of a pulse equals 0
    Parameters
    device->short_widthNominal width of pulse [us]
    device->long_widthNominal width of bit period [us]
    device->reset_limitMaximum gap size before End Of Message [us].
    Returns
    number of events processed

References account_event(), bitbuffer_add_bit(), bitbuffer_clear(), bitbuffer_print(), bitbuffer::bits_per_row, r_device::decode_fn, r_device::f_long_width, r_device::f_short_width, pulse_data::gap, r_device::name, pulse_data::num_pulses, pulse_data::pulse, r_device::s_long_width, r_device::s_reset_limit, r_device::s_short_width, and r_device::verbose.

Referenced by pulse_analyzer(), run_fsk_demods(), and run_ook_demods().

◆ pulse_demod_piwm_dc()

int pulse_demod_piwm_dc ( const pulse_data_t pulses,
r_device device 
)

Demodulate a differential Pulse Interval and Width Modulation signal.

Each level shift is a new bit. A short interval is a logic 1, a long interval a logic 0

Parameters
device->short_widthNominal width of '1' [us]
device->long_widthNominal width of '0' [us]
device->reset_limitMaximum gap size before End Of Message [us].
device->toleranceMaximum deviation from nominal widths [us]
Returns
number of events processed

References account_event(), bitbuffer_add_bit(), bitbuffer_add_row(), bitbuffer_clear(), bitbuffer_print(), bitbuffer::bits_per_row, r_device::decode_fn, pulse_data::gap, r_device::name, pulse_data::num_pulses, bitbuffer::num_rows, pulse_data::pulse, r_device::s_long_width, r_device::s_reset_limit, r_device::s_short_width, r_device::s_tolerance, and r_device::verbose.

Referenced by run_ook_demods().

◆ pulse_demod_piwm_raw()

int pulse_demod_piwm_raw ( const pulse_data_t pulses,
r_device device 
)

Demodulate a raw Pulse Interval and Width Modulation signal.

Each level shift is a new bit. A short interval is a logic 1, a long interval a logic 0

Parameters
device->short_widthNominal width of a bit [us]
device->long_widthMaximum width of a run of bits [us]
device->reset_limitMaximum gap size before End Of Message [us].
device->toleranceMaximum deviation from nominal widths [us]
Returns
number of events processed

References account_event(), bitbuffer_add_bit(), bitbuffer_add_row(), bitbuffer_clear(), bitbuffer_print(), bitbuffer::bits_per_row, r_device::decode_fn, r_device::f_short_width, pulse_data::gap, r_device::name, pulse_data::num_pulses, bitbuffer::num_rows, pulse_data::pulse, r_device::s_long_width, r_device::s_reset_limit, r_device::s_short_width, r_device::s_tolerance, and r_device::verbose.

Referenced by run_ook_demods().

◆ pulse_demod_ppm()

int pulse_demod_ppm ( const pulse_data_t pulses,
r_device device 
)

Demodulate a Pulse Position Modulation signal.

Demodulate a Pulse Position Modulation (PPM) signal consisting of pulses with variable gap. Pulse width may be fixed or variable. Gap between pulses determine the encoding:

  • Short gap will add a 0 bit
  • Long gap will add a 1 bit
    Parameters
    device->short_widthNominal width of '0' [us]
    device->long_widthNominal width of '1' [us]
    device->reset_limitMaximum gap size before End Of Message [us].
    device->gap_limitMaximum gap size before new row of bits [us]
    device->toleranceMaximum deviation from nominal widths (optional, raw if 0) [us]
    Returns
    number of events processed

References account_event(), bitbuffer_add_bit(), bitbuffer_add_row(), bitbuffer_add_sync(), bitbuffer_clear(), bitbuffer_print(), bitbuffer::bits_per_row, r_device::decode_fn, pulse_data::gap, r_device::name, pulse_data::num_pulses, bitbuffer::num_rows, r_device::s_gap_limit, r_device::s_long_width, r_device::s_reset_limit, r_device::s_short_width, r_device::s_sync_width, r_device::s_tolerance, and r_device::verbose.

Referenced by pulse_analyzer(), and run_ook_demods().

◆ pulse_demod_pwm()

int pulse_demod_pwm ( const pulse_data_t pulses,
r_device device 
)

Demodulate a Pulse Width Modulation signal.

Demodulate a Pulse Width Modulation (PWM) signal consisting of short, long, and optional sync pulses. Gap between pulses may be of fixed size or variable (e.g. fixed period)

  • Short pulse will add a 1 bit
  • Long pulse will add a 0 bit
  • Sync pulse (optional) will add a new row to bitbuffer
    Parameters
    device->short_widthNominal width of '1' [us]
    device->long_widthNominal width of '0' [us]
    device->reset_limitMaximum gap size before End Of Message [us].
    device->gap_limitMaximum gap size before new row of bits [us]
    device->sync_widthNominal width of sync pulse (optional) [us]
    device->toleranceMaximum deviation from nominal widths (optional, raw if 0) [us]
    Returns
    number of events processed

References account_event(), bitbuffer_add_bit(), bitbuffer_add_row(), bitbuffer_add_sync(), bitbuffer_clear(), bitbuffer_print(), bitbuffer::bits_per_row, r_device::decode_fn, pulse_data::gap, r_device::name, pulse_data::num_pulses, bitbuffer::num_rows, pulse_data::pulse, r_device::s_gap_limit, r_device::s_long_width, r_device::s_reset_limit, r_device::s_short_width, r_device::s_sync_width, r_device::s_tolerance, and r_device::verbose.

Referenced by pulse_analyzer(), run_fsk_demods(), and run_ook_demods().

◆ pulse_demod_string()

int pulse_demod_string ( const char *  code,
r_device device 
)

Simulate demodulation using a given signal code string.

The (optionally "0x" prefixed) hex code is processed into a bitbuffer_t. Each row is optionally prefixed with a length enclosed in braces "{}" or separated with a slash "/" character. Whitespace is ignored. Device params are disregarded.

Returns
number of events processed

References account_event(), bitbuffer_parse(), bitbuffer_print(), r_device::decode_fn, r_device::name, and r_device::verbose.

Referenced by main().