Commit Graph

307 Commits

Author SHA1 Message Date
Niccolò Izzo 6322cb49a4 Cleanup demodulator, improved quantization log
Unified offset and phase variable to reduce the chance of off-by-ones
between buffers. Improved logging on linux and module17 adding
quantization indices.

TG-81
2022-05-27 21:49:33 +02:00
Silvano Seva ff7a28ff59 RingBuffer class: implemented eraseElement() function, rewritten the pop() function in a cleaner way, fixed a bug in the pop() function causing the not_full condition variable to be never rised. 2022-05-27 21:49:33 +02:00
Niccolò Izzo 29ad0830f0 M17 demodulation improvement
Add logging in syncword sweep, fix unsigned underflow bug,
fixed symbol average computation for quantization.
Do syncword sweep whenever available.

TG-81
2022-05-27 21:49:33 +02:00
Silvano Seva d17d683b2d M17 code cleanup pass: reorganised data type definitions and constants 2022-05-27 21:49:33 +02:00
Silvano Seva 7aff678069 Improved robustness of frame type detection, now based on minimum hamming distance between syncwords 2022-05-27 21:49:33 +02:00
Niccolò Izzo c987848382 Add syncword hot re-sync fix DC removal
DC removal filter had a bug that created weird positive spikes on
Module17, add a syncword hot re-sync to be able to correct small phase
errors that appear every five seconds more or less.

TG-81
2022-05-27 21:48:47 +02:00
Silvano Seva 1f77c2af6c Reorganised logging inside M17 demodulator, logging is disabled by default.
On non-linux devices log data is printed on the serial port in raw binary format.
2022-05-27 21:48:47 +02:00
Silvano Seva 6be567a781 Implementation of a statically allocated ring buffer with blocking and non-blocking push and pop 2022-05-27 21:48:47 +02:00
Niccolò Izzo ef61c532a3 Cleaned up quantization average
Now average is computed over all the syncword symbols, for each syncword
as a simple average.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo 5fe5b0e578 Refactor M17 logging
Refactored logging functions to enable in-system logging on Module17 and
MDx radios.

TG-81
2022-05-27 21:48:47 +02:00
Silvano Seva 361308be16 Generator of pseudorandom binary sequence compliant with M17 specification 2022-05-27 21:48:47 +02:00
Silvano Seva 3988540b6c Changed coefficients for the 41-tap, 24kHz RRC filter to have unitary input-output gain 2022-05-27 21:48:47 +02:00
Niccolò Izzo c3c984d504 Add syncword fuzzy detection
Frame decoder now tolerates bit error in syncword, removed syncword type
detection in demodulator code.

TG-81
2022-05-27 21:48:47 +02:00
Silvano Seva 6b31a73f42 Corrected RRC gain and changed HR_C5000 modulation factor and input gain to have the correct 2.4kHz deviation when transmitting M17 with an MD3x0 radio 2022-05-27 21:48:47 +02:00
Niccolò Izzo 2d59658d60 Switch M17 Rx sample rate to 5SPS
Due to the RRC computation sometimes violating the timing constraints,
we switched the M17 demodulator to 5 samples per symbol (24KHz), thus
dividing the processing time by four ar the number of samples halves as
well as the number of taps of the RRC.
Minor adaptation on the code followed.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo 63bd864674 Fix M17 Rx LED
Now LED turns on when a syncword is successfully detected, not just when
the correlation is sufficiently high.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo c4483edff0 Improve quantization strategy
Now quantization is performed by averaging syncword samples and dividing
the resulting threshold by a constant.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo 7d1b89550e Rewrite quantization algorithm
Quantization algorithm is now based on separate rolling averages for
positive and negative samples.
Merged csv outputs from syncword search and quantization on Linux.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo aa9fcc26b7 Remove useless DC bias in quantization
TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo d1651a702c Add proper DC-bias removal, tuned EMAs 2022-05-27 21:48:47 +02:00
Silvano Seva da5c453852 Implemented unpacking and decoding of M17 audio stream frames 2022-05-27 21:48:47 +02:00
Silvano Seva beca0d2acc Reorganised constants inside M17 demodulator class 2022-05-27 21:48:47 +02:00
Silvano Seva fda0fed5e7 Moved constant specifying sample rate for M17 baseband decoding from hwconfig.h files to M17Demodulator class 2022-05-27 21:48:47 +02:00
Silvano Seva e5b5daba85 Moved state variables of PWM compensator and DC removal filter outside the function bodies to allow keeping their consistency among function calls 2022-05-27 21:48:47 +02:00
Silvano Seva b144657257 Moved CODEC2 management to a dedicated module 2022-05-27 21:48:47 +02:00
Silvano Seva 4b8685b853 Changed gain and added an offset at tx RRC stage only for Module 17 to compensate for an hardware bug 2022-05-27 21:48:47 +02:00
Silvano Seva d1b4973cc9 Fixed reset of DC bias on stream stop in Module 17 output stream driver, made parametric the gain of the RRC at modulator side 2022-05-27 21:48:47 +02:00
Silvano Seva 3d169484e9 Improved management of CODEC2 thread in M17 mode handler, now activated only when transmitting. Fixes a confict with RTX and MIC input streams causing the rtx thread to hang when PTT was pressed 2022-05-27 21:48:47 +02:00
Silvano Seva 54a89abcd0 Removed a printf left behind after debugging from M17 demodulator class and slightly cleaned up the code 2022-05-27 21:48:47 +02:00
Silvano Seva c9a4bfb199 Cleanup and refactoring of M17 modulator class, now using output streams for baseband signal output 2022-05-27 21:48:47 +02:00
Silvano Seva 0df1dc4f7e Extended output stream API to support also circular double-buffered mode, implemented output stream driver for MDx 2022-05-27 21:48:47 +02:00
Silvano Seva 5c90c19bea Data conversion utilities 2022-05-27 21:48:47 +02:00
Silvano Seva 427c5f50b3 Made M17Demodulator::update() return a boolean indicating when a new decoded frame is ready 2022-05-27 21:48:47 +02:00
Niccolò Izzo 77aead675a Improve runtime performance of M17 Demodulator
Tweaked the exponential moving average alpha factors to improve the
reactivity of the M17 demodulator.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo 5ef145cd39 Add fuzzy syncword validation
Now syncword match is not exact but can tolerate up to two erroneous
bits.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo ca49b306b9 Update constants for M17 demodulation
Constants were updated to increase performance based on baseband sample
collected with Module17.

TG-81
2022-05-27 21:48:47 +02:00
Niccolò Izzo 2d8c696a09 Complete M17 demodulator implementation
Make quantization work also on DC offset signal
Add samples plot code
Fix bug in buffer wrap around
Fix oob memory access in M17 modulator
Update tests with DC offset signal
Switch to 48KHz sample rate for Module17 and MD380
Add DC biasing script

TG-81
2022-05-27 21:48:46 +02:00
Niccolò Izzo f9c23452bc Add plotting function to graphics library
Added plotting function to graphics library which is native C++, so
refactored the graphics source file to allow that, consequently adapted
the hwconfig header files to be included also in C++ sources.
Propagated compile flags also to C++ sources, including asan what was
previously disabled for C++ compilation units.

TG-81
2022-05-27 21:48:46 +02:00
Niccolò Izzo ae26cca46f Remove SPS
Now M17_SAPLES_PER_SYMBOL is computed dinamically from sample rate.

TG-81
2022-05-27 21:48:46 +02:00
Niccolò Izzo a091bca35f M17 Demodulator bugfixes
Fixed several bugs in the M17 Demodulator code.

TG-81
2022-05-27 21:48:46 +02:00
Silvano Seva 35c1f062c6 Implementation of M17 frame encoder 2022-05-27 21:48:46 +02:00
Silvano Seva 82dd0a63f1 Clarification of naming: renamed DATA_SYNC_WORD to STREAM_SYNC_WORD and Audio_puncture to DATA_PUNCTURE 2022-05-27 21:48:46 +02:00
Silvano Seva 25087b0e02 Removed BUF_CIRC from the possible buffer management modes for an input audio stream 2022-05-27 21:48:46 +02:00
Silvano Seva 5fbd39959c Implementation of M17 frame decoder 2022-05-27 21:48:46 +02:00
Silvano Seva 49bd8ee2f4 Reorganised internal structure of M17LinkSetupFrame class, renamed M17Frame to M17StreamFrame and reorganised its structure 2022-05-27 21:48:46 +02:00
Silvano Seva c73aa92305 Reorganised M17LinkSetupframe and M17Frame classes, encapsulating structs defining their internal data structure 2022-05-27 21:48:46 +02:00
Niccolò Izzo 7a9bbfcaf2 Demodulator bugfix
Fix several bugs in the demodulator code, tipycally sign errors.
2022-05-27 21:48:46 +02:00
Niccolò Izzo 1a9b3c4168 Implement M17 demodulator logic
Implemented frame wrapping logic and demodulator loop.
2022-05-27 21:48:46 +02:00
Silvano Seva 963fbdc141 M17 mode handler: calling demodulator update function when in RX mode 2022-05-27 21:48:46 +02:00
Niccolò Izzo 5bf4df75ba Fine tune demodulator to OpenRTX M17 baseband
Fine tuned M17 demodulator with code generated from OpenRTX itself.

TG-81
2022-05-27 21:48:46 +02:00