PWM output voltage. Accurate and fast digital PWM to analog voltage converter. For the experiment we need

Previously, a circuit with a step-down (or step-up, or multi-winding) transformer, a diode bridge, and a ripple smoothing filter was used to power devices. For stabilization, linear circuits on parametric or integral stabilizers were used. The main disadvantage was low efficiency and high weight and dimensions of powerful power supplies.

All modern household electrical appliances use switching power supplies (UPS, SMPS are the same). Most of these power supplies use a PWM controller as the main control element. In this article we will look at its structure and purpose.

Definition and Key Benefits

A PWM controller is a device that contains a number of circuitry solutions for controlling power switches. In this case, control is based on information received through the circuits feedback by current or voltage - this is necessary to stabilize the output parameters.

Sometimes, PWM controllers are called PWM pulse generators, but they do not have the ability to connect feedback loops, and they are more suitable for voltage regulators than for providing a stable power supply to devices. However, in the literature and Internet portals you can often find names like "PWM controller, on NE555" or "... on arduino" - this is not entirely true for the above reasons, they can only be used to regulate the output parameters, but not to stabilize them.

The abbreviation "PWM" stands for pulse-width modulation - this is one of the methods of signal modulation not due to the magnitude of the output voltage, but precisely due to the change in the pulse width. As a result, a simulated signal is formed due to the integration of pulses using C- or LC-circuits, in other words, due to smoothing.

Conclusion: A PWM controller is a device that controls a PWM signal.

Main characteristics

There are two main characteristics for a PWM signal:

1. Pulse frequency - the operating frequency of the inverter depends on it. Frequencies above 20 kHz are typical, in fact 40-100 kHz.

2. Fill factor and duty cycle. These are two adjacent quantities that characterize the same thing. The fill factor can be denoted by the letter S, and the duty cycle is D.

where T is the signal period,

Part of the time from the period when the control signal is generated at the controller output is always less than 1. The duty cycle is always greater than 1. At a frequency of 100 kHz, the signal period is 10 μs, and the switch is open for 2.5 μs, then the duty cycle is 0.25, in percent - 25 %, and the duty cycle is 4.

It is also important to take into account the internal design and purpose of the number of controlled keys.

Differences from linear loss schemes

As already mentioned, the advantage over linear circuits is high efficiency (more than 80, and currently 90%). This is due to the following:

Let's say the smoothed voltage after the diode bridge is 15V, the load current is 1A. You need to get a stabilized 12V power supply. In fact, a linear stabilizer is a resistance that changes its value depending on the value of the input voltage to obtain the nominal output voltage - with small deviations (fractions of volts) with changes in the input (units and tens of volts).

On resistors, as you know, when flowing through them electric current heat energy is released. The same process takes place on linear stabilizers. The allocated power will be equal to:

Ploss = (Uin-Uout) * I

Since in the considered example the load current is 1A, the input voltage is 15V, and the output voltage is 12V, then we calculate the losses and efficiency of a linear stabilizer (KRENK or L7812 type):

Ploss = (15V-12V) * 1A = 3V * 1A = 3W

Then the efficiency is equal to:

n = Puseful / Pconsum

n = ((12V * 1A) / (15V * 1A)) * 100% = (12W / 15W) * 100% = 80%

The main feature of PWM is that the power element, let it be a MOSFET, is either fully open or completely closed and no current flows through it. Therefore, efficiency losses are due only to conductivity losses

And switching losses. This is a topic for a separate article, so we will not dwell on this issue. Also, losses of the power supply occur (input and output, if the power supply is networked), as well as on conductors, passive filter elements, and so on.

General structure

Consider the general structure of an abstract PWM controller. I used the word "abstract" because, in general, they are all similar, but their functionality may still differ within certain limits, respectively, the structure and conclusions will differ.

Inside the PWM controller, as in any other IC, there is a semiconductor crystal on which a complex circuit is located. The controller includes the following functional units:

1. Pulse generator.

2. Reference voltage source. (AND HE)

3. Circuits for processing the feedback signal (OS): error amplifier, comparator.

4. The pulse generator controls built-in transistors, which are designed to control the power switch or keys.

The number of power switches that a PWM controller can control depends on its purpose. The simplest flyback converters in their circuit contain 1 power switch, half-bridge circuits (push-pull) - 2 keys, bridge - 4.

The choice of a PWM controller also depends on the type of key. To control a bipolar transistor, the main requirement is that the output control current of the PWM controller is not lower than the transistor current divided by H21e; to turn it on and off, it is enough to simply apply pulses to the base. In this case, most controllers will do.

In the case of management, there are certain nuances. For quick disconnection you need to discharge the shutter capacity. To do this, the gate output circuit is made of two keys - one of them is connected to a power source with an IC output and controls the gate (turns on the transistor), and the second is installed between the output and ground, when you need to turn off the power transistor - the first key closes, the second opens, closing the shutter to the ground and discharges it.

Interesting:

In some PWM controllers for low-power power supplies (up to 50 W), built-in and external power switches are not used. Example - 5l0830R

Generally speaking, the PWM controller can be represented as a comparator, one input of which is fed a signal from the feedback circuit (OS), and the second input is a sawtooth variable signal. When the sawtooth signal reaches and exceeds the feedback signal, a pulse appears at the output of the comparator.

When the signals at the inputs change, the pulse width changes. Let's say that you connected a powerful consumer to the power supply, and the voltage dropped at its output, then the OS voltage will also drop. Then, in most of the period, the sawtooth signal will exceed the feedback signal, and the pulse width will increase. All of the above is reflected to some extent in the charts.

Functional diagram of a PWM controller using the TL494 as an example, we will consider it in more detail later. The assignment of pins and individual assemblies is described in the following subheading.

Pin assignment

PWM controllers are available in various packages. They may have conclusions from three to 16 or more. Accordingly, the flexibility of using the controller depends on the number of pins, or rather their purpose. For example, in a popular microcircuit - most often 8 pins, and in an even more iconic one - TL494- 16 or 24.

Therefore, we will consider the typical names of the conclusions and their purpose:

    GND- the common terminal is connected to the minus of the circuit or to ground.

    Uc (Vc)- microcircuit power supply.

    Ucc (Vss, Vcc)- Output for power control. If the power supply sags, then there is a possibility that the power keys will not open completely, and because of this they will start to warm up and burn out. The output is needed to disable the controller in a similar situation.

    OUT- as the name implies, this is the controller output. The PWM control signal for the power switches is output here. We mentioned above that converters of different topologies have a different number of keys. The pin name may differ depending on this. For example, in half-bridge controllers, it may be called HO and LO for high and low keys, respectively. In this case, the output can also be single-ended and push-pull (with one key and two) - to control field-effect transistors (see above for an explanation). But the controller itself can be for single-cycle and push-pull circuit- with one and two output terminals, respectively. It is important.

    Vref- the reference voltage, usually connected to ground through a small capacitor (microfarad units).

    ILIM- signal from the current sensor. Needed to limit the output current. Connects to feedback circuits.

    ILIMREF- it sets the trigger voltage of the ILIM leg

    SS- a signal is generated for a soft start of the controller. Designed for smooth exit to nominal mode... A capacitor is installed between it and the common wire to ensure a smooth start.

    RtCt- pins for connecting a timing RC circuit, which determines the frequency of the PWM signal.

    CLOCK- clock pulses for synchronizing several PWM controllers with each other, then the RC circuit is connected only to the master controller, and RT of the slaves with Vref, CT of the slaves is connected to the common one.

    RAMP is a comparison input. A sawtooth voltage is applied to it, for example, from the Ct pin. When it exceeds the voltage at the error amplification output, a shutdown pulse appears on OUT - the basis for PWM control.

    INV and NONINV- these are the inverting and non-inverting inputs of the comparator, on which the error amplifier is built. In simple words: the higher the voltage on INV - the longer the output pulses and vice versa. The signal from the voltage divider in the feedback circuit from the output is connected to it. Then the non-inverting input NONINV is connected to the common wire - GND.

    EAOUT or Error Amplifier Output Russian Error amplifier output. Despite the fact that there are inputs of the error amplifier and with their help, in principle, it is possible to adjust the output parameters, but the controller reacts rather slowly to this. A slow response can excite the circuit and break it down. Therefore, signals are sent to INV from this pin through frequency-dependent circuits. This is also called error amplifier frequency correction.

Examples of real devices

To consolidate the information, let's look at a few examples of typical PWM controllers and their switching circuits. We will do this using two microcircuits as an example:

    TL494 (its analogues: KA7500B, KR1114EU4, Sharp IR3M02, UA494, Fujitsu MB3759);

They are actively used. By the way, these power supplies have a lot of power (100 W or more on the 12V bus). Often used as a donor for alteration under laboratory unit power supply or universal powerful Charger, for example for car batteries.

TL494 - overview

Let's start with the 494th microcircuit. Its technical characteristics:

In this particular example, you can see most of the conclusions described above:

1. Non-inverting input of the first error comparator

2. Inverting input of the first error comparator

3. Feedback input

4. Dead time adjustment input

5. Lead for connecting an external time-setting capacitor

6. Lead for connecting a timing resistor

7. General output of the microcircuit, minus power supply

8. Conclusion of the collector of the first output transistor

9. Lead of the emitter of the first output transistor

10. Lead of the emitter of the second output transistor

11. Conclusion of the collector of the second output transistor

12. Power supply input

13. Input for selecting a single-stroke or two-stroke mode of operation of the microcircuit

14. Output of the built-in 5 volt reference voltage

15. Inverting input of the second error comparator

16. Non-inverting input of the second error comparator

The figure below shows an example of a computer power supply on this microcircuit.

UC3843 - overview

Another popular PWM is the 3843 microcircuit - it also builds computer and not only power supplies. Its pinout is located below, as you can see, it has only 8 pins, but it performs the same functions as the previous IC.

Interesting:

There is a UC3843 in a 14-foot case, but they are much less common. Pay attention to the marking - additional pins are either duplicated or not used (NC).

Let's decipher the purpose of the conclusions:

1. Comparator input (error amplifier).

2. Feedback voltage input. This voltage is compared with the reference voltage inside the IC.

3. Current sensor. It is connected to a resistor between the power transistor and the common wire. Needed for overload protection.

4. Timing RC-circuit. With its help, the operating frequency of the IC is set.

6. Exit. Control voltage. It is connected to the gate of the transistor, here is a push-pull output stage for driving a single-ended converter (one transistor), which can be seen in the figure below.

Buck, Boost and Buck-Boost types.

Perhaps one of the most successful examples will be the widespread LM2596 microcircuit, on the basis of which you can find a lot of such converters on the market, as shown below.

Such a microcircuit contains all the above-described technical solutions, and also instead of an output stage on low-power switches, it has a built-in power switch capable of withstanding a current of up to 3A. The internal structure of such a converter is shown below.

One can be convinced that in essence there are no special differences from those considered in it.

And here is an example on a similar controller, as you can see there is no power switch, but only a 5L0380R microcircuit with four pins. It follows from this that in certain tasks the complex circuitry and flexibility of the TL494 is simply not needed. This is true for low-power power supplies where there are no special requirements for noise and interference, and the output ripple can be suppressed by an LC filter. This is a power supply for LED strips, laptops, DVD players and more.

Conclusion

At the beginning of the article, it was said that a PWM controller is a device that simulates the average voltage value by changing the pulse width based on the signal from the feedback circuit. I note that the names and classification of each author are often different, sometimes a simple PWM voltage regulator is called a PWM controller, and the family described in this article electronic microcircuits called "Integral Subsystem for Pulse Stabilized Converters". The essence does not change from the name, but disputes and misunderstandings arise.

Main technical parameters:

  • a) PWM frequency - 400 Hz signal
  • b) The number of PWM gradations - signal 16
  • c) PWM - controller based on TTL / 74XX subtractive counter
  • e) PWM - the controller is to be developed on TTL / 74XX microcircuits of the SN74 series. Carry out the development of the main blocks of the controller on logical elements - Logic Gates (Ideal) and on D-flip-flops (Ideal), draw up diagrams of controller blocks on real TTL ICs - 4-LE and 2-D flip-flops in a case of a given series.
  • d) Prepare custom microcircuits for the main blocks of the controller - clock pulse generator, frequency divider and main unit.

Primary requirements:

Draw up the structural and schematic diagrams of the controller, test individual blocks in the EWB software environment, make an informed choice of the necessary microcircuits.

Provide a principled electrical circuit PWM - controller.

Digital PWM - controller

PWM (pulse width modulation), eng. PWM - pulse width modulation. PWM is a digital signal with which you can set and control the level analog signal using keys.

Fig. 1.

This is especially important in powerful regulators with high efficiency, since the keys dissipate the minimum power only at the moment of switching.

Figure 1 shows a PWM timing diagram with a constant duty cycle. One period contains one single pulse of width T1 and one zero pulse of width T0. Wherein

The PWM period -.T, and, therefore, the pulse repetition rate F = 1 / T is a constant value. The PWM factor G is the analog signal amplitude equivalent:

By changing the pulse duration T 1, you can adjust the average voltage level: if the level of the maximum PWM signal Um = Ep, then by applying the PWM signal to the voltage filter, at the filter output you can get analog voltage

In some cases, the use of a filter is optional - for example, when regulating the current to control the brightness of the lamp glow, the speed of the motor, since they have a certain time constant, and if the PWM period is less than this constant, then there will be no flickering or vibration of the motor. But in some cases, you can't do without a filter. Naturally, the shorter the PWM period, the "smoother" the analog signal will be, but a decrease in the period leads to the fact that the discreteness of the duty cycle increases, the pulse repetition rate F increases and, accordingly, the power losses on the keys increase, and the efficiency decreases.

Analog signal to PWM pulse converters are called PWM - modulators, since they are widely used in pulse-code communication, the simplest automation devices. Converters of binary code into PWM pulses have become especially widespread with the development of microprocessor technology, they are built-in devices of most modern microcontrollers. In the literature received the name PWM - controllers.

Analog-to-digital PWM modulators and digital PWM controllers have a lot in common (see Fig. 2). The clock generator sets the period (T) and the PWM pulse repetition rate (F = 1 / T). The ramp generator generates a ramp signal. The comparator fixes the moment in time when the ramp signal reaches the level of the control signal Uo. At the output, a pulse signal is generated from the beginning of the time base to the moment of equality. In PWM - modulators, the control signal is analog, in PWM - controllers - digital. This defines the specific circuitry (analog or digital) of the sawtooth generator and comparison circuits.

Dear Bobot, could you tell us a little more about impulses?

It's good that you asked, Buddy Babot. Since it is the pulses that are the main carriers of information in digital electronics, it is therefore very important to know the different characteristics of the pulses. Let's start with a single pulse.

An electrical impulse is a surge of voltage or current in a certain and finite period of time.

A pulse always has a beginning (rising edge) and an end (falling edge).
You probably already know that in digital electronics all signals can be represented by only two voltage levels: "logical unit" and "logical zero". These are just conditional voltage values. A "logical unit" is assigned a high voltage level, usually about 2-3 volts, a "logical zero" is a voltage close to zero. Digital pulses are graphically depicted as rectangular or trapezoidal in shape:

The main value of a single pulse is its length. The pulse length is the time interval during which the considered logic level has one stable state. In the figure, the Latin letter t marks the pulse length high level, that is, logical "1". Pulse length is measured in seconds, but more often in milliseconds (ms), microseconds (μs), and even nanoseconds (ns). One nanosecond is a very short time span!
Remember: 1 ms = 0.001 sec.
1 μs = 0.000001 sec
1 ns = 0.000000001 sec

English-language abbreviations are also used: ms - millisecond, μs - microsecond, ns - nanosecond.

I won't even have time to utter a peep in one nanosecond!
Tell me, Bobot, what happens if there are a lot of impulses?

Good question, Bibot! The more impulses, the more information can be transmitted by them. Many impulses have many characteristics. The simplest is the pulse repetition rate.
The pulse repetition rate is the number of total pulses per unit of time. It is customary to take one second per unit of time. The unit of measurement for frequency is hertz, after the German physicist Heinrich Hertz. One hertz is the registration of one full pulse in one second. If there are a thousand oscillations per second, it will be 1000 hertz, or 1000 Hz for short, which is equal to 1 kilohertz, 1 kHz. You can also find an English-language abbreviation: Hz - Hz. The frequency is indicated by the letter F.

There are several more characteristics that appear only with the participation of two or more impulses. One of such important parameters of the pulse train is the period.
A pulse period is a time interval between two characteristic points of two adjacent pulses. Usually the period is measured between two edges or two falls of adjacent pulses and is denoted by a capital Latin letter T.


The pulse repetition period is directly related to the frequency of the pulse train, and it can be calculated using the formula: T = 1 / F
If the pulse length t exactly equal to half the period T, then such a signal is often called " meander".

The duty cycle is the ratio of the pulse repetition period to their duration and is denoted by the letter S: S = T / t The duty cycle is a dimensionless quantity and has no units of measurement, but can be expressed as a percentage. Often in English texts, the term Duty cycle is found, this is the so-called fill factor.
The duty cycle D is the reciprocal of the duty cycle. The fill factor is usually expressed as a percentage and is calculated using the formula: D = 1 / S

Dear Bobot, there are so many different and interesting things about simple impulses! But slowly I am already starting to get confused.

Buddy, Bibot, you have correctly noticed that the impulses are not so simple! But just a little bit remained.

If you listened to me carefully, then you might have noticed that if you increase or decrease the pulse length and at the same time decrease or increase the pause between pulses by the same amount, then the pulse repetition period and frequency will remain unchanged! This is a very important fact that we will need more than once in the future.

But now I also want to add other ways of transmitting information using impulses.
For example, several pulses can be combined into groups. Such groups with pauses of a certain length between them are called packs or packets. By generating a different number of pulses in a group and varying it, you can also transmit any information.


To transmit information in digital electronics (also called discrete electronics), you can use two or more conductors or channels with different pulse signals. In this case, information is transmitted taking into account certain rules. This method allows you to significantly increase the speed of information transfer or adds the ability to control the flow of information between different schemes.

The listed possibilities of transmitting information using pulses can be used both separately and in combination with each other.
There are also many standards for transmitting information using pulses, for example, I2C, SPI, CAN, USB, LPT.

A good definition of Pulse Width Modulation (PWM) lies in its very name. This means modulating (changing) the pulse width (not frequency). To better understand what is PWM Let's see some of the highlights first.

Microcontrollers are intelligent digital components that operate on binary signals. The best representation of a binary signal is a square wave (square wave). The following diagram explains the basic terms associated with a square wave.

In a PWM signal, time (period) and therefore frequency is always constant. Only the on time and the off time of the impulse (duty cycle) are changed. Using this method modulation, we can get the voltage we need.

The only difference between a square wave and a PWM signal is that a square wave has the same on and off times (50% duty cycle), while a PWM signal has a variable duty cycle.

A square wave can be viewed as a special case of a PWM signal that has a 50% duty cycle (on period = off period).

Let's consider using PWM as an example.

Let's say we have a supply voltage of 50 volts and we need to power some load operating from 40 volts. In this case good way getting 40V from 50V is to use the so-called step-down chopper (breaker).

The PWM signal generated by the chapper goes to the power unit of the circuit (thyristor, field-effect transistor), which in turn controls the load. This PWM signal can easily be generated by a microcontroller with a timer.

Requirements for a PWM signal to receive a 40V from 50V using a thyristor: power on, for a time = 400ms and off for a time = 100ms (taking into account the PWM signal period equal to 500ms).

In general terms, this can be easily explained as follows: basically, a thyristor works like a switch. The load receives a supply voltage from a source through a thyristor. When the thyristor is in the off state, the load is not connected to the source, and when the thyristor is in the open state, the load is connected to the source.

This process of turning the thyristor on and off is carried out by means of a PWM signal.

The ratio of the period of a PWM signal to its duration is called the signal duty cycle, and the inverse to the duty cycle is called the duty cycle.

If the duty cycle is 100, then in this case we have a constant signal.

Thus, the duty cycle (duty cycle) can be calculated using the following formula:

Using the above formulas, we can calculate the turn-on time of the thyristor to obtain the voltage we need.

By multiplying the duty cycle by 100, we can represent this as a percentage. Thus, the percentage of the duty cycle of the pulses is directly proportional to the magnitude of the voltage from the original. In the example above, if we want to get 40 volts from a 50 volt power supply, then this can be achieved by generating a signal with a duty cycle of 80%. Because 80% of 50 instead of 40.

To consolidate the material, we will solve the following problem:

  • Let's calculate the duration of switching on and off a signal with a frequency of 50 Hz and a duty cycle of 60%.

The resulting PWM waveform will look like this:

One of best examples The application of pulse width modulation is the use of PWM to adjust the speed of a motor or the brightness of an LED.

This technique of varying the pulse width to obtain the required duty cycle is called “pulse width modulation”.

On the forum quite often there are questions about the implementation of Pulse Width Modulation on microcontroller devices. I myself asked a lot about this and, having figured it out, decided to make it easier for beginners in this area, since there is a lot of information on the network and it is designed for developers of different levels, and I myself just figured it out and my memory is still fresh.

Since the most important thing for me was the use of PWM precisely to control the brightness of the LEDs, then I will use them in the examples. We will use our beloved ATmega8 as a microcontroller.

First, let's remember what PWM is. A PWM signal is a pulse signal of a certain frequency and duty cycle:

Frequency is the number of periods in one second. The duty cycle is the ratio of the pulse duration to the period duration. You can change both, but to control the LEDs, it is enough to control the duty cycle. In the picture above, we see a PWM signal with a duty cycle of 50%, since the pulse width (pulse width) is exactly half of the period. Accordingly, the LED will be on exactly half the time and half off. The PWM frequency is very high and the eye will not notice the flickering of the LED due to the inertia of our vision, so it will seem to us that the LED is shining at half the brightness. If we change the duty cycle to 75%, then the LED brightness will be 3 quarters of full, and the graph will look like this:

It turns out that we can adjust the brightness of the LED from 0 to 100%. Now let's talk about such a PWM parameter as resolution. Resolution is the number of gradations (steps) of duty cycle adjustment, we will consider a resolution of 256 steps.

We sort of figured out the parameters, now let's talk about how we can get this same PWM from the microcontroller. We take a sharply sharpened heated soldering iron and begin to torture the MK, at the same time grabbing its two legs with an oscilloscope and checking for the presence of a signal of the duty cycle we need on them. Microcontrollers have hardware support for PWM and several channels for it, in our case 3. Certain MC pins are responsible for issuing PWM, in our case OC2, OC1A, OC1B (15,16,17 feet in a DIP package). Microcontroller timers are also used for this, in our case TC1, TC2. So how do you configure the MCU to provide the required duty cycle? Everything is very simple, first, let's configure the legs we need for the exit:

PORTB = 0x00; DDRB = 0x0E; // 0b00001110

Next, let's start configuring the timers. For the TC1 timer, we need two registers: TCCR1A and TCCR1B. Open the datasheet and read how these registers are configured. I set it up for an 8-bit PWM signal, which equates to a resolution of 256 steps:

TCCR1A = 0xA1; TCCR1B = 0x09;

For timer TC2 we will use register TCCR2 = 0x69 ;. Its setup looks like this:

TCCR2 = 0x69;

That's it, the timers are configured. The duty cycle will be set with registers OCR1A, OCR1B, OCR2:

Let's set the required duty cycle:

OCR1A = 0x32; // 50 steps OCR1B = 0x6A; // 106 steps OCR2 = 0xF0; // 240 steps

Well, let's put the increment and decrement of these registers in an infinite loop:

While (1) (OCR1A ++; OCR1B--; OCR2 ++; delay_ms (50);)

The first test program is ready and looks like this for CVAVR:

#include "mega8.h" #include "delay.h" void main (void) (PORTB = 0x00; DDRB = 0x0E; // 0b00001110 TCCR1A = 0xA1; TCCR1B = 0x09; TCCR2 = 0x69; OCR1A = 0x32; // 50 OCR1B steps = 0x6A; // 106 OCR2 steps = 0xF0; // 240 steps while (1) (OCR1A ++; OCR1B--; OCR2 ++; delay_ms (50););)