Pulse width modulation signal control method, system and device, and storage medium
By acquiring and generating the generation parameters of multiple pulse width modulated signals and outputting them according to the preset correspondence relationship at the signal output, the problem of poor signal adaptability in the prior art is solved, and efficient output of various signals is achieved.
Patent Information
- Application Number
- CN202410166413.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-04
- Publication Date
- 2025-04-18
AI Technical Summary
In the prior art, multiple pulse width modulated signals are controlled using one counter, so that all signals have the same period and duty cycle, and cannot adapt to multiple needs, resulting in poor adaptability.
By acquiring the generation parameters of multiple pulse width modulated signals, a corresponding signal is generated according to each parameter, and outputting it according to the preset correspondence relationship between the signal and the signal output terminal, the generation and output of various signals are realized.
The output of multiple pulse width modulated signals is realized, which improves the adaptability of the signal and solves the problem of the same signal period and duty cycle in the prior art.
Smart Images

Figure CN119853651A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pulse width modulation signals, and in particular to a control method, system, device and storage medium for a pulse width modulation signal. Background Art
[0002] A pulse width modulation (PWM) signal is a modulation signal, which is often used to control the speed and position of a motor, adjust the brightness of a light-emitting diode (LED), etc. In order to control the pulse width modulation signal, a control method of the pulse width modulation signal is required.
[0003] In order to solve the above problems, in the related art, a counter is used to control multiple pulse width modulation signals. It should be noted that the counter can control the period and duty cycle of the pulse width modulation signal.
[0004] In the process of implementing the present application, the inventors found that there are at least the following problems in the related art: since one counter is used to control multiple pulse width modulation signals, all pulse width modulation signals have the same period and duty cycle, which cannot meet the needs of multiple pulse width modulation signals, resulting in poor adaptability of the pulse width modulation signal. Summary of the invention
[0005] The embodiments of the present invention provide a control method, system, device and storage medium for a pulse width modulation signal, so as to solve the problem in the related art that a counter is used to control multiple pulse width modulation signals, so that all the pulse width modulation signals have the same period and duty cycle, and cannot meet the requirements of multiple pulse width modulation signals, resulting in poor adaptability of the pulse width modulation signal.
[0006] In a first aspect, an embodiment of the present invention provides a method for controlling a pulse width modulation signal, the method comprising:
[0007] Obtaining generation parameters of multiple pulse width modulation signals;
[0008] According to each of the generated parameters, a corresponding pulse width modulation signal is generated;
[0009] According to the preset corresponding relationship between the pulse width modulation signal and the signal output terminal, the corresponding pulse width modulation signal is output through each of the signal output terminals.
[0010] Optionally, the generated parameter includes a period of a pulse width modulation signal; and generating a corresponding pulse width modulation signal according to each of the generated parameters includes:
[0011] Generate a pulse width modulation signal corresponding to each of the cycles according to a preset first value;
[0012] Every time a time period equal to the period elapses, the signal value of the pulse width modulation signal corresponding to the period is set to the first value.
[0013] Optionally, the generated parameter further includes a duty cycle of a pulse width modulation signal, and the duty cycle corresponds to the period one by one; and the step of generating a corresponding pulse width modulation signal according to each of the generated parameters further includes:
[0014] Obtaining an edge change duration according to the period and a duty cycle corresponding to the period;
[0015] After the signal value of the pulse width modulation signal is set to the first value each time, the signal value of the pulse width modulation signal is set to the second value after an edge change time length corresponding to the pulse width modulation signal.
[0016] Optionally, the second value is opposite to the first value.
[0017] Optionally, generating a pulse width modulation signal corresponding to each of the cycles according to a preset first value includes:
[0018] In response to a generation instruction, a pulse width modulation signal corresponding to each of the periods is generated according to the first value.
[0019] Optionally, generating a pulse width modulation signal corresponding to each of the cycles according to a preset first value includes:
[0020] When the first value is binary "1", a high-level pulse width modulation signal is generated;
[0021] When the first value is binary "0", a low-level pulse width modulation signal is generated.
[0022] Optionally, the pulse width modulation signal corresponds to at least one of the signal output terminals, and each of the signal output terminals corresponds to one of the pulse width modulation signals.
[0023] Optionally, the obtaining of generation parameters of a plurality of pulse width modulation signals includes:
[0024] In response to the configuration instruction, the configuration instruction is parsed to obtain the plurality of generation parameters.
[0025] Optionally, parsing the configuration instruction to obtain the plurality of generation parameters includes:
[0026] Acquire multiple address information in the configuration instruction;
[0027] Obtain generation parameters corresponding to the address information from a storage space corresponding to the address information.
[0028] Optionally, the method further comprises:
[0029] In response to the stop command, the generation of the pulse width modulation signal corresponding to the stop command is stopped.
[0030] In a second aspect, an embodiment of the present invention provides a control system for a pulse width modulation signal, comprising a configuration module, a plurality of signal generation modules, a signal distribution module, and a plurality of signal output terminals;
[0031] The configuration module is connected to each of the signal generating modules, the signal distribution module is connected to each of the signal generating modules, and the signal distribution module is connected to each of the signal output terminals;
[0032] The configuration module is used to obtain and store generation parameters of multiple pulse width modulation signals;
[0033] Each of the signal generating modules is used to obtain a corresponding generating parameter from the configuration module, and generate a pulse width modulation signal according to the generating parameter and input the pulse width modulation signal into the signal distribution module;
[0034] The signal distribution module is used for inputting each of the pulse width modulation signals to the corresponding signal output terminal according to the preset corresponding relationship between the pulse width modulation signals and the signal output terminals;
[0035] Each of the signal output terminals is used to output a corresponding pulse width modulation signal.
[0036] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a processor, a communication interface, a memory, and a communication bus; wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0037] Memory, used to store computer programs;
[0038] The processor is used to implement the steps of the pulse width modulation signal control method described in the first aspect when executing the program stored in the memory.
[0039] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the pulse width modulation signal control method described in the first aspect above.
[0040] In summary, in the embodiment of the present invention, by acquiring generation parameters of multiple pulse width modulation signals, and then generating corresponding pulse width modulation signals according to each generation parameter, and then outputting corresponding pulse width modulation signals through each of the signal output terminals according to the preset correspondence between the pulse width modulation signals and the signal output terminals, since the generation parameters are different, the pulse width modulation signals corresponding to the generation parameters are different, and it is possible to output multiple pulse width modulation signals, thereby improving the adaptability of the pulse width modulation signals, and solving the problem in the related art that due to the use of one counter to control multiple pulse width modulation signals, all the pulse width modulation signals have the same period and duty cycle, and cannot meet the needs of multiple pulse width modulation signals, resulting in poor adaptability of the pulse width modulation signals.
[0041] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for describing the embodiments are briefly introduced below.
[0043] Figure 1 A flow chart of the steps of a pulse width modulation signal control method provided by an embodiment of the present invention;
[0044] Figure 2 A flowchart of another method for controlling a pulse width modulation signal provided by an embodiment of the present invention;
[0045] Figure 3 A schematic diagram of a control system for a pulse width modulation signal provided by an embodiment of the present invention;
[0046] Figure 4 A schematic diagram of the specific structure of a pulse width modulation signal control system provided by an embodiment of the present invention;
[0047] Figure 5 A schematic diagram of a control flow of a pulse width modulation signal provided by an embodiment of the present invention;
[0048] Figure 6 A block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can also be implemented in any form and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.
[0050] Figure 1 A pulse width modulation signal control method provided by an embodiment of the present invention comprises steps 101 to 103:
[0051] It should be noted that the data acquisition process and related data involved in the embodiments of the present invention are all carried out in compliance with the corresponding data protection laws and policies of the country where they are located, and with the authorization given by the corresponding device owner.
[0052] Step 101: Obtain generation parameters of multiple pulse width modulation signals.
[0053] In this step, a plurality of pulse width modulation signal generation parameters are obtained, and then a corresponding pulse width modulation signal is generated according to each generation parameter.
[0054] Step 102: Generate a corresponding pulse width modulation signal according to each of the generated parameters.
[0055] In this step, a corresponding pulse width modulation signal is generated according to each generated parameter, and then according to a preset corresponding relationship between the pulse width modulation signal and the signal output terminal, the corresponding pulse width modulation signal is output through each of the signal output terminals.
[0056] It should be noted that a plurality of counters and a plurality of signal generators can be used to cooperate to generate a corresponding pulse width modulation signal according to each generated parameter. Specifically, the counters correspond to the signal generators one by one, each counter obtains the corresponding generated parameter, and generates a control instruction according to the generated parameter and inputs it to the corresponding signal generator, and each signal generator generates a pulse width modulation signal according to the corresponding control instruction.
[0057] Each counter can be configured with a corresponding counting frequency, where the counting frequency is the time interval between each count. For example, if the counting frequency is 2 milliseconds, then the counter counts once every 2 milliseconds. Therefore, each counter can output pulse width modulation signals with different resolutions.
[0058] Step 103: outputting a corresponding pulse width modulation signal through each of the signal output terminals according to a preset corresponding relationship between the pulse width modulation signal and the signal output terminal.
[0059] In this step, according to the preset correspondence between the pulse width modulation signal and the signal output terminal, the corresponding pulse width modulation signal is output through each signal output terminal. Since the generated parameters are different, the pulse width modulation signals corresponding to the generated parameters are different, and the output of multiple pulse width modulation signals can be realized.
[0060] It should be noted that the signal output end is the output end of the channel that outputs the pulse width modulation signal.
[0061] In summary, in the embodiment of the present invention, by acquiring generation parameters of multiple pulse width modulation signals, and then generating corresponding pulse width modulation signals according to each generation parameter, and then outputting corresponding pulse width modulation signals through each of the signal output terminals according to the preset correspondence between the pulse width modulation signals and the signal output terminals, since the generation parameters are different, the pulse width modulation signals corresponding to the generation parameters are different, and it is possible to output multiple pulse width modulation signals, thereby improving the adaptability of the pulse width modulation signals, and solving the problem in the related art that due to the use of one counter to control multiple pulse width modulation signals, all the pulse width modulation signals have the same period and duty cycle, and cannot meet the needs of multiple pulse width modulation signals, resulting in poor adaptability of the pulse width modulation signals.
[0062] Figure 2 A flowchart of another method for controlling a pulse width modulation signal provided by an embodiment of the present invention. Figure 2 , the method may include the following steps:
[0063] Step 201: In response to a configuration instruction, parse the configuration instruction to obtain a plurality of generation parameters.
[0064] In this step, by responding to the configuration instruction, parsing the configuration instruction, obtaining a plurality of generation parameters, and then generating a corresponding pulse width modulation signal according to each generation parameter.
[0065] In some embodiments, step 201 specifically includes the following sub-steps:
[0066] Sub-step 2011: Acquire multiple address information in the configuration instruction.
[0067] In this step, multiple address information in the configuration instruction is obtained, and then the generation parameters corresponding to the address information are obtained from the storage space corresponding to the address information.
[0068] Sub-step 2012: Obtain generation parameters corresponding to the address information from the storage space corresponding to the address information.
[0069] In this step, the generation parameters corresponding to the address information are obtained from the storage space corresponding to the address information, and then the corresponding pulse width modulation signal is generated according to each generation parameter.
[0070] Step 202: Generate a corresponding pulse width modulation signal according to each of the generated parameters.
[0071] The method of generating a corresponding pulse width modulation signal according to each generation parameter has been described in step 102 and will not be repeated here.
[0072] In some embodiments, the generated parameter includes a period of a pulse width modulation signal; step 202 specifically includes the following sub-steps:
[0073] Sub-step 2021: Generate a pulse width modulation signal corresponding to each of the cycles according to a preset first value.
[0074] In this step, a pulse width modulation signal corresponding to each of the periods is generated according to a preset first value, so as to realize generation of a pulse width modulation signal.
[0075] It should be noted that the first value may be a binary “1” or a binary “0.” The pulse width modulation signal corresponds to the period one by one.
[0076] In some embodiments, sub-step 2021 specifically includes the following molecular steps:
[0077] In step 2021a, in response to a generation instruction, a pulse width modulation signal corresponding to each of the periods is generated according to the first value.
[0078] In this step, by responding to the generation instruction, a pulse width modulation signal corresponding to each period is generated according to the first value, so that each pulse width modulation signal has a corresponding period, and each pulse width modulation signal can be generated by controlling the corresponding generation instruction, so that the generation of each pulse width modulation signal does not interfere with each other.
[0079] In some embodiments, sub-step 2021 specifically includes the following molecular steps:
[0080] Numerator step 2021b: when the first value is binary "1", a high-level pulse width modulation signal is generated.
[0081] In this step, when the first value is binary "1", a high-level pulse width modulation signal is generated, and then according to the preset corresponding relationship between the pulse width modulation signal and the signal output terminal, the corresponding pulse width modulation signal is output through each signal output terminal.
[0082] Numerator step 2021c: when the first value is binary "0", a low-level pulse width modulation signal is generated.
[0083] In this step, when the first value is binary "0", a low-level pulse width modulation signal is generated, and then according to the preset corresponding relationship between the pulse width modulation signal and the signal output terminal, the corresponding pulse width modulation signal is output through each signal output terminal.
[0084] Sub-step 2022: every time a time period equal to the period elapses, setting the signal value of the pulse width modulation signal corresponding to the period to the first value.
[0085] In this step, after a pulse width modulation signal corresponding to each of the cycles is generated according to a preset first value, the signal value of the pulse width modulation signal corresponding to the cycle is set to the first value every time a time length equal to the cycle passes, so that the signal value of the pulse width modulation signal is restored to an initial value, i.e., the first value, after one cycle, and each pulse width modulation signal has a one-to-one corresponding cycle, so that the signal value changes of each pulse width modulation signal are independent of each other.
[0086] In some embodiments, the generated parameter further includes a duty cycle of a pulse width modulation signal, and the duty cycle corresponds to the period one by one; step 202 specifically includes the following sub-steps:
[0087] Sub-step 2023: Obtain the edge change duration according to the period and the duty cycle corresponding to the period.
[0088] In this step, the edge change time length is obtained according to the period and the duty cycle corresponding to the period, and then after the signal value of the pulse width modulation signal is set to the first value each time, the signal value of the pulse width modulation signal is set to the second value after the edge change time length corresponding to the pulse width modulation signal, and because each pulse width modulation signal has a one-to-one corresponding period and duty cycle, each pulse width modulation signal has a one-to-one corresponding edge change time length.
[0089] Specifically, the duty cycle is the ratio of the duration of the pulse width modulation signal that is the first value to the duration of one cycle; the edge change time is the product of the cycle and the corresponding duty cycle. For example, if the cycle is 1000 milliseconds and the duty cycle is 60%, the edge change time is 600 milliseconds (1000 milliseconds multiplied by 60%).
[0090] Sub-step 2024: after each time the signal value of the pulse width modulation signal is set to the first value, after an edge change time length corresponding to the pulse width modulation signal, the signal value of the pulse width modulation signal is set to a second value.
[0091] In this step, after each time the signal value of the pulse width modulation signal is set to the first value, the signal value of the pulse width modulation signal is set to the second value after an edge change time corresponding to the pulse width modulation signal, so as to achieve control of the signal value of the corresponding pulse width modulation signal by each duty cycle within the duration of each cycle, and since each pulse width modulation signal has a one-to-one corresponding edge change time, the changes in the signal value of each pulse width modulation signal within the duration of the corresponding cycle are independent of each other.
[0092] It should be noted that the second value can be either binary "1" or binary "0".
[0093] In some embodiments, the second value is opposite to the first value.
[0094] In this step, since the second value is opposite to the first value, the signal value of the corresponding pulse width modulation signal is controlled by each duty cycle within the duration of each cycle to obtain a pulse width modulation signal in the form of a square wave.
[0095] For example, when the first value is binary "1", the second value is binary "0", that is, within the duration of each cycle, after the edge change time corresponding to the pulse width modulation signal, the square wave formed by the pulse width modulation signal changes from a rising edge to a falling edge, and after the same duration as the cycle, the square wave formed by the pulse width modulation signal changes from a falling edge to a rising edge; when the first value is binary "0", the second value is binary "1", that is, within the duration of each cycle, after the edge change time corresponding to the pulse width modulation signal, the square wave formed by the pulse width modulation signal changes from a falling edge to a rising edge, and after the same duration as the cycle, the square wave formed by the pulse width modulation signal changes from a rising edge to a falling edge.
[0096] Step 203: outputting a corresponding pulse width modulation signal through each of the signal output terminals according to a preset corresponding relationship between the pulse width modulation signal and the signal output terminal.
[0097] The method of outputting the corresponding pulse width modulation signal through each signal output terminal according to the preset corresponding relationship between the pulse width modulation signal and the signal output terminal has been described in step 103 and will not be repeated here.
[0098] In some embodiments, the pulse width modulation signal corresponds to at least one of the signal output terminals, and each of the signal output terminals corresponds to one of the pulse width modulation signals.
[0099] In this step, since the pulse width modulation signal corresponds to at least one of the signal output terminals, each of the signal output terminals corresponds to a pulse width modulation signal, so that each signal output terminal outputs a pulse width modulation signal, the pulse width modulation signals output by the two signal output terminals can be the same or different, thereby improving the freedom of generating the pulse width modulation signal.
[0100] In some embodiments, the method further comprises the steps of:
[0101] Step 204: In response to the stop instruction, stop generating the pulse width modulation signal corresponding to the stop instruction.
[0102] In this step, by responding to the stop instruction, the generation of the pulse width modulation signal corresponding to the stop instruction is stopped, so that each pulse width modulation signal can be controlled to stop being generated by the stop instruction, and the stop of the generation of each pulse width modulation signal does not interfere with each other.
[0103] In summary, in the embodiment of the present invention, by acquiring generation parameters of multiple pulse width modulation signals, and then generating corresponding pulse width modulation signals according to each generation parameter, and then outputting corresponding pulse width modulation signals through each of the signal output terminals according to the preset correspondence between the pulse width modulation signals and the signal output terminals, since the generation parameters are different, the pulse width modulation signals corresponding to the generation parameters are different, and it is possible to output multiple pulse width modulation signals, thereby improving the adaptability of the pulse width modulation signals, and solving the problem in the related art that due to the use of one counter to control multiple pulse width modulation signals, all the pulse width modulation signals have the same period and duty cycle, and cannot meet the needs of multiple pulse width modulation signals, resulting in poor adaptability of the pulse width modulation signals.
[0104] Reference Figure 3 An embodiment of the present invention provides a control system for a pulse width modulation signal, comprising a configuration module, a plurality of signal generating modules, a signal distribution module and a plurality of signal output terminals; the configuration module is connected to each of the signal generating modules, the signal distribution module is connected to each of the signal generating modules, and the signal distribution module is connected to each of the signal output terminals; the configuration module is used to obtain and store generation parameters of a plurality of pulse width modulation signals; each of the signal generating modules is used to obtain corresponding generation parameters from the configuration module, and generate a pulse width modulation signal according to the generation parameters and input it into the signal distribution module; the signal distribution module is used to input each of the pulse width modulation signals into the corresponding signal output terminal according to a preset correspondence between the pulse width modulation signal and the signal output terminal; each of the signal output terminals is used to output a corresponding pulse width modulation signal.
[0105] In some embodiments, each signal generation module includes a counter and a signal generator, each counter is connected to a corresponding signal generator, a configuration module is connected to each counter, and a signal distribution module is connected to each signal generator. The configuration module obtains and stores generation parameters of multiple pulse width modulation signals, each counter obtains the corresponding generation parameters from the configuration module, and generates a control instruction based on the generation parameters and inputs it to the corresponding signal generator. Each signal generator generates a pulse width modulation signal according to the corresponding control instruction and inputs it to the signal distribution module. The signal distribution module inputs each pulse width modulation signal to the corresponding signal output terminal according to the preset correspondence between the pulse width modulation signal and the signal output terminal, and then each signal output terminal outputs the corresponding pulse width modulation signal.
[0106] For example, refer to Figure 4 , the configuration module is connected to counter 1, counter 2, ..., counter n (n is a natural number, such as 100, 200, etc.), counter 1 is connected to signal generator 1, counter 2 is connected to signal generator 2, and so on, ..., counter n is connected to signal generator n, the signal distribution module is connected to signal generator 1, signal generator 2, ..., signal generator n, respectively, the signal distribution module is connected to signal output terminal 1, signal output terminal 2, ..., signal output terminal m (m is a natural number, such as 50, 80, etc.), counter 1 obtains the corresponding generation parameter 1 from the configuration module, and generates a control instruction 1 according to the generation parameter 1 and inputs it to the corresponding signal generator 1, the signal generator 1 generates a pulse width modulation signal 1 according to the corresponding control instruction 1 and inputs it to the signal Distribution module, counter 2 obtains the corresponding generation parameter 2 from the configuration module, and generates a control instruction 2 according to the generation parameter 2 and inputs it to the corresponding signal generator 2, signal generator 2 generates a pulse width modulation signal 2 according to the corresponding control instruction 2 and inputs it to the signal distribution module, and so on, ..., counter n obtains the corresponding generation parameter n from the configuration module, and generates a control instruction n according to the generation parameter n and inputs it to the corresponding signal generator n, signal generator n generates a pulse width modulation signal n according to the corresponding control instruction n and inputs it to the signal distribution module, the signal distribution module inputs the pulse width modulation signal 1, the pulse width modulation signal 2, ..., the pulse width modulation signal n to the corresponding signal output terminal according to the preset correspondence between the pulse width modulation signal and the signal output terminal.
[0107] In some embodiments, the configuration module is used to respond to the configuration instruction, parse the configuration instruction, obtain multiple generation parameters, each generation parameter includes a period of a pulse width modulation signal and a duty cycle of the pulse width modulation signal, and the configuration module includes a period register, a duty cycle register, an enable register, etc. The period register is used to store the period of the pulse width modulation signal, the duty cycle register is used to store the duty cycle of the pulse width modulation signal, and the enable register is used to store the generation instruction or stop instruction of the pulse width modulation signal. The configuration module is also used to obtain the generation instruction or stop instruction of the pulse width modulation signal, and input each generation instruction or stop instruction to the corresponding counter, each of the counters is used to forward the corresponding generation instruction or stop instruction to the corresponding signal generator, each of the signal generators is used to respond to the corresponding generation instruction, generate a pulse width modulation signal corresponding to each period according to the first value, and respond to the corresponding stop instruction to stop generating the pulse width modulation signal corresponding to the stop instruction.
[0108] In some embodiments, each counter may be configured with a corresponding counting frequency, where the counting frequency is the time interval between each count. For example, if the counting frequency is 2 milliseconds, then the counter counts once every 2 milliseconds. Therefore, each counter may output a pulse width modulation signal with different resolutions.
[0109] For example, the control system of the pulse width modulation signal includes four counters, namely counter T1, counter T2, counter T3, and counter T4; the control system of the pulse width modulation signal also includes four signal generators, namely signal generator W1, signal generator W2, signal generator W3, and signal generator W4; the control system of the pulse width modulation signal also includes six signal output terminals, namely signal output terminal 1, signal output terminal 2, signal output terminal 3, signal output terminal 4, signal output terminal 5, and signal output terminal 6.
[0110] Referring to the following table (Table 1), the configuration module includes a period register and a duty cycle register. The configuration module responds to the configuration instruction, parses the configuration instruction, obtains the periods of four pulse width modulation signals, namely, period D1 of the pulse width modulation signal, period D2 of the pulse width modulation signal, period D3 of the pulse width modulation signal, and period D4 of the pulse width modulation signal, and stores them in the period register, and obtains the duty cycles of the four pulse width modulation signals, namely, duty cycle S1 of the pulse width modulation signal, duty cycle S2 of the pulse width modulation signal, duty cycle S3 of the pulse width modulation signal, and duty cycle S4 of the pulse width modulation signal, and stores them in the duty cycle register. In addition, the counter can be configured with counting frequencies of counting frequency F1, counting frequency F2, counting frequency F3, and counting frequency F4, wherein counter T1 corresponds to the period D1 of the pulse width modulation signal, the duty cycle S1 of the pulse width modulation signal, and the counting frequency F1, counter T2 corresponds to the period D2 of the pulse width modulation signal, the duty cycle S2 of the pulse width modulation signal, and the counting frequency F2, counter T3 corresponds to the period D3 of the pulse width modulation signal, the duty cycle S3 of the pulse width modulation signal, and the counting frequency F3, and counter T4 corresponds to the period D4 of the pulse width modulation signal, the duty cycle S4 of the pulse width modulation signal, and the counting frequency F4.
[0111] serial number 1 2 3 4 Counting frequency F1 F2 F3 F4 Period Register D1 D2 D3 D4 Duty Cycle Register S1 S2 S3 S4
[0112] Table 1
[0113] The counter T1 of the counting frequency F1 controls the signal generator W1 to output signal 1, the counter T2 of the counting frequency F2 controls the signal generator W2 to output signal 2, the counter T3 of the counting frequency F3 controls the signal generator W3 to output signal 3, and the counter T4 of the counting frequency F4 controls the signal generator W4 to output signal 4, wherein signal 1 is a pulse width modulation signal with a period D1 and a duty cycle S1, signal 2 is a pulse width modulation signal with a period D2 and a duty cycle S2, signal 3 is a pulse width modulation signal with a period D3 and a duty cycle S3, and signal 4 is a pulse width modulation signal with a period D4 and a duty cycle S4. The preset corresponding relationship between the pulse width modulation signal and the signal output terminal is as shown in the following table.
[0114] (Table 2):
[0115]
[0116] Table 2
[0117] Among them, "Y" indicates that the pulse width modulation signal and the signal output terminal have a preset corresponding relationship, for example, signal 1 and signal output terminal 1 have a preset corresponding relationship, and "N" indicates that the pulse width modulation signal and the signal output terminal do not have a preset corresponding relationship, for example, signal 2 and signal output terminal 1 do not have a preset corresponding relationship.
[0118] According to the preset correspondence between the pulse width modulation signal and the signal output terminal in Table 2, signal output terminal 1 and signal output terminal 2 output signal 1, signal output terminal 3 and signal output terminal 4 output signal 2, signal output terminal 5 outputs signal 3, and signal output terminal 6 outputs signal 4.
[0119] If the preset corresponding relationship between the pulse width modulation signal and the signal output terminal is adjusted, the preset corresponding relationship between the pulse width modulation signal and the signal output terminal after adjustment is as shown in the following table (Table 3):
[0120]
[0121] Table 3
[0122] Among them, "Y" indicates that the pulse width modulation signal and the signal output terminal have a preset corresponding relationship, for example, signal 1 and signal output terminal 6 have a preset corresponding relationship, and "N" indicates that the pulse width modulation signal and the signal output terminal do not have a preset corresponding relationship, for example, signal 1 and signal output terminal 1 do not have a preset corresponding relationship.
[0123] According to the preset correspondence between the pulse width modulation signal and the signal output terminal in Table 3, signal output terminal 1 outputs signal 2, signal output terminal 2, signal output terminal 3 and signal output terminal 4 output signal 3, signal output terminal 5 outputs signal 4, and signal output terminal 6 outputs signal 1.
[0124] In some embodiments, reference Figure 5 The control process of the pulse width modulation signal includes: X1, configuring the corresponding period, duty cycle and counting frequency of each counter, and the corresponding signal generator generates the corresponding pulse width modulation signal; X2, the signal distribution module inputs each pulse width modulation signal to the corresponding signal output terminal; X3, each signal output terminal outputs the corresponding pulse width modulation signal.
[0125] In summary, in the embodiment of the present invention, the generation parameters of multiple pulse width modulation signals are obtained and stored through the configuration module, each signal generation module obtains the corresponding generation parameters from the configuration module, and generates a pulse width modulation signal according to the generation parameters and inputs it to the signal distribution module, and the signal distribution module inputs each pulse width modulation signal to the corresponding signal output terminal according to the preset correspondence between the pulse width modulation signal and the signal output terminal, and then each signal output terminal outputs the corresponding pulse width modulation signal. Since the generation parameters are different, the pulse width modulation signals corresponding to the generation parameters are different, and it is possible to output a variety of pulse width modulation signals, thereby improving the adaptability of the pulse width modulation signal, and solving the problem in the related art that due to the use of one counter to control a plurality of pulse width modulation signals, all the pulse width modulation signals have the same period and duty cycle, and cannot meet the needs of a variety of pulse width modulation signals, resulting in poor adaptability of the pulse width modulation signal.
[0126] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it includes a processor 501 , a communication interface 502 , a memory 503 and a communication bus 504 , wherein the processor 501 , the communication interface 502 , and the memory 503 communicate with each other via the communication bus 504 .
[0127] The memory 503 is used to store computer programs.
[0128] When the processor 501 is used to execute the program stored in the memory 503, the following steps are implemented:
[0129] Obtaining generation parameters of multiple pulse width modulation signals;
[0130] According to each of the generated parameters, a corresponding pulse width modulation signal is generated;
[0131] According to the preset corresponding relationship between the pulse width modulation signal and the signal output terminal, the corresponding pulse width modulation signal is output through each of the signal output terminals.
[0132] The processor 501 may also implement other steps in the above-mentioned pulse width modulation signal control method, which will not be described in detail here.
[0133] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus or a Controller Area Network (CAN) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0134] The communication interface is used for communication between the above electronic device and other devices.
[0135] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Alternatively, the memory may also be at least one storage device located away from the aforementioned processor.
[0136] The above-mentioned processor can be a general-purpose processor, including a microcontroller unit (Central Processing Unit, referred to as CPU), a network processor (Network Processor, referred to as NP), etc.; it can also be a digital signal processor (Digital Signal Processing, referred to as DSP), an application specific integrated circuit (Application Specific Integrated Circuit, referred to as ASIC), a field programmable gate array (Field-Programmable Gate Array, referred to as FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0137] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the instructions are executed on a computer, the computer executes the pulse width modulation signal control method in the above embodiment.
[0138] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the pulse width modulation signal control method in the above embodiment.
[0139] An embodiment of the present invention further provides a vehicle, comprising the electronic device as described above.
[0140] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0141] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0142] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. For the embodiments of the device, electronic device, computer-readable storage medium and computer program products containing instructions, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0143] The above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for controlling a pulse width modulation signal, characterized in that: The method comprises: Obtaining generation parameters of multiple pulse width modulation signals; According to each of the generated parameters, a corresponding pulse width modulation signal is generated; According to the preset corresponding relationship between the pulse width modulation signal and the signal output terminal, the corresponding pulse width modulation signal is output through each of the signal output terminals.
2. The method according to claim 1, characterized in that The generated parameters include the period of the pulse width modulation signal; The step of generating a corresponding pulse width modulation signal according to each of the generated parameters comprises: Generate a pulse width modulation signal corresponding to each of the cycles according to a preset first value; Every time a time period equal to the period elapses, the signal value of the pulse width modulation signal corresponding to the period is set to the first value.
3. The method according to claim 2, characterized in that The generated parameters also include a duty cycle of the pulse width modulation signal, and the duty cycle corresponds to the period one by one; and generating a corresponding pulse width modulation signal according to each of the generated parameters also includes: Obtaining an edge change duration according to the period and a duty cycle corresponding to the period; After the signal value of the pulse width modulation signal is set to the first value each time, the signal value of the pulse width modulation signal is set to the second value after an edge change time length corresponding to the pulse width modulation signal.
4. The method according to claim 3, characterized in that The step of obtaining the edge change duration according to the period and the duty cycle corresponding to the period includes: The product of the period and the duty cycle corresponding to the period is used as the edge change time length.
5. The method according to claim 3, characterized in that: The second value is opposite to the first value.
6. The method according to claim 5, characterized in that In the case where the first value is binary "1", the second value is binary "0"; When the first value is binary "0", the second value is binary "1".
7. The method according to claim 2, characterized in that The step of generating a pulse width modulation signal corresponding to each of the cycles according to a preset first value comprises: In response to a generation instruction, a pulse width modulation signal corresponding to each of the periods is generated according to the first value.
8. The method according to claim 2, characterized in that: The step of generating a pulse width modulation signal corresponding to each of the cycles according to a preset first value comprises: When the first value is binary "1", a high-level pulse width modulation signal is generated; When the first value is binary "0", a low-level pulse width modulation signal is generated.
9. The method according to claim 1, characterized in that: The pulse width modulation signal corresponds to at least one of the signal output terminals, and each of the signal output terminals corresponds to one of the pulse width modulation signals.
10. The method according to claim 1, characterized in that The step of obtaining generation parameters of a plurality of pulse width modulation signals comprises: In response to the configuration instruction, the configuration instruction is parsed to obtain the plurality of generation parameters.
11. The method according to claim 10, characterized in that The parsing of the configuration instruction to obtain the plurality of generation parameters includes: Acquire multiple address information in the configuration instruction; Obtain generation parameters corresponding to the address information from a storage space corresponding to the address information.
12. The method according to claim 1, characterized in that The method further comprises: In response to the stop command, the generation of the pulse width modulation signal corresponding to the stop command is stopped.
13. A control system for a pulse width modulation signal, characterized in that: It includes a configuration module, a plurality of signal generation modules, a signal distribution module and a plurality of signal output terminals; The configuration module is connected to each of the signal generating modules, the signal distribution module is connected to each of the signal generating modules, and the signal distribution module is connected to each of the signal output terminals; The configuration module is used to obtain and store generation parameters of multiple pulse width modulation signals; Each of the signal generating modules is used to obtain a corresponding generating parameter from the configuration module, and generate a pulse width modulation signal according to the generating parameter and input the pulse width modulation signal into the signal distributing module; The signal distribution module is used for inputting each of the pulse width modulation signals to the corresponding signal output terminal according to the preset corresponding relationship between the pulse width modulation signals and the signal output terminals; Each of the signal output terminals is used to output a corresponding pulse width modulation signal.
14. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus; wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, configured to implement the steps of the pulse width modulation signal control method as claimed in any one of claims 1 to 12 when executing a program stored in the memory.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the pulse width modulation signal control method according to any one of claims 1 to 12 are implemented.