Piezogenerators in microcontroller circuits. Piezo generators in microcontroller circuits Personal experience of use

Published 10/21/2014

In electronics, piezoelectric sound speakers or piezo buzzers are often used. Popularly known as tweeters or piezo tweeters. They may come in different sizes, but the idea is the same: using the inverse piezo effect to generate sound. Such piezo tweeters can have a built-in generator. It is enough to apply voltage to them and they will squeak monotonously. But most of them do not have a generator. We will talk about them. The main problem with using such tweeters is increasing their volume. You must understand that we are talking about generating sound from a discrete output in digital circuits, not about increasing the power of an analog audio signal.

If you connect such a piezo tweeter to a microcontroller, as shown in the diagram, the volume will be weak.

In fact, in order to achieve normal volume of a piezo tweeter, three main conditions must be met:

  • optimal voltage supplied to the piezo tweeter (about 20 V);
  • the frequency should be close to resonant. For many - in the range of 2500..3500 Hz;
  • correctly selected resonant volume.

By the way, almost no one talks about this, although the correct selection of volume geometry effectively affects the increase in volume. You probably noticed that “branded” tweeters are sold in a housing. This housing creates an optimal resonant volume and has an optimal opening for sound exit.

Voltage boost circuit

There are various voltage boost schemes. I went through several of them and settled on the one with which I achieved the best results:

This circuit produces monopolar pulses, but it is quite simple and compact. The largest part in size is the throttle. The circuit works as follows: when the transistor opens, current begins to flow through the inductor. The current in the inductor cannot increase abruptly; the current in the inductors increases gradually. When the transistor closes, the current decreases, and the voltage at the inductor output increases abruptly. The level of this voltage depends on the inductor rating, input supply voltage, and other circuit parameters. The following elements are involved in this scheme:

  • piezo tweeter – with a diameter of 27 mm;
  • choke – RCH855NP-332K 3.3 mH;
  • transistor – field effect IRLML2402. You can use other transistors that can withstand a voltage of 20 V and a current of 100 mA;
  • diode - any;
  • capacitor - any, preferably tantalum or electrolytic, connected in parallel with a ceramic one, with a total capacity of 100 mF.

Care must be taken to ensure that the transistor does not open on its own. Therefore, do not turn on this circuit when the transistor gate is “hanging in the air”.

Frequency

In order to achieve a loud sound, the frequency of the signal must match the resonant frequency of the tweeter. It is usually indicated in the documentation and for most piezo tweeters it lies within the range of 2500..3500 Hz. If desired, you can select it experimentally. If the sound frequency in a device must change depending on the measured parameters, the sound frequency will almost never fall into the resonant one. In such cases, we must try to keep the audio frequency range as close as possible to the resonant frequency.

Resonance volume

Choosing the right acoustic volume is the most important thing that almost never gets written about. What is it and why is it needed? Have you all ever seen a guitar? I mean acoustic guitar. She also has a box that amplifies the sound. If you remove it and leave only the neck with strings, the sound will be much quieter. A similar volume is needed for our tweeter. Typically, tweeters are mounted in the body of the device, so the elements of the body will form the required volume. I implemented it using a ring that is glued inside the case. In the photo, the rings are printed on a 3D printer. You can make it from any durable material - plastic, wood, etc. The sound comes out through a hole in the body. Ring and Hole Dimensions:



Ring diameter – approximately 28mm
Ring height – 2.6mm
The diameter of the outlet is 5mm.

1 Piezo emitter connection diagram to Arduino

A piezo emitter, or piezoelectric emitter, or “piezo tweeter” is an electroacoustic sound reproduction device using inverse piezoelectric effect. Its principle of operation is based on the fact that under the influence of an electric field, mechanical movement of the membrane occurs, which causes the sound waves we hear. Typically, such sound emitters are installed in household electronic equipment as sound alarms, in desktop personal computer cases, in telephones, in toys, in loudspeakers and much more.

The piezo emitter has 2 outputs, and polarity matters. Therefore, we connect the black pin to ground (GND), and the red pin to any digital pin with the PWM function. In this example, the positive terminal of the emitter is connected to pin "D3".

Diagram for connecting a piezo emitter to Arduino and a circuit assembled on a breadboard

2 using the analogWrite() function

The piezo tweeter can be used in different ways. The simplest one is to use the function analogWrite(). An example of a sketch is in the box. This sketch alternately turns the sound on and off with a frequency of 1 time every 2 seconds.

/* Declare a variable with the number of the pin to which the piezoelectric element is connected: */ int soundPin = 3; void setup() (// set pin "3" to the "Output" operating mode: pinMode(soundPin, OUTPUT); } void loop() ( analogWrite(soundPin, 50); // turn on the piezo emitter delay(1000); // for 1000 ms (1 sec), analogWrite(soundPin, 0); // turn off the sound delay(1000); // for 1 sec. }

We set the pin number and define it as an output. Function analogWrite() takes as arguments the pin number and level, which can be from 0 to 255, because The Arduino PWM pins have an 8-bit DAC. This value will change the volume of the piezo tweeter within small limits. To turn off the piezo beeper, you need to send the value “0” to the port.

Using the function analogWrite(), you cannot change the tone of the sound, unfortunately. The piezo emitter will always sound at a frequency of approximately 980 Hz, which corresponds to the frequency of the pulse width modulation (PWM) outputs on Arduino UNO boards and the like.

3 Extracting sound from a piezo emitter using the tone() function

But the sound frequency can be changed differently. To do this, we extract sound from the piezo emitter using the built-in function tone(). An example of a simple sketch is shown in the inset.

Int soundPin = 3; /* declare a variable with the number of the pin to which we connected the piezoelectric element */ void setup() ( pinMode(soundPin, OUTPUT); //declare pin 3 as an output. } Serial.begin(9600); // we will output the current frequency to the port

void loop() ( for (int i=20; i tone() Function takes Arduino pin number and audio frequency as arguments. The lower frequency limit is 31 Hz, the upper limit is limited by the parameters of the piezo emitter and human hearing. To turn off the sound, send the command to the port.

noTone() tone() And this is what the timing diagram of the signal generated by the function will look like:

. It can be seen that every 100 ms the frequency increases, which is what we hear: tone()

As you can see, using a piezo emitter from Arduino you can extract sounds. You can even write a simple musical composition by setting the notes to the corresponding frequencies, and also determining the duration of each note using the function delay().

Please note that if several piezo emitters are connected to the Arduino, only one will work at a time. To turn on the emitter on another pin, you need to interrupt the sound on the current one by calling the function takes Arduino pin number and audio frequency as arguments. The lower frequency limit is 31 Hz, the upper limit is limited by the parameters of the piezo emitter and human hearing. To turn off the sound, send the command to the port.

Important point: function tone() superimposed on the PWM signal on the “3” and “11” pins of the Arduino. That is, the function called, for example, for pin “5” tone() may interfere with the operation of pins "3" and "11". Keep this in mind when designing your devices.

In this experience, we will once again bridge the gap between the digital and analogue worlds.
We will use a BUZZER, a beeper or a buzzer, as you like, which makes a small “click” if you briefly touch its contacts to the +5 volt power supply and “-” GND, try it!
In itself this is not very interesting, but if you apply voltage to it and immediately turn it off, and so on at a speed of 100 times per second
the buzzer will start beeping. And if you put hundreds of strings of tones together, you have music!

Attention, the Arduino Starter KIT usually contains a tweeter and a piezo-ceramic emitter that are as similar as two peas in a pod; although they are similar, the operating principles are different. The buzzer (buzzer) has a white circle glued on the top side, where the hole is, but the emitter has nothing glued on it.

In this experiment, the Arduino will play a melody, or so we hope!
The circuit is very simple, almost anyone can assemble it, no special knowledge or experience is required.

Above, you see a schematic diagram for this lesson; I repeat once again, no difficulties should arise during assembly.

For this experience you will need:

1. Arduino UNO - 1 pc.

2. Buzzer (squeaker) - 1 pc.

6. Connecting wires.

If the buzzer does not fit into the holes on the board, try turning it a little so that its leads fit into adjacent holes, as if diagonally.

Connection diagram for lesson 11. Arduino and tweeter

Download the code for experiment 11. Sketch and detailed description (Be sure to read the entire sketch!):

ArduinoKit experiment kit
Program code for experience No. 11:

View of the created lesson on the layout diagram:

Arduino and buzzer. Lesson 11

As a result of the experience, you should see, but what you should see is nothing. You must hear!!!

You should hear the electronic melody “Twinkle, Twinkle Little Star” or similar, it’s not so important, the main thing is that you hear it.

The code is written so that you can easily add your own ringtones.

Possible difficulties:

No sound
Given the size and shape of the tweeter, it is easy to miss the desired hole in the board.
Try checking its placement again.
It still doesn't work, I don't understand why
Try pulling the beeper out of the board and plugging it back into place, and then upload the program code to the Arduino board.

Good luck to all! We are waiting for your comments on ARDUINO LESSON 11 - BUZZER.

In this article we will tell you what a buzzer is, its areas of application, and how to connect it.

Boozer, Buzzer, Piezoelectric emitter, Squeaker or something else? - there are a large number of names for this little squeaking infection, which indicates that something not very good has happened. How often have I simply hated this buzzer with its nasty squeaking sound. I'm probably not alone in this desire. Surely you have heard an extremely unpleasant pleasant sound that the system mistakenly (or not so much) gave you at the entrance/exit of the store. Agree that this is an extremely unpleasant sound. In a future article, I will call them all a buzzer, as I am accustomed to this name.

A buzzer is a device that allows you to generate a sound of a certain frequency. Typically, the frequency range is in the range from 1 to 10 kHz, and if you come across an audible buzzer, then a characteristic sound comes out: “piiiiiiip.”

It is the easiest way to make a squeak that can be heard well and far. The buzzer does the latter especially well, since standard buzzers create sound waves with an attenuation coefficient of 85-90 dB at 30 cm. As a result, a small buzzer is enough for a small hangar.

I personally got this copy (model sl1i-12fsp):

I conducted all my buzzer tests with him. It turned out that it is clearly audible even in a crowd of screaming children, since the signal contains a high frequency, which is not enough in the human voice. This allows you to almost always tell whether it works or not. If you don’t have a crowd of children, but have a running fan/motor/something similar, then rest assured, you will hear it very well.

Buzzer connection.

The connection to the circuit is carried out like a battery or diode. The device has “+” and “-” symbols. We connect them to a supply voltage of 3 to 20 volts, and enjoy the resulting sound. The buzzer has a slight inertia, and after turning off the power it will sound for some time. Therefore, it won’t be possible to simulate sound on it, but it will work as an alarm system.

They are usually controlled using an amplifier using bipolar transistors with a common emitter. This allows you to make even polyphonic sound from your MK (ARDUINO/SMT32/MSP430). But it is necessary to take into account that there are buzzers with a built-in generator. They squeak intermittently, with a certain frequency. This allows you to use different buzzers that talk about different events. They cost more, but if you are assembling something without a microcontroller, then this is an excellent trick with your ears.

Areas of application of the Buzzer.

I propose to apply this scheme in the following directions:

1) security systems

2) sensors signaling impacts of any kind.

3) household appliances (for example, in microwave ovens, where the signal about the end of work is given by a buzzer).

4) toys.

5) in any devices where sound notification is required.

Personal experience of use.

I have come across buzzers of various designs and characteristics. They always squeaked very stably, and did not require virtually any expensive audio amplifiers. Many developers love them very much, but I have identified a number of difficulties when working with them:

1) Extremely disgusting sound during testing. Of course, if you operate this part once every few days, then nothing, but during tests it will beep constantly, which will inevitably affect your sensitivity and desire to work.

2) Sufficient power consumption for wearable electronics. It’s definitely not worth betting that you will carry such a thing with you.

3) Sufficient inertia. At one time I spent a lot of time making a midi keyboard based on a cheap buzzer. After all my efforts, good sound transmission did not work out, but I was able to restore the music from the old SEGA, which my customer was extremely happy about.

If you add a transistor self-oscillator to a piezoceramic emitter and place them in one housing, you will get an active piezoelectric oscillator. The English name is “buzzer” (“buzz” - to buzz), in slang “buzer”, although more accurately “bazer”. To operate the piezoelectric generator, it is enough to apply a constant voltage of the correct polarity to it, the sound will be generated automatically.

Typical parameters of piezoelectric generators: operating voltage 3; 5; 6; 9; 12; 24 V (Table 2.8), frequency range of the fundamental generation tone 1700…3500 Hz, sound pressure 75…90 dB(A), cost higher than that of piezo emitters.

Table 2.8. Parameters of Kepo Electronic piezoelectric generators

The nominal voltage of the piezoelectric generator is mildly recommended, since there is a certain “safety margin”. For example, the piezoelectric generator SC235 (Sonitron), instead of 12 V, allows operation at a voltage of 2...35 V. Operation with a reduced power supply will be accompanied by a decrease in volume, and it is better not to allow the supply of ultra-high voltages at all. The golden mean is precisely the safe “microcontroller” voltage range of 3…5 V.

Piezo generators are produced in the form of capsules of the following varieties:

Double-output single-frequency, generating the sound of one tone in the frequency range of approximately 2.5...4 kHz with a factory spread of ±15...20%;

Two-output, two-frequency, the sound of which resembles a police siren, a telephone bell, or the trill of a cricket;

Three-terminal multi-frequency, frequency tunable by installing an external selection capacitor.

It is necessary to distinguish “piezo buzzers” from “magnetic buzzers”, which contain an electromagnetic system with a diaphragm and a transistor self-oscillator. The Advanced Acoustic Technology sound generator user manual contains the following distinguishing features:

The operating voltages for “magnetic buzzers” are 1.5…24 V, and for “piezobusers” -

3...220 V, while the efficiency of the latter is 2...3 times higher;

The operating currents for “magnetic boomers” are tens to hundreds, and for “piezobusers” - a few to tens of milliamps;

The diameters of the housings for “magnetic boomers” are 7...25 mm, and for “piezobusers” -

12...50 mm. And most importantly, magnets are attracted to “magnetic buzzers”.

In Fig. 2.51, a...3 shows diagrams for connecting piezoelectric generators to MK. The polarity of their terminals must be marked on the housing. If the “+” and “-” signs are not visible, then most likely it is a piezo emitter. It does not have a built-in generator, so when a constant voltage is applied it will be “silent, like a fish.”

Rice. 2.51. Diagrams for connecting piezoelectric generators to MK (beginning):

a) when connecting piezoelectric generator A1 directly to MK, you must monitor the permissible load current. To avoid “stress” for the port line, install a low-resistance protective resistor R1, which, however, somewhat reduces the sound volume;

b) similar to Fig. 2.51, a, but with the piezoelectric generator A1 connected not to the common wire, but to the power source. As A1 you can use “boosers” with a voltage of 3...12 V;

c) toggle switch S1 in the open state allows you to turn off the sound, but not completely. Thanks to the capacitor C/, the piezoelectric generator A1 produces a sound reminiscent of a quietly ticking clock;

d) “high-voltage” piezoelectric generator A1 is connected via a transistor switch. The maximum collector current of transistor VT1 must be greater than the operating current A1 by a margin. The protective diode VD1 allows you to connect a “magnetic boozer” instead;

e) a multi-frequency three-terminal piezoelectric generator D/ begins to work when the MK line is switched to the Z-state input mode. When the MK output level is LOW, generation stops. Capacitor C1 changes the sound frequency from 100 Hz (0.033 μF) to 2.4 kHz (100 pF);

e) similar to Fig. 2.51, g, but with a low-voltage supply and with the presence of two resistors: R1 (current limiter) and R3 (closes transistor VT1 when MK restarts); ABOUT

About Fig. 2.51. Connection diagrams for piezoelectric generators to MK (end):

g) a full range of protective measures to reduce impulse noise and radio emissions. Diode VD1 prevents voltage surges from entering the +3.6 V power circuit;

h) the intermittent sound of the piezoelectric generator A1 is provided by the flashing LED HL1, which itself does not visually light up due to the small current flowing through it.