Hi all,
Claude Code delivers now a good solution for the SPLL implementation after I changed the AI query a bit.
AI query (translated to english):
This is the 4.th version. All function and data type names are referring to the 4.th version. I am just copying the output and placing it into the .h and .c files without any changes.
You can find the implementation in the attached zip-file.

Cheers
PS: I had to stand up very early to use Claude Code.
Claude Code delivers now a good solution for the SPLL implementation after I changed the AI query a bit.
AI query (translated to english):
Code:
I have two signals, TX and RX, which are to be digitally demodulated block-wise into I/Q using a lock-in amplifier. Use a software PLL (SPLL4) to provide clean references for lock-in demodulation of the RX signal. TX and RX signals are digitized using ADC converters with a sample rate of nSR, and the ADC's timebase is coherent. TX signal is the reference frequency. The frequency is known and fixed. TX signal contains noise (amplitude and phase jitter) and fluctuates. Trigonometric functions should be calculated incrementally within the block (phase accumulator) to minimize expensive sin()/cos() calls per sample. Implement the solution in ANSI C (C89/C90 standard) and create a C library with a header and implementation file. Optimize the solution for block processing (nFrameSize). Create a data type (SPLL4) for the demodulator for internal variables and resources. All floating-point numbers should be typecast to REAL (use double as the default). Use the following functions: - BOOL SPLL4_Init(SPLL4 *pSPLL, long nSR, REAL fFreq) Initializes the demodulator with a pointer to the SPLL4 object, where nSR is the sampling rate and fFreq is the demodulation frequency. - BOOL SPLL4_Destroy(SPLL4 *pSPLL) Releases all internal resources from the demodulator. - BOOL SPLL4_Demodulate(SPLL4 *pSPLL, REAL *pTX, REAL *pRX, REAL *pI, *pQ, int nFrameSize) Demodulates the real RX signal (pRX) using the real reference TX (pTX) with a sample length of nFrameSize. pI and pQ are pointers to the demodulated I/Q of the entire block (nFrameSize). - BOOL SPLL4_Reset(SPLL4 *pSPLL) Resets the demodulator to start a new demodulation. Use the same names for internal variables as for the function parameters, if possible. The function return an error message. If successful, return TRUE, and if failed, return FALSE. Always declare local variables at the beginning of the function header (C89/C90 standard). Optimize for speed and check your solution for errors. Correct any errors and optimize further. Deliver a flawless production version in strict ANSI C (C89/C90 standard) that can be used in real-time systems.
You can find the implementation in the attached zip-file.
Cheers
PS: I had to stand up very early to use Claude Code.

.
Comment