Since the self-excited buzzer is a DC voltage drive, do not need to use AC signal to drive, only the drive port output drive level and through the transistor amplification drive current can make the buzzer sound, very simple, here does not explain the self-excited buzzer. This is only a description of the 1/2duty buzzer that must be driven with a square wave signal. The single-chip microcomputer drives his buzzer in two ways: one is the direct drive of the PWM output, the other is to use the I/O timing flip level to generate the driving waveform to drive the buzzer. The direct drive of PWM output is to drive the buzzer directly by outputting a certain square wave in the PWM export itself. In the SCM software setup, there are several system registers are used to set the output of the PWM port, you can set the duty cycle, and so on, by setting these registers to produce a waveform that conforms to the frequency of the buzzer requirements, as long as the PWM output is switched on, the PWM outputs can output the square wave of the frequency, This time the waveform can be used to drive the buzzer. For example, the frequency of 2000Hz buzzer driver, you can know that the period is 500μs, so only need to set the PWM period of 500μs, the duty cycle level is set to 250μs, you can produce a frequency of 2000Hz square wave, through this square wave and then use transistor can go to drive this buzzer. And the use of I/O timing flip level to generate a drive waveform will be a bit more trouble, you must use the timer to do timing, through the timing of the flip level to generate the frequency of the buzzer requirements of the waveform, this waveform can be used to drive the buzzer. For example, for the 2500Hz buzzer driver, you can know the cycle is 400μs, so only need to drive the buzzer I/O port every 200μs flip level can produce a frequency of 2500Hz, the duty cycle of 1/2duty square wave, and then through the transistor amplification can drive this buzzer. Because this is to introduce two ways of driving, so in the design module system will be two ways to do a piece, that is, the program is not only introduced in the PWMhow to drive the buzzer in the output outlet, and also introduce the method of the I/O port driving buzzer. Therefore, we will design the following system to explain the microcontroller to the buzzer driver: The system has two of his buzzer, the frequency is 2000Hz, one by the I/O port control, the other is controlled by the PWM output port; there are two keys, one button for port, I/O Mouth control of the buzzer does not tweet when the key I/O port control of the buzzer beep, and then press to stop the tweet, the other key for the PWM button, the PWM port control buzzer does not tweet when the key PWM output control buzzer beep, and then press stop tweet. Introduction Complete
Eighth chapter-: Buzzer Driver