A buzzer is the integration of the electronic structure of the inquiry Xiangqi, the article describes how to drive single-chip buzzer, he is widely used in computers, printers, copiers, alarm, telephone and other electronic products for voice devices.
Into buzzers of the main piezoelectric buzzer and two types of electromagnetic buzzer.
Electromagnetic buzzer by the oscillator, electromagnetic coils, magnets, vibration and the shell membrane, and other components. Access to power, audio oscillator generated by electromagnetic currents through the coil, so that the resulting electromagnetic coil magnetic field, diaphragm vibration in the coil and magnet electromagnetic interaction, periodically sound vibration.
Piezoelectric buzzer by Multivibrator, buzz piezoelectric film, impedance matching and a resonance box, such as the composition of the shell. Multivibrator constituted by the transistor circuits or when connected to power after (1.5 ~ 15v DC voltage), multi-harmonic oscillator start-up, output of 1.5 ~ 2.5khz audio signals, impedance matching device to promote piezoelectric film buzz Audible.
The following is a form of electromagnetic buzzer-picture and chart
Electromagnetic buzzer-in-kind map: electromagnetic buzzer-structure diagram:
Electromagnetic constitute an internal buzzer:
1. Waterproof stickers
2. Bobbin
3. Coil
4. Magnet
5. Base
6. Pin
7. Shell
8. Core
9. Sealed plastic
10. Small metal plates
11. Membrane vibration
12. Circuit board
First, the electromagnetic buzzer-driven principle
Buzzer sound is the principle of electromagnetic current through the coil, so that the electromagnetic coil to produce magnetic fields vibrating membrane-driven sound, a certain amount of current can drive it, io-pin single-chip output current smaller, single-chip output Ttl the level buzzer basically can not drive and therefore a need to increase the current amplification circuit. s51-enhanced single-chip board through a transistor c8550 to drive to enlarge buzzer, schematic, see Figure 3 below:
s51-enhanced single-chip experiment buzzer drive plate schematic:
The buzzer received positive vcc (+5 v) above power, the buzzer from the negative electrode of the transistor emitter e, the transistor-level b after limiting resistance r1 by the single-chip p3.7 pin control, When p3.7 high output, t1 transistor cut-off, there is no current flowing through the coil, the buzzer did not sound; p3.7 when the low output, the transistor turn-on, so that the buzzer circuit current form, sound . Therefore, we can control the level p3.7 foot buzzer to make their voices heard on and off.
Single-chip program to change the output pin p3.7 wave frequency, you can adjust the tone control buzzer, have a different tone, the tone of voice. In addition, p3.7 change the output level of high-duty cycle low, you can control the size of the voice of the buzzer, which we all can be programmed to verify the experiment.
Second, the buzzer Liezi
We are following a few simple programming MCU buzzer drive and circuit design examples.
1, the buzzer experiments simple: this program through audio p3.7 output of a range of the square, the driver of the on-board experiments buzzer sounded a beep sound, the role of the sub-delay delay is to enable the output of Square-wave frequency in the human ear hearing within the following 20khz, if there is no delay in this process, the frequency of the output will go a long way beyond the ears of hearing people, we will not be able to hear voices. Delay constant change, you can change the output frequency, it can adjust the tone of the buzzer. You can experiment to change the value of # 228 for the other, listen to the tone of the buzzer to change.
Org 0000h
Ajmp main; jump to the main program
Org 0030h
Main: cpl p3.7; buzzer drive-level anti-access
Lcall delay; delay
Ajmp main; repeated cycle
delay: mov r7, # 228; subroutine delay, delay of the constant change can change the tone of the buzzer sounded
De1: djnz r7, de1
Ret
End
2, reversing a warning sound experiment: We know that all kinds of trucks, container trucks in reverse, the reverse will be issued a warning beep tone prompted, at the same time synchronization is also flashing yellow light warning to remind the back of the vehicle or attention. Experiments on the realization of this routine reversing warning function on-board experiments through the buzzer sounded a warning tone and at the same time, through on-board experiments p1.2 and p1.5 two yellow light-emitting diodes to issue a yellow warning light.
Org 0000h
Ajmp start; jump to the initialization procedure
Org 0033h
Start:
Mov sp, # 60h; sp initialization
Mov p3, # 0ffh; port initialization
Main: acall sound; buzzer sound
Acall ys500m; delay
Ajmp main
Sound:
mov p1, # 11011011b; light 2 yellow warning light-emitting diodes
Mov r2, # 200; ring cycle, 200
snd1: clr p3.7; output t1 low turn-on, the buzzer sound
Acall ys1ms; delay
setb p3.7; high output cut-off t1, the buzzer did not ring
Acall ys1ms; delay
Djnz r2, snd1
Mov p1, # 0ffh; put out a yellow warning light
Ret
Ys1ms:; 1ms delay subroutine
Mov r0, # 2
yl1: mov r1, # 250; changes in the value r0 can change the frequency of sound
Djnz r1, $
Djnz r0, yl1
Ret
Ys500m:; 500ms delay subroutine
Mov r0, # 6
Yl2: mov r1, # 200
Yl3: mov r2, # 250
Djnz r2, $
Djnz r1, yl3
Djnz r0, yl2
Ret
End
3, “BUZZ” experimental electronic doorbell: common electronic doorbell at the home of a visitor, if the doorbell button push, will be issued by the interior “BUZZ” sound, the experimental procedure analog electronic doorbell sounds, when we push The on-board experiments k1 button, the buzzer sounded, “BUZZ” music is a more practical procedure.
“BUZZ” experimental electronic doorbell asm source: “BUZZ” electronic doorbell c source language:
Org 0000h
Ljmp start; jump to the initialization procedure
Org 000bh
Ljmp pgt0; Jump to interrupt service routine t0
Start:
Obuf1 equ 30h; initialization procedure
Obuf2 equ 31h
Obuf3 equ 32h
Obuf4 equ 33h
Flagb bit 00h
Stopb bit 01h
k1 bit p3.2; button on the definition of k1, as a doorbell button
Mov tmod, # 02h; timer initialization
Mov th0, # 06h
Mov tl0, # 06h
Setb et0; start timer t0
Setb ea; start of the total disruption
Main:; main program
Jb k1, main; detection button k1
Lcall ys10m; to delay jitter
Jb k1, main
Setb tr0; button effective
Mov p1, # 00h; button to light up the indicator light
Mov obuf1, # 00h
Mov obuf2, # 00h
Mov obuf3, # 00h
Mov obuf4, # 00h
Clr flagb
Clr stopb
Jnb stopb, $
Mov p1, # 0ffh
ljmp main; a “BUZZ” after the return of re-testing button
Ys10m:; 10ms delay subroutine
Mov r6, # 20
D1: mov r7, # 248
Djnz r7, $
Djnz r6, d1
Ret
Pgt0:; timer interrupt service routine t0
inc obuf3; interrupt service program to issue a “BUZZ” sound
Mov a, obuf3
Cjne a, # 100, next
Mov obuf3, # 00h
Inc obuf4
Mov a, obuf4
Cjne a, # 20, next
Mov obuf4, # 00h
Jb flagb, pgstp
Cpl flagb
Ajmp next
Pgstp:
Setb stopb
Clr tr0
Ljmp int0ret
Next: jb flagb, sou2
Inc obuf2
Mov a, obuf2
Cjne a, # 03h, int0ret
Mov obuf2, # 00h
Cpl p3.7
Ljmp int0ret
Sou2: inc obuf1
Mov a, obuf1
Cjne a, # 04h, int0ret
Mov obuf1, # 00h
Cpl p3.7
Ljmp int0ret
Int0ret:
Reti
End
# Include
Unsigned char obuf1;
Unsigned char obuf2;
Unsigned int obuf3;
Bit stopb;
Bit flagb;
Void main (void)
(
Unsigned char i, j;
Tmod = 0 × 02; / / initialize t0 timer
Th0 = 0 × 06;
Tl0 = 0 × 06;
Et0 = 1;
Ea = 1; / / allow the interruption of the total
While (1)
(
If (p3_2 == 0) / / detection key k1
(
P1 = 0 × 00;
For (i = 10; i> 0; i-)
For (j = 248; j> 0; j-);
If (p3_2 == 0)
(
Obuf1 = 0;
Obuf2 = 0;
Obuf3 = 0;
Flagb = 0;
Stopb = 0;
tr0 = 1; / / start the timer t0, a “BUZZ” sound
While (stopb == 0);
P1 = 0xff;
)
)
)
)
Void t0 (void) interrupt 1 using 0
(
Obuf3 + +;
If (obuf3 == 2000)
(
Obuf3 = 0;
If (flagb == 0)
(
Flagb = ~ flagb;
)
Else
(
Stopb = 1;
Tr0 = 0;
)
)
If (flagb == 0)
(
Obuf2 + +;
If (obuf2 == 3)
(
Obuf2 = 0;
P3_7 = ~ p3_7;
)
)
Else
(
Obuf1 + +;
If (obuf1 == 4)
(
Obuf1 = 0;
P3_7 = ~ p3_7;
)
)
)




