Audio synchronization stroboscopic system and phase synchronization method
By using an audio-synchronized strobe system and phase synchronization method, the problem of low frequency analysis accuracy in existing technologies is solved, and precise phase synchronization between PWM waves and audio signals is achieved. This is applicable to scenarios such as audio visualization, acoustic testing, and stage lighting control.
Patent Information
- Application Number
- CN202511632362.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-10
- Publication Date
- 2025-12-16
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies in audio synchronous stroboscopic systems have failed to effectively address the issue of low frequency analysis accuracy, which leads to large fundamental frequency identification errors. Furthermore, existing technologies have failed to effectively address the problem of spectral leakage and DC component interference causing large frequency identification errors.
Data acquisition is triggered by a timer, data is stored using DMA transfer, and windowing, DC component removal, complex array construction, FFT operation, maximum value search, noise calibration and accuracy improvement are performed. The fundamental frequency calculation is optimized by combining parabolic interpolation algorithm, and the phase synchronization of PWM wave and audio signal is achieved by using linear extrapolation or weighted period prediction.
It achieves precise phase synchronization between the PWM wave and the audio signal, suppresses spectrum leakage, eliminates DC component interference, and improves the accuracy of fundamental frequency identification. It is suitable for scenarios such as audio visualization, acoustic testing, and stage lighting control.
Smart Images

Figure CN121148418A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of audio processing technology, and in particular to an audio synchronous strobe system and a phase synchronization method. Background Technology
[0002] In fields such as audio visualization, acoustic testing, and stage lighting control, it is often necessary to achieve precise frequency tracking and phase synchronization between the strobe signal (such as a PWM wave) and the input audio signal to achieve signal visualization matching, accurate measurement of acoustic parameters, or coordinated lighting and sound effects. With the increasing demands for synchronization accuracy and real-time performance in application scenarios, audio synchronized strobe technology has received widespread attention and development. Currently, mainstream audio synchronized strobe technology typically uses a microcontroller as its core, acquiring audio signals through an ADC (analog-to-digital converter), and then controlling a PWM (pulse width modulation) module to output the strobe signal after signal processing. However, existing technologies do not employ effective windowing to suppress spectral leakage and do not remove DC component interference in the low-frequency spectrum, resulting in large fundamental frequency identification errors. Summary of the Invention
[0003] Purpose of the invention: The purpose of this invention is to provide an audio synchronous strobe system and a phase synchronization method, which can solve the problem of low frequency analysis accuracy in the prior art.
[0004] Technical Solution: To solve the above-mentioned technical problems, according to one aspect of the present invention, more specifically, an audio synchronous strobe system and a phase synchronization method, specifically including the following steps:
[0005] S1. Data Acquisition: Audio signals are acquired using a timer-triggered method. The 256 sample data points are stored in a preset array using DMA transfer. After acquisition is completed, an acquisition completion marker is sent.
[0006] S2, FFT processing: The 256-point data were processed sequentially with windowing, DC component removal, complex array construction, FFT operation, maximum value search, noise calibration and accuracy improvement to obtain the fundamental frequency of the audio signal;
[0007] S3. Time-domain and frequency-domain analysis: Detect extreme points of audio waveforms, combine with fundamental frequency to filter and store effective peak data;
[0008] S4. Phase Prediction and Synchronization: Predict the position of the next peak based on the effective peak data, and update the PWM timer according to the predicted position so that the PWM wave has the same frequency and phase synchronization with the audio signal.
[0009] S5. Loop Processing: Reset the acquisition completion flag, repeat data acquisition, FFT processing, time-domain and frequency-domain analysis, phase prediction and synchronization. Each loop uses the latest 256-point sampled data to achieve real-time adaptive synchronization of the PWM wave with the audio signal.
[0010] Furthermore, step S2 specifically includes the following steps:
[0011] S21. Windowing Processing: The collected data is processed using a Blackman window. The coefficients of the Blackman window are set to... =0.42、 =0.5、 The formula for the window function is:
[0012]
[0013] Where N is the number of sampling points, 256, and n∈[0,N-1]
[0014] S22. DC component removal: Calculate the DC component using the mean method. Each data point Subtract the average The data after removing the DC component was obtained.
[0015]
[0016] Where n∈[0,N-1];
[0017] S23. Complex array construction: Construct a complex array fft_inputbuf[], where even-indexed positions store the real part of the data after the second step of processing, and odd-indexed positions are set to 0 as the imaginary part;
[0018] S24, FFT operation: Call the STM32FFT library function to process fft_inputbuf[], calculate the amplitude spectrum of the data, and store the amplitude spectrum into the fft_outputbuf[] array;
[0019] S25. Maximum value search: Use the maximum value search algorithm to traverse the fft_outputbuf[] array and find the maximum value in the array and its corresponding index maxIndex;
[0020] S26. Noise calibration: Determine whether to perform noise calibration based on the preset noise calibration flag. If calibration is required, calculate the average amplitude value corresponding to each frequency in the current environment and use it as the noise threshold. Subtract this threshold from the spectrum amplitude value in the fft_outputbuf[] array to remove noise.
[0021] S27. Accuracy Improvement: The vertex index offset value x is calculated using a parabolic interpolation algorithm. The interpolation formula is as follows:
[0022]
[0023] in This represents the amplitude value at the position preceding maxIndex. The amplitude value at the maxIndex position. The amplitude value is the value at the position after maxIndex; the fundamental frequency is calculated by combining maxIndex, x, ADC sampling rate, and FFT points, using the following formula:
[0024]
[0025] Where ADCfreq is the ADC sampling rate (set by the timer frequency), and fftlength is the number of FFT points, 256.
[0026] Furthermore, step S3 specifically includes the following steps:
[0027] S31, Extreme Point Detection: Real-time detection of the raw data acquired by the ADC to determine the extreme points of the waveform;
[0028] S32. Extreme Point Accuracy Optimization: A parabolic interpolation algorithm is used to process the detected extreme points. The interpolation formula is as follows:
[0029]
[0030] To obtain the precise location of the extreme point;
[0031] S33. Effective peak screening: Based on the fundamental frequency, calculate the minimum interval between peaks and eliminate false peaks caused by harmonics.
[0032] S34. Peak storage: Store the filtered valid peak positions into a preset peak array.
[0033] Furthermore, step S4 specifically includes the following steps:
[0034] S41. Peak data judgment: Detect the number of peak points in the stored peak array. If the number of peak points is less than 2, stop phase prediction and the program will pause execution.
[0035] S42, Phase Prediction:
[0036] If there are 2 peak points in the peak array , The period T is calculated using the linear extrapolation method, and the calculation formula is as follows:
[0037]
[0038] Based on the period T and the user-defined phase value, the location of the next peak is predicted using the following formula:
[0039] If there are three or more peaks in the peak array, the weighted period prediction method is used. First, the weighting formula is applied.
[0040]
[0041] Calculate the weight of each wave crest interval, where i∈[1, count-1], and count is the total number of wave crests. The attenuation coefficient;
[0042] Then according to the weighted period formula
[0043]
[0044] Calculate the weighted period T, and based on the weighted period T and the user-defined phase value (phase), predict the location of the next peak. The prediction formula is as follows:
[0045] ;
[0046] S43. Synchronization Control: Real-time monitoring of the ADC timer count value; when the count value reaches the predicted next peak position... When the PWM timer is updated, the frequency of the PWM wave output by the PWM timer is made to match the fundamental frequency of the audio signal, and the phase of the PWM wave is synchronized with the phase of the audio waveform.
[0047] Furthermore, in step S5, during the cyclic processing, after each reset of the acquisition completion flag, the ADC data acquisition module immediately restarts the acquisition of 256 audio data points, ensuring that each cycle performs FFT processing, time-domain and frequency-domain analysis, and phase prediction based on the latest audio signal data, thereby realizing real-time tracking of the frequency and phase of the audio signal by the PWM wave.
[0048] Furthermore, in step S2, the STM32FFT library function called is a dedicated FFT algorithm library that comes with the STM32 microcontroller. It supports FFT operations on 256-point complex data, and the operation results are directly output to the fft_outputbuf[] array, without the need to write an additional FFT core algorithm.
[0049] Furthermore, in step S4, the phase value set by the user is in the range of 0°-360°, which can be adjusted according to the flicker requirements of the actual application scenario. The phase value is configured through the input interface of the STM32 microcontroller or preset parameters.
[0050] According to another aspect of the present invention, an audio synchronous strobe system is provided for a phase synchronization method of the audio synchronous strobe system described above, characterized in that it includes: an ADC data acquisition module, an FFT processing module, a time-domain and frequency-domain analysis module, and a phase prediction and synchronization module;
[0051] ADC data acquisition module: used to acquire audio signals in a timer-triggered manner, store 256 sampled data into a preset array using DMA transfer, and send an acquisition completion flag after acquisition is completed;
[0052] The FFT processing module is used to sequentially perform windowing processing, DC component removal, complex array construction, FFT operation, maximum value search, noise calibration and accuracy improvement on the 256 points of data collected to obtain the fundamental frequency of the audio signal.
[0053] Time-domain and frequency-domain analysis module: used to detect extreme points of audio waveforms, filter effective peak data and store them in combination with the fundamental frequency;
[0054] Phase prediction and synchronization module: It is used to predict the position of the next peak based on the effective peak data, and update the PWM timer according to the predicted position so that the PWM wave has the same frequency and phase synchronization with the audio signal.
[0055] Beneficial effects: Spectral leakage is suppressed through Blackman windowing, avoiding frequency aliasing; DC components are removed using the mean method, eliminating low-frequency amplitude interference; parabolic interpolation algorithm is combined to correct peak index offset, further optimizing fundamental frequency calculation accuracy and solving the core problem of large fundamental frequency identification errors in existing technologies. The prediction method is dynamically selected based on the amount of peak data: linear extrapolation is used for two peaks (considering real-time performance), while exponential decay weighted period prediction is used for three or more peaks (emphasizing recent data weight and improving prediction accuracy); custom phase values from 0° to 360° are supported, adapting to the flicker phase requirements of different scenarios and achieving precise phase synchronization between PWM waves and audio signals.
[0056] DMA-based data transfer reduces CPU usage and ensures efficient storage of 256 data points. Calling STM32's dedicated FFT library functions simplifies the computation process and reduces computational burden. Noise calibration (threshold method to remove environmental noise) and effective peak filtering (eliminating harmonic false peaks) enhance system stability in complex environments, enabling real-time tracking and synchronization of dynamic audio signals. Modular design (ADC data acquisition, FFT processing, time-domain and frequency-domain analysis, phase prediction and synchronization) ensures clear functionality and efficient collaboration among components, facilitating hardware portability and software upgrades. The loop processing mechanism uses the latest sampled data to achieve adaptive synchronization of the PWM wave with the audio signal, making it suitable for various scenarios such as audio visualization, acoustic testing, and stage lighting control. Attached Figure Description
[0057] Figure 1 This is a flowchart illustrating the method. Detailed Implementation
[0058] To make the technical solution of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0059] Example 1
[0060] Applications for audio visualization devices
[0061] In stage lighting control, it is necessary to achieve real-time synchronization between LED strobe lights and background music. Requirements:
[0062] Frequency tracking range 20Hz-20kHz (covering the audible audio frequency band);
[0063] Phase synchronization error ≤5°, ensuring precise matching of light flashing rhythm with music beat;
[0064] It has strong resistance to environmental noise (the stage environment may be disturbed by audience cheers, equipment noise, etc.);
[0065] Response latency ≤10ms to avoid significant time differences between light and music.
[0066] II. System Hardware Configuration
[0067] Module Hardware selection and parameter setting Core controller STM32F407ZGT6 microcontroller is selected, with a main frequency of 168 MHz, high-speed ADC, DMA and multi-timer resources, meeting real-time processing requirements ADC data acquisition module Configure ADC1 channel 0, timer 2 triggers sampling (trigger frequency 10 kHz, ADC sampling rate = 10 kHz); DMA1 channel 0 transmits data, and the cache array is adc_buf
[256] (storing 256-point sampling data) FFT processing module Based on STM32CubeMX, configure ARM CMSIS-DSP library, enable 256-point complex FFT operation, and the amplitude spectrum storage array is fft_outputbuf
[256] Phase prediction and synchronization module Timer 3 outputs PWM wave (frequency range 20 Hz-20 kHz, duty cycle 50%, matching LED stroboscopic lamp driving requirements); timer 2 count value as wave peak position judgment reference Peripheral interface Audio input interface: through electret microphone + signal amplification circuit (gain 20 dB) to connect ADC1 channel 0; LED driving interface: PWM output end drives 10W LED stroboscopic lamp through MOS tube
[0068] III. Software Flow and Parameter Configuration
[0069] 1. Initial configuration (based on STM32CubeIDE development environment)
[0070] ADC configuration: Sampling mode is timer triggered (timer 2 update event triggered), sampling resolution is 12 bits, scan mode is off, continuous sampling is off;
[0071] DMA configuration: DMA1 channel 0, data transfer direction is "ADC1 → memory", memory address increments, data width is 16 bits, number of transfers is 256, and an interrupt is triggered after the transfer is completed;
[0072] FFT parameter configuration: Blackman window coefficients =0.42、 =0.5、 =0.08; FFT points = 256, complex array fft_inputbuf
[512] (even indices store the real part, odd indices store the imaginary part);
[0073] Phase and weight configuration: The user sets the phase value phase=0° (the light and music peaks are synchronized); the weighted period prediction attenuation coefficient α=0.8 (the recent peak data has higher weight);
[0074] Noise calibration configuration: After the system is powered on, a 3-second noise calibration is performed first, and the ambient noise data is collected to calculate the average amplitude value of each frequency and stored as a noise threshold array noise_threshold
[256] .
[0075] 2. Core Process Execution Steps
[0076] (1) Data acquisition (step S1)
[0077] Timer 2 generates an update event every 100μs (1 / 10kHz), triggering ADC1 to acquire one audio data point;
[0078] DMA1 automatically writes the acquired data. When the acquisition of 256 data points is completed, DMA triggers an interrupt, sets the acquisition completion flag, and disables ADC sampling (to avoid data overwriting).
[0079] (2) FFT processing (step S2)
[0080] S21 Windowing Processing: Perform Blackman window operations on the acquired data, using the following formula:
[0081] (n∈[0,255]);
[0082] S22 DC component removal: Calculation average Assuming the calculation yields (12-bit ADC midpoint value), then Eliminate microphone DC bias;
[0083] S23 Complex array construction: fft_inputbuf[2k] = (real part, k∈[0, 255]), fft_inputbuf[2k+1]=0 (imaginary part), which satisfies the data format requirements of the FFT algorithm;
[0084] S24FFT operation: Calls CMSIS-DSP library functions to calculate the amplitude spectrum after the operation;
[0085] S25 maximum value search: Traverse fft_outputbuf to find the maximum value maxmag=1024 and the corresponding index maxIndex=50 (corresponding frequency: 50×10kHz / 256≈1953Hz, i.e. the current music fundamental frequency);
[0086] S26 Noise calibration: Subtract the noise amplitude of the 1953Hz frequency band measured during the calibration phase from fft_outputbuf[maxIndex] to obtain the denoised amplitude value of 960;
[0087] S27 accuracy improvement: [The sentence is incomplete and lacks context.] , , Substituting into the parabola interpolation formula:
[0088] ;
[0089] Fundamental frequency (The accuracy has been improved to within 1Hz after correction).
[0090] (3) Time-domain and frequency-domain analysis (step S3)
[0091] S31 Extreme Point Detection: Traverse the original data and, by comparing the values of three adjacent points, initially detect eight peak points, which are stored in a temporary array;
[0092] S32 Extreme Point Accuracy Optimization: For each temporary peak point, take one data point before and after it and substitute it into the parabolic interpolation formula. For example, for a peak point i=100... , , The calculation yields x≈0.2, so the precise peak position is 100.2 (unit: sampling point number, corresponding time 100.2×100μs=10.02ms).
[0093] S33 Effective Peak Selection: Calculate the minimum peak interval based on the fundamental frequency of 1947Hz. (Sampling point number interval), remove harmonic false peaks with an interval less than 5.136, and finally retain 5 valid peaks, which are stored in valid_peak[5]=[20.1, 25.3, 30.2, 35.4, 40.3] (sampling point number);
[0094] S34 Peak Storage: Writes the valid_peak array to a specified sector (address 0x080E0000) of the STM32's internal FLASH to prevent the loss of critical data in the event of a power outage.
[0095] (4) Phase prediction and synchronization (step S4)
[0096] S41 peak data judgment: valid_peak array length = 5 ≥ 2, which satisfies the phase prediction condition;
[0097] S42 phase prediction: Using the weighted periodic prediction method, count=5, i∈[1,4], calculate the interval and weight of each peak:
[0098] Crest interval: , =4.9、 =5.2、 =4.9;
[0099] Weight: , , , ;
[0100] Weighted period: (Sampling point sequence number interval);
[0101] Next peak predicted location: (Sampling point number, corresponding time 45.333×100μs=4.533ms);
[0102] S43 Synchronous Control: Real-time monitoring of the count value of Timer 2 (incrementing by 1 every 100μs). When the count value reaches 45.333, a Timer 3 update event is triggered.
[0103] Timer 3 automatically adjusts the ARR register value (ARR=10000 / 1947≈5, to match the 1947Hz frequency).
[0104] Adjust the CCR1 register value (duty cycle 50%, CCR1=ARR / 2=2) to make the LED strobe light output a 1947Hz PWM wave, synchronized with the music base frequency.
[0105] (5) Loop processing (step S5)
[0106] Re-enable ADC sampling and DMA transfer to acquire the next set of 256 data points;
[0107] Repeat steps S2-S4, completing one cycle every 25.6ms (256×100μs) to achieve continuous synchronization between LED lights and background music.
[0108] IV. Performance Test Results
[0109] Frequency tracking accuracy: At a base frequency of 1947Hz, the measured PWM wave frequency is 1946.8Hz, with an error of 0.2Hz, which meets the ±1Hz requirement;
[0110] Phase synchronization error: The phase difference between the audio waveform and the PWM waveform observed with an oscilloscope is 3.2°, which is less than the required threshold of 5°.
[0111] Response latency: The delay from audio signal input to LED flashing is 8.5ms, less than 10ms;
[0112] Anti-interference capability: Under 80dB ambient noise, the effective peak recognition rate is 98%, and no synchronization failure occurs.
[0113] Example 2
[0114] Applications of acoustic testing equipment
[0115] I. Application Scenario Requirements
[0116] In acoustic testing on a loudspeaker production line, the vibration state of the loudspeaker diaphragm needs to be observed using a stroboscope. Requirements:
[0117] Frequency tracking accuracy ≤ 0.1Hz (accurate measurement of diaphragm resonant frequency is required).
[0118] The phase is adjustable from 0° to 360° (allowing observation of the diaphragm's vibration displacement at different phases).
[0119] High data sampling resolution (16-bit ADC) prevents small-amplitude vibration signals from being overwhelmed by noise;
[0120] It supports continuous operation for ≥8 hours and has strong system stability.
[0121] II. System Hardware Configuration
[0122] Module Hardware selection and parameter setting Core controller STM32H743IIT6 microcontroller is selected, with a main frequency of 400 MHz, built-in 16-bit ADC and high-speed DMA, meeting high-precision data processing requirements ADC data acquisition module Configure ADC3 channel 2 (16-bit resolution), timer 4 triggers sampling (trigger frequency 20 kHz, ADC sampling rate = 20 kHz); DMA2 channel 1 transmits data, and the cache array is adc_buf
[256] FFT processing module Enable the built-in hardware FFT accelerator of STM32H7 (supporting 256-point complex FFT, operation time ≤1μs), and the amplitude spectrum storage array is fft_outputbuf
[256] Phase prediction and synchronization module Timer 7 outputs PWM wave (frequency range 10 Hz-10 kHz, duty cycle 30%, adaptive stroboscope light source driving); timer 4 count value as wave peak position reference Peripheral interface Audio input interface: through capacitor microphone + differential amplification circuit (gain 40 dB, common mode rejection ratio 80 dB) to connect ADC3 channel 2; stroboscope interface: PWM output end connects industrial stroboscope through differential driving circuit Data storage module External SD card (capacity 16GB) is connected, which stores the collected audio data and FFT results for subsequent data analysis
[0123] III. Software Flow and Parameter Configuration
[0124] 1. Initialization Configuration (Developed based on STM32CubeIDE + HAL library)
[0125] ADC configuration: 16-bit resolution, 8x oversampling rate (increasing effective resolution to 19 bits), Timer 4 update event triggered, continuous sampling disabled;
[0126] DMA configuration: DMA2 channel 1, data transfer direction "ADC3 → memory", memory address auto-increment, data width 32 bits (adapting to 16-bit ADC data extension), number of transfers 256, interrupt enabled upon transfer completion;
[0127] FFT parameter configuration: Blackman window coefficients =0.42、 =0.5、 =0.08; The hardware FFT accelerator is configured for 256-point complex number operations, and the result format is a 32-bit floating-point number;
[0128] Phase and weight configuration: Users can set the phase value phase=90° via the touch screen (to observe the displacement of the diaphragm at the trough); the weighted period prediction attenuation coefficient α=0.9 (to enhance the weight of recent data and improve the accuracy of resonant frequency tracking);
[0129] Noise calibration configuration: After the system starts, a 10-second noise calibration is performed, which collects environmental data when there is no speaker vibration, calculates the noise threshold for each frequency, and stores it in the noise_calib.bin file on the SD card.
[0130] 2. Core Process Execution Steps
[0131] (1) Data acquisition (step S1)
[0132] Timer 4 generates an update event every 50μs (1 / 20kHz), triggering ADC3 to acquire one audio data point (the sound signal generated by the diaphragm vibration).
[0133] DMA2 stores the collected 16-bit data. After 256 points are collected, DMA triggers an interrupt and starts data storage on the SD card.
[0134] (2) FFT processing (step S2)
[0135] S21 Windowing Processing: Blackman window calculation is performed on the acquired data, formula...
[0136] , ;
[0137] S22 DC component removal: Calculation average value (16-bit ADC midpoint value), then Eliminate microphone DC bias;
[0138] S23 Complex array construction: fft_inputbuf[2k] = (Real part), fft_inputbuf[2k+1]=0 (Imaginary part), a total of 512 elements;
[0139] S24FFT operation: Configure the hardware FFT accelerator, input fft_inputbuf, start the operation and read the result, calculate the amplitude spectrum through the arm_cmplx_mag_f32 function and store it in fft_outputbuf;
[0140] S25 maximum value search: Traverse fft_outputbuf to find the maximum value max_mag=12800 and the corresponding index maxIndex=80 (initial frequency: 80×20000 / 256=6250Hz).
[0141] S26 Noise Calibration: Read from SD Card 6250Hz frequency band threshold After denoising, the amplitude value is 12800 - 128 = 12672;
[0142] S27 accuracy improvement: [The sentence is incomplete and lacks context.] , , Substitute into the interpolation formula:
[0143] ;
[0144] Fundamental frequency (Accuracy up to 0.01Hz).
[0145] (3) Time-domain and frequency-domain analysis (step S3)
[0146] S31 Extreme Point Detection: Traversing the original data, 12 temporary peaks were detected using the "adjacent 3-point comparison method";
[0147] S32 extreme point precision optimization: Perform parabolic interpolation for each temporary peak, for example, peak point i=80. , , The calculated value is x=0.3, and the precise peak position is 80.3 (sampling point number, corresponding to time 80.3×50μs=4.015ms).
[0148] S33 Effective Peak Selection: Based on the fundamental frequency of 6242.1875Hz, calculate the minimum peak interval. (Sampling point sequence interval), remove harmonic false peaks with an interval less than 3.204, and retain 7 valid peaks [15.2, 18.5, 21.7, 24.9, 28.1, 31.3, 34.5];
[0149] S34 Peak Storage: Valid peaks are associated with the base frequency 6242.1875Hz and stored in the peak_data.txt file on the SD card, in the format "timestamp, base frequency, peak 1, peak 2, ...".
[0150] (4) Phase prediction and synchronization (step S4)
[0151] S41 peak data judgment: if array length = 7 ≥ 2, perform phase prediction;
[0152] S42 phase prediction: Using the weighted periodic prediction method, count=7, i∈[1,6], calculate:
[0153] Crest intervals: 5.3, 3.2, 3.2, 3.2, 3.2, 3.2;
[0154] Weight: , , , , , ;
[0155] Weighted period: (Sampling point sequence number interval);
[0156] Next peak predicted location: (Sampling point number, corresponding time 38.5025 × 50 μs = 1.925125 ms);
[0157] S43 Synchronization Control: When the timer 4 count value reaches 38.5025, timer 7 is triggered to update.
[0158] Adjust the ARR register value (ARR=20000 / 6242.1875≈3) to make the PWM wave frequency = 6242.1875Hz;
[0159] Adjust the CCR1 register value (CCR1=ARR×30%≈1, to match the 30% duty cycle requirement of the stroboscope) to achieve phase synchronization (90° phase difference) between the stroboscope and the speaker diaphragm vibration.
[0160] (5) Loop processing (step S5)
[0161] Restart the ADC and DMA to acquire the next set of 256 data points;
[0162] One cycle is completed every 12.8 ms (256 × 50 μs), and it works continuously for 8 hours, executing a total of [number missing] cycles. The loop ensures no data loss or synchronization failure.
[0163] IV. Performance Test Results
[0164] Frequency tracking accuracy: The measured PWM wave frequency is 6242.18Hz, with an error of 0.0075Hz compared to the calculated value of 6242.1875Hz, which meets the requirement of ≤0.1Hz;
[0165] Phase adjustment accuracy: The phase value can be adjusted from 0° to 360°, and the measured phase difference error is ≤2°, which meets the observation requirements;
[0166] Signal resolution: With 19-bit effective resolution, it can identify small-amplitude audio signals of 5mV generated by diaphragm vibration;
[0167] Stability: After 8 hours of continuous operation, the system showed no crashes or synchronization drift, and data storage integrity reached 100%.
[0168] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A phase synchronization method for an audio synchronous stroboscopic system, characterized in that, Specifically, the following steps are included: S1. Data Acquisition: Audio signals are acquired using a timer-triggered method. The 256 sample data points are stored in a preset array using DMA transfer. After acquisition is completed, an acquisition completion marker is sent. S2, FFT processing: The 256-point data were processed sequentially with windowing, DC component removal, complex array construction, FFT operation, maximum value search, noise calibration and accuracy improvement to obtain the fundamental frequency of the audio signal; S3. Time-domain and frequency-domain analysis: Detect extreme points of audio waveforms, combine with fundamental frequency to filter and store effective peak data; S4. Phase Prediction and Synchronization: Predict the position of the next peak based on the effective peak data, and update the PWM timer according to the predicted position so that the PWM wave has the same frequency and phase synchronization with the audio signal. S5. Loop Processing: Reset the acquisition completion flag, repeat data acquisition, FFT processing, time-domain and frequency-domain analysis, phase prediction and synchronization. Each loop uses the latest 256-point sampled data to achieve real-time adaptive synchronization of the PWM wave with the audio signal.
2. The phase synchronization method for an audio synchronous strobe system according to claim 1, characterized in that: Step S2 specifically includes the following steps: S21. Windowing Processing: The collected data is processed using a Blackman window. The coefficients of the Blackman window are set to... =0.42、 =0.5、 The formula for the window function is: . Where N is the number of sampling points, 256, and n∈[0,N-1] S22. DC component removal: Calculate the DC component using the mean method. Each data point Subtract the average The data after removing the DC component was obtained. . . Where n∈[0,N-1]; S23. Complex array construction: Construct a complex array fft_inputbuf[], where even-indexed positions store the real part of the processed data and odd-indexed positions are set to 0 as the imaginary part; S24, FFT operation: Call the STM32FFT library function to process fft_inputbuf[], calculate the amplitude spectrum of the data, and store the amplitude spectrum into the fft_outputbuf[] array; S25. Maximum value search: Use the maximum value search algorithm to traverse the fft_outputbuf[] array and find the maximum value in the array and its corresponding index maxIndex; S26. Noise calibration: Determine whether to perform noise calibration based on the preset noise calibration flag. If calibration is required, calculate the average amplitude value corresponding to each frequency in the current environment and use it as the noise threshold. Subtract this threshold from the spectrum amplitude value in the fft_outputbuf[] array to remove noise. S27. Accuracy Improvement: The vertex index offset value x is calculated using a parabolic interpolation algorithm. The interpolation formula is as follows: . in This represents the amplitude value at the position preceding maxIndex. The amplitude value at the maxIndex position. The amplitude value is the value at the position after maxIndex; the fundamental frequency is calculated by combining maxIndex, x, ADC sampling rate, and FFT points, using the following formula: . Where ADCfreq is the ADC sampling rate (set by the timer frequency), and fftlength is the number of FFT points, 256.
3. The phase synchronization method for an audio synchronous strobe system according to claim 1, characterized in that: Step S3 specifically includes the following steps: S31, Extreme Point Detection: Real-time detection of the raw data acquired by the ADC to determine the extreme points of the waveform; S32. Extreme Point Accuracy Optimization: A parabolic interpolation algorithm is used to process the detected extreme points. The interpolation formula is as follows: . To obtain the precise location of the extreme point; S33. Effective peak screening: Based on the fundamental frequency, calculate the minimum interval between peaks and eliminate false peaks caused by harmonics. S34. Peak storage: Store the filtered valid peak positions into a preset peak array.
4. The phase synchronization method for an audio synchronous strobe system according to claim 1, characterized in that: Step S4 specifically includes the following steps: S41. Peak data judgment: Detect the number of peak points in the stored peak array. If the number of peak points is less than 2, stop phase prediction and the program will pause execution. S42, Phase Prediction: If there are 2 peak points in the peak array , The period T is calculated using the linear extrapolation method, and the calculation formula is as follows: . Based on the period T and the user-defined phase value, the location of the next peak is predicted using the following formula: . If there are three or more peaks in the peak array, the weighted period prediction method is used. First, the weighting formula is applied. . Calculate the weight of each wave crest interval, where i∈[1, count-1], and count is the total number of wave crests. The attenuation coefficient; Then according to the weighted period formula . Calculate the weighted period T, and based on the weighted period T and the user-defined phase value (phase), predict the location of the next peak. The prediction formula is as follows: ; S43. Synchronization Control: Real-time monitoring of the ADC timer count value; when the count value reaches the predicted next peak position... When the PWM timer is updated, the frequency of the PWM wave output by the PWM timer is made to match the fundamental frequency of the audio signal, and the phase of the PWM wave is synchronized with the phase of the audio waveform.
5. The phase synchronization method for an audio synchronous strobe system according to claim 1, characterized in that: In step S5, during the cyclic processing, after each reset of the acquisition completion flag, the ADC data acquisition module immediately restarts the acquisition of 256 audio data points, ensuring that each cycle performs FFT processing, time-domain and frequency-domain analysis, and phase prediction based on the latest audio signal data, thereby realizing real-time tracking of the frequency and phase of the audio signal by the PWM wave.
6. The phase synchronization method for an audio synchronous stroboscopic system according to claim 2, characterized in that: In step S2, the STM32FFT library function called is a dedicated FFT algorithm library that comes with the STM32 microcontroller. It supports FFT operations on 256-point complex data and the operation results are directly output to the fft_outputbuf[] array, without the need to write an additional FFT core algorithm.
7. The phase synchronization method for an audio synchronous strobe system according to claim 4, characterized in that: In step S4, the phase value set by the user is in the range of 0°-360°, which can be adjusted according to the flicker requirements of the actual application scenario. The phase value is configured through the input interface of the STM32 microcontroller or preset parameters.
8. An audio synchronous stroboscopic system for implementing the phase synchronization method of the audio synchronous stroboscopic system according to any one of claims 1-7, characterized in that, include: ADC data acquisition module, FFT processing module, time-domain and frequency-domain analysis module, phase prediction and synchronization module; ADC data acquisition module: used to acquire audio signals in a timer-triggered manner, store 256 sampled data into a preset array using DMA transfer, and send an acquisition completion flag after acquisition is completed; The FFT processing module is used to sequentially perform windowing processing, DC component removal, complex array construction, FFT operation, maximum value search, noise calibration and accuracy improvement on the 256 points of data collected to obtain the fundamental frequency of the audio signal. Time-domain and frequency-domain analysis module: used to detect extreme points of audio waveforms, filter effective peak data and store them in combination with the fundamental frequency; Phase prediction and synchronization module: It is used to predict the position of the next peak based on the effective peak data, and update the PWM timer according to the predicted position so that the PWM wave has the same frequency and phase synchronization with the audio signal.