Laboratory power supply controlled by a microcontroller. Laboratory power supply with microprocessor control on ATMega16 from an old Back-UPS Voltage regulation with a microcontroller

The power supply is designed for setting up and repairing equipment in an amateur radio laboratory. The temperature sensor controls the temperature of the powered device. If it exceeds the threshold, the device will be disabled. This allows you to interrupt the development of an emergency situation at an early stage and prevent catastrophic consequences. The timer turns off the power supply after a certain time, which, in particular, can be used when charging batteries.

Main technical characteristics

Output stabilized voltage, V………..0...15
Digital voltmeter resolution, V...................0.1
Output current limit threshold. A
minimum................................................. ......0.1
maximum................................................. .......1
Temperature measurement interval, °C................0...100
Maximum timer duration......9 hours 50 minutes
Dimensions, mm ......................................105x90x70

The power supply diagram is shown in Fig. 1. The basis of the device is the PIC16F88 (DD1) microcontroller, the use of peripheral modules of which made it possible to expand the functionality of the unit without complicating it.
Adjustable voltage stabilizer - linear compensation. It contains an adjustable reference voltage source, an output voltage regulator and a voltage comparison device. The comparison device is a built-in comparator of the microcontroller, the inverting input RA1 of which is supplied with an output voltage through a divider R26R28 and resistor R27, and a reference voltage is supplied to the non-inverting input RA2. The output signal of the comparison device controls the output voltage regulator.

The source of the regulated reference voltage is the SSR microcontroller module, operating in the mode of generating rectangular pulses with variable duration at the RB0 output. The reference voltage is a constant component of these pulses, proportional to their duty cycle, which can be controlled by program. The reference voltage is isolated by the low-pass filter R1C1R2R5C3. The tuning resistor R2 is used to regulate it during setup.

The output voltage regulator is assembled on a powerful composite pnp transistor VT1, connected to the positive power wire. Since transistor VT1 has a large transfer coefficient of the base current, a small base current, which is provided by the low-power field-effect transistor VT2, is sufficient to open it. Resistor R7 connects the gate of transistor VT2 to the common wire, which keeps this transistor in the closed state during initialization of the microcontroller ports at the beginning of its program execution. Capacitor C9 corrects the frequency response of the control loop, preventing self-excitation of the stabilizer.

The output voltage regulator control circuit is connected to line RA4 of the microcontroller. Using an internal electronic switch, this pin can be connected to or disconnected from the comparator output of the comparison device. By programmatically controlling this switch, you can set the output voltage regulator to off when the output voltage is zero, or on when the output voltage is proportional to the reference voltage.

An analog calibrated temperature sensor LM35 (BK1), which linearly converts temperature into voltage with a coefficient of 10 mV/ºС, is connected via circuit R4C2 to pin RA3 of the microcontroller, configured as an analog input. The internal analog-to-digital converter (ADC) of the microcontroller is used in the digital voltage and temperature meter. The ADC input can be software connected to pins RA1 - RAZ. To increase the noise immunity of the measuring path, the operation of the ADC is synchronized with a dynamic indication period of 20 ms. The conversion result is processed by a software averaging filter.

At the beginning of each measurement period, the ADC converts the voltage first from the output, then from the temperature sensor. From 16 readings of each parameter, the arithmetic mean value is calculated, which is displayed on the indicator. The reading update period is 320 ms. The average temperature value, regardless of whether it is displayed on the HG1 indicator or not, is compared with a user-defined threshold before updating. If it exceeds the threshold, the output voltage will be turned off. As soon as the temperature drops 2 ºС below the threshold, the output voltage will turn on again.

The microcontroller program provides a time counter for the power supply's on state. The counter register values ​​are updated every minute and compared with a set value, above which the output voltage is turned off. This may be necessary to limit the time of some process, for example, charging a battery.

The output current limiter operates independently of the microcontroller and its program. It protects the power supply from short circuits at the output and limits the output current by reducing the output voltage. The basis of the limiter is a unit that converts the load current into a voltage proportional to it relative to the common wire, described in the article by I. Nechaev “Current limit indicator” in “Radio”, 2002, No. 9, p. 23. This unit is assembled using op-amp DA2.2, transistor VT4 and resistors R23-R25. Resistor R25 is a load current sensor connected to the positive power wire circuit.

A voltage proportional to the output current from the source of transistor VT4 through resistor R20 is supplied to the inverting input (pin 6) of op-amp DA2.1, and its non-inverting input (pin 5) is supplied with voltage from the motor of variable resistor R18. When the position of this engine remains unchanged, the voltage on it is stable, since the series-connected resistors R17 and R18 are connected to a stabilized voltage of +5 V from the output of the DA1 microcircuit. By moving the slider of the variable resistor R18, the threshold for limiting the output current is adjusted.

If the voltage at the non-inverting input of op-amp DA2.1 is greater than the voltage at the source of transistor VT4, which is proportional to the current, then the voltage at the output of this op-amp is close to its supply voltage, diode VD2 is closed and does not affect the stabilization of the output voltage. LED HL1 is switched off and protected from reverse voltage by diode VD3. If the voltage at the source of transistor VT4 exceeds the voltage at the non-inverting input of op-amp DA2.1, the voltage at the output of this op-amp DA2.1 will drop to almost zero. Current will begin to flow through resistor R19, diode VD3 and LED HL1. Diode VD2 opens, causing the output voltage to decrease as follows. so that the output current does not exceed the limit threshold. The HL1 LED will turn on - an indicator of the load current limiting mode.

After turning on the unit, the 5 V supply voltage from the DA1 stabilizer is supplied to the DD1 microcontroller. which configures input-output ports, configuration and modes of built-in peripheral modules according to the program, reads output voltage values, temperature settings and time delay from EEPROM (non-volatile memory) into registers. The HG1 indicator displays the program version number for two seconds and then, with reduced brightness, the voltage value that should be at the output, but it is not yet turned on at this time. By pressing the SB1 button, the output voltage is turned on with the value previously recorded in the EEPROM, the indicator HG1 will show it at full brightness. The next press of this button will turn off the output voltage again, and so on. Pressing SB3 and SB4 respectively increases or decreases the output voltage. By short pressing you can fine-tune the output voltage, and by holding the buttons you can set it coarsely. If it is necessary that the next time the power source is turned on, the output will have a new voltage value, then you need to write it into memory by pressing and holding the SB2 button. When the indicator shows "SAU", the button is released, the new value will be saved in the EEPROM.

A short press on SB2 allows you to view the temperature and time counter value on the indicator in 10-minute increments. The values ​​of the temperature and time settings can be viewed by holding this button, and the indicator will show flashing values ​​of the corresponding settings, which can be changed using the SB3 and SB4 buttons. Pressing and holding the SB2 button will save the new values ​​to the EEPROM.

If, during operation of the device with the output voltage turned on, the temperature of the BK1 sensor exceeds the set one, the output voltage will turn off. The indicator will display a flashing “o.t”, which means the temperature has been exceeded. As soon as the temperature drops below the set value by 2 C, the output voltage will be turned on, and the HG1 indicator will show its value.

If the time counter value matches the set value, the output voltage will be turned off and the indicator will display a flashing “o.h”, which means the time has been exceeded. You can turn on the input voltage after this by moving the time setting forward or to “0”.

Network transformer T1 is industrially manufactured with a secondary winding voltage of 17 V and a permissible load current of 1.2 A. You can use a transformer TP-115-K8 with two secondary windings of 9 V each and a current of 1.1 A, which are connected in-phase-series. A network transformer from lamp technology with three filament windings of 6.3 V each, which are connected in the same way, is also suitable. The VD1 diode bridge must be designed for a voltage of at least 50 V and an average rectified current of at least 2 A. Diodes 1N4148 (VD2 and VD3) can be replaced with KD522 with any letter index. BAT85 diodes (VD4-VD6) can be replaced with other Schottky diodes, for example, 1N5817, 1N5818.

The regulating transistor VT1 of the pnp structure, a composite KT825G in a metal case, was selected with a large current reserve to ensure the reliability of the device. It can be replaced with a similar one with a maximum collector-emitter voltage of at least 50 V and a collector current of 3 A or more. Transistor VT1 is installed on a finned heat sink with a cooling surface area of ​​100 cm2. The heat sink with transistor VT1 is fixed on the top cover of the case from the outside, as shown in the photo in Fig. 2. Field-effect transistors VT2 and VT4 - any from the KP501 series or imported 2N7000. Transistor VT3 can be any of the KT3102, KT342 series.

The HG1 indicator is three- or four-digit with a common anode. It can be composed of three separate single-digit indicators. In this case, the terminals of the same name of the segments are connected to each other, the transistor VT3 is not installed, and the output of the decimal point of the second digit is connected to the common wire through a 1 kOhm resistor.
Buttons SB1-SB4 were taken from faulty office equipment, including an inkjet printer. Voltage stabilizer DA1 - any of the 7805 series in a TO220 housing. Trimmer resistor R28 - 3266W-1-103 - imported small-sized multi-turn manufactured by Bourns. The R25 current sensor is made up of four parallel-connected resistors with a resistance of 1 Ohm and a rated power of 0.5 W.

The power supply is assembled without the VD2 diode. check for correct installation and absence of short circuits. For the first time, connect the unit to the network without microcontroller DD1 and load. Using a voltmeter, check that the voltage in socket 14 of the DD1 panel is 5 V, at the emitter of the transistor VT1 - 17...20 V, at its collector - about 0 V. The unit is turned off and the DD1 microcontroller is installed in the panel with a pre-recorded program, codes which are given in the ad_ps1 .hex file.

Effects, frequency meters and so on. It will soon come to the point that it will be easier to assemble a multivibrator on a controller :) But there is one point that all types of controllers are very similar to conventional digital microcircuits of the K155 series - this is a strictly 5 volt power supply. 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 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, logical zero is a voltage from 0 to 1.3 V, and logical one is from 1.8 to 5 V. Therefore, for its normal operation, this value of the supply voltage is required.

When it comes to AVR microcontrollers, there are two main types:

To obtain maximum performance at high frequencies - 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 the second type of microcircuit differs from the first in that the letter “L” is added to 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 reduced, the clock frequency must also be reduced. For ATtiny2313V, with a power supply of 1.8...5.5 V, the frequency should be in the range of 0...4 MHz, with a power supply of 2.7...5.5 V - in the range of 0...10 MHz. Therefore, if maximum performance is required, you need to install ATtiny26 or ATmega8 and increase the clock frequency to 8...16 MHz with a 5V power supply. If efficiency is most important, it is better to use ATtiny26L or ATmega8L and lower the 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 to be 5V to provide sufficient power to most microcontrollers. The load current is up to 50mA, which is quite normal - after all, when operating at a frequency of, for example, 4 MHz, PIC controllers, depending on the model, have a current consumption of less than 2 mA.


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


Fortunately, technology does not stand still, and what recently seemed like the latest technology is now noticeably outdated. I present a new development from the STMicroelectronics campaign - a line of STM8L microcontrollers, which are produced using 130 nm technology, specially designed to obtain ultra-low leakage currents. The operating frequencies of the MK are 16 MHz. The most interesting property of the new microcontrollers is the ability to operate with supply voltages in the range from 1.7 to 3.6 V. And the built-in voltage stabilizer provides additional flexibility in choosing the supply voltage source. Since the use of STM8L microcontrollers requires battery power, each microcontroller has built-in power-on/off-reset and low-voltage reset circuits. The built-in supply voltage detector compares the input supply voltages with a specified 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 non-volatile memory and a variety of reduced power modes, which include an active mode with a power consumption of 5 μA, a standby mode of 3 μA, a stop mode with a running real-time clock of 1 μA, and a full stop - only 350 nA! The microcontroller can recover from stall mode in 4 µs, allowing the lowest power 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 MICROCONTROLLER POWER POWER

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

An industrial stabilized power supply is a fairly expensive device. Using a microcontroller when designing a power supply, you can build a device that has many additional functions, is easy to manufacture and is very affordable.

This digital DC power supply has been a very successful product and is now in its third version. It's still based on the same idea as the first option, but comes with some nice improvements.

Introduction

This power supply is the least complex to make than most other circuits, but has many more features:

The display shows the current measured voltage and current values.
- The display shows preset voltage and current limits.
- Only standard components are used (no special chips).
- Requires single-polarity supply voltage (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 keypad for directly entering the desired voltage and maximum current.
- This is a really small but powerful power source.

Is it possible to remove some components or add additional features? The trick is to move the functionality of analog components such as op-amps into the microcontroller. In other words, the complexity of software, algorithms increases and hardware complexity decreases. This reduces the overall complexity for you as the software can be simply 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 falls between B and E at the transistor. The zener diode and resistor create a reference voltage that is stable even if there are voltage spikes at the input. A transistor is needed to switch high currents that a zener diode and a resistor cannot provide. In this role, the transistor only amplifies the current. To calculate the current on the resistor and zener diode, you need to divide the output current by the HFE of the transistor (HFE number, which can be found in the table with the characteristics of the transistor).

What are the problems with this scheme?

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

These are quite 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” that will regulate the output current and change the reference voltage. That's it (...and this makes the circuit a lot more complicated).

In the last few decades, people have been using op-amps to power this algorithm. Operational amplifiers can in principle be used as analog computers to add, subtract, multiply, or perform logical "or" operations on voltages and currents.

Nowadays, all these operations can be quickly performed using a microcontroller. The best part is that you get a voltmeter and an ammeter as a free add-on. In any case, the microcontroller must know the current and voltage output parameters. You just need to display them. What do we need from a 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 needs 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 that is quite fast, and at first glance it does not have a DAC. You can use pulse width modulation (PWM) and an analog low-pass filter to achieve a DAC, but PWM on its own 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 must be fast and simple, which will interface easily with our microcontroller. There is a converter circuit known as an "R-2R matrix". It consists only of resistors and switches. Two types of resistor values ​​are used. One with an R value and one with double the R value.

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

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

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

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

Creating a DC signal of different levels using PWM (pulse width modulation)

Pulse width modulation is a technique that generates pulses and passes them through a low-pass filter with 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.

Atmega8 has hardware 16-bit PWM. That is, it is theoretically possible to have a 16-bit DAC using 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 at high resolutions. The more accuracy is needed, the lower the frequency of the PWM signal should be. This means that large capacitors are needed 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 ATmega8 with an 8 MHz clock generator and 10-bit PWM, then the PWM signal pulses will have a frequency of 8MHz/1024 = 7.8KHz. To get the best DC signal you need to filter it with a second order filter of 700 Hz or less.

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

Combining R2R matrix and PWM

You can use PWM and R2R matrix together. In this project we will be using a 7-bit R2R matrix combined with a 5-bit PWM signal. With a controller clock speed of 8 MHz and a 5-bit resolution, we will get a 250 kHz signal. 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 R2R matrix-based DAC. In the new design, we use an R2R matrix and PWM with a total resolution of 12 bits.

Oversampling

At the expense of some processing time, the resolution of the analog-to-digital converter (ADC) can be increased. This is called resampling. Quadruple resampling results in double resolution. That is: 4 consecutive samples can be used to obtain twice as many steps per ADC. The theory behind resampling is explained in the PDF document which 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 description of the project

A few technical details are still missing:

DAC (Digital to Analog Converter) cannot drive power transistor
- The microcontroller operates from 5V, this means that the maximum output of the DAC is 5V, and the maximum output voltage on the power transistor will be 5 - 0.7 = 4.3V.

To fix this we must add current and voltage amplifiers.

Adding an amplifier stage to the DAC

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

We could use op-amps, but those would require additional positive and negative supply voltage, 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 fluctuations when the power is turned on.

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

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

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

Vampl = (R6 + R7) / R7

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

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

Rin = hfe1 * S1 * R7 * R5 = 100 * 50 * 1K * 47K = 235 MOhm

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

This is more than high enough to connect to our DAC, which has an internal resistance of 5k ohms.

Internal equivalent output resistance:

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

Low enough to use transistor 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 turned off. This means that we will not get any input or output oscillations from the transistors when the power is turned on or off. This is a very important point. I've seen expensive industrial power supplies that experience power surges when turned off. Such sources should certainly be avoided as they can easily kill sensitive devices.

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 a temperature of 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 ensure that the current is distributed equally, add a 0.22 ohm resistor to the emitter line of each BD245B. The same circuit and board can be used. Mount the transistors on the proper aluminum cooler and connect them with short wires to the board. The amplifier can drive a second power transistor (this is the maximum), but you may need to adjust the gain.

Current sensing shunt: We use a 0.75ohm 6W resistor. There is enough power 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 with the second option, because... adapters are sometimes sold very cheaply (on sale), and some of them provide 70W at 24V or even 32V DC.

Most hams will probably use regular transformers because they are easy to get.

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

It won't hurt to use a higher current transformer. A bridge rectifier with 4 low dropout diodes (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 voltage may be 110/230 V. Connect all metal parts of the case to ground (not GND circuits).

Transformers and power adapters for laptops

If you want to use two or more power supplies in your device to produce positive and negative voltage, 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 the negative output pin connected to the input ground pin. This will possibly cause a short circuit through 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 output voltage or current limits (just decrease), then simply change the hardware_settings.h file.

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

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

Testing

The last element 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 that the voltage regulator produces exactly 5V DC voltage.

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 2kOhm or 5kOhm resistors instead of the load.)

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

make 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 tested the limiting function. A safe way to test current limiting is to use low resistance resistors (units of ohms), such as car light bulbs.

Set the current limit low, for example 30mA at 10V. You should see the voltage drop immediately to almost zero as soon as you connect the light bulb to the output. There is a fault in the circuit if the voltage does not go down. With a car lamp, you can protect the power circuit even if there is a fault because it does not 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 short circuit protection is done in software. If you made a mistake somewhere, the protection may not work. If you short circuit the output, your device will end up in a cloud of smoke. To avoid this, you should 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 (file main.c, 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, there are two infinite loops in this program. One is the main loop ("while(1)( ...)" in main.c) and the other is a periodic interrupt from the analog-to-digital converter (the "ISR(ADC_vect)(...)" function in analog.c). After initialization, the interrupt is executed every 104 µs. All other functions and code are executed within 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 execution of the task will again continue 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 C 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 may suddenly change in the middle of execution.

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

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

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, everything 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 with analog.c
kbd.c - keyboard data processing program
lcd.c - LCD driver. This is a special version that does not require a display RW contact.

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

Edit the hardware_settings.h file and configure 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 run the microcontroller from the internal 8 MHz 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 you turn on the unit there will be the same voltage and current settings.

U+ increases the voltage and U - decreases it. When you hold the button, after a while the readings will “run” faster to easily change the voltage within a large range. The I + and I - buttons work the same way.

Display

The display indication looks like this:

The arrow on the right indicates that voltage limiting is currently in effect. If there is a short circuit at the output or the connected device consumes more than the set current, an arrow will appear on the bottom line of the display, indicating that the current limit is enabled.

Some photos of the device

Here are some photos of the power supply I assembled.

It's very small, but more capable and more powerful than many other power supplies:

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

Placing the board and adapter inside the case:

Appearance of the device:

Dual channel power supply option. Posted by boogyman:

Most modern laboratory power supplies are equipped with digital indicators to monitor output currents and voltages. At the same time, the use of specialized ADC microcircuits for these purposesICL7106 andICL7107 is observed less frequently. These chips are bulky and do not have dynamic indicator control. Instrumentation manufacturers are trying to implement measurement and control functions on one chip - a microcontroller. This simplifies and reduces the cost of the device design by reducing the number of elements. The ability to update software is also an important advantage of microcontroller circuits.

In the proposed device, in addition to the main functions, the microcontroller calculates the power supplied to the load, turns on cooling if necessary, and in standby mode, switches the device to clock mode with calendar.

Specifications:

Main features and modes:

1. Date time display mode taking into account leap year.
2. Automatic time correction function.
3. Brightness reduction mode in standby mode (only for VFD version).
4. Display the temperature of the heated zone.
5. Display mode for voltages, currents and powers in operating mode.
6. Function for checking the health of the temperature sensor.
7. Automatic cooling fan on/off function.
8. Function of manual control of power supply to the load.

The laboratory power supply consists of the following functional blocks:

1. Control and display unit.
2. Measurement block.
3. Power supply for the control and display unit and the measuring unit.
4. Power block.
5. Voltage and current stabilization device.
6. Cooling device.

Control and display unit

The control and display unit is a device built on the ATMEGA8 microcontroller (diagram 1.1 and 1.2).

It has four analog inputs for measuring voltages and currents, outputs for turning on the voltage supply relay to the load and turning on the cooling fan, an input for connecting a temperature sensor, control buttons and an indicator panel.
The program for the ATMEGA8 microcontroller was written for the VFD - 4 * 20 vacuum fluorescent display CU20045SCPB-T23A FUTABA and a standard 4 * 20 LCD.

The power supply of the unit is stabilized 5 volts. The maximum rated current consumption of VFD is 1 ampere. This is two orders of magnitude greater than that of the LCD, which should be taken into account when choosing a power source for this unit.

Measurement block

The measurement unit (Scheme 2) is a galvanically isolated system between the input and output of the double conversion of the analog signal - voltage - frequency - voltage (V - F - V).

The measuring unit is a precision device with nonlinearity no worse than 0.01%. The power supply of the device on the measurement side (the left side according to diagram 2) is 8.5 volts and can range from 5...40 volts. It should be noted that a significant change in the supply voltages from those indicated in the diagram will require a change in the ratings in the power supply circuits of the optocouplers' LEDs. The right side of the measurement unit is galvanically connected to the control and display unit and also has a 5 volt power supply.

The diagram of the measurement unit shows only one channel, voltage and current channel A. Channel B is identical to channel A.

Setting up the unit comes down to setting the output voltage at the corresponding input voltage using trimming resistors RS – 10k and 50k for current and voltage, respectively. To simplify setting up the measurement unit, it is necessary to use one 5...10 volt power source connected in parallel to all channel supplies and a second one as a source of measured voltage at the input.

Then you need to check the signal flow from input to output in accordance with the values ​​​​indicated in the diagram. To avoid failure of the measurement unit, when setting up, do not exceed the maximum permissible voltage value at the input of the LM331 microcircuits.

Power supply for control and display unit and measuring unit

The power supply for the control and display unit and the measurement unit is the most complex device and requires some experience in manufacturing (Scheme 3). The source supplies the corresponding blocks with several stabilized voltages, galvanically isolated from each other.

The author's version uses a T1 37P-6000 pulse transformer from a motor driver that has expired. This is a standard transformer that was used to power the control circuits of power modules with composite transistors and power the processor part. It is quite acceptable to use any pulse transformer with a 5-volt winding of 1.5 amperes and four insulated windings with voltages of 8...20 volts 30-100 mA for the measurement unit. Such transformers are installed in all servo and AC motor drivers. Pulse transformers are also suitable for powering the control circuits of IGBT modules. Sometimes it’s easier to use a ready-made switching power supply by replacing the missing windings. In this case, you should observe the phasing according to diagram 3 and do not connect the housing of the controller power winding with the common buses of the secondary windings.

Table 1 shows the output voltages and currents of transformer T1.

Table 1

Transformer contact number T1

Purpose

Voltage after rectifier

Minimum permissible current

Primary winding
Winding for powering controller IC1
Power winding control and display unit(diagram 1) and the right side measurement unit(scheme 2)
measurement unit(scheme 2)
Winding for powering the left side measurement unit(scheme 2)
Winding for powering the left side measurement unit(scheme 2)
Winding for powering the left side measurement unit(scheme 2)

Power block

The power unit consists of four adapted power supplies from the laptop. Adaptation comes down to switching the ground bus and screen from the negative 19 volt bus and connecting them through 4.7 nF 1 kV separating capacitors to both poles of the 19 volt output voltage according to diagram 4. This is done so that when the channels are connected in series, a short circuit does not occur through the bus grounding. The power unit should use power supplies with an output current of at least 3.5 amperes and a voltage of 17-20 volts. The finished power supplies should be inserted into a curved steel screen made of tinned tin, then soldered along the seam and grounded.

Voltage and current stabilization device

The voltage and current stabilization device is a linear power control circuit. Diagram 5 shows one channel A. Channels A and B are identical. Common buses and channel power buses are isolated from each other. The device input is connected to the power unit, and the output is connected to the input contacts of the pwrout1_2 switching relays in the control and display unit. The output contacts of the pwrout1_2 switching relays are connected directly to the terminals located on the front panel of the device. The inputs of the voltage measurement unit are connected to these terminals. To measure current, the corresponding inputs of the measurement unit are connected to current shunts R16 in accordance with the polarity indicated on the diagram.

To configure the voltage and current stabilization device, it is necessary to set the supply voltage +/-17.5 volts at the control points according to the diagram with uninstalled or disabled operational amplifier chips OP1 and set the limit for turning on the current protection indicator limit_I.

The supply voltages +/-17.5 volts at the control points are set by potentiometers R23 and R24 using a digital voltmeter.

The limit for turning on the current protection indicator limit_I is set by potentiometer R20 in the position when the current regulator R11 is at a minimum - in the extreme left position. The protection indicator should glow smoothly and without flickering.

Measuring resistors R16, composite transistors VT1 from two channels, temperature sensor IC2 from the control and display unit, and a cooling fan are placed on the main radiator (with an area of ​​2100 cm²) in the rear of the power supply housing. The voltage stabilizer chips for two channels DA3 and DA4 also need to be installed on the radiator. This can be either the main one or a radiator installed in the voltage and current stabilization device. The elements installed on the body of the main radiator must be insulated, and the radiator must be grounded. The common 5V power wire must also be grounded. Low-power channel power transformers 220V/2*22V-2.5W.

For convenience, a line of parallel-connected connectors is installed on the board of the voltage and current stabilization device to supply 220 volts to all source units (diagram 6).

When using the elements indicated in the diagram and observing the ratings of the trimming elements, additional adjustment of the voltage and current stabilization device is not required.

If an oscilloscope observes excitations at the output of the operational amplifier element OP1.2, it is necessary to increase the capacitance of capacitor C6.

Cooling device

The cooling device consists of a radiator and a cooling fan installed on the main radiator. To power the cooling fan and backlight the LCD LEDs (if the indicator is backlit), a ready-made miniature power supply for charging a mobile phone, rated for a current of 500 mA and a voltage of 12 volts, is used. Its output voltage is supplied to the input of the COLLER relay contact group in the control and display unit and to the LCD backlight input in the manner described above. The output of the COLLER relay contact group is connected directly to the cooling fan.


The front panel contains control buttons, current protection indicators, terminals and regulators. Voltage regulators are multi-turn. If necessary, a power switch is placed on the side.

About details

Resistors in the measuring circuits in the measurement unit and the voltage and current stabilization device must have an accuracy of no worse than 1%, optocouplers IC2, IC5 - 4N35, CNY17 or similar. Transistor VT1 in the voltage and current stabilization device is any N-P-N Darlington transistor 60 - 250 volts, with a power of at least 150 watts and a collector current of at least 10 amperes. Measuring shunt - resistor R16 - with a power of at least 5 watts. Without changing the circuit, the KA1M0565R microcircuit can be replaced with KA1H0565R. With certain modifications, it is permissible to use controllers of the TOP or VIPER series. Contact groups of switching relays must be designed for the currents indicated in the diagram.

To reduce the overall dimensions of the device, it is advisable to use surface SMD components, and the required resistance values ​​for the measuring circuits can be obtained using the Parcalc program (http://pgurovich.ru/parcalc/).

Working with the device

The device is designed to display information on the indicator in 2 modes:
mode 0 – time, calendar and temperature are displayed at reduced brightness;
mode 1 – voltages, currents and powers of 2 channels are displayed at full brightness.

The mode is selected by the corresponding logical voltage level at the MODE input (pin 19 ATmega).

When transitioning from mode 0 to mode 1, holding down the MODE button, voltage from the LIP will not be supplied to the load until this button is released. This is done to control the moment the voltage is applied.

If the sensor temperature exceeds +45.0°C, regardless of the display mode, the fan will turn on, and if it drops to +35.5°C, the fan will turn off.

If the sensor temperature exceeds +85.0°C in mode 1, the indicator will display “ALARM!” instead of power values. .

If the normal operation of the temperature sensor is disrupted, regardless of the indication mode, the inscription “TempERR” will be displayed in the bottom line of the indicator.

Editing time and calendar

Setting new time and calendar values ​​is possible only in mode 0. The Sel button (pin 17 ATmega) selects a parameter to change in the following order: hours, minutes, day, month, day of the week, year, seconds. The selected parameter flashes on the indicator. It is set to the desired value using the “+” and “-“ buttons (pins 18 and 19 ATmega) except for seconds, with the Sel button the seconds are reset, i.e. the current minute starts over.

The device exits editing mode:
— 3 seconds after the last press of any button;
— after editing seconds;
— after editing the clock accuracy.

After holding the “+” or “-“ button pressed for more than 3 seconds, the speed of change of the value of the selected parameter will increase.

Editing clock accuracy

If you need to adjust the accuracy of the clock, you need to hold the Sel button pressed in mode 0 for at least 3 seconds. A parameter that controls accuracy will appear on the indicator. When you change this number by one using the “+” and “-“ buttons, the accuracy of the move will change in the same direction by about 1 second in 3 months. After setting a new parameter value, to write it to EEPROM and exit editing, you need to press the Sel button. The accuracy parameter can range from 0 to 2000000.

The power supply device is not critical in terms of EMC, does not require additional measures and can be assembled on test boards using SMD components. It is important that all screens of switching power supplies are connected to ground, and that high-voltage primary circuits are reliably insulated and closed. tapes. Both comments and pings are currently closed.

A laboratory power supply with a digital voltmeter and ammeter has been serving me for six months now. It is assembled in a case from a computer power supply. I haven't gotten around to designing the front panel yet. Voltage is adjustable from 1.32 to 24.00 volts, current - up to 3 amperes. The indicators are 4-digit LED indicators with a common cathode. Voltmeter with a resolution of 0.04. B (with suppression of insignificant zeros in the two left indicators), a comma after the 2nd character. Ammeter with a resolution of 4 mA (with suppression of insignificant zeros in the two left indicators), a comma after the 1st digit.

The program in the microcontroller is designed to measure voltage from 00.00 to 40.92 V and current from 0.000 to 4.092 A. You can make a digital display unit and integrate it into an existing power supply, or use another power transformer and another voltage regulator (within the specified limits ). My voltage regulator is assembled on a special microcircuit almost according to the standard diagram from the datasheet. The microcircuit operates in pulse mode at a frequency of 52 kHz and has high efficiency.

The regulator is assembled on a separate board, the microcircuit is attached via heat-conducting paste to a plate radiator. For adjustment, it is better to use a multi-turn potentiometer.

The voltmeter and ammeter are assembled on a separate board and are powered by a separate 9-15 V transformer and a stabilized power supply of 5.12 volts. Setting this voltage must be done before installing the microcontroller using trimming resistor R2. You also need to carefully select resistor R5. Its resistance should be 7 times greater than R6. If R6 = 5.11 K, then R5 = 5.11 x 7 = 35.77 K. After installing the programmed microcontroller and eliminating the identified mechanical errors, check (adjust) the voltage on the first leg to 5.12V. The accuracy of the voltmeter readings depends on this.

The “current” resistor R1 was taken from an unusable M-830 multimeter. An ammeter does not have the same linearity as a voltmeter. This is due to the use of op-amps.

By selecting resistor R8, the gain of the op-amp is adjusted. Calibrate using the most accurate ammeter.

Resistors R9 – R16 from 270 to 330 Ohms.

In the video: adjusting the voltage without a load, and then with a load - a 24v 21w car lamp.

You can download the firmware and printed circuit boards in LAY format below.

Update 04/16/2014: New firmware (AVmetr_2.rar). Improved resolution.

List of radioelements

Designation Type Denomination Quantity NoteShopMy notepad
MK PIC 8-bit

PIC16F873

1 To notepad
Linear regulator

LM317

1 LM317T To notepad
DC/DC pulse converter

LM2576

1 LM2576-Adj To notepad
OP1 Operational amplifier

LM358

1 To notepad
Diode

KD202A

4 To notepad
Diode bridge

DB157

1 To notepad
VD1 Schottky diode

MBR350

1 To notepad
C1 100 µF, 50 V1 Regulator To notepad
C2, C3 Electrolytic capacitor1000 µF, 35 V2 Regulator To notepad
C1 Electrolytic capacitor100 µF, 25 V1 To notepad
C2 Electrolytic capacitor100 µF, 16 V1 To notepad
C3, C4 Capacitor0.1 µF2 To notepad
C5, C6 Capacitor20 µF2 To notepad
R1 Variable resistor51 kOhm1 Regulator To notepad
R2 Resistor

1.2 kOhm

1 Regulator To notepad
R1 Resistor

0.01 kOhm

1 The current resistor is taken from the M-830 multimeter To notepad
R2 Trimmer resistor100 Ohm1 To notepad
R3 Resistor

680 Ohm

1 To notepad
R4 Resistor

1 kOhm

1 To notepad
R5 Resistor

36 kOhm

1 Resistance should be 7 times greater than R6 To notepad
R6 Resistor

5.1 kOhm

1 To notepad
R7 Resistor

240 Ohm

1 To notepad
R8 Resistor

75 kOhm

1 To notepad
R9-R16 Resistor

300 Ohm

8 270-330 Ohm
Share with friends or save for yourself:

Loading...