ScratchRadio Library: Difference between revisions

Democratising Wireless Innovation
Jump to navigation Jump to search
(Added information about the framer/deframer blocks.)
m (AndrewBack moved page ScratchRadio:Library to ScratchRadio Library)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
Back to the main Scratch Radio Wiki page: [[ScratchRadio]]
==Data Source Blocks==
==Data Source Blocks==


Line 57: Line 59:
===Simple Deframer Block===
===Simple Deframer Block===


The ''simple deframer'' block accepts input messages that are formatted as previously described for the ''simple framer'' block. It uses the synchronisation word (7E 81 C3 3C) to align to the start of the received message and then validates the checksum for the length and payload fields. If the checksum passes, the received message is forwarded to the deframer output as a series of bytes, consisting of the message length byte followed by the decoded payload bytes. The input of the simple deframer block is compatible with outputs from the ''Manchester decoder'' block, the ''bit rate sampler'' block and the ''simple framer'' block. The output is compatible with inputs to the ''message sink'' block.
The ''simple deframer'' block accepts input messages that are formatted as previously described for the ''simple framer'' block. It uses the synchronisation word (7E 81 C3 3C) to align to the start of the received message and then validates the checksum for the length and payload fields. If the checksum passes, the received message is forwarded to the deframer output as a series of bytes, consisting of the message length byte followed by the decoded payload bytes.
 
The input of the simple deframer block is compatible with outputs from the ''Manchester decoder'' block, the ''bit rate sampler'' block and the ''simple framer'' block. The output is compatible with inputs to the ''message sink'' block.
 
===Manchester Encoder Block===
 
The ''Manchester encoder'' block accepts a stream of bytes at the input, where each byte encodes a single bit value for transmission. A byte value of 0x00 corresponds to a bit value of 0, a byte value of 0x01 corresponds to a bit value of 1 and a byte value of 0xFF corresponds to an ‘idle’ bit which is used to pad the transmit data stream when no transmit data is present. It emits a stream of bytes that use the same representations for the encoded bits, but which has twice the bit rate of the input. The Manchester encoding variant used is such that a bit value of 1 is encoded as a pair of bits giving a 0->1 rising edge and a bit 0 is encoded as a pair of bits giving a 1->0 falling edge. Further information about Manchester encoding can be found via the [https://en.wikipedia.org/wiki/Manchester_code Wikipedia article].
 
The input to the Manchester encoder block is compatible with outputs from the ''simple framer'' block. The output from the Manchester encoder block is compatible with inputs to the ''OOK modulator'' block and the ''Manchester decoder'' block.
 
===Manchester Decoder Block===
 
The ''Manchester decoder'' block accepts a stream of bytes at the input, where each byte encodes a single bit value that has been received. A byte value of 0x00 corresponds to a bit value of 0 and all other byte values correspond to a bit value of 1. The Manchester decoder aligns to valid bit pairs and then decodes them - emitting a stream of bytes that use the same representations for the encoded bits, but which has half the bit rate of the input.
 
The input to the Manchester decoder block is compatible with outputs from the ''Manchester encoder'' block and ''bit rate sampler'' block. The output from the Manchester decoder block is compatible with the ''simple deframer'' block.
 
===OOK Modulator Block===
 
The ''OOK modulator'' block implements a simple on-off keying modulation scheme, where a bit value of 1 is represented by the presence of a carrier wave and a bit value of 0 is represented by the absence of the carrier. The input is a stream of bytes, where each byte encodes a single bit value that is to be transmitted. A byte value of 0x00 corresponds to a bit value of 0, a byte value of 0x01 corresponds to a bit value of 1 and a byte value of 0xFF corresponds to an ‘idle’ bit which is also characterised by the absence of the carrier wave. The output is a stream of complex data samples at a sample rate of 400kHz, each of which is an I/Q pair of single precision floating point values.
 
The OOK modulator block has a single parameter which specifies the frequency of the carrier wave to be used. This should be less than 200kHz in order to be compatible with the output sample rate. The input to the OOK modulator block is compatible with outputs from the ''simple framer'' block and the ''Manchester encoder'' block. The output of the OOK modulator block is compatible with inputs to the ''radio sink'' block, the ''spectrum display'' block, the ''low pass filter'' block, the ''band pass filter'' block and the ''OOK demodulator'' block.
 
===OOK Demodulator Block===
 
The ''OOK demodulator'' block implements a simple demodulation scheme that relies on the modulated signal consisting of an equal number of on and off periods – something that is guaranteed by the use of Manchester encoding. It accepts a stream of complex data samples, each of which is an I/Q pair of single precision floating point values and calculates the absolute value of each sample. The long term average of these absolute values is calculated and can be subtracted from the absolute value of the input signal to yield a real valued output signal that is positive when the modulated carrier signal is present and negative when it is absent. This output is presented at the same 400kHz sample rate as the demodulator input, ready for timing recovery and bit rate sampling.
 
The input to the OOK demodulator block is compatible with outputs from the ''OOK modulator'' block, the ''radio source'' block, the ''low pass filter'' block and the ''band pass filter'' block. The output of the OOK demodulator block is compatible with inputs to the ''bit rate sampler'' block.
 
===Bit Rate Sampler Block===
 
The ''bit rate sampler'' block implements a simple timing recovery algorithm and symbol sampler. Since the real value sample rate at the block input is several times greater than the output bit rate, this can use a basic zero crossing detector and an input sample counter. Since the input sample counter is reset on each zero crossing, the input samples presented at 1/2 the symbol period (and subsequently 3/2, 5/2 etc.) can be used directly as the sampled symbol value and then sliced to give the sampled bit value - with positive symbol values implying a bit value of ‘1’ and negative symbol values implying a bit value of ‘0’. The output of the bit rate sampler is a sequence of byte values where a byte value of 0x00 implies a bit value of ‘0’ and a byte value of 0x01 implies a bit value of ‘1’.
 
The input to the bit rate sampler block is compatible with the output of the ''OOK demodulator'' block. The output of the bit rate sampler block is compatible with the inputs to the ''Manchester decoder'' block or ''simple deframer'' block.
 
===Low Pass Filter Block===
 
The ''low pass filter'' block implements a finite impulse response filter with a configurable passband. It accepts a stream of complex data samples, each of which is an I/Q pair of single precision floating point values and emits a stream of filtered complex data samples at the same sample rate. The low pass filter block has a single configurable parameter, which is the required filter bandwidth. This should be less than 200kHz in order to be compatible with the 400kHz input sample rate.
 
The input to the low pass filter block is compatible with the outputs of the ''OOK modulator'' block, the ''radio source'' block, the ''low pass filter'' block and the ''band pass filter'' block. The output of the low pass filter block is compatible with the inputs to the ''OOK demodulator'' block, the ''radio sink'' block, the ''low pass filter'' block and the ''band pass filter'' block.
 
===Band Pass Filter Block===
 
The ''band pass filter'' block implements a finite impulse response filter with a configurable passband, with complex filter coefficients being used to provide a single sided filter characteristic. It accepts a stream of complex data samples, each of which is an I/Q pair of single precision floating point values and emits a stream of filtered complex data samples at the same sample rate. The band pass filter block has two configurable parameters, which are the lower and upper frequencies of the required passband. These should be less than 200kHz in order to be compatible with the 400kHz input sample rate.
 
The input to the band pass filter block is compatible with the outputs of the ''OOK modulator block'', the ''radio source'' block, the ''low pass filter'' block and the ''band pass filter'' block. The output of the band pass filter block is compatible with the inputs to the ''OOK demodulator'' block, the ''radio sink'' block, the ''low pass filter'' block and the ''band pass filter'' block.


Back to the main Scratch Radio Wiki page: [[ScratchRadio]]


{{Community}}
{{Community}}

Latest revision as of 12:22, 23 January 2020

Back to the main Scratch Radio Wiki page: ScratchRadio

Data Source Blocks

Radio Source Block

The radio source block takes data samples that are supplied by the LimeSDR-Mini receiver and forwards them as a stream of complex data values, each of which is an I/Q pair of single precision floating point values. The radio source block has two configurable parameters:

  • Centre Frequency - This is the front-end mixer frequency used by the LimeSDR-Mini. It specifies the centre frequency of the 400kHz wide spectrum segment which is mixed down and presented at the block output.
  • Fixed Input Gain - This is the front-end amplifier gain used by the LimeSDR-Mini. It sets the amount by which the radio input is amplified before being sampled.

The output of the radio source block is compatible with inputs to the radio sink block, the spectrum display block, the low pass filter block, the band pass filter block and the OOK demodulator block.

Message Source Block

The message source block takes text messages that are supplied via the send message block and formats them as a stream of data bytes at the message source block output. Each message is made up of a length byte that specifies the number of bytes in the message (1 to 255) followed by the message body consisting of the specified number of bytes. When no message is available for transmission, zero valued padding bytes are inserted. A typical "Hello World!" message complete with padding bytes would be formatted as follows:

 ... 00 00 0C 48 65 6C 6C 6F 20 57 6F 72 6C 64 21 00 00 ...

The output of the message source block is compatible with inputs to the message sink block and the simple framer block.

Data Source Tap Block

The data source tap block is used to tap into the data stream at the output of other blocks, replicating the data so that it can be processed in two or more parallel datapaths. The block has a single configurable parameter that specifies the name of the source block from which the output data is being derived. The output of the data source tap block will be compatible with the same set of downstream blocks as for the original data source.

Data Sink Blocks

Radio Sink Block

The radio sink block accepts a stream of complex data values, each of which is an I/Q pair of single precision floating point values, and forwards them to the LimeSDR-Mini transmitter. The radio sink block has two configurable parameters:

  • Centre Frequency – This is the front-end mixer frequency used by the LimeSDR-Mini. It specifies the centre frequency of the 400kHz spectrum segment which is presented at the block input.
  • Fixed Output Gain – This is the front-end amplifier gain used by the LimeSDR-Mini. It sets the amount by which the radio output is amplified before being transmitted.

The input of the radio sink block is compatible with outputs from the radio source block, the low pass filter block, the band pass filter block and the OOK modulator block.

Spectrum Display Block

The spectrum display block accepts a stream of complex data values, each of which is an I/Q pair of single precision floating point values, and displays the associated frequency spectrum. Two graphical representations are supported – a conventional power spectral density plot and a colourised waterfall plot. The appropriate representation can be selected using the block’s drop down menu as spectrum and waterfall respectively. The block also has an additional configurable parameter which sets the centre frequency to be used when labelling the frequency axis of the plots.

Message Sink Block

The message sink block accepts messages that are formatted within a stream of data bytes at the block input and converts them for use within the Scratch programming environment via the receive message block. Each input message is made up of a length byte that specifies the number of bytes in the message (1 to 255) followed by the message body consisting of the specified number of bytes. When no message has been received, zero valued padding bytes are inserted. A typical “Hello World!” message complete with padding bytes would be formatted as follows:

 ... 00 00 0C 48 65 6C 6C 6F 20 57 6F 72 6C 64 21 00 00 ...

The input of the message sink block is compatible with outputs from the message source block and the simple deframer block.

Data Processing Blocks

Simple Framer Block

The simple framer block is used to add a header and checksum to messages prior to transmission. The block accepts input messages that are made up of a length byte that specifies the number of bytes in the message, followed by the specified number of payload bytes. It generates an output which consists of the same message, but with header and checksum bytes added and the data serialised into individual bits. When no message is being sent, idle bits may be inserted. The generated frame consists of a six byte preamble, a four byte synchronisation word, the length and payload bytes from the original message, two checksum bytes and a single byte frame terminator. The checksum is calculated over the length and payload fields using Fletcher’s checksum method (modulo 255). For more information about using this checksum method, see the Wikipedia article. The overall format is as follows:

 A5 F0 A5 F0 A5 F0 7E 81 C3 3C <LEN> <PAYLOAD…> <CS0> <CS1> FF

The input of the simple framer block is compatible with outputs from the message source block. The output is compatible with inputs to the Manchester encoder block, the OOK modulator block and the simple deframer block.

Simple Deframer Block

The simple deframer block accepts input messages that are formatted as previously described for the simple framer block. It uses the synchronisation word (7E 81 C3 3C) to align to the start of the received message and then validates the checksum for the length and payload fields. If the checksum passes, the received message is forwarded to the deframer output as a series of bytes, consisting of the message length byte followed by the decoded payload bytes.

The input of the simple deframer block is compatible with outputs from the Manchester decoder block, the bit rate sampler block and the simple framer block. The output is compatible with inputs to the message sink block.

Manchester Encoder Block

The Manchester encoder block accepts a stream of bytes at the input, where each byte encodes a single bit value for transmission. A byte value of 0x00 corresponds to a bit value of 0, a byte value of 0x01 corresponds to a bit value of 1 and a byte value of 0xFF corresponds to an ‘idle’ bit which is used to pad the transmit data stream when no transmit data is present. It emits a stream of bytes that use the same representations for the encoded bits, but which has twice the bit rate of the input. The Manchester encoding variant used is such that a bit value of 1 is encoded as a pair of bits giving a 0->1 rising edge and a bit 0 is encoded as a pair of bits giving a 1->0 falling edge. Further information about Manchester encoding can be found via the Wikipedia article.

The input to the Manchester encoder block is compatible with outputs from the simple framer block. The output from the Manchester encoder block is compatible with inputs to the OOK modulator block and the Manchester decoder block.

Manchester Decoder Block

The Manchester decoder block accepts a stream of bytes at the input, where each byte encodes a single bit value that has been received. A byte value of 0x00 corresponds to a bit value of 0 and all other byte values correspond to a bit value of 1. The Manchester decoder aligns to valid bit pairs and then decodes them - emitting a stream of bytes that use the same representations for the encoded bits, but which has half the bit rate of the input.

The input to the Manchester decoder block is compatible with outputs from the Manchester encoder block and bit rate sampler block. The output from the Manchester decoder block is compatible with the simple deframer block.

OOK Modulator Block

The OOK modulator block implements a simple on-off keying modulation scheme, where a bit value of 1 is represented by the presence of a carrier wave and a bit value of 0 is represented by the absence of the carrier. The input is a stream of bytes, where each byte encodes a single bit value that is to be transmitted. A byte value of 0x00 corresponds to a bit value of 0, a byte value of 0x01 corresponds to a bit value of 1 and a byte value of 0xFF corresponds to an ‘idle’ bit which is also characterised by the absence of the carrier wave. The output is a stream of complex data samples at a sample rate of 400kHz, each of which is an I/Q pair of single precision floating point values.

The OOK modulator block has a single parameter which specifies the frequency of the carrier wave to be used. This should be less than 200kHz in order to be compatible with the output sample rate. The input to the OOK modulator block is compatible with outputs from the simple framer block and the Manchester encoder block. The output of the OOK modulator block is compatible with inputs to the radio sink block, the spectrum display block, the low pass filter block, the band pass filter block and the OOK demodulator block.

OOK Demodulator Block

The OOK demodulator block implements a simple demodulation scheme that relies on the modulated signal consisting of an equal number of on and off periods – something that is guaranteed by the use of Manchester encoding. It accepts a stream of complex data samples, each of which is an I/Q pair of single precision floating point values and calculates the absolute value of each sample. The long term average of these absolute values is calculated and can be subtracted from the absolute value of the input signal to yield a real valued output signal that is positive when the modulated carrier signal is present and negative when it is absent. This output is presented at the same 400kHz sample rate as the demodulator input, ready for timing recovery and bit rate sampling.

The input to the OOK demodulator block is compatible with outputs from the OOK modulator block, the radio source block, the low pass filter block and the band pass filter block. The output of the OOK demodulator block is compatible with inputs to the bit rate sampler block.

Bit Rate Sampler Block

The bit rate sampler block implements a simple timing recovery algorithm and symbol sampler. Since the real value sample rate at the block input is several times greater than the output bit rate, this can use a basic zero crossing detector and an input sample counter. Since the input sample counter is reset on each zero crossing, the input samples presented at 1/2 the symbol period (and subsequently 3/2, 5/2 etc.) can be used directly as the sampled symbol value and then sliced to give the sampled bit value - with positive symbol values implying a bit value of ‘1’ and negative symbol values implying a bit value of ‘0’. The output of the bit rate sampler is a sequence of byte values where a byte value of 0x00 implies a bit value of ‘0’ and a byte value of 0x01 implies a bit value of ‘1’.

The input to the bit rate sampler block is compatible with the output of the OOK demodulator block. The output of the bit rate sampler block is compatible with the inputs to the Manchester decoder block or simple deframer block.

Low Pass Filter Block

The low pass filter block implements a finite impulse response filter with a configurable passband. It accepts a stream of complex data samples, each of which is an I/Q pair of single precision floating point values and emits a stream of filtered complex data samples at the same sample rate. The low pass filter block has a single configurable parameter, which is the required filter bandwidth. This should be less than 200kHz in order to be compatible with the 400kHz input sample rate.

The input to the low pass filter block is compatible with the outputs of the OOK modulator block, the radio source block, the low pass filter block and the band pass filter block. The output of the low pass filter block is compatible with the inputs to the OOK demodulator block, the radio sink block, the low pass filter block and the band pass filter block.

Band Pass Filter Block

The band pass filter block implements a finite impulse response filter with a configurable passband, with complex filter coefficients being used to provide a single sided filter characteristic. It accepts a stream of complex data samples, each of which is an I/Q pair of single precision floating point values and emits a stream of filtered complex data samples at the same sample rate. The band pass filter block has two configurable parameters, which are the lower and upper frequencies of the required passband. These should be less than 200kHz in order to be compatible with the 400kHz input sample rate.

The input to the band pass filter block is compatible with the outputs of the OOK modulator block, the radio source block, the low pass filter block and the band pass filter block. The output of the band pass filter block is compatible with the inputs to the OOK demodulator block, the radio sink block, the low pass filter block and the band pass filter block.

Back to the main Scratch Radio Wiki page: ScratchRadio