모터·릴레이·솔레노이드 구동: 트랜지스터와 플라이백 다이오드Driving Motors, Relays, and Solenoids: Transistors and Flyback Diodes
마이크로컨트롤러 핀으로 큰 부하를 켜는 방법, 트랜지스터·MOSFET 선택, 유도성 부하의 플라이백 다이오드, 전원 분리와 접지 공유를 설명합니다.How to switch large loads from a microcontroller pin, choosing a transistor or MOSFET, flyback diodes for inductive loads, and separating power while sharing ground.
마이크로컨트롤러나 로직 IC의 출력 핀은 LED 한두 개를 켜는 정도의 전류만 낼 수 있습니다. 모터, 릴레이, 솔레노이드, 큰 램프 같은 부하는 수십~수백 mA에서 수 A까지 필요해 핀에 직접 연결하면 핀이 망가집니다. 이 글에서는 작은 신호로 큰 부하를 켜는 구동 회로의 구성, 트랜지스터와 MOSFET 선택, 코일 부하에 반드시 필요한 플라이백 다이오드, 전원 분리와 접지 공유 요령을 정리합니다.
핀이 낼 수 있는 전류와 부하
부하
필요한 전류(대략)
LED 한 개
5~20mA
소형 5V 릴레이 코일
약 40~100mA
소형 직류 모터
100~500mA(회전 시작·정지 때 더 큼)
솔레노이드
200mA 이상
부저(능동)
약 10~30mA
마이크로컨트롤러 핀 하나가 줄 수 있는 전류는 보통 20mA 안팎 이하입니다. 정확한 값은 칩의 데이터시트에서 확인하세요(데이터시트 읽는 법). 큰 부하는 드라이버(트랜지스터·MOSFET·전용 IC)를 거쳐 전원에서 직접 전류를 받아야 합니다.
부하를 켤 때마다 마이크로컨트롤러가 리셋되면 전원 분리, 커패시터, 다이오드를 의심합니다.
정리
큰 부하는 마이크로컨트롤러 핀이 아니라 트랜지스터·MOSFET·드라이버 IC가 전원에서 직접 전류를 받아 구동하게 하고, 코일 부하에는 플라이백 다이오드를 반드시 다세요. 모터는 별도 전원을 쓰고 접지는 공유하며, 교류 전원을 직접 다루는 작업은 하지 마세요. 기본 원리는 트랜지스터 스위치 회로에서 이어서 볼 수 있습니다.
The output pin of a microcontroller or logic IC can supply only enough current to light an LED or two. Loads like motors, relays, solenoids, and big lamps need tens of mA up to several amps, and connecting them straight to the pin destroys it. This article covers the arrangement of a driver circuit that switches a big load with a small signal, choosing between transistors and MOSFETs, the flyback diode that coil loads absolutely need, and tips on separating power and sharing ground.
Current a pin can supply, and loads
Load
Current needed (approx.)
One LED
5–20 mA
Small 5 V relay coil
About 40–100 mA
Small DC motor
100–500 mA (more at start and stall)
Solenoid
200 mA or more
Buzzer (active)
About 10–30 mA
The current one microcontroller pin can supply is usually around 20 mA or less. Check the exact value in the chip's datasheet (How to Read a Datasheet). A big load must get its current straight from the supply through a driver (transistor, MOSFET, or dedicated IC).
7 channels, about 500 mA per channel, built-in flyback diodes
Relays, stepper motors, several loads at once
Logic-level N-channel MOSFET
Small voltage drop when on and large current
High-current motors, lamps
H-bridge IC (L298N, TB6612, DRV8833, and so on)
Motor direction reversal and speed control
Forward and reverse motor rotation
Driving a relay with a transistor
Say a 5 V relay's coil current is 70 mA and the microcontroller output is 3.3 V.
Collector current Ic = 70 mA, base current Ib ≈ Ic ÷ 10 = 7 mA
R_B = (3.3 V − 0.7 V) ÷ 7 mA ≈ 370 Ω → use 330 Ω.
Check that the microcontroller pin can supply 7 mA. If it cannot, use a ULN2003 or a MOSFET.
Tips for using a MOSFET
Use a logic-level MOSFET. Pick one that turns on fully at a 3.3 V gate voltage (the IRLZ44N, or small-signal ones like the 2N7000 and AO3400). A regular MOSFET (such as the IRF540) needs a gate voltage near 10 V and does not turn on properly at 3.3 V.
Put 100–220 Ω in series between the gate and the pin, and a 10 kΩ pull-down between the gate and GND. That keeps the load from turning on even if the pin floats while the microcontroller boots.
Connect the load between the MOSFET drain and +V, and the source to GND (low side).
The flyback (freewheeling) diode
When the current through a coil load (relay, motor, solenoid) is cut, the coil releases energy and creates a momentary high reverse voltage (tens to hundreds of volts). That voltage can destroy the transistor or reset the microcontroller.
If you attach a diode in reverse, in parallel with the coil, this current circulates through the diode and dies away safely.
The diode's cathode (band) goes to the +V side and its anode to the transistor (collector or drain) side.
Driver ICs like the ULN2003 include this diode (connect the COM pin to the load supply).
Choosing a relay
Coil voltage: 5 V, 12 V, 24 V. Match it to the circuit's supply.
Contact rating: markings like 10 A 250 V AC are the limits the contacts can withstand. But switching mains such as 220 V AC directly carries a high risk of shock and fire, so beginners should not do it. It is safer to use the coil at low voltage and the contacts only for low-voltage loads (such as a 12 V lamp).
Relay modules: modules that are isolated from the control circuit with an optocoupler and include a driver and a diode are convenient. Many turn on when the signal is Low, so check the instructions.
Touch the driver or transistor to check that it is not getting hot.
If the microcontroller resets each time the load turns on, suspect power separation, capacitors, or the diode.
Summary
Have a big load driven by a transistor, MOSFET, or driver IC taking current directly from the supply, not by a microcontroller pin, and always attach a flyback diode to coil loads. Use a separate supply for motors and share ground, and do not work directly with AC mains. Continue with the basic principle in Transistor Switch Circuits.
에디터에서 직접 해 보기Try it in the editor
읽은 내용을 패턴도 에디터에서 바로 확인해 보세요. 회원가입 없이 열리고, 납땜 전에 배치와 배선을 몇 번이고 고쳐 볼 수 있습니다.Try what you just read right in the Patterndo editor. It opens without sign-up, and you can rework the layout and wiring as many times as you like before you solder.
이 글은 학습 목적의 일반적인 안내입니다. 부품마다 규격과 핀 배열이 다를 수 있으니 실제 작업 전에는 사용하는 부품의 데이터시트를 확인하세요. 안전과 관련된 작업은 항목별 주의 사항을 먼저 읽고 진행하세요.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.