Bioelectric signal generation method and device based on PWM and storage medium

By combining the PWM generation module and the RC filter, the frequency and duty cycle of the PWM signal are adjusted to generate a bioelectric signal that meets the application requirements, solving the problem of inflexible adjustment in existing technologies and expanding the application prospects of bioelectric stimulation equipment.

CN120613072APending Publication Date: 2025-09-09SHENZHEN OMA IND
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510464338.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-09-09

AI Technical Summary

Technical Problem

Existing bioelectric signal generation methods cannot flexibly adjust the frequency and duty cycle of the PWM signal, and cannot generate signals that match application requirements, which limits the application prospects of bioelectric stimulation devices.

Method used

The PWM generation module outputs a PWM signal with adjustable frequency, and combined with an RC filter, the frequency and duty cycle are adjusted to generate a smooth bioelectric signal.

Benefits of technology

It realizes the generation of bioelectric signals that meet application requirements according to user needs, and expands the application scope of bioelectric stimulation equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120613072A_ABST
    Figure CN120613072A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of signal processing, and provides a PWM (Pulse Width Modulation)-based bio-electricity signal generation method, which comprises the following steps of: outputting a first PWM signal with an adjustable frequency through a PWM generation module; in response to the frequency and amplitude selected by the user, adjusting the frequency and duty ratio of the first PWM signal to obtain a second PWM signal; and inputting the second PWM signal to an RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectricity signal. And by flexibly adjusting the frequency and the duty ratio of the PWM signal and performing accurate RC filtering processing, a bio-electricity signal meeting application requirements can be generated, and the method has a wide application prospect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of signal processing technology, and in particular to a PWM-based bioelectric signal generation method, device, and storage medium. Background Art

[0002] With the development of modern medical technology, bioelectric signals are increasingly being used in rehabilitation therapy, muscle therapy, pain relief, and other fields. Traditional methods for generating bioelectric signals rely on fixed-frequency pulse width modulation (PWM) signal output. However, in many applications, especially in bioelectric stimulation devices, the frequency and duty cycle of the PWM signal need to be dynamically adjusted according to user needs to generate a bioelectric signal that matches the application requirements. Therefore, existing methods for generating bioelectric signals cannot meet application requirements, limiting their application prospects. Summary of the Invention

[0003] The embodiments of the present application provide a PWM-based bioelectric signal generation method, device, equipment and storage medium. By flexibly adjusting the frequency and duty cycle of the PWM signal and precise RC filtering processing, it can generate bioelectric signals that meet application requirements and has broad application prospects.

[0004] In a first aspect, an embodiment of the present application provides a PWM-based bioelectric signal generation method, comprising:

[0005] Outputting a first PWM signal with adjustable frequency through a PWM generation module;

[0006] In response to the frequency and amplitude selected by the user, adjusting the frequency and duty cycle of the first PWM signal to obtain a second PWM signal;

[0007] The second PWM signal is input to an RC circuit, and the second PWM signal is processed in the RC circuit to convert the second PWM signal into a smooth bioelectric signal.

[0008] In one embodiment, the PWM generation module includes: a PWM counter, a PWM comparison register, and a PWM output pin;

[0009] The step of outputting a first PWM signal with adjustable frequency through a PWM generation module includes:

[0010] Setting a clock source of the PWM counter, and configuring a frequency division ratio of the clock source and a first counting period of the PWM counter to obtain a frequency of a first PWM signal;

[0011] Dynamically adjusting the value of the PWM comparison register to set the duty cycle of the first PWM signal;

[0012] The PWM counter is started, and the PWM output pin is enabled to output the first PWM signal.

[0013] In one embodiment, the PWM generation module further includes a phase-locked loop;

[0014] The step of adjusting the frequency and duty cycle of the first PWM signal in response to the frequency and amplitude selected by the user to obtain a second PWM signal includes:

[0015] Calculating the frequency of the second PWM signal based on the preset output frequency of the phase-locked loop and the frequency division ratio of the clock source;

[0016] Calculating a second counting period of the clock source based on the calculated frequency of the second PWM signal and a frequency selected by a user;

[0017] Calculating a duty cycle of the second PWM signal based on the second calculation period and the amplitude selected by the user;

[0018] The second PWM signal is obtained according to the frequency of the second PWM signal and the duty cycle of the second PWM signal.

[0019] In one embodiment, the RC circuit includes a first-order RC low-pass filter and a second-order RC filter.

[0020] In one embodiment, inputting the second PWM signal to an RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectric signal includes:

[0021] Inputting the second PWM signal into the first-order RC low-pass filter, and filtering out higher harmonics of the second PWM signal in the first-order RC low-pass filter;

[0022] The second PWM signal with higher harmonics filtered out is input into the second-order RC filter for smoothing to obtain the bioelectric signal.

[0023] In one embodiment, a value range of the first cutoff frequency of the first-order RC low-pass filter is: greater than or equal to one-tenth of the frequency of the second PWM signal and less than or equal to one-fifth of the frequency of the second PWM signal.

[0024] In one embodiment, a second cutoff frequency of the second-order RC filter is half of the first cutoff frequency.

[0025] In a second aspect, an embodiment of the present application provides a PWM-based bioelectric signal generating device, comprising:

[0026] An output module, configured to output a first PWM signal with adjustable frequency through a PWM generation module;

[0027] an adjustment module, configured to adjust the frequency and duty cycle of the first PWM signal in response to a frequency and amplitude selected by a user to obtain a second PWM signal;

[0028] A processing module is used to input the second PWM signal into an RC circuit, process the second PWM signal in the RC circuit, and convert the second PWM signal into a smooth bioelectric signal.

[0029] In one embodiment, the PWM generation module includes: a PWM counter, a PWM comparison register, and a PWM output pin;

[0030] The output module includes:

[0031] an obtaining unit, configured to set a clock source of the PWM counter, and configure a frequency division ratio of the clock source and a first counting period of the PWM counter to obtain a frequency of a first PWM signal;

[0032] an adjusting unit, configured to dynamically adjust a value of the PWM comparison register to set a duty cycle of the first PWM signal;

[0033] The output unit is used to start the PWM counter and enable the PWM output pin to output the first PWM signal.

[0034] In one embodiment, the PWM generation module further includes a phase-locked loop;

[0035] The adjustment module includes:

[0036] a first calculation unit, configured to calculate a frequency of a second PWM signal based on a preset output frequency of the phase-locked loop and a frequency division ratio of the clock source;

[0037] a second calculating unit, configured to calculate a second counting period of the clock source based on the calculated frequency of the second PWM signal and a frequency selected by a user;

[0038] a third calculation unit, configured to calculate a duty cycle of the second PWM signal based on the second calculation period and an amplitude selected by a user;

[0039] The obtaining unit is configured to obtain the second PWM signal according to the frequency of the second PWM signal and the duty cycle of the second PWM signal.

[0040] In one embodiment, the RC circuit includes a first-order RC low-pass filter and a second-order RC filter.

[0041] In one embodiment, the processing module includes:

[0042] a filtering unit, configured to input the second PWM signal into the first-order RC low-pass filter, and filter out higher harmonics of the second PWM signal in the first-order RC low-pass filter;

[0043] The processing unit is configured to input the second PWM signal from which the high-order harmonics are filtered out into the second-order RC filter for smoothing to obtain the bioelectric signal.

[0044] In one embodiment, a value range of the first cutoff frequency of the first-order RC low-pass filter is: greater than or equal to one-tenth of the frequency of the second PWM signal and less than or equal to one-fifth of the frequency of the second PWM signal.

[0045] In one embodiment, a second cutoff frequency of the second-order RC filter is half of the first cutoff frequency.

[0046] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0047] Memory and processing modules;

[0048] The memory is used to store computer programs;

[0049] The processing module is used to execute the computer program and implement the steps of the PWM-based bioelectric signal generation method of the first aspect when executing the computer program.

[0050] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program;

[0051] When the computer program is executed by one or more processing modules, the one or more processing modules execute the steps of the PWM-based bioelectric signal generation method of the first aspect as described above.

[0052] Embodiments of the present application provide a PWM-based bioelectric signal generation method, apparatus, device, and storage medium. The PWM-based bioelectric signal generation method includes: outputting a first PWM signal with adjustable frequency through a PWM generation module; adjusting the frequency and duty cycle of the first PWM signal in response to a user-selected frequency and amplitude to obtain a second PWM signal; and inputting the second PWM signal into an RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectric signal. By flexibly adjusting the frequency and duty cycle of the PWM signal and performing precise RC filtering, the method can generate a bioelectric signal that meets application requirements, thus having broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0054] Figure 1 A schematic flow chart of a PWM-based bioelectrical signal generation method according to an embodiment of the present application;

[0055] Figure 2 A schematic diagram of the structure of a PWM generation module provided in one embodiment of the present application;

[0056] Figure 3 A schematic diagram of a process for outputting a first PWM signal with adjustable frequency through a PWM generation module according to an embodiment of the present application;

[0057] Figure 4 A schematic structural diagram of a PWM generation module provided in another embodiment of the present application;

[0058] Figure 5 A schematic block diagram of a PWM-based bioelectric signal generating device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.

[0060] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.

[0061] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.

[0062] It should be further understood that the term "and / or" used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0063] The technical solution provided in this application will be described in detail below with reference to the accompanying drawings.

[0064] See also Figure 1 , Figure 1 The flow chart of the PWM-based bioelectric signal generation method provided in the embodiment of the present application is provided. The PWM-based bioelectric signal generation method provided in the embodiment of the present application is implemented by a bioelectric signal stimulation device or other device capable of generating bioelectric signals. The embodiment of the present application does not impose any limitation on the PWM-based bioelectric signal generation device. Specifically, Figure 1 As shown, the PWM-based bioelectric signal generation method includes steps S101 to S103. The details are as follows:

[0065] S101: Outputting a first PWM signal with adjustable frequency through a PWM generation module.

[0066] A common PWM generation module includes a microcontroller or digital signal processor with a timer, which is used to generate a PWM signal with a fixed frequency and duty cycle. In the present application, the PWM generation module is capable of dynamically adjusting the frequency of the output PWM signal. In other words, the PWM signal output by the PWM generation module is a PWM signal with an adjustable frequency. Specifically, the PWM generation module is configured with a PWM counter, which is used to adjust the frequency of the PWM signal. The PWM generation module is also configured with a PWM compare register, which is used to adjust the duty cycle of the PWM signal, thereby generating a first PWM signal with an adjustable frequency.

[0067] For example, Figure 2 As shown, Figure 2 This is a schematic diagram of the structure of the PWM generation module provided in one embodiment of the present application. Figure 2 As can be seen, in this application, the PWM generation module 200 includes a PWM counter 210, a PWM comparison register 220, and a PWM output pin 230. The PWM counter 210 is configured to count based on a set clock source and its division ratio. In this application, by configuring the counting period of the PWM counter 210, the frequency of the PWM signal can be controlled, thereby achieving dynamic adjustment of the PWM signal frequency.

[0068] The PWM comparison register 220 is used to store a reference value for comparison. During the counting process of the PWM counter 210, the current count value is compared with the value in the PWM comparison register 220 to determine the high level duration of the PWM signal and adjust the duty cycle of the PWM signal.

[0069] The PWM output pin 230 is used to output a PWM signal determined by the PWM counter 210 and the PWM comparison register 220. The frequency and duty cycle of the output PWM signal can be dynamically adjusted to suit different application requirements.

[0070] Specifically, PWM counter 210 receives a set clock source and counts based on the set frequency division ratio. Within a counting cycle, the comparison value set in PWM compare register 220 determines the moment when the PWM signal switches from a high level to a low level, thereby forming a PWM signal with a specified frequency and duty cycle. Ultimately, the PWM signal is output via PWM output pin 230.

[0071] The core function of PWM counter 210 is to count clock signals. It first receives a clock source, which can be the microcontroller's main clock, an internal timer clock, or an external clock signal. Because the main clock frequency is typically high, using it directly for PWM control would result in a too-short counting period. Therefore, the clock frequency is typically divided. The division ratio represents the multiple by which the original clock frequency is reduced. For example, if the system clock is 48 MHz and the division ratio is set to 48, the actual counting frequency of the PWM counter becomes 1 MHz.

[0072] The PWM counter counts up according to this "slowed-down" clock frequency, generally starting from 0. After reaching the preset counting period (TOP value), it is cleared to zero and the counting of the next cycle begins again. This counting process forms the "periodicity" of the PWM signal.

[0073] Within a count cycle, the comparison value set in PWM compare register 220 determines the moment when the PWM signal switches from a high level to a low level. Each time the PWM counter begins a new cycle (starting from 0 and incrementing), it continuously compares the current count value with the value in PWM compare register 220. When the current count value is less than the comparison value, the PWM output pin remains high. When the current count value is greater than or equal to the comparison value, the PWM output pin switches to a low level. Therefore, this "comparison value" in the compare register determines how long the high level of the PWM signal lasts, thereby defining the duty cycle of the PWM signal: Duty cycle = comparison value / count cycle × 100%.

[0074] For example, if the count period is set to 1000 and the comparison value is set to 500, the high level will last for 500 count periods, resulting in a 50% duty cycle. If the comparison value is 250, the duty cycle will be 25%. Finally, the PWM signal is output via PWM output pin 230. Once the PWM counter 210 and PWM compare register 220 have completed the frequency and duty cycle settings described above, the PWM generation module 200 will output the PWM signal according to the configured pattern on PWM output pin 230. This output PWM signal is a periodic waveform whose frequency is determined by the PWM counter's count period and the input clock; the duty cycle is determined by the ratio between the comparison value and the count period.

[0075] Therefore, by adjusting the clock configuration and counting period of the PWM counter 210 and setting the comparison value in the PWM comparison register 220, a PWM signal with adjustable frequency and duty cycle can be output, thereby realizing the adjustable frequency PWM signal generation function described in this application.

[0076] For example, Figure 3 As shown, Figure 3 This is a flow chart of outputting a first PWM signal with adjustable frequency through a PWM generation module provided in an embodiment of the present application. Figure 3 It can be seen that the first PWM signal with adjustable frequency is outputted by the PWM generation module, including:

[0077] S310: Setting a clock source of the PWM counter, and configuring a frequency division ratio of the clock source and a first counting period of the PWM counter to obtain a frequency of a first PWM signal.

[0078] The clock frequency can be adjusted by selecting an appropriate clock source and setting the division ratio. The division ratio determines the frequency of the counter clock, which in turn affects the frequency of the PWM signal. When configuring the division ratio, ensure that the selected clock source frequency is appropriate for the desired PWM output frequency. The frequency of the PWM signal can be adjusted by dynamically configuring the first count period of the PWM counter. Specifically, the frequency of the first PWM signal can be expressed as: Among them, f PWM is the frequency of the output PWM signal, f clk is the frequency of the counter clock, N is the division ratio, and ARR is the first counting cycle of the PWM counter.

[0079] S320: Dynamically adjust the value of the PWM comparison register to set the duty cycle of the first PWM signal.

[0080] The PWM compare register can know the high level time of the PWM signal. Changing the value of the PWM compare register directly affects the duty cycle of the PWM signal, thereby changing the characteristics of the output PWM signal. The calculation formula of the duty cycle can be expressed as:

[0081]

[0082] Where D is the duty cycle, CCR is the value of the PWM compare register, and ARR is the first counting cycle of the PWM counter.

[0083] The high-level duration of the PWM signal is defined by setting the CCR value. By adjusting the CCR value, the duty cycle of the PWM signal can be precisely controlled, thereby controlling the power, brightness and other characteristics of the PWM signal.

[0084] S330: Start the PWM counter and enable the PWM output pin to output the first PWM signal.

[0085] The PWM counter generates the PWM signal and outputs it according to the set period and duty cycle. When the PWM output pin is enabled, the PWM signal is output through the pin.

[0086] By setting the appropriate clock source and divider ratio, adjusting the PWM counter's clock frequency, dynamically configuring the PWM counter's count period, and adjusting the PWM compare register value to set the duty cycle, the PWM signal's frequency and duty cycle can be precisely adjusted. Once configured, start the PWM counter and enable the PWM output pin. The PWM output pin will automatically output the desired first PWM signal at the set frequency and duty cycle.

[0087] S102: In response to the frequency and amplitude selected by the user, adjust the frequency and duty cycle of the first PWM signal to obtain a second PWM signal.

[0088] The user can select the frequency and amplitude through the preset interface. In response to the frequency and amplitude input by the user, the frequency and duty cycle of the PWM signal are dynamically adjusted to output a second PWM signal.

[0089] For example, Figure 4 As shown, Figure 4 This is a structural diagram of a PWM generation module provided in another embodiment of the present application. Figure 4 It can be seen that in this application, the PWM generation module 200 further includes a phase-locked loop 240. The phase-locked loop 240 is used to adjust the main clock frequency. The main clock frequency is the frequency of the second PWM signal.

[0090] In one embodiment, in response to a frequency and amplitude selected by a user, the frequency and duty cycle of the first PWM signal are adjusted to obtain a second PWM signal, including: calculating the frequency of the second PWM signal based on a preset output frequency of a phase-locked loop and a frequency division ratio of a clock source; calculating a second counting period of the clock source based on the calculated frequency of the second PWM signal and the frequency selected by the user; calculating the duty cycle of the second PWM signal based on the second counting period and the amplitude selected by the user; and obtaining the second PWM signal based on the frequency of the second PWM signal and the duty cycle of the second PWM signal.

[0091] Wherein, based on the preset output frequency of the phase-locked loop and the frequency division ratio of the clock source, the frequency of the second PWM signal is calculated and expressed as: f timer =f PLL / N; where f timer is the frequency of the second PWM signal, f PLL is the output frequency of the phase-locked loop, and N is the division ratio of the clock source.

[0092] Based on the calculated frequency of the second PWM signal and the frequency selected by the user, the second counting period of the clock source is calculated, which is expressed as: Among them, ARR is the second counting cycle of the clock source, f targel The frequency selected by the user.

[0093] Based on the second calculation period and the amplitude selected by the user, the duty cycle of the second PWM signal is calculated and expressed as: Where D is the duty cycle, A target Amplitude selected by the user.

[0094] S103: Inputting the second PWM signal into the RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectric signal.

[0095] PWM signals are essentially square waves, while bioelectric signals are typically smooth, continuous, low-frequency analog signals. To convert PWM signals into smooth bioelectric signals, an RC low-pass filter can be used for signal processing. In this application, by using a two-stage RC filter and correctly setting the filter frequency of the two-stage RC filter, the output is further smoothed while reducing the PWM high-order harmonics, resulting in a near-pure DC signal.

[0096] Exemplarily, the RC circuit includes a first-order RC low-pass filter and a second-order RC filter. The first-order RC low-pass filter is used to filter out high-order harmonics and perform preliminary smoothing, while the second-order RC filter is used to further smooth the signal to obtain a near-ideal signal.

[0097] The second PWM signal is input into an RC circuit, the second PWM signal is processed in the RC circuit, and the second PWM signal is converted into a smooth bioelectric signal, including: inputting the second PWM signal into a first-order RC low-pass filter, filtering out higher harmonics of the second PWM signal in the first-order RC low-pass filter; and inputting the second PWM signal with the higher harmonics filtered out into a second-order RC filter for smoothing to obtain the bioelectric signal.

[0098] Because the first-order RC low-pass filter's function is to filter out PWM higher harmonics and bring the output signal closer to the PWM signal's average value, a very low cutoff frequency is not recommended. In one embodiment, the first cutoff frequency of the first-order RC low-pass filter is within a range of greater than or equal to one-tenth the frequency of the second PWM signal and less than or equal to one-fifth the frequency of the second PWM signal. Once the cutoff frequency is determined, appropriate standard resistors and capacitors can be selected.

[0099] The second-order RC filter is used to further reduce noise and improve signal smoothness. It typically uses a lower cutoff frequency than the first-order RC low-pass filter. In one embodiment, the second cutoff frequency of the second-order RC filter is half the first cutoff frequency, thereby achieving even greater smoothing of the output signal.

[0100] By using two RC filters, the PWM signal can be effectively converted into a smooth bioelectric signal, which is suitable for application scenarios such as electrical stimulation and rehabilitation equipment.

[0101] The above analysis indicates that the PWM-based bioelectric signal generation method provided in the embodiments of the present application includes: outputting a first PWM signal with adjustable frequency through a PWM generation module; adjusting the frequency and duty cycle of the first PWM signal in response to a user-selected frequency and amplitude to obtain a second PWM signal; and inputting the second PWM signal into an RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectric signal. By flexibly adjusting the frequency and duty cycle of the PWM signal and performing precise RC filtering, a bioelectric signal that meets application requirements can be generated, which has broad application prospects.

[0102] See also Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of the PWM-based bioelectric signal generating device provided in the embodiment of the present application. Figure 4 It can be seen that the PWM-based bioelectric signal generating device 400 provided in the embodiment of the present application includes:

[0103] The output module 410 is configured to output a first PWM signal with adjustable frequency through the PWM generation module;

[0104] an adjustment module 420 for adjusting the frequency and duty cycle of the first PWM signal in response to the frequency and amplitude selected by the user to obtain a second PWM signal;

[0105] The processing module 430 is configured to input the second PWM signal into an RC circuit, process the second PWM signal in the RC circuit, and convert the second PWM signal into a smooth bioelectric signal.

[0106] In one embodiment, the PWM generation module includes: a PWM counter, a PWM comparison register, and a PWM output pin;

[0107] The output module 410 includes:

[0108] an obtaining unit, configured to set a clock source of the PWM counter, and configure a frequency division ratio of the clock source and a first counting period of the PWM counter to obtain a frequency of a first PWM signal;

[0109] an adjusting unit, configured to dynamically adjust a value of the PWM comparison register to set a duty cycle of the first PWM signal;

[0110] The output unit is used to start the PWM counter and enable the PWM output pin to output the first PWM signal.

[0111] In one embodiment, the PWM generation module further includes a phase-locked loop;

[0112] The adjustment module 420 includes:

[0113] a first calculation unit, configured to calculate a frequency of a second PWM signal based on a preset output frequency of the phase-locked loop and a frequency division ratio of the clock source;

[0114] a second calculating unit, configured to calculate a second counting period of the clock source based on the calculated frequency of the second PWM signal and a frequency selected by a user;

[0115] a third calculation unit, configured to calculate a duty cycle of the second PWM signal based on the second calculation period and an amplitude selected by a user;

[0116] The obtaining unit is configured to obtain the second PWM signal according to the frequency of the second PWM signal and the duty cycle of the second PWM signal.

[0117] In one embodiment, the RC circuit includes a first-order RC low-pass filter and a second-order RC filter.

[0118] In one embodiment, the processing module 430 includes:

[0119] a filtering unit, configured to input the second PWM signal into the first-order RC low-pass filter, and filter out higher harmonics of the second PWM signal in the first-order RC low-pass filter;

[0120] The processing unit is configured to input the second PWM signal from which the high-order harmonics are filtered out into the second-order RC filter for smoothing to obtain the bioelectric signal.

[0121] In one embodiment, a value range of the first cutoff frequency of the first-order RC low-pass filter is: greater than or equal to one-tenth of the frequency of the second PWM signal and less than or equal to one-fifth of the frequency of the second PWM signal.

[0122] In one embodiment, a second cutoff frequency of the second-order RC filter is half of the first cutoff frequency.

[0123] It should be noted that the specific implementation process of the above modules or units can refer to the specific implementation process of each step in the previous method embodiment, which will not be repeated here.

[0124] See also Figure 5 As shown, Figure 5 A schematic block diagram of a PWM-based bioelectric signal generating device provided in an embodiment of the present application.

[0125] Exemplarily, the PWM-based bioelectric signal generating device 500 includes a processing module 510 and a memory 520 .

[0126] Exemplarily, the processing module 510 and the memory 520 are connected via a bus 530 , which is, for example, an I 2 C (Inter-integrated Circuit) bus.

[0127] Specifically, the processing module 510 may be a micro-controller unit (MCU), a central processing unit (CPU), or a digital signal processing module (DSP).

[0128] Specifically, the memory 520 may be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk.

[0129] The processing module 510 is used to run the computer program stored in the memory 520 and implement the steps of the above-mentioned PWM-based bioelectric signal generation method when executing the computer program.

[0130] Exemplarily, the processing module 510 is configured to run a computer program stored in the memory 520 and implement the following steps when executing the computer program:

[0131] Outputting a first PWM signal with adjustable frequency through a PWM generation module;

[0132] In response to the frequency and amplitude selected by the user, adjusting the frequency and duty cycle of the first PWM signal to obtain a second PWM signal;

[0133] The second PWM signal is input to an RC circuit, and the second PWM signal is processed in the RC circuit to convert the second PWM signal into a smooth bioelectric signal.

[0134] In one embodiment, the PWM generation module includes: a PWM counter, a PWM comparison register, and a PWM output pin;

[0135] The step of outputting a first PWM signal with adjustable frequency through a PWM generation module includes:

[0136] Setting a clock source of the PWM counter, and configuring a frequency division ratio of the clock source and a first counting period of the PWM counter to obtain a frequency of a first PWM signal;

[0137] Dynamically adjusting the value of the PWM comparison register to set the duty cycle of the first PWM signal;

[0138] The PWM counter is started, and the PWM output pin is enabled to output the first PWM signal.

[0139] In one embodiment, the PWM generation module further includes a phase-locked loop;

[0140] The step of adjusting the frequency and duty cycle of the first PWM signal in response to the frequency and amplitude selected by the user to obtain a second PWM signal includes:

[0141] Calculating the frequency of the second PWM signal based on the preset output frequency of the phase-locked loop and the frequency division ratio of the clock source;

[0142] Calculating a second counting period of the clock source based on the calculated frequency of the second PWM signal and a frequency selected by a user;

[0143] Calculating a duty cycle of the second PWM signal based on the second calculation period and the amplitude selected by the user;

[0144] The second PWM signal is obtained according to the frequency of the second PWM signal and the duty cycle of the second PWM signal.

[0145] In one embodiment, the RC circuit includes a first-order RC low-pass filter and a second-order RC filter.

[0146] In one embodiment, inputting the second PWM signal to an RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectric signal includes:

[0147] Inputting the second PWM signal into the first-order RC low-pass filter, and filtering out higher harmonics of the second PWM signal in the first-order RC low-pass filter;

[0148] The second PWM signal with higher harmonics filtered out is input into the second-order RC filter for smoothing to obtain the bioelectric signal.

[0149] In one embodiment, a value range of the first cutoff frequency of the first-order RC low-pass filter is: greater than or equal to one-tenth of the frequency of the second PWM signal and less than or equal to one-fifth of the frequency of the second PWM signal.

[0150] In one embodiment, a second cutoff frequency of the second-order RC filter is half of the first cutoff frequency.

[0151] The specific principles and implementation methods of the PWM-based bioelectric signal generation device provided in the embodiments of the present application are similar to those of the PWM-based bioelectric signal generation method in the aforementioned embodiments, and will not be repeated here.

[0152] The present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processing module, the processing module implements the following steps:

[0153] Outputting a first PWM signal with adjustable frequency through a PWM generation module;

[0154] In response to the frequency and amplitude selected by the user, adjusting the frequency and duty cycle of the first PWM signal to obtain a second PWM signal;

[0155] The second PWM signal is input to an RC circuit, and the second PWM signal is processed in the RC circuit to convert the second PWM signal into a smooth bioelectric signal.

[0156] In one embodiment, the PWM generation module includes: a PWM counter, a PWM comparison register, and a PWM output pin;

[0157] The step of outputting a first PWM signal with adjustable frequency through a PWM generation module includes:

[0158] Setting a clock source of the PWM counter, and configuring a frequency division ratio of the clock source and a first counting period of the PWM counter to obtain a frequency of a first PWM signal;

[0159] Dynamically adjusting the value of the PWM comparison register to set the duty cycle of the first PWM signal;

[0160] The PWM counter is started, and the PWM output pin is enabled to output the first PWM signal.

[0161] In one embodiment, the PWM generation module further includes a phase-locked loop;

[0162] The step of adjusting the frequency and duty cycle of the first PWM signal in response to the frequency and amplitude selected by the user to obtain a second PWM signal includes:

[0163] Calculating the frequency of the second PWM signal based on the preset output frequency of the phase-locked loop and the frequency division ratio of the clock source;

[0164] Calculating a second counting period of the clock source based on the calculated frequency of the second PWM signal and a frequency selected by a user;

[0165] Calculating a duty cycle of the second PWM signal based on the second calculation period and the amplitude selected by the user;

[0166] The second PWM signal is obtained according to the frequency of the second PWM signal and the duty cycle of the second PWM signal.

[0167] In one embodiment, the RC circuit includes a first-order RC low-pass filter and a second-order RC filter.

[0168] In one embodiment, inputting the second PWM signal to an RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectric signal includes:

[0169] Inputting the second PWM signal into the first-order RC low-pass filter, and filtering out higher harmonics of the second PWM signal in the first-order RC low-pass filter;

[0170] The second PWM signal with higher harmonics filtered out is input into the second-order RC filter for smoothing to obtain the bioelectric signal.

[0171] In one embodiment, a value range of the first cutoff frequency of the first-order RC low-pass filter is: greater than or equal to one-tenth of the frequency of the second PWM signal and less than or equal to one-fifth of the frequency of the second PWM signal.

[0172] In one embodiment, a second cutoff frequency of the second-order RC filter is half of the first cutoff frequency.

[0173] The computer-readable storage medium may be an internal storage unit of the PWM-based bioelectric signal generating device in the aforementioned embodiment, such as a hard disk or memory of the PWM-based bioelectric signal generating device. The computer-readable storage medium may also be an external storage device of the PWM-based bioelectric signal generating device, such as a plug-in hard disk equipped on the PWM-based bioelectric signal generating device, a smart media card (SMC), a secure digital (SD) card, a flash card, etc.

[0174] It should be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application.

[0175] It will also be understood that the term "and / or" as used in this application and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0176] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A method for generating bioelectrical signals based on PWM, characterized in that: The method comprises: Outputting a first PWM signal with adjustable frequency through a PWM generation module; In response to the frequency and amplitude selected by the user, adjusting the frequency and duty cycle of the first PWM signal to obtain a second PWM signal; The second PWM signal is input to an RC circuit, and the second PWM signal is processed in the RC circuit to convert the second PWM signal into a smooth bioelectric signal.

2. The PWM-based bioelectric signal generation method according to claim 1, characterized in that: The PWM generation module includes: a PWM counter, a PWM comparison register and a PWM output pin; The step of outputting a first PWM signal with adjustable frequency through a PWM generation module includes: Setting a clock source of the PWM counter, and configuring a frequency division ratio of the clock source and a first counting period of the PWM counter to obtain a frequency of a first PWM signal; Dynamically adjusting the value of the PWM comparison register to set the duty cycle of the first PWM signal; The PWM counter is started, and the PWM output pin is enabled to output the first PWM signal.

3. The PWM-based bioelectric signal generation method according to claim 2, characterized in that: The PWM generation module further includes a phase-locked loop; The step of adjusting the frequency and duty cycle of the first PWM signal in response to the frequency and amplitude selected by the user to obtain a second PWM signal includes: Calculating the frequency of the second PWM signal based on the preset output frequency of the phase-locked loop and the frequency division ratio of the clock source; Calculating a second counting period of the clock source based on the calculated frequency of the second PWM signal and a frequency selected by a user; Calculating a duty cycle of the second PWM signal based on the second calculation period and the amplitude selected by the user; The second PWM signal is obtained according to the frequency of the second PWM signal and the duty cycle of the second PWM signal.

4. The PWM-based bioelectric signal generation method according to claim 1, characterized in that: The RC circuit includes a first-order RC low-pass filter and a second-order RC filter.

5. The PWM-based bioelectric signal generation method according to claim 4, characterized in that: Inputting the second PWM signal to an RC circuit, processing the second PWM signal in the RC circuit, and converting the second PWM signal into a smooth bioelectric signal includes: Inputting the second PWM signal into the first-order RC low-pass filter, and filtering out higher harmonics of the second PWM signal in the first-order RC low-pass filter; The second PWM signal with higher harmonics filtered out is input into the second-order RC filter for smoothing to obtain the bioelectric signal.

6. The PWM-based bioelectric signal generation method according to claim 5, characterized in that: The first cutoff frequency of the first-order RC low-pass filter has a value range of: greater than or equal to one tenth of the frequency of the second PWM signal and less than or equal to one fifth of the frequency of the second PWM signal.

7. The PWM-based bioelectric signal generation method according to claim 5, characterized in that: The second cutoff frequency of the second-order RC filter is half of the first cutoff frequency.

8. A PWM-based bioelectric signal generating device, characterized in that: include: An output module, configured to output a first PWM signal with adjustable frequency through a PWM generation module; an adjustment module, configured to adjust the frequency and duty cycle of the first PWM signal in response to a frequency and amplitude selected by a user to obtain a second PWM signal; A processing module is used to input the second PWM signal into an RC circuit, process the second PWM signal in the RC circuit, and convert the second PWM signal into a smooth bioelectric signal.

9. An electronic device, characterized in that: include: Memory and processing modules; The memory is used to store computer programs; The processing module is used to execute the computer program and implement the steps of the PWM-based bioelectric signal generation method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program; when the computer program is executed by one or more processing modules, the one or more processing modules execute the steps of the PWM-based bioelectric signal generation method as described in any one of claims 1 to 7.