Infrared

IR NEC Protocol

38 kHz IR

Worldwide Consumer electronics de facto standard

Core Technical Specifications

center Freq 38 kHz infrared carrier
modulation Pulse Distance Encoding (carrier burst + gap)
data Encoding 32-bit frame: 8-bit address + inverse + 8-bit command + inverse
operating Range 5–10 m (line of sight)
antenna IR LED (TX) / Photodiode with bandpass (RX)
tx Power IR LED: 20–100 mA peak, 940 nm wavelength
bandwidth 38 kHz ±2 kHz carrier
channel Spacing N/A (single optical channel)

Real-World Devices & Applications

Consumer Electronics

  • TV remotes (Samsung, LG, Vizio, TCL, Hisense)
  • Set-top box and cable box remotes
  • Air conditioner remotes (extended NEC)
  • Soundbar and AV receiver remotes
  • LED strip controllers

Reference Circuits & Schematics

IR Receiver Circuit — VS1838B / TSOP1738

The VS1838B is a 38 kHz IR receiver module with built-in bandpass filter, AGC, and demodulator. It outputs a clean digital signal — LOW when carrier is present, HIGH when absent.

PinDescription
VOUT Demodulated digital output (active LOW during carrier burst)
GND Ground
VCC 2.7–5.5V supply (add 100 nF bypass cap)

Circuit Walk-Through

The IR receiver filters ambient light and passes only 38 kHz modulated IR. The AGC adjusts gain for varying distances. The demodulator strips the carrier, outputting LOW during bursts and HIGH during gaps. Connect VOUT to an MCU interrupt pin. Use IRremote (Arduino) or LIRC (Linux) to decode the pulse train into address + command bytes.

IR Transmitter Circuit

A simple IR LED driven by an MCU GPIO through a current-limiting resistor and NPN transistor for higher current.

PinDescription
IR LED 940 nm IR LED, 20–100 mA peak forward current
NPN Transistor BC547 or 2N2222 switches LED current via MCU GPIO
Resistor 22–47Ω current limiter (value depends on LED Vf and supply)
MCU GPIO 38 kHz PWM output modulated with data

Circuit Walk-Through

The MCU generates a 38 kHz PWM carrier on a GPIO pin, gating it on/off according to the NEC timing. The NPN transistor amplifies the current to drive the IR LED at 50–100 mA peak. A 22–47Ω resistor limits current. For extended range, use multiple LEDs in series or a higher-power LED with a lens.

Signal Structure & Waveform Analysis

NEC Protocol Frame Structure

The NEC protocol uses pulse distance encoding: a 562.5 µs carrier burst followed by a gap whose length encodes the bit value.

Leader
AGC burst
9 ms carrier burst + 4.5 ms space
Address
8 bits
LSB first, 562.5 µs burst + 562.5 µs space = '0', + 1687.5 µs space = '1'
Address Inverse
8 bits
Bitwise complement for error checking
Command
8 bits
Same encoding as address
Command Inverse
8 bits
Bitwise complement for error checking
Stop Bit
1 burst
562.5 µs final burst marks end
Timing Notes: Total frame time: 67.5 ms. Repeat code (for held buttons): 9 ms burst + 2.25 ms space + 562.5 µs burst, sent every 108 ms. Extended NEC uses full 16-bit address (no inverse) for more device addresses.

Analysis & Capture Tips

  • Use Arduino + IRremote library to capture and decode NEC frames
  • Logic analyser on VOUT pin: trigger on falling edge, measure burst/gap timing
  • Oscilloscope: verify 38 kHz carrier frequency and burst width
  • For unknown remotes: capture raw timing first, then identify protocol

Bench Troubleshooting & Repair Guide

1. Dead IR LED

Phone camera / Multimeter (diode mode)

View the IR LED through a phone camera while pressing buttons — you should see a faint purple/white flash. No flash = dead LED, flat battery, or broken trace. Measure LED forward voltage with multimeter diode test (~1.1–1.3V for IR LED).

2. Wrong Carrier Frequency

Oscilloscope / Frequency counter

NEC uses 38 kHz but some devices use 36 or 40 kHz. A 38 kHz receiver has ~2 kHz tolerance. If decoding fails, check carrier with oscilloscope. Replace receiver with correct frequency variant.

3. Range Issues

Multimeter / Phone camera

Clean the IR LED and receiver lens. Check IR LED current — should be 20–100 mA peak. Low battery reduces LED brightness. Verify receiver orientation and line-of-sight path.

4. Decode Errors

Arduino + IRremote / Logic Analyser

If address/command inverses don’t match, suspect noise or weak signal. Check for fluorescent light interference at 38 kHz (ballast frequency). Add 100 nF bypass cap on receiver VCC. Shield receiver from ambient IR.

Theme Palette

Default Dark
High-contrast dark
Amber Terminal
Monochrome amber
Matrix CRT
Phosphor green
Workbench Light
Clean light mode

Audio & Display

Relay Click Sounds Web Audio API — soft mechanical clicks
CRT Scanline & Flicker Pure CSS overlay effect

System Info

Customization Panel Theme preference, audio FX, and CRT overlay settings are saved to your browser's localStorage and persist between visits. No cookies or server-side storage is used.
Keyboard Shortcuts Press Esc to close this panel. Use the header moon/sun icon to cycle themes.