Now the problem is that the duty cycle of the pulse output by the single-chip microcomputer cannot be changed, and the hardware can only be changed by replacing the single-chip microcomputer with high processing speed, but the cost has increased, and it is not necessarily more reliable than the control performance of using a special PWM control chip, so we choose to solve it on the software. The specific idea is: first, define two variables, one cycle T, one duty cycle D Assign values to them. T is greater than D. first, let the I / O output of the single chip microcomputer high level, let t and D count at the same time. When D is calculated to the expected value, the I / O port is low level, and then the low level continues to the T value, the I / O port outputs high level. Changing the value of D and t can change the pulse frequency, and changing the value of D can control the duty cycle. The algorithm needs to use a timer to set the timing time according to the working frequency of the power supply.<br>
正在翻译中..