ohahaha

[Open Source] STC8A8K adjustable fixed voltage source

 
Overview

STC8A8K adjustable/fixed voltage source

(Prototype only provides inspiration and ideas, not suitable for reproduction)v0JFD5GAqgQbDLgmiqMEhMAasUrFtCA3Q6JlFycW.jpeg

Main picture

cLehkLWjQXWGhsIdArT8rmPUj2hPQzW2PcLIlDlb.jpeg

front

QtnzbmsP3IgLdzQAjIYWEblX4tataZOqoREGvb0g.jpeg

Preview of plan one

Option 2 preview

one. Function introduction

The power supply is controlled by STC8A8K64SMCU and has:

  1. Adjustable and fixed output modes;
  2. 0.96-inch OLED voltage display and Led working status indicator;
  3. Short circuit protection, output overvoltage and low voltage warning, input overvoltage protection;
  4. Hardware protection circuit during program debugging;
  5. AC 220V mains input and DC 4.5~12V wide voltage input.

2. Basic principles of hardware

1. Control layer (top layer)

         The top layer is mainly responsible for transmitting 4-bit binary control signals to the middle layer, connecting the enable terminals of the four power modules respectively. The upper knob controls "standby", "3.3V", "5.0V", "12V" and "ADJ". Switching between states, thereby controlling the working state of the module and changing the output voltage.

(1) MCU control

        The ADC analog-to-digital conversion port of the MCU is connected to the potentiometer. Different intervals are set for the conversion results in the program to realize the knob (potentiometer) control working mode. In different working modes, the MCU outputs different 3-bit binary signals and passes them to the input terminal of the next-level 3-8 decoder (74HC238). 4 of the 8 output ports are selected as the above-mentioned The "4-bit binary control signal" is not only passed to the next layer, but also used as a control signal for the LED to drive the LED to indicate the current working status. When the OLED or MCU is offline, it indicates the current working status or the cause of the error.

Why use digital IC as buffer between MCU and power module? Why not directly connect the MCU and power module to simplify the design? First, because this power supply is a prototype, during the process of hardware programming, if two power modules are mistakenly enabled at the same time, the power supply may be damaged. Therefore, the interlocking principle of the 3-8 decoder is used to ensure that only A power module is enabled. This step can be eliminated if the program and hardware are already feasible. The second is that it can be used as a decoration, so even a large piece of it will remain empty.

(2) ADC voltage sampling

       The ADC sampling function of STC8A8K is used, the original resistor voltage division sampling is used, and the ADC sampling port is protected by SMBJ5.0. A total of two sampling channels are set up. First, burn the test program (the attachment has been uploaded), use a more accurate voltmeter in the adjustable mode to record the ADC conversion results corresponding to different voltages (theoretically it changes linearly), and calculate the regression The equation is written into a formal program, and the two channels are calculated and averaged separately, and finally the current voltage value is obtained. Finally, the results are displayed on the screen through the OLED driver.

pzWYlXAGkMLHsU1JIaCt1agxlcwXRSoF5gD6i0iW.jpeg

Sampling channel (lower)

6OKvCfqeAlOICzcWMWliEvC3fPqlPAIgCKW4jaVI.jpeg

Upper PCB

 

2. (Being) driven layer (middle layer)

      The middle layer is mainly responsible for enabling the corresponding power module and outputting the correct level based on the control signal passed down from the top layer.

Control signal output voltage

000 0V (idle)

001 3.3V

010 5V

011 12V

100 1.8~13V (adjustable)

111 0V (protection status)

(1) Fixed output power module

Fixed output modes include 3.3V, 5V, and 12V fixed voltage output modes. The corresponding model LM2596 is used as the power module. The function can be realized by connecting the enable terminal and signal line according to the correct wiring method.

(2) Output adjustable power module

         Select the LM2596-ADJ switching power supply module, use a knob potentiometer with two resistance values, one large and one small, in series as a feedback resistor. Rotate the knob to change the feedback voltage to achieve the output voltage adjustment function. A large resistance and a small resistance can achieve Coarse and fine voltage adjustment.

         Note : This simple design does not belong to the category of digital power supply. If you want to realize a digital adjustable power supply with pure digital control, you can use discrete components to rebuild the middle layer, build a large step-down switching power supply, and connect the IO port of the MCU. To the gate of the switch tube, high-frequency square wave signals (PWM modulation) with different duty cycles are output, and a closed-loop feedback system is designed to output and maintain different Vout.

N3GVhPWtIZMP38BqqO02T8cawNnrRcPMQkzcBMyV.jpeg

Middle PCB

 

 

3. Power layer (bottom layer)

Option 1 (built-in transformer, 2.2W)

          The bottom layer is mainly responsible for the energy supply of the upper two layers, converting 220V AC mains power into 15V DC, which is used as the VDD of each power module before step-down. Then DC 15V is converted into DC 5V through LDO and provided to MCU, OLED and other devices. In addition, a backup path for DC input is also set up to increase the DC 4.5~8V input voltage to 15V, which is then used as the above-mentioned VDD.

        (1) AC 220V to DC 15V

The 220V mains power is converted to about 16.9V (≤12*√2 V) through a 220:12 transformer and rectifier bridge, and then reduced to a more stable 15V voltage through a LM2596-ADJ power module, which is provided to the middle layer as VDD. At the same time, VDD is converted into 5V control signal power through LDO (ASM1117-5.0), which is provided to the middle and upper layers.

        (2)DC 4.5~8V to 15V

         In order to prevent sudden power outages or situations where there is no mains interface but an urgent need for a voltage source, this power supply is designed with input paths for traditional 5V power interfaces such as USB, DC 2.1 and DC 1.3. The 5V voltage is boosted to 15V through the boost power module XL6019, and is directly provided as VDD to the 5V LDO and middle power module next to it. It is also equipped with a Schottky diode as a PN junction isolation to block the backup path flow on the main path to prevent conflicts or unexpected reverse currents that may occur when AC 220V and 5V DC are connected at the same time. It is worth noting that due to the conservation of power (energy) and the fact that it is not equipped with any fast charging protocol, the output power of this path is extremely small.

        (3) Short circuit protection

In addition to the GND of each layer having a self-restoring insurance, out of basic respect for the 220V mains power, the input pin of the transformer of the bottom mains power supply also has a glass tube fuse holder, and fuses with different parameters can be selected according to needs.

        (4) Overvoltage protection (hardware)

Add a TVS transient suppressor and a Zener diode overvoltage cutoff circuit between 5V and GND of the top-level key devices (MCU and OLED).

Screenshot(1)(1)Screenshots(2)(1)

                                     Overvoltage cut-off circuit

(The wire drawn from the top of the circuit diagram is connected to the Pmos gate and used as a switching signal to control the on and off of Vcc)

(5) Relay switch

          The 5V power supply generated by the LDO controls the 5V power supply and the switches on the middle and upper layers. It is turned on when the relay is turned off and turned off when the relay is started, so it does not participate in the output shunt (this design is purely for safety, in fact, it is completely unnecessary) .

           defect:

          Since the selected transformer has a maximum output current of 400mA (12V), and the conversion efficiency of the two-stage switching power supply is at most 80%, the output capability of this solution is very weak, with an output power of only 2.2W. Many feedback resistors have a narrow value range. Due to design negligence, incorrect values ​​may lead to the scrapping of the 5V LDO.

Option 2 (external transformer, 15W)

(1)AC-DC

           Based on the first plan, a higher power transformer (30W) will be replaced, but it also takes up more space. Therefore, the transformer is moved out of the bottom circuit board, so that the AC 220V can be stepped down to AC 12V through the transformer outside, and then Enter the underlying PCB. In addition, replace the LM2596-ADJ with the XL4015 step-down switching power supply module to enhance the output capability of the "AC 12V → DC (12 *√2) V → DC 15V" process mentioned in Solution 1 (to put it bluntly, it means increasing the output current upper limit).

1g43yoGSLTRFM76OW2a5bE7nEOYbsoxuuOhnE4rE.png

[Option 2] Transformer interface (right) and DC binding post (left)

(2) 5V control power supply

            In scheme one, the 5V control power supply is directly generated by DC 15V step-down through LDO. Once Vin (original DC 15V) exceeds the upper limit of LDO (which often occurs during the test process), the LDO function fails and turns into a small resistor, and Vin is directly input to Middle and upper floors. Although the protection mechanisms of the middle and upper layers will be triggered, the LDO will definitely be gone. Therefore, adding a 12V LDO as a buffer stage between DC 15V and Vin of the LDO, coupled with an overvoltage cutoff circuit, although the efficiency is reduced, fully protects the safety of the components. So why not just add an overvoltage cutoff circuit to the 5V LDO instead of adding a buffer stage? This is indeed better, but I have an extra 12V LDO that I can't use anymore.

(3) Others

           The line width of the PCB power circuit is increased, and the rest including relays, backup inputs, and overcurrent and overvoltage protection are consistent with plan (1).

(4) Power test

Working mode (mode)

Load resistance (R L /Ω)

Maximum output voltage (Vout,max/V)

Output power (P/W)

3.3

5

2.5

1.25

twenty four

2.92

0.36

47

3.11

0.21

5

5

3.8

2.89

twenty four

4.63

0.89

47

4.85

0.5

12

5

(low voltage alarm)

(low voltage alarm)

twenty four

10.8

4.86

47

11.39

2.76

ADJ

5

8.1

13.12

twenty four

11.91

5.91

47

12.76

3.46

 

N9Ec032RV4f3W3lFE8Hb9IfYPwGI5eHzoDJbDt2c.jpeg

Bottom PCB (Option 1)

HA5ntrZWwEsiaU77qY94uIkFbfmj7kYieEjCuG8U.png

Underlying circuit diagram (Option 1)

Aor5pKc0i3pWUvQwilXpUmraR64wqgsuCQ0Sifki.jpeg

Bottom PCB (Option 2)

 

mWOl0pPA1ttTskr2wItKk5pHryGe4cbSXXSTol6X.png

Underlying circuit diagram (Option 2)

3. Basic principles of the program

(Coding style and performance are not for reference, so the following only introduces the control principle)

1.ADC and mode switching

        (Already introduced above, no need to repeat them)

2. Overvoltage and low voltage protection

          The idea of ​​the protection mechanism is: when Vout deviates too far from the expected value, the output power supply should be cut off and enter the preset protection state. When Vout returns to zero, the power supply should try to restart automatically. In theory, the protection function is very easy to implement through the ADC output results, but in fact there are many special cases, causing many discontinuities in the protection mechanism.

special case:

(1) The charging and discharging process when switching gears;

(2) The instantaneous voltage reduction and recovery process when the load is connected;

(3) The charging process when leaving the protection state (VEM, V_Emergency) and trying to restart.

          Therefore, it is necessary to set up multiple timers and apply multiple delay rules to allow sufficient time (hundred milliseconds) for charging and discharging to prevent false alarms from the protection mechanism. Interrupts in the program behave as follows:

          T0: Dynamic protection rule. Write rules for the charging process of capacitive components. Since the capacitor charging VT curve is a differential equation, an approximate three-segment linear rule is simulated to approximate it (in fact, more segments are better, but without professional equipment, it can only be approximated. stop here);

          T1: Static protection rule. When the gear switching stops for a period of time, it returns to the normal protection rule - that is, setting the upper and lower limits of Vout. Once the line is crossed, it directly enters the T2 rule.

          T2: Transient protection rule. When Vout crosses the line, the timing starts. When the timing ends, if the voltage has not returned to the correct range, a unified protection mechanism is triggered: enter protection mode (VEM), and the OLED display prompts the cause of the warning. And try to restart after the capacitor is discharged (when Vout = 0 V). The length of the timing determines the sensitivity of the protection mechanism, and is generally set to hundreds of milliseconds.

rfEBfLrfPJT42ht8GhdENJOHQzwSsyeg0GRkhnLo.jpeg

Low voltage (load too small), short circuit protection

3.OLED driver

          Refer to the code provided by the OLED merchant.

4. Precautions

1. Option 1:

         Option 1 is only the first version of the prototype. Since the maximum output current of the transformer selected at that time is 400mA, and the conversion efficiency of the two-stage switching power supply is at most 80%, the output capability of the power supply is very weak, with an output power of only 2.2W. The values ​​of many feedback resistors in the lower layer are relatively precise. Due to design negligence, incorrect values ​​may lead to the scrapping of the 5V LDO;

2.Option 2:

          When the load is small and the output current is large, although the two-stage switching power supply module can barely support the output, the output voltage will decrease to varying degrees. In addition, the decrease in the output voltage of the first stage will cause the input voltage Vin of the second stage to decrease. When it is less than a certain threshold, the internally provided reference voltage V REF will also decrease, causing the voltage reduction effect of the second stage output to be superimposed, thus greatly reducing the Small output capability. The maximum output power of this solution is 15W (although the transformer is 30W, but the transformer is not fully charged, the efficiency is definitely more than 50%, but it is not much higher).

          To sum up, this plan only provides inspiration and is not suitable for reproduction;

3. Crazy rotation of the gear knob may cause false alarms, especially when turning directly from the "ADJ" gear that outputs the highest voltage (13.4V) to the "StandBy" gear. During the process of restarting the power supply and restoring it, please think about why you are turning it so crazily;

4. During operation, never directly touch the parts directly connected to the mains, such as transformer pins, fuse pins, etc. It is recommended to wrap them with insulating glue or rubber;

5.Improvement ideas:

(1) Deleting the first-stage switching power supply can greatly increase the output capability under low-resistance loads, but it will also increase the output ripple and reduce the system fault tolerance;

(2) The MCU download port is changed to USB direct connection download (refer to STC data manual), which reduces the floor space and improves the aesthetics;

(3) Rebuild the middle layer and use discrete devices to build a BUCK step-down power supply. The PWM control signal is given by the MCU and negative feedback is implemented through the ADC (under design).

BWTQuTB8l5jbJk1UTZBY1QvPRjw9k83lFXwcfGL2.png

Upper PCB 3D rendering

BNXqwbcMlfIwwEK183qSemWYxXth8mMiYz1UsrZw.png

Bottom PCB 3D rendering

 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-24 00:28:32

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号