diff --git a/radio/composites/bpsk31receiver.lua b/radio/composites/bpsk31receiver.lua new file mode 100644 index 000000000..6ed916193 --- /dev/null +++ b/radio/composites/bpsk31receiver.lua @@ -0,0 +1,49 @@ +--- +-- Demodulate and decode bytes from a baseband BPSK31 modulated complex-valued +-- signal. +-- +-- @category Receivers +-- @block BPSK31Receiver +-- +-- @signature in:ComplexFloat32 > out:Byte +-- +-- @usage +-- local receiver = radio.BPSK31Receiver() +-- local snk = radio.RawFileSink(io.stdout) +-- top:connect(src, receiver, snk) + +local block = require('radio.core.block') +local types = require('radio.types') +local blocks = require('radio.blocks') + +local BPSK31Receiver = block.factory("BPSK31Receiver", blocks.CompositeBlock) + +function BPSK31Receiver:instantiate() + blocks.CompositeBlock.instantiate(self) + + local bandwidth = 100 + local baudrate = 31.25 + + local filter = blocks.LowpassFilterBlock(128, bandwidth) + local rrc_filter = blocks.RootRaisedCosineFilterBlock(101, 1, baudrate) + local phase_corrector = blocks.BinaryPhaseCorrectorBlock(50) + local clock_demod = blocks.ComplexToRealBlock() + local clock_recoverer = blocks.ZeroCrossingClockRecoveryBlock(baudrate) + local sampler = blocks.SamplerBlock() + local bit_demod = blocks.ComplexToRealBlock() + local slicer = blocks.SlicerBlock() + local bit_decoder = blocks.DifferentialDecoderBlock(true) + local decoder = blocks.VaricodeDecoderBlock() + + self:connect(filter, rrc_filter, phase_corrector) + self:connect(phase_corrector, clock_demod, clock_recoverer) + self:connect(phase_corrector, 'out', sampler, 'data') + self:connect(clock_recoverer, 'out', sampler, 'clock') + self:connect(sampler, bit_demod, slicer, bit_decoder, decoder) + + self:add_type_signature({block.Input("in", types.ComplexFloat32)}, {block.Output("out", types.Byte)}) + self:connect(self, "in", filter, "in") + self:connect(self, "out", decoder, "out") +end + +return BPSK31Receiver diff --git a/radio/composites/init.lua b/radio/composites/init.lua index 3941fecc5..1085b474b 100644 --- a/radio/composites/init.lua +++ b/radio/composites/init.lua @@ -22,4 +22,5 @@ return { RDSReceiver = require('radio.composites.rdsreceiver'), AX25Receiver = require('radio.composites.ax25receiver'), POCSAGReceiver = require('radio.composites.pocsagreceiver'), + BPSK31Receiver = require('radio.composites.bpsk31receiver'), }