# 具遲滯的比較器 (`comparatorHyst`)

> 比較兩個電壓，輸出高準位或低準位。

![comparatorHyst](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/comparatorHyst.svg)

[元件參考](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/) · [English](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/comparatorHyst/)

**分類:** 積體電路 · **種類:** `{"definition":"comparatorHyst","kind":"subsystem"}`

## 何時使用

用於保護臨界、過零偵測與史密特觸發式邏輯，且延遲與輸出型式會影響結果時。需要線性輸出時改用單極點運算放大器。

## 接腳

| 接腳 | 訊號域 | 意義 |
|---|---|---|
| `INP` | 電氣 | 非反相輸入，高於 INN 時輸出變高 |
| `INN` | 電氣 | 反相輸入 |
| `OUT` | 電氣 | 輸出，開汲極或推挽 |
| `VCC` | 電氣 | 電源，只有推挽輸出會用到 |
| `GND` | 電氣 | 輸出的接地參考 |

## 常用參數

- `vHys`: Hysteresis: total width of the band around zero input difference (預設值: 0.05)
- `vos`: Input offset voltage (the datasheet gives it as +/-) (預設值: 0.00037)
- `tPdLh`: Delay from the input crossing the threshold to OUT going high (預設值: 0.0000003)
- `tPdHl`: Delay from the input crossing the threshold to OUT going low (預設值: 0.0000003)
- `openDrain`: 1 = open drain (needs an external pull-up), 0 = push-pull from VCC (預設值: 1)

## 參數

| 鍵 | 單位 | 預設值 | 典型範圍 | 說明 | 規格書來源 |
|---|---|---|---|---|---|
| `vHys` | V | 0.05 | 0 – 10 V | Hysteresis: total width of the band around zero input difference | assumption: the LM393B has no internal hysteresis (typical comparators with it: tens of mV) |
| `vos` | V | 0.00037 | -100m – 100m V | Input offset voltage (the datasheet gives it as +/-) | Section 5.5 VIO typ +/-0.37 mV, p.6 |
| `tPdLh` | s | 0.0000003 | 0 – 1m s | Delay from the input crossing the threshold to OUT going high | Section 5.7 tresponse typ, TTL input with Vref = 1.4 V, p.7 |
| `tPdHl` | s | 0.0000003 | 0 – 1m s | Delay from the input crossing the threshold to OUT going low | Section 5.7 tresponse typ, TTL input with Vref = 1.4 V, p.7 |
| `rOutLo` | Ω | 27.5 | 1m – 100k Ω | Output resistance to GND when low (110 mV at 4 mA) | Section 5.5 VOL typ 110 mV at ISINK <= 4 mA, p.6 |
| `rOutHi` | Ω | 50 | 1m – 100k Ω | Output resistance to VCC when high (push-pull only) | assumption: not specified for an open-collector part |
| `openDrain` | — | 1 | 0 – 1 | 1 = open drain (needs an external pull-up), 0 = push-pull from VCC | Section 5.5 IOH-LKG: the LM393B output is open collector, p.6 |
| `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the output switches (leakage) | assumption: IOH-LKG typ 0.1 nA at 5 V is far below this model's resolution |

_參數說明在兩種語言中都是英文。_

## 模型

差值 Vid = V(INP) - V(INN) + vos 先經過史密特觸發：高於 +vHys/2 變高、低於 -vHys/2 變低。結果再延遲 tPdLh（上升）或 tPdHl（下降），並驅動兩個開關：低準位時 OUT 經 rOutLo 接到 GND；推挽零件在高準位時再由 VCC 經 rOutHi 接到 OUT。輸出初始為低，所以 t = 0 時輸入若落在遲滯帶內會被讀成低。比延遲更短的脈波會被丟棄，延遲不隨過驅動而變，輸入偏壓電流與輸出漏電流未建模。

## 常見錯誤

- 預設的開汲極輸出自己沒有高準位。請從 OUT 加一個上拉電阻到電源，例如 10 kOhm 接到 VCC，否則輸出永遠不會升高。
- 實際的切換點會被偏移 vos 移動。沒有內建遲滯的實際零件要在外部加正回授才有遲滯，預設的 50 mV 只是有內建遲滯之零件的典型值。
- 輸出控制會晚一個求解步長才到達開關。步長請設在 300 ns 延遲的十分之一以下，否則邊緣時間不準。

Problems 規則: `step.too_large`

## 規格書與來源

vos 取典型輸入偏移電壓。rOutLo 取低準位輸出電壓除以其測試電流（110 mV、4 mA 得 27.5 Ohm）。tPdLh 與 tPdHl 取自回應時間列，並依該列所給的過驅動與輸入步階條件。vHys 若零件有內部遲滯就取其規格值，沒有則由你外加的正回授決定。openDrain 對開集極或開汲極輸出填 1，推挽輸出填 0，此時 rOutHi 是高準位的導通電阻。

## 範例

以指令 `file.openExample` 開啟範例，名稱為 `demo:comparatorHyst`.

---
由 `cargo xtask reference` 依使用說明文字與參數規格產生，請勿手動編輯。
