Switching power supply with microcontroller control. Laboratory power supply unit with indication on a microcontroller

Tell in:

The output voltage of the power supply can be changed in the range of 1.25 ... 26 V, the maximum output current is 2 A. The operating threshold of the current protection can be changed in the range of 0.01 ... 2 A with a step of 0.01 A, and response delay - within 1 ... 10 ms in 1 ms steps and 10 ... 100 ms in 10 ms steps. The voltage stabilizer (Fig. 1) is assembled on the LT1084-ADJ (DA2) microcircuit. It provides an output current of up to 5 A and has built-in protection units both against overheating (response temperature about 150 ° C) and against overcurrent. Moreover, the current protection threshold depends on the voltage drop across the microcircuit (the difference between the input and output voltages). If the voltage drop does not exceed 10 V, the maximum output current can reach 5 A, with an increase in this voltage to 15 V it will decrease to 3 ... 4 A, and at a voltage of 17 ... 18 V and more it will not exceed 1 A. the output voltage in the range 1.25 ... 26 V is carried out with a variable resistor R8.

To provide an output current of up to 2 A in the power supply in the entire range of output voltages, a stepwise voltage change at the input of the DA2 stabilizer is applied. Four full-wave rectifiers are assembled on a step-down transformer T1 and diodes VD1-VD8. A rectifier on diodes VD1, VD2 and a voltage stabilizer DA1 are designed to power the DD1 microcontroller, DA3 op-amp and the HG1 digital indicator. The output voltage of the rectifier on diodes VD5, VD6 is 9 ... 10 V, on diodes VD4, VD7 - 18 ... 20 V, and on VD3, VD8 - 27 ... 30 V. Outputs of these three rectifiers, depending on values \u200b\u200bof the output voltage of the power supply, through field effect transistors opto-relay U1-U3 can be connected to the smoothing capacitor C4 and the input of the stabilizer DA2. The opto-relay is controlled by the DD1 microcontroller.

The switching transistor VT1 performs the function of an electronic key; it, at the command of the microcontroller DD1, connects or disconnects the voltage of the stabilizer from the output (XS1 socket) of the power supply. A current sensor is assembled on resistor R14, the voltage across it depends on the output current. This voltage is amplified by a scaling amplifier. direct current on op-amp DA3.1 and from the output of the buffer amplifier to op-amp DA3.2 is fed to the PCO line (pin 23) of the microcontroller DD1, which is configured as an input of the built-in ADC. The display of the operating modes of the power supply, as well as the current values \u200b\u200bof current and voltage, is carried out by the LCD indicator HG1.

When the power supply is turned on at the output of the RSZ microcontroller DD1, regardless of the output voltage, a high logic level, the field-effect transistors of the optocoupler U1 will open and a rectifier on diodes VD3, VD8 (27 ... 30 V) will be connected to the input of the stabilizer DA2. Next, the output voltage of the unit is measured using the ADC built into the DD1 microcontroller. This voltage is fed to the resistive divider R9R11R12, and from the slider of the adjusted resistor R11, the already reduced voltage is fed to the PC1 line of the microcontroller, which is configured as an ADC input.

During operation, the output voltage is constantly measured, and a corresponding rectifier will be connected to the input of the stabilizer. Due to this, the difference between the input and output voltages of the DA2 stabilizer does not exceed 10 ... 12 V, which makes it possible to provide the maximum output current at any output voltage. In addition, it significantly reduces the heating of the DA2 stabilizer.

If the unit's output voltage is less than 5.7 V, high level will be at the output of PC5 of the microcontroller DD1, and at the outputs of PC3 and PC4 it will be low, therefore, a voltage of 9 ... 10V will be supplied to the input of the DA2 stabilizer from a rectifier on diodes VD5, VD6. In the range of output voltages of 5.7 ... 13.7 V, a voltage of 18 ... 20 V will be applied to the stabilizer from the rectifier on the diodes VD4, VD7. With an output voltage of more than 13.7 V, a voltage of 27 ... 30 V will be applied to the DA2 stabilizer from the rectifier on the VD3, VD8 diodes. The switching threshold voltages can be changed in the menu initial settings from 1 to 50 V.

At the same time, the output current is measured; if it exceeds a predetermined value, a low logic level will be set at the PC2 output, the VT1 transistor will close and the voltage will not go to the output of the power supply. When the consumed current is pulsating, its peak value is indicated.
Immediately after turning on the power supply, the transistor VT1 is closed, and no voltage is supplied to the output. The program is in the mode of setting the protection operation current and the delay time (if required), the HG1 LCD indicator will display the message:

PROTECTION
I \u003d 0.00A

and after pressing the SB3 button with a blinking high-order digit:

DELAY 1ms

In the first case, one of the three digits flashes, the current value in this digit is changed by pressing the SB1 "+" or SB2 "-" button. The selection of this category is carried out by pressing the SB3 "Select" button. To disable protection, you must press the SB2 "-" button until the message appears on the screen:
U \u003d 10.0V
z off z

After setting the required protection operation current, press the SB3 "Select" button and hold it for about a second - the device will go into operating mode, the VT1 transistor will open and the HG1 LCD indicator will display the current voltage and current values:
U \u003d 10.0V
I \u003d 0.00A

When the delay is enabled, in addition to the voltage and current values, a blinking exclamation mark will be displayed as a reminder:
U \u003d 10.0V
I 0.00A!

If the protection is disabled, instead exclamation mark a flashing lightning symbol appears.
If the output current is equal to or exceeds the set value of the protection operation current, the transistor VT1 will close and a message will appear on the screen:
PROTECTION
I \u003d 1.00A

Moreover, the word "PROTECTION" will be blinking. After a short press on any of the buttons, the device will return to the protection operation current setting mode.
If in the operating mode press the SB1 "+" or SB2 "-" button, the section for setting the time delay of the current protection operation will turn on and the message will appear on the indicator:
DELAY 1ms

Pressing the SB1 "+" or SB2 "-" button changes the delay in the range from 1 ms to 10 ms in 1 ms steps and from 10 to 100 ms in 10 ms steps. The overcurrent protection operation delay works as follows. If the output current becomes equal to or exceeds the set value, a pause of the set duration (from 1 to 100 ms) will be made, after which the measurement is performed again. If the current is still equal to or exceeds the set value, the transistor VT1 will close and the load will be de-energized. If, during this time interval, the output current becomes less than the pickup current, the device will remain in operation. To turn off the delay, you must decrease its value by pressing the SB2 "-" button until the message appears on the screen:
DELAY OFF

In the operating mode, you can manually turn off the output voltage and go to the protection current setting mode, for this you need to press the SB3 "Select" button.
The program has a menu of initial settings, in order to enter it, you must turn on the power supply while holding down the SB3 "Select" button. The menu for setting the clock frequency of the built-in ADC of the microcontroller DD1 will be displayed first:
CLOCK ADC 500kHz

By pressing the SB1 "+" or SB2 "-" button, you can select three values \u200b\u200bof the clock frequency of the built-in ADC: 500 kHz, 1 MHz and 2 MHz. At a frequency of 500 kHz, the response time of the protection is 64 μs, at frequencies of 1 and 2 MHz - 36 and 22 μs, respectively. It is best to calibrate the device at 500 kHz (set by default).

To move to next setting, press the SB3 "Select" button, and a message will appear:
STUPENB2
FROM 5.7V

In this section of the menu, you can change (by pressing the SB1 "+" or SB2 "-" button) the value of the output voltage at which a particular rectifier is connected to the input of the DA2 stabilizer. The next time you press the SB3 "Select" button, the menu for setting this switching threshold will appear:
STEP
FROM 13,7V

When you go to the next section of the menu, the transistor VT1 will open, and the current protection will be disabled. A message will appear: U \u003d 10.0V * I \u003d 0, OOA *
In this section, the value of the coefficient k is changed, which is used in the program to correct the readings of the output voltage depending on the output current. The fact is that across the resistor R14 and the transistor VT1 at the maximum output current, the voltage drop is up to 0.5 V. Since the resistive divider R9R11R12 is used to measure the output voltage, connected to the resistor R14 and the transistor VT1, in the program, depending on the flowing current , this voltage drop is calculated and subtracted from the measured voltage value. When you press the SB1 "+" or SB2 "-" button, the indicator instead of the current value will display the value of the coefficient k:
U \u003d 10.0V * k \u003d 80

By default it is equal to 80, it is changed by pressing the SB1 "+" or SB2 "-" button.
When you next press the SB3 "Select" button, the DD1 microcontroller will restart, with all installed settings will be saved in its non-volatile memory and will be used during subsequent launches.




Most of the parts, including the T1 transformer, are placed on the breadboard printed circuit board (fig. 2). Wired installation was used. Capacitors C5 and C7 are installed as close as possible to the terminals of the DA2 stabilizer. The front panel (Fig. 3) contains an indicator, power switch, variable resistor, buttons and output sockets.


Fixed resistors MLT, C2-23 were used, except for the resistor R14 - it is SQP-15 type, multi-turn trimmer resistors - SP5-2, variable resistor - SPZ-1, SPZ-400, the engine of which is driven through a gear train with a gear ratio, equal to three (Fig. 4). The result is a three-turn variable resistor that allows you to quickly and at the same time accurately change the voltage at the output of the stabilizer.

It is advisable to use tantalum capacitors C5, C7, oxide capacitors - imported, the rest - K10-17. Instead of what is indicated on the diagram, you can use an LCD indicator (two lines of eight characters each) with an English-Russian character set on the KS0066, HD47780 controllers, for example, WH0802A-YGH-CT from Winstar. Diodes 1N4005 are replaceable with diodes 1N4002-1N4007, 1N5819, diodes P600V - for P600DP600M, 1 N5401-1 N5408.

The LT1084 stabilizer is attached to the metal case of the device through a heat-conducting insulating gasket, which acts as a heat sink, this stabilizer can be replaced with the LM1084, but it must be necessarily with an adjustable output voltage (with the ADJ index). The domestic analogue is the KR142EN22A microcircuit, but its performance in this device has not been tested. The 7805 stabilizer can be replaced with the domestic KR142EN5A.

Choke L1 - domestic DM-0.1 or imported EC-24, it can be replaced with a 100 Ohm resistor. Quartz resonator ZQ1 - RG-05, HC-49U. Buttons - any with a normally open contact, for example SDTM-630-N, power switch - B100G. A transformer was used, the type of which is unknown (only the parameters of the secondary winding are indicated - 24 V, 2.5 A), but in terms of dimensions it is similar to the TTP-60 transformer. The secondary has been removed and two new ones have been wound. To determine the required number of turns before removing the winding, the output voltage was measured and the number of turns per 1 V of voltage was found. Then, with a PEV-2 0.7 ... 0.8 wire, two windings with two taps each are simultaneously wound. The number of turns should be such that the first taps of both windings have a voltage of 9 V, and the second - 18V. In the author's version, each of the windings contained 162 turns with taps from the 54th and 108th turns.

Establishment begins without the installed microcontroller, op-amp and indicator with checking the constant voltages at the outputs of the rectifiers and the DA1 stabilizer. When programming the microcontroller, you must set the configuration bits (fuse bits):
CKSELO - 1;
CKSEL1 - 1;
CKSEL2-1;
CKSEL3-1;
SUT1 - 1;
BOOTRST - 1;
EESAVE - 1;
WDTON - 1;
RSTDISBL - 1;
SUTO - 0;
BODEN - 0;
BODLEVEL - 0;
BOOTSZO - 0;
BOOTSZ1 - 0;
CKOPT - 0;
SPIEN - 0.

The microcontroller can be programmed in-circuit, while the programmer is connected to the XP2 plug. In this case, the microcontroller is powered from the power supply.
After installing the microcontroller and the op-amp, connect the indicator and turn on the device (without load) by holding down the SB3 "Select" button, while the microcontroller program will enter the initial settings mode. Resistor R16 sets the desired contrast of the indicator image, and by selecting resistor R18 - the brightness of the display panel illumination.

Further, by pressing the SB3 "Select" button, you must select the section for setting the coefficient k in the menu. An exemplary voltmeter is connected to the output of the device and the output voltage is set close to the maximum. Resistor R11 equalizes the readings of the indicator and voltmeter. In this case, the output current must be zero.

Then set the minimum output voltage (1.25V) and connect a series-connected exemplary ammeter and a load resistor with a resistance of about 10 ohms and a power of 40 ... 50 watts to the output. By changing the output voltage, the output current is set to about 2 A and the resistor R17 bring the indicator readings in line with the ammeter readings. After that, a 1 kΩ resistor is connected in series with the ammeter and the output current is set to 10 mA by changing the output voltage. The indicator should have the same current value; if this is not so and the readings are less, it is necessary between the output of the stabilizer DA1 and the source of the transistor VT1 to install a resistor with a resistance of 300 ... 1000 Ohm and its selection to equalize the readings of the indicator and ammeter. Temporarily, you can use a variable resistor, then replacing it with a constant one with the appropriate resistance.

In conclusion, the value of the coefficient k is specified. To do this, a reference voltmeter and a powerful load resistor are again connected to the output. By varying the output voltage, the output current is set close to the maximum. By pressing the SB1 "+" or SB2 "-" button, the coefficient k is changed so that the readings of the indicator and voltmeter coincide. After pressing the SB3 "Select" button, the microcontroller will reboot and the power supply will be ready for operation.
It should be noted that the maximum output current (2 A) is limited by the type of opto-relays used and can be increased to 2.5 A if they are replaced with more powerful ones.

ARCHIVE: Download from server


D. MALTSEV, Moscow
"Radio" No. 12 2008
Section:
Score 1 Score 2 Score 3 Score 4 Score 5

A good, reliable and easy-to-use power supply is the most important and frequently used device in every ham radio lab.

An industrial stabilized power supply is a rather expensive device. By using a microcontroller in the design of a power supply, it is possible to build a device that has many additional functions, is easy to manufacture and very affordable.

This digital DC power supply has been a very successful product and its third version is now available. It is still based on the same idea as the first variant, but comes with a number of nice improvements.

Introduction

This PSU is the least complicated to make than most other circuits, but it has many more features:

The display shows the current measured voltage and current values.
- The display shows the preset voltage and current limits.
- Only standard components are used (no special chips).
- Single polarity supply voltage required (no separate negative supply voltage for op amps or control logic)
- You can control the power supply from your computer. You can read current and voltage, and you can set them with simple commands. This is very useful for automated testing.
- Small keyboard for direct input of the desired voltage and maximum current.
- It's a really small but powerful power supply.

Is it possible to remove some components or add additional functions? The trick is to move the functionality of analog components such as operational amplifiers into a microcontroller. In other words, the complexity of software and algorithms increases and hardware complexity decreases. This reduces the overall complexity for you, since software can just be downloaded.

Basic electrical project ideas

Let's start with the simplest stabilized power supply. It consists of 2 main parts: a transistor and a zener diode, which creates a reference voltage.

The output voltage of this circuit will be Uref minus 0.7 Volts, which drops between B and E across the transistor. The zener diode and resistor create a reference voltage that is stable even if there are voltage surges at the input. The transistor is necessary for switching large currents that the zener diode and resistor cannot provide. In this role, the transistor only amplifies the current. To calculate the current across the resistor and zener diode, you need to divide the output current by the HFE of the transistor (the HFE number, which can be found in the table with the characteristics of the transistor).

What are the problems with this circuit?

The transistor will burn out when there is a short circuit at the output.
- It only provides a fixed output voltage.

These are rather severe limitations that make this circuit unsuitable for our project, but it is the basis for designing an electronically controlled power supply.

To overcome these problems, it is necessary to use "intelligence", which will regulate the output current and change reference voltage... That's it (... and this makes the circuit much more complicated).

In the past few decades, people have been using operational amplifiers to provide this algorithm. Operational amplifiers, in principle, can be used as analog calculators for addition, subtraction, multiplication, or for performing a logical "or" operation of voltages and currents.

Nowadays, all these operations can be quickly performed using a microcontroller. The beauty is that you get a voltmeter and ammeter as a free add-on. In any case, the microcontroller must know the output parameters of the current and voltage. You just need to display them. What we need from the microcontroller:

ADC (analog-to-digital converter) for measuring voltage and current.
- DAC (digital-to-analog converter) for controlling the transistor (adjusting the reference voltage).

The problem is, the DAC has to be very fast. If a short circuit is detected at the output, then we must immediately reduce the voltage at the base of the transistor, otherwise it will burn out. The response speed should be within milliseconds (as fast as an op-amp).

The ATmega8 has an ADC which is fast enough and at first glance it doesn't have a DAC. You can use pulse width modulation (PWM) and an analog low pass filter to get a DAC, but the PWM itself is too slow in software to implement short circuit protection. How to build a fast DAC?

There are many ways to create digital-to-analog converters, but it should be fast and simple, which will easily interact with our microcontroller. There is a converter circuit known as an "R-2R matrix". It only consists of resistors and switches. There are two types of resistor ratings. One with an R value and one with twice the R value.

Above is the schematic of a 3-bit R2R-DAC. The logic control switches between GND and Vcc. A logic one connects the switch to Vcc, and a logic zero connects to GND. What does this circuit do? It adjusts the voltage in Vcc / 8 steps. The total output voltage is:

Uout \u003d Z * (Vcc / (Zmax +1), where Z is the resolution of the DAC (0-7), in this case 3-bit.

The internal resistance of the circuit, as you can see, will be equal to R.

Instead of using a separate switch, you can connect an R-2R matrix to the microcontroller port lines.

Generating a DC signal of different levels using PWM (Pulse Width Modulation)

Pulse width modulation is a technique where pulses are generated and passed through a low pass filter at a cutoff frequency significantly lower than the pulse frequency. As a result, the DC current and voltage signal depends on the width of these pulses.

The Atmega8 has hardware 16-bit PWM. That is, it is theoretically possible to have a 16-bit DAC with a small number of components. To get a real DC signal from a PWM signal, you need to filter it, this can be a problem when high resolutions... The more precision you need, the lower the frequency of the PWM signal should be. This means that capacitors are needed large capacity, and the response time is very slow. The first and second versions of the digital DC power supply were built on a 10-bit R2R matrix. That is, the maximum output voltage can be set in 1024 steps. If you use an ATmega8 with an 8 MHz clock and 10 bit PWM, the PWM signal will be 8MHz / 1024 \u003d 7.8KHz. To get the most good signal DC must be filtered with a second order filter of 700 Hz or less.

You can imagine what would happen if you use 16-bit PWM. 8MHz / 65536 \u003d 122Hz. Below 12Hz is what you need.

Combining R2R-matrix and PWM

PWM and R2R matrix can be used together. In this project, we will be using a 7-bit R2R matrix combined with a 5-bit PWM signal. FROM clock frequency controller 8 MHz and 5-bit resolution, we get a signal of 250 kHz. The 250 kHz frequency can be converted to a DC signal using a small number of capacitors.

The original version of the digital DC power supply used a 10-bit DAC based on an R2R matrix. In the new design, we use an R2R matrix and a PWM with general permission 12 bit.

Resampling

Some processing time can increase the resolution of the analog-to-digital converter (ADC). This is called oversampling. Quadruple oversampling results in double resolution. That is: 4 consecutive samples can be used to get twice as many steps per ADC. The theory behind oversampling is explained in PDF documentwhich you can find at the end of this article. We use oversampling for the control loop voltage. For the current control loop we use the original resolution of the ADC as fast response time is more important here than resolution.

Detailed project description

Several technical details are still missing:

DAC (digital to analog converter) cannot drive the power transistor
- The microcontroller operates from 5V, which means that the maximum DAC output is 5V, and the maximum output voltage on the power transistor will be 5 - 0.7 \u003d 4.3V.

To fix this, we must add current and voltage amplifiers.

Adding an amplifier stage to the DAC

When adding an amplifier we have to keep in mind that it has to handle large signals. Most amplifier designs (for example, for audio) are made with the assumption that the signals will be small compared to the supply voltage. So forget all the classic books on calculating an amplifier for a power transistor.

We could use op-amps, but those will require additional positive and negative supply voltages, which we want to avoid.

There is also an additional requirement that the amplifier must amplify the voltage from zero in a stable state without oscillation. Simply put, there should be no voltage fluctuation at power-up.

Below is a schematic diagram of an amplifier stage that is suitable for this purpose.

Let's start with the power transistor. We are using BD245 (Q1). According to the characteristics, the transistor has HFE \u003d 20 at 3A. Therefore, it will draw about 150mA at the base. To amplify the driving current we use a coupler known as the "Darlington transistor". For this we use a medium power transistor. Typically, the HFE should be between 50-100. This will reduce the required current to 3 mA (150 mA / 50). The 3mA current is a signal coming from low power transistors such as the BC547 / BC557. Transistors with such an output current are very well suited for building a voltage amplifier.

To get 30V output we have to amplify the 5V from the DAC by a factor of 6. To do this, we combine PNP and NPN transistors as shown above. The gain voltage of this circuit is calculated:

Vampl \u003d (R6 + R7) / R7

The power supply can be available in 2 versions: with a maximum output voltage of 30 and 22V. Combining 1K and 6.8K gives a factor of 7.8, which is good for the 30V version, but there may be some losses at higher currents (our formula is linear, but not really). For the 22V version, we use 1K and 4.7K.

The internal resistance of the circuit as shown on the BC547 base will be:

Rin \u003d hfe1 * S1 * R7 * R5 \u003d 100 * 50 * 1K * 47K \u003d 235 MΩ

HFE approximately 100 to 200 for BC547 transistor
- S is the slope of the transistor gain curve and about 50 [unit \u003d 1 / Ohm]

This is more than high enough to be connected to our DAC, which has an internal resistance of 5kΩ.

Internal equivalent resistance of the output:

Rout \u003d (R6 + R7) / (S1 + S2 * R5 * R7) \u003d about 2Ω

Low enough to use Q2.

R5 connects the base of the BC557 to the emitter, which means "off" for the transistor before the DAC and BC547 come up. R7 and R6 tie the base of Q2 first to ground, which turns the Darlington output stage down.

In other words, every component in this amplifier stage is initially off. This means that we will not receive any input and output oscillations from the transistors when the power is turned on or off. This is a very important point. I have seen expensive industrial power supplies that have power surges when turned off. Such sources should certainly be avoided as they can easily kill sensitive devices.

The limits

From previous experience, I know that some radio amateurs would like to "customize" the device for themselves. Here is a list of hardware limitations and ways to overcome them:

BD245B: 10A 80W. 80W at 25 "C. In other words, there is a power reserve based on 60-70W: (Max input voltage * Max current)< 65Вт.

You can add a second BD245B and increase the power to 120W. To make sure the current is shared equally add a 0.22Ω resistor to the emitter line of each BD245B. The same circuit and board can be used. Place the transistors on a proper aluminum cooler and connect them with short wires to the board. The amplifier can drive a second supply transistor (this is the maximum), but you may need to adjust the gain.

Current shunt: We use a 0.75Ω 6W resistor. The power is sufficient at a current of 2.5A (Iout ^ 2 * 0.75<= 6Вт). Для больших токов используйте резисторы соответствующей мощности.

Power supplies

You can use a transformer, rectifier and large capacitors, or you can use a 32 / 24V laptop adapter. I went according to the second option, because adapters are sometimes sold very cheaply (on offer), and some of them provide 70W at 24V or even 32V DC.

Most radio amateurs are likely to use conventional transformers because they are easy to obtain.

For the 22V 2.5A version you need: 3A 18V transformer, rectifier and 2200uF or 3300uF capacitor. (18 * 1.4 \u003d 25V)
For 30V 2A version you need: 2.5A 24V transformer, rectifier and 2200uF or 3300uF capacitor. (24 * 1.4 \u003d 33.6V)

It won't hurt if you use a more powerful current transformer. A 4-diode rectifier bridge with low voltage drop (eg BYV29-500) gives much better performance.

Check your device for poor insulation. Make sure that it will not be possible to touch any part of the device where there may be a voltage of 110/230 V. Connect all metal parts of the case to ground (not the GND circuit).

Laptop Power Transformers & Adapters

If you want to use two or more power supplies in your device to get positive and negative voltages, then it is important that the transformers are isolated. Be careful with laptop power adapters. Low-power adapters may still work, but some may have a negative output pin connected to an input ground pin. This will possibly cause a short circuit across the ground wire when using two power supplies in the unit.


Other voltage and current

There are two options 22V 2.5A and 30V 2A. If you want to change the limits of the output voltage or current (only decrease), then just change the hardware_settings.h file.

Example: To build an 18V 2.5A version, you simply change the maximum output voltage of 18V in the hardware_settings.h file. You can use a 20V 2.5A power supply.

Example: To build an 18V 1.5A version, you simply change the maximum output voltage to 18V and max in the hardware_settings.h file. current 1.5A. You can use a 20V 1.5A power supply.

Testing

The last item to be installed on the board should be a microcontroller. Before installing it, I would recommend doing some basic hardware tests:

Test1: Connect a small voltage (10V is enough) to the input terminals of the board and make sure the voltage regulator outputs exactly 5V DC.

Test2: Measure the output voltage. It should be 0V (or close to zero, for example, 0.15, and it will tend to zero if you connect 2k or 5k resistors instead of a load.)

Test3: Install the microcontroller on the board and load the LCD test software by executing the commands in the unpacked tar.gz digitaldcpower directory.

do test_lcd.hex
do load_test_lcd

You should see "LCD works" on the display.

You can now download the working software.

Some words of warning for further testing with working software: Be careful with short circuits until you have tried the limiting function. A safe way to test current limiting is to use low resistance resistors (ohm units), such as car bulbs.

Set the current limiting to a low, for example 30mA at 10V. You should see that the voltage drops immediately to almost zero as soon as you connect the output light. There is a fault in the circuit if the voltage does not drop. With a car lamp, it is possible to protect the power circuit even if there is a fault, as it does not make a short circuit.

Software

This section will give you an understanding of how the program works and how you can use the knowledge to make some changes to it. However, it should be remembered that the short circuit protection is done in software. If you make a mistake somewhere, then the protection may not work. If you short-circuit the output, your device will be in a cloud of smoke. To avoid this, you must use a 12V car lamp (see above) to test the short circuit protection.

Now a little about the structure of the program. When you first look at the main program (main.c file, download at the end of this article), you will see that there are only a few lines of initialization code that are executed at power-up, and then the program enters an infinite loop.

Indeed, this program has two infinite loops. One is the main loop ("while (1) (...)" in the main.c file), and the other is a periodic interrupt from the analog digital converter (the "ISR (ADC_vect) (...)" function in the file analog.c). After initialization, an interrupt is executed every 104μs. All other functions and code are executed in the context of one of these loops.

An interrupt can stop the execution of a main loop task at any time. Then it will be processed without being distracted by other tasks, and then the task will continue again in the main loop at the place where it was interrupted. Two conclusions follow from this:

1. The interrupt code should not be too long, as it must complete before the next interrupt. Because the number of instructions in the machine code is important here. A mathematical formula that can be written as one line of CI code can use up to hundreds of lines of machine code.

2. Variables that are used in the interrupt function and in the main loop code can suddenly change in the middle of execution.

All of this means that complex things like updating the display, checking buttons, converting current and voltage must be done in the body of the main loop. In interrupts, we perform time-critical tasks: measuring current and voltage, overload protection and tuning the DAC. To avoid complex mathematical calculations in interrupts, they are performed in DAC units. That is, in the same units as the ADC (integer values \u200b\u200bfrom 0 ... 1023 for current and 0 .. 2047 for voltage).

This is the main idea of \u200b\u200bthe program. I will also briefly explain about the files you find in the archive (assuming you are familiar with CI).

main.c - This file contains the main program. All initializations are done here. The main loop is also implemented here.
analog.c is an analog to digital converter, anything that works in the context of a task interrupt can be found here.
dac.c - digital-to-analog converter. Initialized from ddcp.c, but only used from analog.c
kbd.c - program for processing data from the keyboard
lcd.c - LCD driver. This is a special version that does not require the display RW contact.

To download software to the microcontroller, you need a programmer such as the avrusb500. You can download the zip archives of the software at the end of the article.

Edit the hardware_settings.h file and customize it according to your hardware. Here you can also calibrate the voltmeter and ammeter. The file is well commented.

Connect the cable to the programmer and to your device. Then set the configuration bits to operate the microcontroller from an internal 8MHz oscillator. The program is designed for this frequency.

Buttons

The power supply has 4 buttons for local voltage control and max. current, the 5th button is used to save the settings in the EEPROM memory, so that the next time the unit is turned on, the same voltage and current settings are available.

U + increases the voltage and U - decreases. When you hold down the button, after a while the reading will "run" faster to easily change the voltage over a wide range. The I + and I - buttons work the same way.

Display

The display indication looks like this:

An arrow on the right indicates that voltage limiting is currently in operation. If there is a short circuit at the output or the connected device consumes more than the set current, the arrow will be highlighted in the lower line of the display, which means the current limitation is on.

Some photos of the device

Here are some pictures of the power supply I collected.

It is very small, but more powerful and more powerful than many other power supplies:

Old aluminum heatsinks from Pentium processors are well suited for cooling power elements:

Placing the board and adapter inside the case:

Device appearance:

Dual channel power supply option. Sent by Boogyman:

Effects, frequency meters and so on. Soon it will come to the point that it will be easier to assemble the multivibrator on the controller :) But there is one thing that makes all types of controllers very similar to conventional digital microcircuits of the K155 series - this is strictly 5 volts. Of course, finding such a voltage in a device connected to the network is not a problem. But using microcontrollers as part of small-sized battery-powered devices is already more difficult. As you know, the microcontroller perceives only digital signals - logical zero or logical one. For the ATmega8 microcontroller with a supply voltage of 5V, a logical zero is a voltage from 0 to 1.3 V, and a logical one is from 1.8 to 5 V. Therefore, this value of the supply voltage is required for its normal operation.

As far as AVR microcontrollers go, there are two main types:

For maximum performance at high frequency - power supply in the range from 4.5 to 5.5 volts at a clock frequency of 0 ... 16 MHz. For some models - up to 20 MHz, for example ATtiny2313-20PU or ATtiny2313-20PI.

For economical operation at low clock frequencies - 2.7 ... 5.5 volts at a frequency of 0 ... 8 MHz. The marking of microcircuits of the second type differs from the first in that the letter "L" is added at the end. For example, ATtiny26 and ATtiny26L, ATmega8 and ATmega8L.

There are also microcontrollers with the ability to reduce the power supply to 1.8 V, they are marked with the letter "V", for example ATtiny2313V. But you have to pay for everything, and when the power is lowered, the clock frequency must also be reduced. For ATtiny2313V with 1.8 ... 5.5 V power supply, the frequency should be in the 0 ... 4 MHz range, with 2.7 ... 5.5 V power supply - in the 0 ... 10 MHz range. Therefore, if maximum speed is required, you need to install ATtiny26 or ATmega8 and increase the clock frequency to 8 ... 16 MHz with a 5V supply. If efficiency is the most important, it is better to use ATtiny26L or ATmega8L and lower frequency and power supply.

In the proposed converter circuit, when powered by two AA batteries with a total voltage of 3V, the output voltage is selected 5V to ensure sufficient power supply for most microcontrollers. The load current is up to 50 mA, which is quite normal - after all, when operating at a frequency of, for example, 4 MHz, PIC controllers, depending on the model, have a consumption current of less than 2 mA.


The transformer of the converter is wound on a ferrite ring with a diameter of 7-15 mm and contains two windings (20 and 35 turns) with a wire of 0.3 mm. As a core, you can take an ordinary small 2.5x7mm ferrite rod from the coils of radio receivers. We use transistors VT1 - BC547, VT2 - BC338. They can be replaced by others of a similar structure. We select the output voltage with a 3.6k resistor. Naturally, when the dummy load is connected - a 200-300 Ohm resistor.


Fortunately, technologies do not stand still, and what seemed recently the last squeak of technology is already noticeably outdated today. I present a new development of the STMicroelectronics campaign - the STM8L line of microcontrollers, which are manufactured using 130 nm technology, specially designed to obtain ultra-low leakage currents. The operating frequencies of the MK are 16 MHz. An interesting feature of the new microcontrollers is their ability to operate in the range of supply voltages from 1.7 to 3.6 V. A built-in voltage regulator gives additional flexibility in choosing a supply voltage. Since the use of STM8L microcontrollers requires battery power, each microcontroller has built-in power-on / power-down reset and power-down reset circuits. A built-in supply voltage detector compares the input supply voltages with a preset threshold and generates an interrupt when it is crossed.


Other methods of reducing power consumption in the presented design include the use of built-in nonvolatile memory and many modes of reduced power consumption, which include active mode with power consumption - 5 μA, standby mode - 3 μA, stop mode with running real time clock - 1 μA, and full stop - only 350 nA! The microcontroller can recover from stop mode in 4 µs, thus allowing the lowest power consumption mode to be used as often as possible. In general, the STM8L provides a dynamic current consumption of 0.1mA per megahertz.

Discuss the article NUTRITION OF MICROCONTROLLER

I present for your attention a proven circuit of a good laboratory power supply published in the journal "Radio" No. 3, with a maximum voltage of 40 V and a current of up to 10 A. The power supply is equipped with a digital display unit with microcontroller control. The power supply circuit is shown in the figure:

Description of device operation. The optocoupler maintains a voltage drop across the linear regulator of about 1.5 V. If the voltage drop across the microcircuit increases (for example, due to an increase in the input voltage), the optocoupler LED and, accordingly, the phototransistor open. The PWI controller turns off by closing the switching transistor. The voltage at the input of the linear regulator will decrease.

To increase stability, the resistor R3 is placed as close as possible to the DA1 stabilizer chip. Chokes L1, L2 - pieces of ferrite tubes worn on the terminals of the gates of field-effect transistors VT1, VT3. The length of these tubes is approximately half the length of the outlet. Choke L3 is wound on two K36x25x7.5 annular magnetic circuits folded together from permalloy MP 140. Its winding contains 45 turns, which are wound in two PEV-2 wires with a diameter of 1 mm, laid evenly around the perimeter of the magnetic circuit. The IRF9540 transistor can be replaced with IRF4905, and the IRF1010N transistor with BUZ11, IRF540.

If required with an output current exceeding 7.5 A, it is necessary to add another DA5 regulator in parallel with DA1. Then the maximum load current will reach 15 A. In this case, the L3 choke is wound with a bundle consisting of four PEV-2 wires with a diameter of 1 mm, and the capacitance of the C1-C3 capacitors is approximately doubled. Resistors R18, R19 are selected according to the same degree of heating of DA1, DA5 microcircuits. The ShI controller should be replaced with another one that allows operation at a higher frequency, for example, KR1156EU2.

Module for digital measurement of voltage and current of laboratory power supply

The basis of the device is the PICI6F873 microcontroller. A voltage regulator is assembled on the DA2 microcircuit, which is also used as a model for the built-in ADC of the DDI microcontroller. Port lines RA5 and RA4 are programmed as ADC inputs to measure voltage and current, respectively, and RA3 - to control a field effect transistor. The resistor R2 serves as the current sensor, and the resistor divider R7 R8 serves as the voltage sensor. The current sensor signal amplifies the DAI op-amp. 1. and op amp DA1.2 is used as a buffer amplifier.

Specifications:

  • Voltage measurement, V - 0..50.
  • Current measurement, A - 0.05..9.99.
  • Protection operation thresholds:
  • - by current. A - from 0.05 to 9.99.
  • - by voltage. B - from 0.1 to 50.
  • Supply voltage, V - 9 ... 40.
  • Maximum current consumption, mA - 50.

Microcontroller controlled power supply + encoder

What more than one radio amateur cannot do without? That's right - without a GOOD power supply. In this article I will describe how you can make a decent, in my opinion, power supply from a regular computer (AT or ATX). The good idea is that you do not need to buy expensive transformers, transistors, wind pulse transformers and coils ... It is not difficult to get a computer power supply today. For example, on the local radio market, an average ATX 300W PSU costs ~ $ 8. Naturally, this is for second-hand. But it should be borne in mind that the better the computer power supply unit, the better the device we will get \u003d) It happens that the Chinese power supply unit is so poorly equipped / assembled that it’s scary to look at - absolutely all filters at the input are absent, and almost all filters at the output! So you need to choose carefully. The basis was taken by BP ATXC ODEGEN 300W which has been converted to 20V and a control board has been added.


Specifications:

Voltage - 3 - 20.5 Volts
Current- 0.1 - 10A
Ripple - depends on the "source" model.

There is one "BUT" in the manufacture of such a power supply unit: if you have never repaired or at least disassembled a computer power supply unit, then it will be problematic to make a laboratory power supply. This is due to the fact that there are a lot of schematic solutions for computer power supplies and I cannot describe all the necessary alterations. In this article I will describe how to make a board for monitoring voltage and current, where to connect it, and what to alter in the power supply unit itself, but I will not give you the exact scheme of alteration. Search engines to help you.One more "but": the circuit is designed for use in a power supply unit based on a fairly common PWM microcircuit - TL494 (analogues of KA7500, MV3759, mPC494C, IR3M02, M1114EU).

Control circuit

ATX circuit C ODEGEN 300W

A few explanations for the first scheme. A part of the circuit, which is located on the power supply board, is circled in a dotted line. There are indicated the elements that need to be put instead of what is there. We do not touch the rest of the TL494 harness.

We use the 12 Volt channel as a voltage source, which we will slightly alter. The alteration consists in replacing ALL capacitors in the 12 Volt circuit with capacitors of the same (or more) capacity, but with a higher voltage of 25-35 Volts. I threw out the 5 Volt channel altogether - I dropped out the diode assembly and all the elements, except for the common choke. The -12V channel also needs to be redone for a higher voltage - we will also use it. The 3.3 Volt channel also needs to be removed so that it does not interfere with us.

In general, ideally, only the diode assembly of the 12 Volt channel and the capacitors / chokes of the filter of this channel should be left. It is also necessary to remove the voltage and current feedback circuits. If the OS circuit is not difficult to find by voltage - usually for 1 output of TL494, then for current (protection against short-circuit) it is usually necessary to search for a rather long time, especially if there is no circuit. Sometimes this is an OS for 15-16 output of the same PWM, and sometimes a tricky connection from the midpoint of the control transformer. But these circuits need to be removed and make sure that nothing is blocking the operation of our power supply. Otherwise, the laboratory will not work. For example - in CODEGEN I forgot to remove the OS by current ... And I could not raise the voltage above 14 Volts - the current protection worked and turned off the power supply completely.

Another important note: It is necessary to isolate the power supply case from all internal circuits.

This is due to the fact that there is a common wire on the PSU case. If, quite by accident, you touch the "+" output to the body, you get a good fireworks display. Because now there is no short-circuit protection, and there is only current limitation, but it is implemented on the negative terminal. This is how I burned the first model of my PSU.

I would like the block parameters to be set using an encoder.

The stabilization voltage and current are controlled by the PWM built into the controller. Its duty cycle is regulated by an encoder, each step of which leads to an increase or decrease in the voltage and current reference voltages and, as a consequence, to a change in the voltage at the PSU output or stabilization current.

When you press the encoder button on the indicator opposite the parameter to be changed, an arrow appears, and the next rotation changes the selected parameter.

If you do not carry out any actions for some time, the control system goes into standby mode and does not react to the rotation of the encoder.

The set parameters are saved in the non-volatile memory and at the next power-up are set to the last set value.

The indicator in the upper line displays the measured voltage and current.

The lower line shows the set limiting current.

When the condition is metI i zm \u003e I set The power supply unit goes into the current stabilization mode.


Adjusting the voltage

Set the current


Characteristics of the experimental BP

The idea of \u200b\u200bthe power supply was taken from the website http://hardlock.org.ua/viewtopic.php? F \u003d 10 & t \u003d 3

C Uv. SONATA

E-mail: [email protected]

All questions on the forum \u003d)

Did you like the article? To share with friends: