如何使用 UliEngineering 在 Python 中计算迟滞阈值比例

你可以使用 UliEngineering Python 库轻松计算迟滞阈值比例:

hysteresis_threshold_ratios.py
from UliEngineering.Electronics.Hysteresis import hysteresis_threshold_ratios

# 计算 10% 迟滞时的阈值比例
low_ratio, high_ratio = hysteresis_threshold_ratios(0.10)
print(f"低阈值比例 (10% 迟滞): {low_ratio:.4f}")
print(f"高阈值比例 (10% 迟滞): {high_ratio:.4f}")

# 计算 20% 迟滞时的阈值比例
low_ratio, high_ratio = hysteresis_threshold_ratios(0.20)
print(f"低阈值比例 (20% 迟滞): {low_ratio:.4f}")
print(f"高阈值比例 (20% 迟滞): {high_ratio:.4f}")

示例输出

hysteresis_threshold_ratios_output.txt
低阈值比例 (10% 迟滞): 0.4500
高阈值比例 (10% 迟滞): 0.5500
低阈值比例 (20% 迟滞): 0.4000
高阈值比例 (20% 迟滞): 0.6000

迟滞阈值比例以输入信号范围的小数形式表示下切换点和上切换点。迟滞用于防止因噪声或信号波动引起的不必要切换。这些比例决定了输出根据输入信号电平切换状态的位置。

阈值比例通过以下公式计算:$R_{low} = \frac{1 - h}{2}$ 和 $R_{high} = \frac{1 + h}{2}$,其中 $h$ 为迟滞百分比(例如 10% 对应 0.10)。下阈值设定在中点以下,上阈值设定在中点以上,从而形成一个不会发生切换的死区。

相关文章


Check out similar posts by category: Electronics, Python