计算buck芯片FB的分压电阻

软件从唐老师的课看到:DCDC开关电源PCB设计实战(9)BUCK电路PCB设计(9)TI杯电赛和NXP智能车电源设计第9讲_哔哩哔哩_bilibili没有原版,就用gpt写了一个。

下载链接:https://github.com/lumole/Calculate-the-partial-resistance

核心逻辑

import numpy as np

def calculate_resistor_values(Vref, Vout, resistor_tolerance=0.01, error_tolerance=0.01):
    # Standard resistor values (E24 series)
    standard_resistors = np.array([1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1,
                                   10, 11, 12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 43, 47, 51, 56, 62, 68, 75, 82, 91,
                                   100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300, 330, 360, 390, 430, 470, 510, 560, 620, 680, 750, 820, 910,
                                   1000, 1100, 1200, 1300, 1500, 1600, 1800, 2000, 2200, 2400, 2700, 3000, 3300, 3600, 3900, 4300, 4700, 5100, 5600, 6200, 6800, 7500, 8200, 9100,
                                   10000, 11000, 12000, 13000, 15000, 16000, 18000, 20000, 22000, 24000, 27000, 30000, 33000, 36000, 39000, 43000, 47000, 51000, 56000, 62000, 68000, 75000, 82000, 91000,
                                   100000, 110000, 120000, 130000, 150000, 160000, 180000, 200000, 220000, 240000, 270000, 300000, 330000, 360000, 390000, 430000, 470000, 510000, 560000, 620000, 680000, 750000, 820000, 910000,
                                   1000000])

    results = []

    for R1 in standard_resistors:
        for R2 in standard_resistors:
            # Calculate with nominal, maximum, and minimum resistor values
            R1_min = R1 * (1 - resistor_tolerance)
            R1_max = R1 * (1 + resistor_tolerance)
            R2_min = R2 * (1 - resistor_tolerance)
            R2_max = R2 * (1 + resistor_tolerance)

            Vout_nominal = Vref * (1 + (R2/ R1))
            Vout_min = Vref * (1 + ((R2_min) / R1_max))
            Vout_max = Vref * (1 + ((R2_max) / R1_min))

            # Check if the Vout with tolerances is within error tolerance
            nominal_error = abs(Vout_nominal - Vout) / Vout
            min_error = abs(Vout_min - Vout) / Vout
            max_error = abs(Vout_max - Vout) / Vout

            if nominal_error < error_tolerance:
                results.append((R1, R2, nominal_error, min_error, max_error))

    # Sort results by nominal error
    results.sort(key=lambda x: x[2])

    return results

# Input parameters
Vref = 1.235
Vout = 8.0
resistor_tolerance = 0.01  # 1%
error_tolerance = 0.01  # 1%

# Calculate resistor values
results = calculate_resistor_values(Vref, Vout, resistor_tolerance, error_tolerance)

# Display the results
for result in results:
    R1, R2, nominal_error, min_error, max_error = result
    print(f"R1={R1:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值