목차 보기
- LM358이란
- 비교기 동작
- 예제: 12V 배터리 저전압 경보
- 출력이 떨리는 이유와 히스테리시스
- LM358을 비교기로 쓸 때의 한계
- 패턴도에서 확인하기
- 정리
Table of contents
- What the LM358 is
- How a comparator works
- Example: a 12V battery low-voltage alarm
- Why the output chatters, and hysteresis
- Limits of using an LM358 as a comparator
- Checking in Patterndo
- Summary
비교기는 두 전압을 비교해 어느 쪽이 큰지를 High 또는 Low로 알려 주는 회로입니다. 배터리 전압이 낮아지면 알려 주는 경보, 빛의 밝기에 따라 켜지는 조명 같은 "문턱 판단"이 필요한 곳에 쓰입니다. 전용 비교기 IC도 있지만, 입문 단계에서는 흔한 연산증폭기 LM358을 비교기로 쓰는 경우가 많습니다. 이 글에서는 LM358의 특징, 비교기 회로 만들기, 출력이 떨리는 이유와 히스테리시스로 해결하는 방법, 쓸 때 주의점을 정리합니다.
LM358이란
LM358은 8핀 DIP 안에 연산증폭기(op-amp) 두 개가 들어 있는 IC입니다. LM324는 같은 회로가 네 개 들어 있는 14핀 제품입니다.
LM358의 장점은 단일 전원으로 쓸 수 있고 입력이 접지 전압(0V)까지 허용된다는 점입니다. 출력은 0V 근처까지 내려가지만, 높은 쪽은 전원 전압보다 약 1.5V 낮은 곳까지만 올라갑니다. 5V 전원이면 출력 High가 약 3.5V입니다.
비교기 동작
연산증폭기를 피드백 없이 쓰면 두 입력의 차이를 매우 크게 증폭하므로 출력이 거의 항상 한쪽 끝에 붙습니다.
- IN+ 전압 > IN− 전압: 출력 High
- IN+ 전압 < IN− 전압: 출력 Low
즉, 한쪽 입력에 기준 전압을, 다른 쪽에 감시할 전압을 넣으면 문턱을 넘었는지 알 수 있습니다.
예제: 12V 배터리 저전압 경보
12V 배터리가 10.5V 아래로 떨어지면 LED를 켜는 회로를 만들어 봅니다.
- 기준 전압: 5.1V 제너 다이오드와 저항으로 안정된 5.1V를 만듭니다(다이오드와 제너 다이오드). 12V 전원에서 제너 전류 5mA를 흘리면 저항은
(12 − 5.1) ÷ 0.005 ≈ 1.4kΩ이므로 1.5kΩ을 씁니다. - 감시 전압: 배터리를 분압해 10.5V에서 5.1V가 되게 합니다. R1 = 10kΩ(위), R2 = 9.1kΩ(아래)이면
10.5 × 9.1 / 19.1 ≈ 5.0V입니다. 분압 설계는 분압 회로 설계와 부하 효과를 참고하세요. - 비교기 연결: 분압 출력(감시 전압)을 IN−에, 기준 전압을 IN+에 넣습니다. 배터리가 충분하면 감시 전압 > 기준이라 출력 Low, 10.5V 아래로 내려가면 감시 전압 < 기준이 되어 출력이 High가 됩니다.
- LED: 출력에서 1kΩ과 LED를 거쳐 접지로 연결하면 저전압일 때 켜집니다(전류는 약
(12 − 1.5 − 2) ÷ 1k ≈ 8mA).
출력이 떨리는 이유와 히스테리시스
감시 전압이 기준 전압 근처에서 천천히 변하면 노이즈 때문에 출력이 High와 Low 사이를 빠르게 오갑니다(채터링). LED가 깜빡이거나 릴레이가 덜덜거리는 현상입니다. 해결책이 히스테리시스입니다. 출력을 IN+에 저항으로 되먹임(양의 피드백)해, 켜질 때와 꺼질 때의 문턱을 일부러 다르게 만듭니다.
구성은 다음과 같습니다. 기준 전압을 Ra(+V 쪽)와 Rb(접지 쪽) 분압으로 만들어 IN+에 넣고, 출력에서 IN+까지 피드백 저항 Rf를 연결합니다.
히스테리시스 폭 ΔV ≈ (출력 High − 출력 Low) × (Ra ∥ Rb) / (Rf + Ra ∥ Rb)
Ra = Rb = 10kΩ(병렬 5kΩ), Rf = 470kΩ이고 출력이 약 0V와 3.5V 사이를 오갈 때 ΔV ≈ 3.5 × 5k / 475k ≈ 37mV입니다. Rf를 줄이면 폭이 넓어집니다. 필요한 폭은 감시하는 신호의 노이즈 크기보다 크게 잡으세요.
LM358을 비교기로 쓸 때의 한계
- 속도가 느립니다. 연산증폭기 출력은 비교기만큼 빠르게 변하지 않아 고속 신호에는 맞지 않습니다. 느리게 변하는 전압을 감시하는 용도에 쓰세요.
- 출력 High가 전원까지 오르지 않습니다. 5V 로직에 직접 연결할 때 High 레벨이 TTL 기준을 넘는지 확인하세요.
- 전용 비교기(LM393 등)는 출력이 오픈 컬렉터라서 풀업 저항이 필요하지만 속도가 빠르고 전원 레벨로 직접 맞출 수 있습니다. 진짜 비교기가 필요하면 이것을 쓰세요.
- 쓰지 않는 증폭기는 반전 입력을 출력과 연결하고(버퍼 구성), 비반전 입력을 전원 중간 전압이나 접지에 묶어 두세요. 입력을 떠 있게 두면 발진해 전체 전류를 늘릴 수 있습니다.
- 전원 핀 옆에 100nF을 답니다(전원 레일과 접지 설계).
패턴도에서 확인하기
패턴도에는 LM358과 LM324 모델이 있고, 개방 루프 이득과 출력 전압 한계(High·Low 여유)를 반영한 증폭기로 시뮬레이션합니다. 기준 전압과 감시 전압을 분압으로 만들고 입력 전압을 바꿔 가며 출력이 뒤집히는 지점을 확인해 보세요. 모델은 이상적인 소자에 가까우므로 실제 부품의 속도와 노이즈 특성은 반영되지 않습니다.
정리
연산증폭기를 피드백 없이 쓰면 비교기가 되고, 한쪽에 기준 전압을 다른 쪽에 감시 전압을 넣습니다. 기준점 근처의 떨림은 양의 피드백으로 히스테리시스를 주어 막고, 속도가 중요하면 LM393 같은 전용 비교기를 선택하세요. 문제가 생겼을 때의 점검 순서는 완성했는데 동작하지 않을 때: 단계별 점검표에서 볼 수 있습니다.
A comparator is a circuit that compares two voltages and tells you which is larger as High or Low. It is used where a "threshold decision" is needed, such as an alarm that warns when the battery voltage drops, or a light that turns on depending on the brightness of light. There are dedicated comparator ICs, but at the beginner stage the common LM358 op-amp is often used as a comparator. This article covers the features of the LM358, building a comparator circuit, why the output chatters and how hysteresis fixes it, and what to watch out for.
What the LM358 is
The LM358 is an IC with two operational amplifiers (op-amps) in an 8-pin DIP. The LM324 is a 14-pin product with four of the same circuit.
The strengths of the LM358 are that it works from a single supply and that its inputs are allowed down to ground (0 V). The output goes down close to 0 V, but at the high end it only rises to about 1.5 V below the supply voltage. With a 5 V supply, the output High is about 3.5 V.
How a comparator works
An op-amp used without feedback amplifies the difference between its two inputs enormously, so the output almost always sticks to one extreme.
- IN+ voltage > IN− voltage: output High
- IN+ voltage < IN− voltage: output Low
So by putting a reference voltage on one input and the voltage to watch on the other, you can tell whether the threshold has been crossed.
Example: a 12V battery low-voltage alarm
Let us build a circuit that lights an LED when a 12 V battery falls below 10.5 V.
- Reference voltage: make a stable 5.1 V with a 5.1 V Zener diode and a resistor (How to Use Diodes and Zener Diodes). With 5 mA of Zener current from the 12 V supply, the resistor is
(12 − 5.1) ÷ 0.005 ≈ 1.4kΩ, so use 1.5 kΩ. - Voltage to watch: divide the battery so that 10.5 V becomes 5.1 V. With R1 = 10 kΩ (top) and R2 = 9.1 kΩ (bottom),
10.5 × 9.1 / 19.1 ≈ 5.0V. For the divider design, see Designing Voltage Dividers and the Loading Effect. - Comparator connection: put the divider output (the voltage to watch) on IN− and the reference voltage on IN+. When the battery is healthy, the watched voltage is above the reference, so the output is Low; when it falls below 10.5 V, the watched voltage is below the reference and the output goes High.
- LED: connect the output through 1 kΩ and the LED to ground and it lights on low voltage (the current is about
(12 − 1.5 − 2) ÷ 1k ≈ 8mA).
Why the output chatters, and hysteresis
If the watched voltage changes slowly near the reference voltage, noise makes the output flip quickly between High and Low (chattering). The LED flickers or the relay rattles. The remedy is hysteresis. Feed the output back to IN+ through a resistor (positive feedback) to deliberately make the turn-on and turn-off thresholds different.
The arrangement is as follows. Make the reference voltage with a divider of Ra (toward +V) and Rb (toward ground), feed it to IN+, and connect a feedback resistor Rf from the output to IN+.
Hysteresis width ΔV ≈ (output High − output Low) × (Ra ∥ Rb) / (Rf + Ra ∥ Rb)
With Ra = Rb = 10 kΩ (5 kΩ in parallel), Rf = 470 kΩ, and the output swinging between about 0 V and 3.5 V, ΔV ≈ 3.5 × 5k / 475k ≈ 37mV. Reducing Rf widens the band. Make the width larger than the noise on the signal you are watching.
Limits of using an LM358 as a comparator
- It is slow. An op-amp output does not switch as fast as a comparator, so it is not suited to fast signals. Use it to watch slowly changing voltages.
- The output High does not reach the supply. When connecting directly to 5 V logic, check that the High level exceeds the TTL threshold.
- A dedicated comparator (LM393 and so on) has an open-collector output so it needs a pull-up resistor, but it is fast and can be matched directly to the supply level. If you need a true comparator, use one of these.
- For an unused amplifier, connect the inverting input to the output (a buffer configuration) and tie the non-inverting input to mid-supply or ground. Leaving inputs floating can make it oscillate and raise the total current.
- Put a 100 nF next to the supply pin (Power Rails, Grounding, and Decoupling Capacitor Placement).
Checking in Patterndo
Patterndo has LM358 and LM324 models, simulated as amplifiers that reflect open-loop gain and output voltage limits (High and Low headroom). Make the reference voltage and the watched voltage with dividers, and change the input voltage to see the point where the output flips. The model is close to an ideal device, so the speed and noise characteristics of real parts are not reflected.
Summary
An op-amp used without feedback becomes a comparator, with the reference voltage on one input and the watched voltage on the other. Prevent chatter near the threshold by giving hysteresis with positive feedback, and if speed matters, choose a dedicated comparator such as the LM393. For the order of checks when something goes wrong, see It Is Finished but It Does Not Work: A Step-by-Step Checklist.
이 글은 학습 목적의 일반적인 안내입니다. 부품마다 규격과 핀 배열이 다를 수 있으니 실제 작업 전에는 사용하는 부품의 데이터시트를 확인하세요. 안전과 관련된 작업은 항목별 주의 사항을 먼저 읽고 진행하세요.This article is general guidance for learning purposes. Specifications and pinouts differ between parts, so check the datasheet of the part you use before real work. For safety-related work, read the cautions for each item first.