Disclosure of Invention
In view of the above, the invention provides a PWM signal conversion method and apparatus, and a lamp brightness control apparatus thereof, which implement signal conversion at low cost, and can flexibly set output signals according to the characteristics of the lamp, thereby solving the problem that the compatibility of the lamp controller to LED lamps is poor, and the phenomenon that the lamps display flickering or is not smooth due to the low frequency of the original PWM.
To achieve the object, the present invention provides a PWM signal conversion method, comprising:
The first step: receiving a first PWM signal sent by a lamp controller, processing the first PWM signal, and converting square waves with the duty ratio of the first PWM signal changed into DC voltage values with the level changed;
And a second step of: the micro control unit performs AD sampling on the DC voltage value with the level changing to obtain a relevant color gray value;
And a third step of: and processing the DC voltage value, and generating a lamp control signal according to the related color gray value, wherein the lamp control signal is used for regulating and controlling the brightness of the lamp.
Preferably, the lamp control signal comprises a second PWM signal and/or an SPI signal and/or a DMX512 signal.
Preferably, in the second step, the step of the micro control unit performing AD sampling on the DC voltage value with the level varying between high and low to obtain the corresponding color gray value further includes:
Scanning and reading an AD sampling value obtained by AD sampling, and obtaining the duty ratio of the first PWM signal according to the AD sampling value;
And obtaining the related color gray value according to the product of the maximum color gray value and the duty ratio of the first PWM signal.
Further, the calculation formula of the gray value of the related color is as follows:
(AD sample value/AD max) maximum color gray value = the relevant color gray value, where: the ratio of the AD sampling value to the AD max obtains the duty ratio of the first PWM signal, the AD max is a preset value in the micro control unit, and the maximum color gray value is a preset value.
The invention provides a PWM signal conversion device, which is used for executing any one of the PWM signal conversion methods to adapt to brightness regulation of lamps with different models, and comprises the following steps:
The square wave processing module is used for receiving a first PWM signal sent by the lamp controller, processing the first PWM signal and converting square waves with the duty ratio of the first PWM signal into DC voltage values with the level changing;
the color gray value acquisition module is used for carrying out AD sampling on the DC voltage value with the level changing to obtain the related color gray value; and
And the lamp control signal generation module is used for processing the DC voltage value, generating a lamp control signal according to the related color gray value and realizing the regulation and control of the brightness of the lamp.
Preferably, the square wave processing module is an integrating circuit module, and the square wave with the duty ratio of the first PWM signal changed is converted into a DC voltage value with the level changed, and the design cost is reduced.
Preferably, the color gray value obtaining module includes the micro control unit, an AD sampling module is built in the micro control unit, the AD sampling module realizes the AD sampling of the DC voltage value with the level varying, and obtains an AD sampling value, the micro control unit obtains the AD sampling value, obtains the duty ratio of the first PWM signal according to the ratio of the AD sampling value to the AD max, and obtains the relevant color gray value according to the product of the maximum color gray value and the duty ratio of the first PWM signal.
Preferably, the lamp control signal comprises a second PWM signal and/or an SPI signal and/or a DMX512 signal to adapt the lamp of the second PWM signal and/or the SPI signal and/or the DMX512 signal.
The invention also provides a device for regulating and controlling the brightness of the lamp, which comprises: the light assembly comprises a decoding module and a light, wherein the decoding module receives the light control signal generated by the PWM signal conversion device and decodes the light control signal, and the light control signal is used for indicating the decoding module to regulate and control the brightness of the light.
Preferably, the decoding module includes: and a decoder for decoding the second PWM signal and/or the SPI signal and/or the DMX512 signal to adapt to the lamp of the second PWM signal and/or the SPI signal and/or the DMX512 signal, wherein the lamp control signal indicates the decoder to regulate the brightness of the lamp.
The beneficial effects are that:
The invention provides a PWM signal conversion method, a device and a lamp brightness regulation device thereof, wherein the PWM signal conversion method converts square waves with the duty ratio of a first PWM signal into DC voltage values with the level changing, performs AD sampling to obtain related color gray values, and finally processes the DC voltage values by software to generate lamp control signals according to the related color gray values; the PWM signal conversion device is used for executing the PWM signal conversion method through the mutual coordination of the square wave processing module, the color gray value acquisition module and the lamp control signal generation module to obtain lamp control signals of different lamps; the lamp brightness regulating device realizes the decoding of the lamp control signal through a decoding module in the lamp, and the lamp control signal is used for indicating the decoding module to regulate the brightness of the lamp. The PWM signal conversion device has a simple structure, and can convert the first PWM signal into a lamp control signal adapted to different lamps, for example, a DMX512 lamp is installed, the first PWM signal conversion device is only required to convert the first PWM signal into a DMX512 output, and similarly, an SPI signal can be output, so that the problem of poor compatibility of a lamp controller is solved, meanwhile, for a PWM signal sent by the lamp controller for a bathtub, the frequency may be too low (for example, lower than 100 HZ), if the frequency of the PWM signal is too low, the controlled lamp may flicker, slightly shake, or change of jump, but the effect of soft and smooth transition cannot be achieved, so that a second PWM signal is output through the PWM signal conversion device, and the second PWM signal may be a change of frequency or a change of brightness level. The manufacturer can flexibly set the output lamp control signals according to the characteristics of the lamp and flexibly design the lamp according to the characteristics of the product, and meanwhile, the square wave processing module adopts an integrating circuit module, so that the signal conversion cost is reduced.
Detailed Description
All technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and/or" as used herein includes any and all combinations of one or more of the associated listed items.
The technical scheme of the invention is further described below with reference to the accompanying drawings and the examples.
Example 1
Referring to fig. 1, a PWM signal conversion method provided in embodiment 1 of the present invention includes:
step S100, a first PWM signal sent by a lamp controller is received, the first PWM signal is processed, and square waves with the duty ratio of the first PWM signal changed are converted into DC voltage values with the level changed;
Step S200, the micro control unit (Microcontroller Unit; MCU) performs AD sampling on the DC voltage value with the level changed to obtain a relevant color gray value;
and step S300, processing the DC voltage value and generating a lamp control signal according to the related color gray value.
Referring to fig. 1 and fig. 2, in step S200, the step of performing AD sampling on the DC voltage value with the level varying by the micro control unit to obtain a corresponding color gray value further includes:
Step S210, scanning and reading an AD sampling value obtained by AD sampling, and obtaining the duty ratio of the first PWM signal according to the AD sampling value;
Step S220, obtaining the relevant color gray value according to the product of the maximum color gray value and the duty ratio of the first PWM signal.
Referring to fig. 3 and 4, the software processing the DC voltage values may be an executable program, where the range of color gray values is 0 to 255, the related color gray values correspond to the brightness of the luminaire 520, and a larger related color gray value represents a larger brightness of the luminaire 520. Referring to fig. 3, in this embodiment, the lamp Control signal may be the second PWM (Pulse Width Modulation) signal and/or the SPI (Serial Peripheral Interface) signal and/or the DMX512 (DMX Control 512) signal, which is not limited to the above-mentioned signals, but may also be other signals for adjusting the brightness of the lamp 520.
Referring to fig. 1 and fig. 2, the implementation is specifically realized by firstly generating a first PWM signal by a lamp signal controller (which may be a lamp controller for a bathtub purchased by a bathtub manufacturer), receiving the first PWM signal sent by the lamp signal controller, processing the first PWM signal, and converting a square wave with a duty ratio changed by the first PWM signal into a DC voltage value with a level changed by the first PWM signal; the micro control unit performs AD sampling on the DC voltage value with the level changing through a built-in AD sampling module, scans and reads the AD sampling value generated above, and obtains the duty ratio of the first PWM signal according to the ratio of the AD sampling value to AD max preset in the micro control unit; obtaining the related color gray level value according to the product of the maximum color gray level value and the duty ratio of the first PWM signal, wherein the maximum color gray level value is preset by a programming program and ranges from 0 to 255; and processing the DC voltage value by a set software program, and generating a lamp control signal according to the related color gray value, wherein the lamp control signal is used for regulating and controlling the brightness of the lamp 520.
Further, the calculation formula of the gray value of the related color is as follows:
(AD sample value/AD max)*Lmax =l
Wherein: the ratio of the AD sampling value to the AD max obtains the duty ratio of the first PWM signal; AD max is a preset value (such as 512, 1024 or 2048) in the micro control unit, and L max is a maximum color gray value, which is a preset value; l is the relevant color gray value.
Referring to fig. 1,2, 3 and 5, in one aspect of the present embodiment, the PWM signal conversion method converts the first PWM signal into a second PWM signal, an SPI signal and a DMX512 signal, where the first PWM signal includes a first red PWM signal, a first green PWM signal and a first blue PWM signal, and the second red PWM signal, the second green PWM signal and the second blue PWM signal are respectively generated for the three first PWM signals by the conversion method in the present embodiment 1; red, green and blue SPI signals; and red DMX512I signal, green DMX512 signal, and blue DMX512I signal, which are used to regulate the brightness of the corresponding luminaire 520, respectively. The foregoing is only an illustration of one scheme, and certainly is not limited to outputting three first PWM signals and three different lamp control signals correspondingly at the same time, so that manufacturers can select and match according to product design requirements to improve flexibility of use.
Furthermore, the frequency of the input first PWM signal is a low frequency or an intermediate frequency signal, the output second PWM signal may be a high frequency signal or a second PWM signal with a brightness level higher than that of the first PWM signal, and the Gao Pindi two PWM signals mainly solve the problem that when the brightness of the lamp 520 is unchanged and weak, the lamp may flicker or slightly shake; the second PWM signal with the changed brightness level solves the problem that the lamp light may change in a jump manner when the brightness of the lamp changes, and the effect of soft and smooth transition is not achieved.
Example 2
Referring to fig. 3, 4 and 5, embodiment 2 of the present invention provides a PWM signal conversion apparatus 400 for performing the PWM signal conversion method described in embodiment 1 to adapt to brightness regulation of different types of lamps 520, including:
The square wave processing module 410 is configured to receive a first PWM signal sent by the lamp controller, process the first PWM signal, and convert a square wave with a duty ratio of the first PWM signal changed into a DC voltage value with a level changed in height;
A color gray value obtaining module 420, configured to perform AD sampling on the DC voltage value with the level varying to obtain the related color gray value; and
A lamp control signal generating module 430, configured to process the DC voltage value, and generate a lamp control signal according to the related color gray value, so as to regulate and control the brightness of the lamp 520.
In this embodiment, the square wave processing module 410 is an integrating circuit module, and converts the square wave with the duty ratio of the first PWM signal changed into the DC voltage value with the level changed, and reduces the design cost; the color gray value obtaining module 420 includes the micro control unit, an AD sampling module is built in the micro control unit, the AD sampling module performs AD sampling of the DC voltage value with the level varying, and obtains an AD sampling value, the micro control unit obtains the AD sampling value, obtains the duty ratio of the first PWM signal according to the ratio of the AD sampling value to the AD max, and obtains the relevant color gray value according to the product of the maximum color gray value and the duty ratio of the first PWM signal, where in this embodiment, the lamp control signal generating module 430 is a software program module, and of course, the lamp control signal generating module 430 may operate as an independent module or may be built in the micro control unit.
Referring to fig. 3 and 5, in the design of the present embodiment, the PWM signal conversion device 400 that inputs the first PWM signal may generate the second PWM signal and/or the SPI signal and/or the DMX512 signal, so as to adapt to the lamp 520 that is the second PWM signal and/or the SPI signal and/or the DMX512 signal.
Example 3
The embodiment 3 of the invention provides a lamp brightness adjusting device, which applies the PWM signal conversion method provided in the embodiment 1 and the PWM signal conversion device 400 provided in the embodiment 2.
Referring to fig. 5, specifically, the device for regulating and controlling the brightness of the lamp includes: the light fixture assembly 500 comprises a decoding module 510 and a light fixture 520, wherein the decoding module 510 receives the light fixture control signal generated by the PWM signal conversion device 400 and decodes the light fixture control signal, and the light fixture control signal is used for indicating the decoding module 510 to regulate the brightness of the light fixture 520.
Referring to fig. 4 and fig. 5, in the technical solution of the present embodiment, the lamp 520 is a color LED lamp, which includes three colors of red, green and blue, the lamp controller sends out a first red PWM signal, a first green PWM signal and a first blue PWM signal, and the PWM signal conversion device 400 receives the three first PWM signals and converts the three first PWM signals into a pair of second PWM signals, an SPI signal and a DMX512 signal, so as to realize the adjustment and control of the brightness of the color LED lamp.
The method is specifically realized as follows: the square wave processing module 410 is an integrating circuit module, and receives three first PWM signals sent by the lamp controller, and processes the three first PWM signals by using the waveform change characteristics of the integrating circuit module, so as to convert square waves with the duty ratios changed by the three first PWM signals into DC voltage values with the level changed;
the color gray value obtaining module 420 is configured to obtain an AD sampling value by using an AD sampling module in the micro control unit, obtain an AD sampling value, obtain a duty ratio of the first PWM signal according to a ratio of the AD sampling value to the AD max, and obtain the related color gray value according to a product of a maximum color gray value and the duty ratio of the first PWM signal;
The lamp control signal generating module 430 is configured to process the DC voltage value, and generate a lamp control signal according to the related color gray value, where the lamp control signal includes a second red PWM signal, a second green PWM signal, and a second blue PWM signal; red, green and blue SPI signals; and red DMX512I signal, green DMX512 signal and blue DMX512I signal, and transmit these signals to the corresponding decoding module 510, the decoding module 510 decodes the second PWM signal and/or the SPI signal and/or the DMX512 signal to adapt to the color LED lamp of the second PWM signal and/or the SPI signal and/or the DMX512 signal, and the lamp control signal instructs the decoder to regulate the brightness of the color LED lamp.
Of course, the above is only an illustration, and the manufacturer can select and match according to the design requirement of the product, so as to improve the flexibility of use.
The PWM signal conversion device 400 has a simple structure, and can convert the first PWM signal into a lamp control signal adapted to different lamps, thereby solving the problem of poor compatibility of the lamp controller. The manufacturer can flexibly set the output lamp control signal according to the characteristics of the lamp and flexibly design the lamp 520 according to the characteristics of the product, and meanwhile, the square wave processing module 410 adopts an integrating circuit module, so that the signal conversion cost is greatly reduced.
The foregoing description is only of a few specific embodiments of the invention, but it will be understood by those skilled in the art that the present invention is illustrative only and the scope of the invention is defined by the appended claims. Equivalent variations to the claims of the present invention are therefore intended to be covered by the present invention.