วัตถุประสงค์การเรียนรู้Learning Objectives
  • บอกได้ว่าออปโตอิเล็กทรอนิกส์คืออะไร และแยกอุปกรณ์เป็นฝั่ง กำเนิดแสง กับ รับแสง ได้
  • อธิบายการทำงานของ LED, IR LED, เลเซอร์ไดโอด และ 7-Segment display ได้
  • เปรียบเทียบ LDR, โฟโตไดโอด, โฟโตทรานซิสเตอร์, โซลาร์เซลล์ (ความไว/ความเร็ว) ได้
  • อธิบายโครงสร้างและประโยชน์ของ ออปโตคัปเปลอร์ (PC817) และคำนวณจากค่า CTR ได้
  • เช็คอุปกรณ์ออปโตด้วยมัลติมิเตอร์ได้
  • State what optoelectronics is and sort devices into emitters vs detectors
  • Explain LEDs, IR LEDs, laser diodes and the 7-segment display
  • Compare the LDR, photodiode, phototransistor and solar cell (sensitivity/speed)
  • Explain the structure and benefits of an optocoupler (PC817) and calculate with its CTR
  • Test opto devices with a multimeter
ออปโตอิเล็กทรอนิกส์คืออะไร?What is Optoelectronics?
  • อุปกรณ์ที่เปลี่ยนพลังงานไฟฟ้าเป็นแสง หรือเปลี่ยนแสงกลับเป็นพลังงานไฟฟ้า
  • แบ่งเป็น 2 ฝั่งใหญ่:
    💡 ตัวกำเนิดแสง (Emitter): ไฟฟ้า → แสง เช่น LED, เลเซอร์ไดโอด
    👁️ ตัวรับแสง (Detector): แสง → ไฟฟ้า เช่น LDR, โฟโตไดโอด
  • คำว่า "แสง" รวมถึงแสงที่ตามองไม่เห็นด้วย เช่น อินฟราเรด (IR) และอัลตราไวโอเลต (UV)
  • จับคู่ emitter + detector = ส่งสัญญาณด้วยแสง เช่น รีโมท, ไฟเบอร์ออปติก, ออปโตคัปเปลอร์
  • The field of devices that convert between electricity and light
  • Two big families:
    💡 Emitters: electricity → light, e.g. LEDs, laser diodes
    👁️ Detectors: light → electricity, e.g. LDRs, photodiodes
  • "Light" includes invisible bands too — infrared (IR) and ultraviolet (UV)
  • Pair an emitter with a detector = signalling with light: remotes, fiber optics, optocouplers
แสง / light ⚡ Emitter LED / Laser Detector Photodiode / LDR ⚡ ไฟฟ้า → แสง electricity → light แสง → ไฟฟ้า light → electricity
🔗 อุปกรณ์ออปโตส่วนใหญ่สร้างจาก รอยต่อ PN เหมือนไดโอด — ทบทวนหลักการได้ในบท ไดโอด (มีตาราง Vf ของ LED แต่ละสีด้วย) 🔗 Most opto devices are built on a PN junction just like a diode — review the Diode lesson (it has the LED Vf-by-color table too).
💡 ฝั่งกำเนิดแสง (Emitters)💡 Light Emitters
  • LED: ไดโอดเปล่งแสงเมื่อไบแอสตรง — สีขึ้นกับสารกึ่งตัวนำ (Vf แดง ≈ 1.8 V … น้ำเงิน/ขาว ≈ 3.2 V) ต้องมี R จำกัดกระแสเสมอ (ดูบทไดโอด)
  • IR LED (อินฟราเรด): เปล่งแสงที่ตามองไม่เห็น (~940 nm), Vf ต่ำ ≈ 1.2 V — หัวใจของรีโมทและเซนเซอร์วัตถุ
  • เลเซอร์ไดโอด: แสงเข้ม เฟสเดียว เป็นลำแคบ — ใช้ในพอยน์เตอร์, เครื่องอ่านบาร์โค้ด, ไฟเบอร์ออปติก ⚠️ ห้ามส่องตา
  • LED: emits light under forward bias — color set by the semiconductor (Vf red ≈ 1.8 V … blue/white ≈ 3.2 V). Always needs a current-limit resistor (see the Diode lesson)
  • IR LED: emits invisible light (~940 nm), low Vf ≈ 1.2 V — the heart of remotes and object sensors
  • Laser diode: intense, coherent, narrow beam — pointers, barcode scanners, fiber optics ⚠️ never aim at eyes
📱 ทิปช่าง: ตาเรามองแสง IR ไม่เห็น แต่กล้องหน้ามือถือเห็น — จ่ายไฟให้ IR LED (หรือกดรีโมท) แล้วส่องผ่านกล้อง จะเห็นเป็นแสงม่วงจางๆ ใช้เช็คว่ารีโมทเสียหรือไม่ 📱 Technician tip: your eyes can't see IR, but a phone's front camera can — power the IR LED (or press a remote) and view it through the camera: it glows faint purple. Great for checking dead remotes.
a b c d e f g dp = LED 8 ดวง = 8 LEDs (a–g + dp) Common Anode / Common Cathode
7-Segment Display — LED 7 แท่ง + จุด7-Segment Display — 7 bars + dot

  • 7-Segment คือ LED 8 ดวง (แท่ง a–g + จุด dp) เรียงเป็นเลข "8" — เลือกติดทีละแท่งเพื่อแสดงเลข 0–9
  • Common Cathode (CC): ขา K ทุกดวงรวมกันต่อ GND → จ่าย ลอจิก HIGH เข้าขาแท่งเพื่อให้ติด
  • Common Anode (CA): ขา A ทุกดวงรวมกันต่อ Vcc → ดึงขาแท่งลง LOW เพื่อให้ติด
  • ทุกแท่งต้องมี R จำกัดกระแส ของตัวเอง (ห้ามใช้ R ตัวเดียวที่ขา common — ความสว่างจะเปลี่ยนตามจำนวนแท่งที่ติด)
  • A 7-segment is 8 LEDs (bars a–g + dot dp) arranged as an "8" — light chosen bars to show 0–9
  • Common Cathode (CC): all cathodes tied to GND → drive a segment HIGH to light it
  • Common Anode (CA): all anodes tied to Vcc → pull a segment LOW to light it
  • Every segment needs its own current-limit resistor (one shared R at the common pin makes brightness vary with digit)
เลขDigitแท่งที่ติดSegments on
0a b c d e f
1b c
7a b c
8a b c d e f g
9a b c d f g
👁️ ฝั่งรับแสง (Detectors)👁️ Light Detectors
อุปกรณ์Device หลักการPrinciple ความเร็วSpeed เหมาะกับBest for
LDR
(Light Dependent Resistor)
ตัวต้านทานที่ค่า R ลดลงเมื่อแสงมาก (มืด ≈ MΩ → สว่าง ≈ kΩ)Resistor whose R drops with light (dark ≈ MΩ → bright ≈ kΩ) ช้ามาก (ms–s)Very slow (ms–s) ไฟถนนอัตโนมัติ, วัดความสว่างแบบง่ายAuto street lights, simple light sensing
โฟโตไดโอดPhotodiode ไดโอดที่ ไบแอสกลับ — แสงยิ่งมาก กระแสรั่วย้อนกลับยิ่งมาก (เชิงเส้นดี)Reverse-biased diode — more light, more reverse current (very linear) เร็วมาก (ns)Very fast (ns) ไฟเบอร์ออปติก, เครื่องวัดแสง, การสื่อสารFiber optics, light meters, comms
โฟโตทรานซิสเตอร์Phototransistor ทรานซิสเตอร์ที่ใช้ แสงแทนกระแสเบส — ขยายในตัว ไวกว่าโฟโตไดโอด 100–1000 เท่าTransistor whose base current is light — built-in gain, 100–1000× more sensitive than a photodiode ปานกลาง (µs)Medium (µs) รีโมท IR, ออปโตคัปเปลอร์, เซนเซอร์นับชิ้นงานIR remotes, optocouplers, object counters
โซลาร์เซลล์Solar cell รอยต่อ PN พื้นที่ใหญ่ ทำงานโหมด photovoltaic — สร้างแรงดันเอง (~0.5–0.6 V/เซลล์)Large-area PN junction in photovoltaic mode — generates its own voltage (~0.5–0.6 V/cell) — ผลิตพลังงาน (ต่ออนุกรมเพิ่มแรงดัน)Energy harvesting (series cells for voltage)
🔬 ลองเล่นจริงได้เลย: เบรดบอร์ดเสมือน มี LDR ให้วาง + แผงปรับความเข้มแสง — ต่อวงจรแบ่งแรงดันด้วย LDR แล้วเลื่อนสไลเดอร์แสงดูแรงดันเปลี่ยน 🔬 Try it live: the Breadboard Lab has an LDR component + a light-level slider — build an LDR voltage divider and watch the voltage move
⭐ ออปโตคัปเปลอร์ (Optocoupler / Opto-isolator)⭐ Optocoupler / Opto-isolator
  • จับ LED (IR) + โฟโตทรานซิสเตอร์ ใส่ไว้ใน IC ตัวเดียว — สัญญาณข้ามจากฝั่งเข้าไปฝั่งออก ด้วยแสงล้วนๆ ไม่มีสายไฟเชื่อมถึงกัน
  • สองฝั่ง แยกกันทางไฟฟ้า (isolation) ทนแรงดันต่างกันได้หลาย kV (PC817 ≈ 5 kV)
  • ประโยชน์: แยกกราวด์ สองระบบ, ป้องกันวงจรควบคุม (MCU) จากฝั่งแรงดันสูง, กันสัญญาณรบกวน
  • เบอร์ยอดนิยม: PC817 (DIP-4, ทรานซิสเตอร์ออก), 4N35, 6N137 (ความเร็วสูง), MOC3021 (ขับ TRIAC ฝั่งไฟบ้าน)
  • An IR LED + phototransistor sealed in one IC — the signal crosses from input to output as pure light, with no wire between the sides
  • The two sides are electrically isolated, withstanding several kV between them (PC817 ≈ 5 kV)
  • Why: separate the grounds of two systems, protect a controller (MCU) from a high-voltage side, block noise
  • Popular parts: PC817 (DIP-4, transistor output), 4N35, 6N137 (high speed), MOC3021 (mains TRIAC driver)
PC817 (DIP-4) 1 · A 2 · K 4 · C 3 · E ↔ isolation ~5 kV
โครงสร้างภายใน: LED (ขา 1-2) → แสง → โฟโตทรานซิสเตอร์ (ขา 4-3)Inside: LED (pins 1-2) → light → phototransistor (pins 4-3)

CTR = ( IC / IF ) × 100%
  • CTR (Current Transfer Ratio) = อัตราส่วนกระแสออกต่อกระแสเข้า เทียบได้กับ β ของทรานซิสเตอร์
  • PC817 มี CTR ≈ 50–300% (แล้วแต่เกรด) เช่น CTR 100%: จ่าย IF = 10 mA → ได้ IC สูงสุด ≈ 10 mA
  • งานสวิตช์ควรจ่าย IF เผื่อให้ทรานซิสเตอร์ อิ่มตัว (saturate) ไปเลย → เอาต์พุตชัดเจน HIGH/LOW
  • CTR (Current Transfer Ratio) = output current over input current — the opto's version of a transistor's β
  • PC817 has CTR ≈ 50–300% (grade-dependent); e.g. CTR 100%: drive IF = 10 mA → up to IC ≈ 10 mA
  • For switching, overdrive IF so the transistor saturates → clean HIGH/LOW output
ฝั่งควบคุม 5V Control side 5V ฝั่งโหลด 12/24V Load side 12/24V MCU 330Ω PC817 R +V รีเลย์/โหลดRelay/Load กราวด์แยกกันคนละฝั่ง separate grounds
ตัวอย่าง: MCU ฝั่ง 5V สั่งงานโหลดฝั่ง 12/24V โดยไม่แตะกันทางไฟฟ้าExample: a 5V MCU drives a 12/24V load with no electrical contact
🔗 ถ้าโหลดเป็นขดลวดรีเลย์ อย่าลืม ไดโอด flyback — ดูวงจรขับรีเลย์เต็มๆ ในบท รีเลย์; SSR (Solid State Relay) ก็คือออปโตคัปเปลอร์ + สวิตช์กำลัง ในกล่องเดียว โดยตัวสวิตช์กำลังนั้นคือ TRIAC/SCR ซึ่งคุมไฟบ้านได้โดยตรง 🔗 If the load is a relay coil, don't forget the flyback diode — see the full driver circuit in the Relay lesson; an SSR (solid-state relay) is just an optocoupler + power switch in one box, and that power switch is a TRIAC/SCR able to control mains directly.
⭐ จำลองออปโตคัปเปลอร์: จาก IF ถึง Vout⭐ Optocoupler Simulation: from IF to Vout

ปรับกระแส LED ฝั่งเข้า (IF) ดูแสงข้ามช่องแยกไปขับโฟโตทรานซิสเตอร์ — กระแสออก IC = CTR × IF ไหลผ่าน RL ทำให้ Vout ตกลงจาก Vcc ถ้าขับแรงพอ ทรานซิสเตอร์จะ อิ่มตัว → Vout ≈ 0.2 V (เอาต์พุตเป็น LOW ชัดเจน)

Adjust the input LED current (IF) and watch light cross the isolation gap to drive the phototransistor — the output current IC = CTR × IF flows through RL, pulling Vout down from Vcc. Drive it hard enough and the transistor saturates → Vout ≈ 0.2 V (a clean LOW).

จุดส้ม = โฟตอน (แสง) — ยิ่ง IF มาก แสงยิ่งหนาแน่น • แถบขวา = Vout Orange dots = photons — more IF, denser light • right bar = Vout

⚙ ปรับค่า⚙ Adjust
Vcc = 5 V • VCE(sat) ≈ 0.2 V
5.0 mA
100%
1.0 kΩ
IC
— mA
Vout
— V
CTR × IF
— mA
สถานะState
—
🔬 ลองดู: ที่ RL = 1 kΩ ต้องมี IC ≈ 4.8 mA ถึงจะอิ่มตัว — CTR 100% จึงต้องจ่าย IF ≥ ~4.8 mA • ลด CTR เหลือ 50% (ตัวเสื่อม/เกรดต่ำ) → ต้องจ่าย IF เพิ่มเป็น 2 เท่า • ลด RL → ยิ่งต้องขับแรงขึ้นอีก นี่คือเหตุผลที่งานจริงเผื่อ IF ไว้เสมอ 🔬 Try it: at RL = 1 kΩ saturation needs IC ≈ 4.8 mA — so at CTR 100% you must drive IF ≥ ~4.8 mA • drop CTR to 50% (aged/low-grade part) → you need twice the IF • lower RL → even more drive needed. This is why real designs overdrive IF.
การใช้งานจริงReal-World Uses
  • รีโมทคอนโทรล: IR LED ส่งรหัสแบบกะพริบเร็วบนคลื่นพาห์ 38 kHz → ตัวรับ (เช่น TSOP1738) กรองเฉพาะ 38 kHz จึงไม่กวนด้วยแสงห้อง
  • Opto-interrupter (ตัวขวางแสง): LED กับโฟโตทรานซิสเตอร์หันหน้าชนกันเป็นร่อง — วัตถุผ่านร่อง = สัญญาณขาด ใช้นับชิ้นงาน/หาตำแหน่งในพรินเตอร์
  • Rotary encoder แบบแสง: จานเจาะรูหมุนตัดลำแสง → นับพัลส์ = ความเร็ว/ตำแหน่งมอเตอร์
  • Remote controls: an IR LED blinks a code on a 38 kHz carrier → the receiver (e.g. TSOP1738) filters for 38 kHz, ignoring room light
  • Opto-interrupter: LED and phototransistor face each other across a slot — an object in the slot breaks the beam; used for counting/positioning in printers
  • Optical rotary encoders: a slotted disc chops the beam → count pulses = motor speed/position
  • ไฟเบอร์ออปติก: เลเซอร์/LED ยิงแสงเข้าเส้นใยแก้ว สะท้อนกลับหมดภายใน (total internal reflection) วิ่งได้หลายกิโลเมตร — กระดูกสันหลังของอินเทอร์เน็ต
  • เครื่องวัดออกซิเจนปลายนิ้ว (pulse oximeter): LED แดง + IR ยิงผ่านนิ้ว วัดการดูดกลืนแสงของเลือด
  • แหล่งจ่ายสวิตชิง: ใช้ออปโตคัปเปลอร์ส่งสัญญาณ feedback ข้ามฝั่งไฟบ้าน↔ฝั่งไฟต่ำอย่างปลอดภัย (มีในที่ชาร์จโทรศัพท์แทบทุกตัว)
  • Fiber optics: a laser/LED fires light down a glass fiber with total internal reflection for kilometers — the backbone of the internet
  • Pulse oximeters: red + IR LEDs shine through a fingertip, measuring blood's light absorption
  • Switching power supplies: an optocoupler carries the feedback signal safely across the mains↔low-voltage barrier (inside nearly every phone charger)
เช็คอุปกรณ์ออปโตด้วยมัลติมิเตอร์Testing Opto Devices with a Multimeter
  • LED / IR LED: โหมด diode-test — จิ้มถูกขั้วอ่านค่า Vf (IR ≈ 1.1–1.3 V, แดง ≈ 1.8 V, ขาว/น้ำเงิน ≈ 2.6–3 V) LED อาจเรืองแสงจางๆ; กลับขั้วต้องขึ้น OL
  • LDR: โหมด Ω — เอามือบัง: ค่า R พุ่งขึ้น (แสน Ω–MΩ), ส่องไฟ: ตกเหลือหลัก kΩ
  • โฟโตไดโอด/โฟโตทรานซิสเตอร์: วัด R ขณะบัง vs ส่องไฟ — ต้องต่างกันชัดเจน
  • LED / IR LED: diode-test mode — forward reads Vf (IR ≈ 1.1–1.3 V, red ≈ 1.8 V, white/blue ≈ 2.6–3 V), the LED may glow faintly; reversed must read OL
  • LDR: Ω mode — cover it: R jumps (100s kΩ–MΩ); shine a light: drops to a few kΩ
  • Photodiode/phototransistor: measure R covered vs lit — expect a clear difference
  • ออปโตคัปเปลอร์ (PC817):
    ① diode-test ขา 1→2: ต้องอ่านเหมือน LED (~1.2 V) กลับขั้ว = OL
    ② วัด Ω คร่อมขา 4-3 (C-E): ปกติ = OL
    ③ จ่ายไฟให้ LED ฝั่งเข้า (5V ผ่าน R 330Ω เข้าขา 1-2) แล้ววัดขา 4-3 ใหม่ → ค่า R ต้อง ตกฮวบ = ตัวคัปเปลอร์ยังดี
  • Optocoupler (PC817):
    ① diode-test pins 1→2: reads like an LED (~1.2 V), reversed = OL
    ② measure Ω across pins 4-3 (C-E): normally OL
    ③ power the input LED (5V through 330Ω into pins 1-2) and re-measure 4-3 → R must drop sharply = coupler is good
🔗 วิธีใช้โหมด diode-test และ Ω ทบทวนได้ในบท เครื่องมือวัด — หรือฝึกกับ มัลติมิเตอร์เสมือน ในเบรดบอร์ดแล็บ 🔗 Review diode-test and Ω modes in the Measuring Tools lesson — or practice with the virtual multimeter in the Breadboard Lab