Current location - Health Preservation Learning Network - Health preserving recipes - Driving mode of buzzer
Driving mode of buzzer
Since the self-excited buzzer is driven by DC voltage, there is no need to use AC signal to drive it. Just output the driving level to the driving port, amplify the driving current through the triode, and make the buzzer sound. It's very simple. I won't explain the self-excited buzzer here. Only the separately excited buzzer that must be driven by the square wave signal of 1/2duty will be described here.

There are two ways for single chip microcomputer to drive the other buzzer: one is to drive directly through PWM output port, and the other is to use I/O timing to flip the level to generate driving waveform to drive the buzzer.

The direct drive of PWM output port is to directly drive the buzzer by using a certain square wave output from PWM output port itself. There are several system registers in the software setting of single chip microcomputer to set the output of PWM port, such as duty cycle and cycle. After setting these registers to generate a waveform with a frequency meeting the requirements of the buzzer, as long as the PWM output is turned on, the PWM output port can output a square wave with this frequency, and then the buzzer can be driven by this waveform. For example, if we drive a buzzer with a frequency of 2000Hz, we can know that the period is 500μs, then we only need to set the PWM period to 500μs and the duty cycle level to 250μs, and we can generate a square wave with a frequency of 2000Hz, and then drive the buzzer with a transistor through this square wave.

However, it will be a bit troublesome to use I/O timing to flip the level to generate the driving waveform. A timer must be used for timing, and a waveform that meets the requirements of the buzzer is generated by timing to flip the level, and the buzzer is driven by this waveform. For example, if the buzzer is driven at 2500Hz, we can know that the period is 400μs, so that every 200μs, the I/O port of the buzzer can generate a square wave with a frequency of 2500Hz and a duty ratio of 1/2duty, and then the buzzer can be driven by transistor amplification.