Laboratory power supply controlled by a microcontroller. Laboratory two-channel power supply with microprocessor control Do-it-yourself power supply on a microcontroller

Share to:

The output voltage of the power supply can be changed within 1.25....26 V, the maximum output current is 2 A. The current protection threshold can be changed within 0.01...2 A in steps of 0.01 A, and response delay - within 1...10 ms in steps of 1 ms and 10...100 ms in steps of 10 ms. The voltage stabilizer (Fig. 1) is assembled on the LT1084-ADJ (DA2) chip. It provides an output current of up to 5 A and has built-in protection units against both overheating (operation temperature is about 150 °C) and against exceeding the output current. Moreover, the threshold for current protection 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; when this voltage increases to 15 V, it will decrease to 3...4 A, and at a voltage of 17... 18 V or more it will not exceed 1 A. Adjustment output voltage in the range of 1.25...26 V is achieved by variable resistor R8.

To provide the power supply with an output current of up to 2 A over the entire range of output voltages, a step change in voltage is applied at the input of the DA2 stabilizer. Four full-wave rectifiers are assembled on a step-down transformer T1 and diodes VD1-VD8. The diode rectifier VD1, VD2 and voltage stabilizer DA1 are designed to power the microcontroller DD1, op-amp DA3 and digital indicator HG1. 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. The outputs of these three rectifiers, depending on the values ​​of the output voltage of the power supply, through the field-effect transistors of the 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 microcontroller DD1.

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

When the power supply is turned on, the output of the RSZ microcontroller DD1, regardless of the output voltage, will be set to a high logical level, the field-effect transistors of the optocoupler U1 will open and a rectifier using 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 microcontroller DD1. This voltage is supplied to the resistive divider R9R11R12, and from the engine of the adjusted resistor R11, the already reduced voltage is supplied to the PC1 line of the microcontroller, which is configured as an ADC input.

During operation, the output voltage is constantly measured, and the 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 maximum output current at any output voltage. In addition, this significantly reduces the heating of the DA2 stabilizer.

If the output voltage of the unit does not exceed 5.7 V, a high level will be at the PC5 output of the DD1 microcontroller, and a low level at the RSZ and RS4 outputs, so the input of the DA2 stabilizer will receive a voltage of 9...10V from the rectifier on diodes VD5, VD6. In the output voltage range of 5.7...13.7 V, a voltage of 18...20 V will be supplied to the stabilizer from the rectifier using diodes VD4, VD7. If the output voltage is more than 13.7 V, the DA2 stabilizer will be supplied with a voltage of 27...30 V from the rectifier on diodes VD3, VD8. The switching threshold voltages can be changed in the initial settings menu from 1 to 50 V.

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

PROTECTION
I=0.00A

and after pressing the SB3 button with the most significant digit blinking:

DELAY 1ms

In the first case, one of the three digits blinks; the current value in this digit is changed by pressing the SB1 “+” or SB2 “-” button. This digit is selected by pressing the SB3 “Select” button. To disable the protection, you must press the SB2 “-” button until the message appears on the screen:
U= 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, transistor VT1 will open and the LCD indicator HG1 will display the current voltage and current values:
U= 10.0V
I=0.00A

When the delay is turned on, in addition to the voltage and current values, a flashing exclamation mark will be displayed on the indicator as a reminder:
U=10.0V
I 0.00A!

If protection is turned off, a flashing lightning bolt will appear instead of the exclamation mark.
If the output current is equal to or exceeds the set value of the protection current, transistor VT1 will close and the message will appear on the screen:
PROTECTION
I=1.00A

Moreover, the word “PROTECTION” will be flashing. After briefly pressing any of the buttons, the device will again switch to the mode of setting the protection operation current.
If you press the SB1 “+” or SB2 “-” button in operating mode, the section for setting the time delay for current protection will turn on and the following message will appear on the indicator:
DELAY 1ms

By pressing the SB1 "+" or SB2 "-" button, you change the delay from 1 ms to 10 ms in 1 ms steps and from 10 to 100 ms in 10 ms steps. The current protection delay operates as follows. If the output current becomes equal to or exceeds the set value, a pause of the set duration will be made (from 1 to 100 ms), after which the measurement will be taken again. If the current is still equal to or greater than the set value, transistor VT1 will close and the load will be de-energized. If during this time interval the output current becomes less than the operating current, the device will remain in operating mode. To disable the delay, you need to decrease its value by pressing the SB2 “-” button until the message appears on the screen:
OFF DELAY

In operating mode, you can manually turn off the output voltage and switch to the protection current setting mode; to do this, press the SB3 “Select” button.
The program has an initial settings menu; in order to enter it, you need to 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 DD1 microcontroller will be displayed first:
ADC CLOCK 500 kHz

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

To go to the next setting, press the SB3 “Select” button and the message will appear:
STEP2
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 one or another rectifier is connected to the input of the DA2 stabilizer. The next time you press the SB3 “Select” button, a menu for setting the following switching threshold will appear:
STEPS
FROM 13.7V

When you go to the next section of the menu, transistor VT1 will open, and the current protection will be disabled. The message will appear: U= 10.0V* I=0.OOA*
In this section, the value of the coefficient k, which is used in the program to correct the output voltage readings depending on the output current, is changed. The fact is that across resistor R14 and transistor VT1 at the maximum output current the voltage drop is up to 0.5 V. Since a resistive divider R9R11R12, connected before resistor R14 and transistor VT1, is used to measure the output voltage, 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 will display the k coefficient value instead of the current value:
U= 10.0V* k=80

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




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


Fixed resistors MLT, S2-23 are used, in addition to resistor R14 - it is of type SQP-15, multi-turn tuning resistors - SP5-2, variable resistor - SPZ-1, SPZ-400, the engine of which is driven into rotation through a gear with a gear ratio, equal to three (Fig. 4). The result is a three-turn variable resistor, which 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, imported oxide capacitors, the rest - K10-17. Instead of what is indicated in the diagram, you can use an LCD indicator (two lines of eight characters each) with an English-Russian character set on controllers KS0066, HD47780, for example WH0802A-YGH-CT from Winstar. Diodes 1N4005 are replaceable with diodes 1N4002-1N4007, 1N5819, diodes P600B - with P600DP600M, 1 N5401-1 N5408.

The LT1084 stabilizer is attached through a heat-conducting insulating gasket to the metal body of the device, which acts as a heat sink. This stabilizer can be replaced with the LM1084, but it must have an adjustable output voltage (with the index ADJ). The domestic analogue is the KR142EN22A microcircuit, but its performance in this device has not been tested. Stabilizer 7805 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 winding is removed and two new ones are 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, using 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 taps - 18 V. In the author's version, each of the windings contained 162 turns with taps from the 54th and 108th turns.

The setup begins without an installed microcontroller, op-amp and indicator by checking the constant voltages at the outputs of the rectifiers and stabilizer DA1. When programming the microcontroller, it is necessary to 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, with the programmer connected to the XP2 plug. In this case, the microcontroller is powered from a power supply.
After installing the microcontroller and op-amp, connect the indicator and turn on the device (without load), holding down the SB3 “Select” button, and the microcontroller program will go into the initial settings mode. Resistor R16 sets the desired contrast of the indicator image, and the selection of resistor R18 sets the brightness of the indicator panel backlight.

Next, by pressing the SB3 “Select” button, you need to select the k coefficient setting section in the menu. A standard 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 the voltmeter. In this case, the output current should be zero.

Then set the minimum output voltage (1.25V) and connect a series-connected standard ammeter and a load resistor with a resistance of about 10 Ohms and a power of 40...50 W to the output. By changing the output voltage, set the output current to about 2 A and use resistor R17 to bring the indicator readings into line with the ammeter readings. After this, a resistor with a resistance of 1 kOhm is connected in series with the ammeter and the output current is set to 10 mA by changing the output voltage. The indicator should show the same current value; if this is not the case and the readings are smaller, it is necessary to install a resistor with a resistance of 300...1000 Ohms between the output of the stabilizer DA1 and the source of the transistor VT1 and its selection to equalize the readings of the indicator and the ammeter. You can temporarily use a variable resistor, then replacing it with a constant one with the appropriate resistance.

Finally, the value of the coefficient k is clarified. To do this, a standard voltmeter and a powerful load resistor are again connected to the output. By changing the output voltage, the output current is set close to the maximum. By pressing the SB1 "+" or SB2 "-" button, change the coefficient k so that the readings of the indicator and the voltmeter coincide. After pressing the SB3 “Select” button, the microcontroller will reboot and the power supply will be ready for use.
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
Chapter:

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
Resolution of digital voltmeter, 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.

I present for your attention a proven diagram of a good laboratory power supply, published in the magazine "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 the device operation. The optocoupler maintains a voltage drop across the linear regulator of approximately 1.5 V. If the voltage drop across the chip increases (for example, due to an increase in input voltage), the optocoupler LED and, accordingly, the phototransistor turn on. The PHI controller turns off, closing the switching transistor. The voltage at the input of the linear stabilizer will decrease.

To increase stability, resistor R3 is placed as close as possible to the stabilizer chip DA1. Chokes L1, L2 are sections of ferrite tubes placed on the gate terminals of field-effect transistors VT1, VT3. The length of these tubes is approximately half the length of the lead. The L3 inductor is wound on two K36x25x7.5 ring magnetic cores folded together from MP 140 permalloy. Its winding contains 45 turns, which are wound into two PEV-2 wires with a diameter of 1 mm, laid evenly around the perimeter of the magnetic core. It is permissible to replace the IRF9540 transistor 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 regulator DA5 in parallel with DA1. Then the maximum load current will reach 15 A. In this case, inductor L3 is wound with a bundle consisting of four PEV-2 wires with a diameter of 1 mm, and the capacitance of capacitors C1-SZ is approximately doubled. Resistors R18, R19 are selected according to the same degree of heating of microcircuits DA1, DA5. The PHI 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 unit

The basis of the device is the PICI6F873 microcontroller. The DA2 chip contains a voltage stabilizer, which is also used as a reference for the built-in ADC of the DDI microcontroller. Port lines RA5 and RA4 are programmed as ADC inputs for measuring voltage and current, respectively, and RA3 is for controlling a field-effect transistor. The current sensor is resistor R2, and the voltage sensor is resistive divider R7 R8. The current sensor signal is amplified by 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 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.

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. Op-amps 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 Vcc/8 steps. 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 pin on the output connected to the ground pin on the input. 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 the maximum output voltage in the hardware_settings.h file 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 the message “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 do voltmeter and ammeter calibration. 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:

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. Op-amps 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 Vcc/8 steps. 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 pin on the output connected to the ground pin on the input. 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 the maximum output voltage in the hardware_settings.h file 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 the message “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 do voltmeter and ammeter calibration. 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:

mob_info